File indexing completed on 2025-02-22 09:36:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <DDSegmentation/GridRPhiEta.h>
0012 #include <DDSegmentation/SegmentationUtil.h>
0013
0014 namespace dd4hep {
0015 namespace DDSegmentation {
0016
0017 GridRPhiEta::GridRPhiEta(const std::string& cellEncoding) :
0018 GridPhiEta(cellEncoding) {
0019
0020 _type = "GridRPhiEta";
0021 _description = "R-phi-eta segmentation in the global coordinates";
0022
0023
0024 registerParameter("grid_size_r", "Cell size in radial distance", m_gridSizeR, 1., SegmentationParameter::LengthUnit);
0025 registerParameter("offset_r", "Angular offset in radial distance", m_offsetR, 0., SegmentationParameter::LengthUnit, true);
0026 registerIdentifier("identifier_r", "Cell ID identifier for R", m_rID, "r");
0027 }
0028
0029 GridRPhiEta::GridRPhiEta(const BitFieldCoder* aDecoder) :
0030 GridPhiEta(aDecoder) {
0031
0032 _type = "GridRPhiEta";
0033 _description = "R-phi-eta segmentation in the global coordinates";
0034
0035
0036 registerParameter("grid_size_r", "Cell size in radial distance", m_gridSizeR, 1., SegmentationParameter::LengthUnit);
0037 registerParameter("offset_r", "Angular offset in radial distance", m_offsetR, 0., SegmentationParameter::LengthUnit, true);
0038 registerIdentifier("identifier_r", "Cell ID identifier for R", m_rID, "r");
0039 }
0040
0041 Vector3D GridRPhiEta::position(const CellID& cID) const {
0042 return Util::positionFromREtaPhi(r(cID), eta(cID), phi(cID));
0043 }
0044
0045 CellID GridRPhiEta::cellID(const Vector3D& , const Vector3D& globalPosition, const VolumeID& vID) const {
0046 double lRadius = Util::radiusFromXYZ(globalPosition);
0047 double lEta = Util::etaFromXYZ(globalPosition);
0048 double lPhi = Util::phiFromXYZ(globalPosition);
0049 CellID cID = vID ;
0050 _decoder->set( cID, m_etaID, positionToBin(lEta, m_gridSizeEta, m_offsetEta) );
0051 _decoder->set( cID, m_phiID, positionToBin(lPhi, 2 * M_PI / (double) m_phiBins, m_offsetPhi) );
0052 _decoder->set( cID, m_rID , positionToBin(lRadius, m_gridSizeR, m_offsetR) );
0053 return cID;
0054 }
0055
0056 double GridRPhiEta::r(const CellID& cID) const {
0057 CellID rValue = _decoder->get(cID, m_rID);
0058 return binToPosition(rValue, m_gridSizeR, m_offsetR);
0059 }
0060 }
0061 }
0062