Skip to content

Commit

Permalink
Add a "CartesianGridUV" segmentation class, providing for a readout a…
Browse files Browse the repository at this point in the history
…t an angle w.r.t. X,Y axes.
  • Loading branch information
ybedfer committed Dec 8, 2024
1 parent bc985a8 commit 1bb07c7
Show file tree
Hide file tree
Showing 8 changed files with 439 additions and 3 deletions.
111 changes: 111 additions & 0 deletions DDCore/include/DD4hep/CartesianGridUV.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
//==========================================================================
// AIDA Detector description implementation
//--------------------------------------------------------------------------
// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
// All rights reserved.
//
// For the licensing terms see $DD4hepINSTALL/LICENSE.
// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
//
// \author Markus Frank
// \date 2016-10-18
// \version 1.0
//
//==========================================================================
#ifndef DD4HEP_CARTESIANGRIDUV_H
#define DD4HEP_CARTESIANGRIDUV_H 1

// Framework include files
#include <DD4hep/Segmentations.h>

/// Namespace for the AIDA detector description toolkit
namespace dd4hep {

/// Namespace for base segmentations
namespace DDSegmentation { class CartesianGridUV; }

/// We need some abbreviation to make the code more readable.
typedef Handle<SegmentationWrapper<DDSegmentation::CartesianGridUV> > CartesianGridUVHandle;

/// Implementation class for the grid UV segmentation.
/**
* Concrete user handle to serve specific needs of client code
* which requires access to the base functionality not served
* by the super-class Segmentation.
*
* Note:
* We only check the validity of the underlying handle.
* If for whatever reason the implementation object is not valid
* This is not checked.
* In principle this CANNOT happen unless some brain-dead has
* fiddled with the handled object directly.....
*
* Note:
* The handle base corresponding to this object in for
* conveniance reasons instantiated in dd4hep/src/Segmentations.cpp.
*
* \author M.Frank
* \version 1.0
* \ingroup DD4HEP_CORE
*/
class CartesianGridUV : public CartesianGridUVHandle {
public:
/// Default constructor
CartesianGridUV() = default;
/// Copy constructor
CartesianGridUV(const CartesianGridUV& e) = default;
/// Copy Constructor from segmentation base object
CartesianGridUV(const Segmentation& e) : Handle<Object>(e) { }
/// Copy constructor from handle
CartesianGridUV(const Handle<Object>& e) : Handle<Object>(e) { }
/// Copy constructor from other equivalent handle
template <typename Q> CartesianGridUV(const Handle<Q>& e) : Handle<Object>(e) { }
/// Assignment operator
CartesianGridUV& operator=(const CartesianGridUV& seg) = default;
/// Equality operator
bool operator==(const CartesianGridUV& seg) const {
return m_element == seg.m_element;
}

/// determine the position based on the cell ID
Position position(const CellID& cellID) const;
/// determine the cell ID based on the position
CellID cellID(const Position& local, const Position& global, const VolumeID& volID) const;
/// access the grid size in U
double gridSizeU() const;
/// access the grid size in V
double gridSizeV() const;
/// set the grid size in U
void setGridSizeU(double cellSize) const;
/// set the grid size in V
void setGridSizeV(double cellSize) const;
/// access the coordinate offset in U
double offsetU() const;
/// access the coordinate offset in V
double offsetV() const;
/// access the rotation angle
double gridAngle() const;
/// set the coordinate offset in U
void setOffsetU(double offset) const;
/// set the coordinate offset in V
void setOffsetV(double offset) const;
/// set the rotation angle
void setGridAngle(double angle) const;
/// access the field name used for U
const std::string& fieldNameU() const;
/// access the field name used for V
const std::string& fieldNameV() const;
/** \brief Returns a vector<double> of the cellDimensions of the given cell ID
in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi
Returns a vector of the cellDimensions of the given cell ID
\param cellID is ignored as all cells have the same dimension
\return std::vector<double> size 2:
-# size in U
-# size in V
*/
std::vector<double> cellDimensions(const CellID& cellID) const;
};

} /* End namespace dd4hep */
#endif // DD4HEP_CARTESIANGRIDUV_H
126 changes: 126 additions & 0 deletions DDCore/include/DDSegmentation/CartesianGridUV.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
//==========================================================================
// AIDA Detector description implementation
//--------------------------------------------------------------------------
// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
// All rights reserved.
//
// For the licensing terms see $DD4hepINSTALL/LICENSE.
// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
//
//==========================================================================
/*
* CartesianGridUV.h
*
* Created on: December 5, 2024
* Author: Yann Bedfer, ePIC/Saclay
*/

