DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
GridRPhiEta.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 //==========================================================================
13 
14 namespace dd4hep {
15 namespace DDSegmentation {
16 
17 GridRPhiEta::GridRPhiEta(const std::string& cellEncoding) :
18  GridPhiEta(cellEncoding) {
19  // define type and description
20  _type = "GridRPhiEta";
21  _description = "R-phi-eta segmentation in the global coordinates";
22 
23  // register all necessary parameters (additional to those registered in GridPhiEta)
24  registerParameter("grid_size_r", "Cell size in radial distance", m_gridSizeR, 1., SegmentationParameter::LengthUnit);
25  registerParameter("offset_r", "Angular offset in radial distance", m_offsetR, 0., SegmentationParameter::LengthUnit, true);
26  registerIdentifier("identifier_r", "Cell ID identifier for R", m_rID, "r");
27 }
28 
30  GridPhiEta(aDecoder) {
31  // define type and description
32  _type = "GridRPhiEta";
33  _description = "R-phi-eta segmentation in the global coordinates";
34 
35  // register all necessary parameters (additional to those registered in GridPhiEta)
36  registerParameter("grid_size_r", "Cell size in radial distance", m_gridSizeR, 1., SegmentationParameter::LengthUnit);
37  registerParameter("offset_r", "Angular offset in radial distance", m_offsetR, 0., SegmentationParameter::LengthUnit, true);
38  registerIdentifier("identifier_r", "Cell ID identifier for R", m_rID, "r");
39 }
40 
42  return Util::positionFromREtaPhi(r(cID), eta(cID), phi(cID));
43 }
44 
45 CellID GridRPhiEta::cellID(const Vector3D& /* localPosition */, const Vector3D& globalPosition, const VolumeID& vID) const {
46  double lRadius = Util::radiusFromXYZ(globalPosition);
47  double lEta = Util::etaFromXYZ(globalPosition);
48  double lPhi = Util::phiFromXYZ(globalPosition);
49  CellID cID = vID ;
51  _decoder->set( cID, m_phiID, positionToBin(lPhi, 2 * M_PI / (double) m_phiBins, m_offsetPhi) );
52  _decoder->set( cID, m_rID , positionToBin(lRadius, m_gridSizeR, m_offsetR) );
53  return cID;
54 }
55 
56 double GridRPhiEta::r(const CellID& cID) const {
57  CellID rValue = _decoder->get(cID, m_rID);
58  return binToPosition(rValue, m_gridSizeR, m_offsetR);
59 }
60 }
61 }
62 
dd4hep::DDSegmentation::GridRPhiEta::m_offsetR
double m_offsetR
the coordinate offset in r
Definition: GridRPhiEta.h:101
dd4hep::DDSegmentation::VolumeID
uint64_t VolumeID
Definition: BitFieldCoder.h:27
SegmentationUtil.h
dd4hep::DDSegmentation::Segmentation::_decoder
const BitFieldCoder * _decoder
The cell ID encoder and decoder.
Definition: Segmentation.h:168
dd4hep::DDSegmentation::GridPhiEta::m_phiID
std::string m_phiID
the field name used for phi
Definition: GridPhiEta.h:155
dd4hep::DDSegmentation::Vector3D
Simple container for a physics vector.
Definition: Segmentation.h:48
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::BitFieldCoder::get
FieldID get(CellID bitfield, size_t idx) const
Definition: BitFieldCoder.h:165
dd4hep::DDSegmentation::GridPhiEta::m_phiBins
int m_phiBins
the number of bins in phi
Definition: GridPhiEta.h:147
dd4hep::DDSegmentation::GridRPhiEta::r
double r(const CellID &aCellID) const
Definition: GridRPhiEta.cpp:56
dd4hep::DDSegmentation::GridPhiEta::m_offsetEta
double m_offsetEta
the coordinate offset in eta
Definition: GridPhiEta.h:149
dd4hep::DDSegmentation::Util::radiusFromXYZ
double radiusFromXYZ(const Vector3D &position)
calculates the radius in the xy-plane from Cartesian coordinates
Definition: SegmentationUtil.h:49
dd4hep::DDSegmentation::GridPhiEta::m_offsetPhi
double m_offsetPhi
the coordinate offset in phi
Definition: GridPhiEta.h:151
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::Util::phiFromXYZ
double phiFromXYZ(const Vector3D &position)
calculates the azimuthal angle phi from Cartesian coordinates
Definition: SegmentationUtil.h:64
dd4hep::DDSegmentation::GridPhiEta::m_etaID
std::string m_etaID
the field name used for eta
Definition: GridPhiEta.h:153
dd4hep::DDSegmentation::GridRPhiEta::position
virtual Vector3D position(const CellID &aCellID) const
Definition: GridRPhiEta.cpp:41
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::GridPhiEta::eta
double eta(const CellID &aCellID) const
Definition: GridPhiEta.cpp:60
dd4hep::DDSegmentation::GridPhiEta::m_gridSizeEta
double m_gridSizeEta
the grid size in eta
Definition: GridPhiEta.h:145
dd4hep::DDSegmentation::Segmentation::_description
std::string _description
The description of the segmentation.
Definition: Segmentation.h:162
GridRPhiEta.h
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::GridRPhiEta::cellID
virtual CellID cellID(const Vector3D &aLocalPosition, const Vector3D &aGlobalPosition, const VolumeID &aVolumeID) const
Definition: GridRPhiEta.cpp:45
dd4hep::DDSegmentation::GridRPhiEta::GridRPhiEta
GridRPhiEta(const std::string &aCellEncoding)
default constructor using an arbitrary type
Definition: GridRPhiEta.cpp:17
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::DDSegmentation::GridRPhiEta::m_gridSizeR
double m_gridSizeR
the grid size in r
Definition: GridRPhiEta.h:99
dd4hep::DDSegmentation::Util::positionFromREtaPhi
Vector3D positionFromREtaPhi(double ar, double aeta, double aphi)
calculates the Cartesian position from spherical coordinates (r, phi, eta)
Definition: SegmentationUtil.h:123
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::GridPhiEta
Segmentation class describing segmentation in Phi-Eta.
Definition: GridPhiEta.h:30
dd4hep::DDSegmentation::GridPhiEta::phi
double phi(const CellID &aCellID) const
Definition: GridPhiEta.cpp:64
dd4hep::DDSegmentation::GridRPhiEta::m_rID
std::string m_rID
the field name used for r
Definition: GridRPhiEta.h:103
dd4hep::DDSegmentation::Util::etaFromXYZ
double etaFromXYZ(const Vector3D &aposition)
calculates the pseudorapidity from Cartesian coordinates
Definition: SegmentationUtil.h:70