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/GridPhiEta.h>
0012 #include <DDSegmentation/SegmentationUtil.h>
0013 
0014 namespace dd4hep {
0015 namespace DDSegmentation {
0016 
0017 GridPhiEta::GridPhiEta(const std::string& cellEncoding) :
0018   Segmentation(cellEncoding) {
0019   // define type and description
0020   _type = "GridPhiEta";
0021   _description = "Phi-eta segmentation in the global coordinates";
0022 
0023   // register all necessary parameters
0024   registerParameter("grid_size_eta", "Cell size in Eta", m_gridSizeEta, 1., SegmentationParameter::LengthUnit);
0025   registerParameter("phi_bins", "Number of bins phi", m_phiBins, 1);
0026   registerParameter("offset_eta", "Angular offset in eta", m_offsetEta, 0., SegmentationParameter::AngleUnit, true);
0027   registerParameter("offset_phi", "Angular offset in phi", m_offsetPhi, 0., SegmentationParameter::AngleUnit, true);
0028   registerIdentifier("identifier_eta", "Cell ID identifier for eta", m_etaID, "eta");
0029   registerIdentifier("identifier_phi", "Cell ID identifier for phi", m_phiID, "phi");
0030 }
0031 
0032 GridPhiEta::GridPhiEta(const BitFieldCoder* aDecoder) :
0033   Segmentation(aDecoder) {
0034   // define type and description
0035   _type = "GridPhiEta";
0036   _description = "Phi-eta segmentation in the global coordinates";
0037 
0038   // register all necessary parameters
0039   registerParameter("grid_size_eta", "Cell size in Eta", m_gridSizeEta, 1., SegmentationParameter::LengthUnit);
0040   registerParameter("phi_bins", "Number of bins phi", m_phiBins, 1);
0041   registerParameter("offset_eta", "Angular offset in eta", m_offsetEta, 0., SegmentationParameter::AngleUnit, true);
0042   registerParameter("offset_phi", "Angular offset in phi", m_offsetPhi, 0., SegmentationParameter::AngleUnit, true);
0043   registerIdentifier("identifier_eta", "Cell ID identifier for eta", m_etaID, "eta");
0044   registerIdentifier("identifier_phi", "Cell ID identifier for phi", m_phiID, "phi");
0045 }
0046 
0047 Vector3D GridPhiEta::position(const CellID& cID) const {
0048   return Util::positionFromREtaPhi(1.0, eta(cID), phi(cID));
0049 }
0050 
0051 CellID GridPhiEta::cellID(const Vector3D& /* localPosition */, const Vector3D& globalPosition, const VolumeID& vID) const {
0052   double lEta = Util::etaFromXYZ(globalPosition);
0053   double lPhi = Util::phiFromXYZ(globalPosition);
0054   CellID cID = vID ;
0055   _decoder->set( cID, m_etaID, positionToBin(lEta, m_gridSizeEta, m_offsetEta) );
0056   _decoder->set( cID, m_phiID, positionToBin(lPhi, 2 * M_PI / (double) m_phiBins, m_offsetPhi) );
0057   return cID;
0058 }
0059 
0060 double GridPhiEta::eta(const CellID& cID) const {
0061   CellID etaValue = _decoder->get(cID, m_etaID);
0062   return binToPosition(etaValue, m_gridSizeEta, m_offsetEta);
0063 }
0064 double GridPhiEta::phi(const CellID& cID) const {
0065   CellID phiValue = _decoder->get(cID, m_phiID);
0066   return binToPosition(phiValue, 2.*M_PI/(double)m_phiBins, m_offsetPhi);
0067 }
0068 }
0069 }