Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 09:36:49

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
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   // define type and description
0020   _type = "GridRPhiEta";
0021   _description = "R-phi-eta segmentation in the global coordinates";
0022 
0023   // register all necessary parameters (additional to those registered in GridPhiEta)
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   // define type and description
0032   _type = "GridRPhiEta";
0033   _description = "R-phi-eta segmentation in the global coordinates";
0034 
0035   // register all necessary parameters (additional to those registered in GridPhiEta)
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& /* localPosition */, 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