#ifndef DDSEGMENTATION_CARTESIANGRIDUV_H
#define DDSEGMENTATION_CARTESIANGRIDUV_H

#include <DDSegmentation/CartesianGrid.h>

namespace dd4hep {
namespace DDSegmentation {

/// Segmentation base class describing cartesian grid segmentation in along U,V rotated some angle from local X,Y axes
class CartesianGridUV: public CartesianGrid {
public:
/// Default constructor passing the encoding string
CartesianGridUV(const std::string& cellEncoding = "");
/// Default constructor used by derived classes passing an existing decoder
CartesianGridUV(const BitFieldCoder* decoder);
/// destructor
virtual ~CartesianGridUV();

/// determine the position based on the cell ID
virtual Vector3D position(const CellID& cellID) const;
/// determine the cell ID based on the position
virtual CellID cellID(const Vector3D& localPosition, const Vector3D& globalPosition, const VolumeID& volumeID) const;
/// access the grid size in U
double gridSizeU() const {
return _gridSizeU;
}
/// access the grid size in V
double gridSizeV() const {
return _gridSizeV;
}
/// access the coordinate offset in U
double offsetU() const {
return _offsetU;
}
/// access the coordinate offset in V
double offsetV() const {
return _offsetV;
}
/// access the rotation angle
double gridAngle() const {
return _gridAngle;
}
/// access the field name used for U
const std::string& fieldNameU() const {
return _uId;
}
/// access the field name used for V
const std::string& fieldNameV() const {
return _vId;
}
/// set the grid size in U
void setGridSizeU(double cellSize) {
_gridSizeU = cellSize;
}
/// set the grid size in V
void setGridSizeV(double cellSize) {
_gridSizeV = cellSize;
}
/// set the coordinate offset in U
void setOffsetU(double offset) {
_offsetU = offset;
}
/// set the coordinate offset in V
void setOffsetV(double offset) {
_offsetV = offset;
}
/// set the rotation angle
void setGridAngle(double angle) {
_gridAngle = angle;
}
/// set the field name used for U
void setFieldNameU(const std::string& fieldName) {
_uId = fieldName;
}
/// set the field name used for V
void setFieldNameV(const std::string& fieldName) {
_vId = fieldName;
}
/** \brief Returns a vector<double> of the cellDimensions of the given cell ID
in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi
Returns a vector of the cellDimensions of the given cell ID
\param cellID is ignored as all cells have the same dimension
\return std::vector<double> size 2:
-# size in U
-# size in V
*/
virtual std::vector<double> cellDimensions(const CellID& cellID) const;

protected:
/// the grid size in U
double _gridSizeU;
/// the coordinate offset in U
double _offsetU;
/// the grid size in V
double _gridSizeV;
/// the coordinate offset in V
double _offsetV;
/// the field name used for U
std::string _uId;
/// the field name used for V
std::string _vId;
/// the U grid angle
double _gridAngle;
};

} /* namespace DDSegmentation */
} /* namespace dd4hep */
#endif // DDSEGMENTATION_CARTESIANGRIDUV_H
4 changes: 3 additions & 1 deletion DDCore/include/XML/UnicodeValues.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,11 @@ UNICODE (global);
UNICODE (global_grid_xy);
UNICODE (grid_size_x);
UNICODE (grid_size_y);
UNICODE (grid_size_z);
UNICODE (grid_size_u);
UNICODE (grid_size_v);
UNICODE (grid_size_phi);
UNICODE (grid_xyz);
UNICODE (grid_angle);
UNICODE (gridSizePhi);
UNICODE (gridSizeX);
UNICODE (gridSizeY);
Expand Down
91 changes: 91 additions & 0 deletions DDCore/src/CartesianGridUV.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
//==========================================================================
// AIDA Detector description implementation
//--------------------------------------------------------------------------
// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
// All rights reserved.
//
// For the licensing terms see $DD4hepINSTALL/LICENSE.
// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
//
// Author : M.Frank
//
//==========================================================================

// Framework include files
#include <DD4hep/CartesianGridUV.h>
#include <DDSegmentation/CartesianGridUV.h>

using namespace dd4hep;

/// determine the position based on the cell ID
Position CartesianGridUV::position(const CellID& id) const {
return Position(access()->implementation->position(id));
}

/// determine the cell ID based on the position
dd4hep::CellID CartesianGridUV::cellID(const Position& local,
const Position& global,
const VolumeID& volID) const
{
return access()->implementation->cellID(local, global, volID);
}

