DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
CylindricalGridPhiZ.cpp
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 //==========================================================================
11 /*
12  * CylindricalGridPhiZ.cpp
13  *
14  * Created on: Jun 28, 2024
15  * Author: Yann Bedfer, ePIC/Saclay
16  */
17 
19 
20 namespace dd4hep {
21 namespace DDSegmentation {
22 
23 using std::make_pair;
24 using std::vector;
25 
27 CylindricalGridPhiZ::CylindricalGridPhiZ(const std::string& cellEncoding) :
28  CylindricalSegmentation(cellEncoding) {
29  // define type and description
30  _type = "CylindricalGridPhiZ";
31  _description = "Cylindrical segmentation in the local PhiZ-cylinder";
32 
33  // register all necessary parameters
34  registerParameter("grid_size_phi", "Cell size in phi", _gridSizePhi, 1., SegmentationParameter::AngleUnit);
35  registerParameter("grid_size_z", "Cell size in Z", _gridSizeZ, 1., SegmentationParameter::LengthUnit);
36  registerParameter("offset_phi", "Cell offset in phi", _offsetPhi, 0., SegmentationParameter::AngleUnit, true);
37  registerParameter("offset_z", "Cell offset in Z", _offsetZ, 0., SegmentationParameter::LengthUnit, true);
38  registerParameter("radius", "Radius of Cylinder", _radius, 0., SegmentationParameter::LengthUnit);
39  registerIdentifier("identifier_phi", "Cell ID identifier for phi", _phiId, "phi");
40  registerIdentifier("identifier_z", "Cell ID identifier for Z", _zId, "z");
41 }
42 
45  CylindricalSegmentation(decode) {
46  // define type and description
47  _type = "CylindricalGridPhiZ";
48  _description = "Cylindrical segmentation in the local PhiZ-cylinder";
49 
50  // register all necessary parameters
51  registerParameter("grid_size_phi", "Cell size in phi", _gridSizePhi, 1., SegmentationParameter::AngleUnit);
52  registerParameter("grid_size_z", "Cell size in Z", _gridSizeZ, 1., SegmentationParameter::LengthUnit);
53  registerParameter("offset_phi", "Cell offset in phi", _offsetPhi, 0., SegmentationParameter::AngleUnit, true);
54  registerParameter("offset_z", "Cell offset in Z", _offsetZ, 0., SegmentationParameter::LengthUnit, true);
55  registerParameter("radius", "Radius of Cylinder", _radius, 0., SegmentationParameter::LengthUnit);
56  registerIdentifier("identifier_phi", "Cell ID identifier for phi", _phiId, "phi");
57  registerIdentifier("identifier_z", "Cell ID identifier for Z", _zId, "z");
58 }
59 
62 
63 }
64 
67  vector<double> localPosition(3);
68  Vector3D cellPosition;
69  double phi =
71  cellPosition.Z =
73  const double &R = _radius;
74  cellPosition.X = R*cos(phi); cellPosition.Y = R*sin(phi);
75 
76  return cellPosition;
77 }
78 
80  CellID CylindricalGridPhiZ::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const {
81  double phi = atan2(localPosition.Y,localPosition.X);
82  double Z = localPosition.Z;
83  if ( phi < _offsetPhi) {
84  phi += 2*M_PI;
85  }
86  CellID cID = vID ;
89 
90  return cID ;
91 }
92 
93 std::vector<double> CylindricalGridPhiZ::cellDimensions(const CellID&) const {
95 }
96 
97 
98 } /* namespace DDSegmentation */
99 } /* namespace dd4hep */
dd4hep::DDSegmentation::CylindricalGridPhiZ::cellID
virtual CellID cellID(const Vector3D &localPosition, const Vector3D &globalPosition, const VolumeID &volumeID) const
determine the cell ID based on the position
Definition: CylindricalGridPhiZ.cpp:80
dd4hep::DDSegmentation::VolumeID
uint64_t VolumeID
Definition: BitFieldCoder.h:27
dd4hep::DDSegmentation::Segmentation::_decoder
const BitFieldCoder * _decoder
The cell ID encoder and decoder.
Definition: Segmentation.h:168
dd4hep::DDSegmentation::Vector3D
Simple container for a physics vector.
Definition: Segmentation.h:48
dd4hep::DDSegmentation::CylindricalSegmentation
Segmentation base class describing a cylindrical grid segmentation.
Definition: CylindricalSegmentation.h:30
dd4hep::DDSegmentation::CylindricalGridPhiZ::_zId
std::string _zId
the field name used for Z
Definition: CylindricalGridPhiZ.h:121
M_PI
#define M_PI
Definition: Handle.h:33
dd4hep::DDSegmentation::SegmentationParameter::LengthUnit
@ LengthUnit
Definition: SegmentationParameter.h:111
dd4hep::DDSegmentation::BitFieldCoder
Helper class for decoding and encoding a bit field of 64bits for convenient declaration.
Definition: BitFieldCoder.h:114
dd4hep::DDSegmentation::SegmentationParameter::AngleUnit
@ AngleUnit
Definition: SegmentationParameter.h:111
dd4hep::DDSegmentation::BitFieldCoder::get
FieldID get(CellID bitfield, size_t idx) const
Definition: BitFieldCoder.h:165
CylindricalGridPhiZ.h
dd4hep::DDSegmentation::CylindricalGridPhiZ::_offsetPhi
double _offsetPhi
the coordinate offset in phi
Definition: CylindricalGridPhiZ.h:111
dd4hep::DDSegmentation::CylindricalGridPhiZ::cellDimensions
virtual std::vector< double > cellDimensions(const CellID &cellID) const
Returns a vector<double> of the cellDimensions of the given cell ID in the following order: R*dPhi,...
Definition: CylindricalGridPhiZ.cpp:93
dd4hep::DDSegmentation::CylindricalGridPhiZ::~CylindricalGridPhiZ
virtual ~CylindricalGridPhiZ()
destructor
Definition: CylindricalGridPhiZ.cpp:61
dd4hep::DDSegmentation::CylindricalGridPhiZ::_gridSizePhi
double _gridSizePhi
the grid size in phi
Definition: CylindricalGridPhiZ.h:109
dd4hep::DDSegmentation::CylindricalGridPhiZ::_offsetZ
double _offsetZ
the coordinate offset in Z
Definition: CylindricalGridPhiZ.h:115
dd4hep::DDSegmentation::CylindricalGridPhiZ::position
virtual Vector3D position(const CellID &cellID) const
determine the local based on the cell ID
Definition: CylindricalGridPhiZ.cpp:66
dd4hep::DDSegmentation::Segmentation::registerParameter
void registerParameter(const std::string &nam, const std::string &desc, TYPE &param, const TYPE &defaultVal, UnitType unitTyp=SegmentationParameter::NoUnit, bool isOpt=false)
Add a parameter to this segmentation. Used by derived classes to define their parameters.
Definition: Segmentation.h:138
dd4hep::DDSegmentation::CylindricalGridPhiZ::_gridSizeZ
double _gridSizeZ
the grid size in Z
Definition: CylindricalGridPhiZ.h:113
dd4hep::DDSegmentation::Vector3D::Y
double Y
Definition: Segmentation.h:71
dd4hep::DDSegmentation::BitFieldCoder::set
void set(CellID &bitfield, size_t idx, FieldID value) const
Definition: BitFieldCoder.h:177
dd4hep::DDSegmentation::CellID
uint64_t CellID
Definition: BitFieldCoder.h:26
dd4hep::DDSegmentation::Segmentation::registerIdentifier
void registerIdentifier(const std::string &nam, const std::string &desc, std::string &ident, const std::string &defaultVal)
Add a cell identifier to this segmentation. Used by derived classes to define their required identifi...
Definition: Segmentation.cpp:135
dd4hep::DDSegmentation::CylindricalGridPhiZ::_phiId
std::string _phiId
the field name used for phi
Definition: CylindricalGridPhiZ.h:119
dd4hep::DDSegmentation::Segmentation::_description
std::string _description
The description of the segmentation.
Definition: Segmentation.h:162
dd4hep::DDSegmentation::Segmentation::positionToBin
static int positionToBin(double position, double cellSize, double offset=0.)
Helper method to convert a 1D position to a cell ID.
Definition: Segmentation.cpp:150
dd4hep::DDSegmentation::Vector3D::X
double X
Definition: Segmentation.h:71
dd4hep::DDSegmentation::Segmentation::binToPosition
static double binToPosition(FieldID bin, double cellSize, double offset=0.)
Helper method to convert a bin number to a 1D position.
Definition: Segmentation.cpp:145
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::DDSegmentation::Segmentation::_type
std::string _type
The segmentation type.
Definition: Segmentation.h:160
dd4hep::DDSegmentation::CylindricalGridPhiZ::CylindricalGridPhiZ
CylindricalGridPhiZ(const std::string &cellEncoding)
default constructor using an arbitrary type
Definition: CylindricalGridPhiZ.cpp:27
dd4hep::DDSegmentation::CylindricalGridPhiZ::_radius
double _radius
the radius
Definition: CylindricalGridPhiZ.h:117
dd4hep::DDSegmentation::Vector3D::Z
double Z
Definition: Segmentation.h:71