/// access the grid size in U
double CartesianGridUV::gridSizeU() const {
return access()->implementation->gridSizeU();
}

/// access the grid size in V
double CartesianGridUV::gridSizeV() const {
return access()->implementation->gridSizeV();
}

/// set the grid size in U
void CartesianGridUV::setGridSizeU(double cellSize) const {
access()->implementation->setGridSizeU(cellSize);
}

/// set the grid size in V
void CartesianGridUV::setGridSizeV(double cellSize) const {
access()->implementation->setGridSizeV(cellSize);
}

/// access the coordinate offset in U
double CartesianGridUV::offsetU() const {
return access()->implementation->offsetU();
}

/// access the coordinate offset in V
double CartesianGridUV::offsetV() const {
return access()->implementation->offsetV();
}

/// access the rotation angle
double CartesianGridUV::gridAngle() const {
return access()->implementation->gridAngle();
}

/// set the coordinate offset in U
void CartesianGridUV::setOffsetU(double offset) const {
access()->implementation->setOffsetU(offset);
}

/// set the coordinate offset in V
void CartesianGridUV::setOffsetV(double offset) const {
access()->implementation->setOffsetV(offset);
}

/// access the field name used for U
const std::string& CartesianGridUV::fieldNameU() const {
return access()->implementation->fieldNameU();
}

/// access the field name used for V
const std::string& CartesianGridUV::fieldNameV() const {
return access()->implementation->fieldNameV();
}

// Returns a vector<double> of the cellDimensions of the given cell ID
std::vector<double> CartesianGridUV::cellDimensions(const CellID& id) const {
return access()->implementation->cellDimensions(id);
}
2 changes: 2 additions & 0 deletions DDCore/src/SegmentationDictionary.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <DDSegmentation/CartesianGridXYZ.h>
#include <DDSegmentation/CartesianGridXZ.h>
#include <DDSegmentation/CartesianGridYZ.h>
#include <DDSegmentation/CartesianGridUV.h>
#include <DDSegmentation/CartesianStripX.h>
#include <DDSegmentation/CartesianStripY.h>
#include <DDSegmentation/CartesianStripZ.h>
Expand Down Expand Up @@ -74,6 +75,7 @@ typedef dd4hep::DDSegmentation::CellID CellID;
#pragma link C++ class dd4hep::DDSegmentation::CartesianGridXYZ+;
#pragma link C++ class dd4hep::DDSegmentation::CartesianGridXZ+;
#pragma link C++ class dd4hep::DDSegmentation::CartesianGridYZ+;
#pragma link C++ class dd4hep::DDSegmentation::CartesianGridUV+;
#pragma link C++ class dd4hep::DDSegmentation::CartesianStripX+;
#pragma link C++ class dd4hep::DDSegmentation::CartesianStripY+;
#pragma link C++ class dd4hep::DDSegmentation::CartesianStripZ+;
Expand Down
3 changes: 3 additions & 0 deletions DDCore/src/Segmentations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGridXZ);
#include <DDSegmentation/CartesianGridYZ.h>
DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGridYZ);

#include <DDSegmentation/CartesianGridUV.h>
DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGridUV);

#include <DDSegmentation/CartesianGridXYZ.h>
DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGridXYZ);

Expand Down
4 changes: 2 additions & 2 deletions DDCore/src/plugins/ReadoutSegmentations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ DECLARE_SEGMENTATION(CartesianGridXZ,create_segmentation<dd4hep::DDSegmentation:
#include <DDSegmentation/CartesianGridYZ.h>
DECLARE_SEGMENTATION(CartesianGridYZ,create_segmentation<dd4hep::DDSegmentation::CartesianGridYZ>)

#include <DDSegmentation/CartesianGridXYZ.h>
DECLARE_SEGMENTATION(CartesianGridXYZ,create_segmentation<dd4hep::DDSegmentation::CartesianGridXYZ>)
#include <DDSegmentation/CartesianGridUV.h>
DECLARE_SEGMENTATION(CartesianGridUV,create_segmentation<dd4hep::DDSegmentation::CartesianGridUV>)

#include <DDSegmentation/CartesianGridXYStaggered.h>
DECLARE_SEGMENTATION(CartesianGridXYStaggered,dd4hep::create_segmentation<dd4hep::DDSegmentation::CartesianGridXYStaggered>)
Expand Down
Loading

0 comments on commit 1bb07c7

Please sign in to comment.