Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 09:58:01

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 //  \author   A. Zaborowska
0011 //  \date     2016-10-18
0012 //  \version  1.0
0013 //
0014 //==========================================================================
0015 #ifndef DD4HEP_GRIDPHIETA_H
0016 #define DD4HEP_GRIDPHIETA_H 1
0017 
0018 // Framework includes
0019 #include <DDSegmentation/GridPhiEta.h>
0020 #include <DD4hep/Segmentations.h>
0021 
0022 /// Namespace for the AIDA detector description toolkit
0023 namespace dd4hep {
0024 
0025   /// We need some abbreviation to make the code more readable.
0026   typedef Handle<SegmentationWrapper<DDSegmentation::GridPhiEta>> GridPhiEtaHandle;
0027 
0028   /// Implementation class for the grid phi-eta segmentation.
0029   /**
0030    *  Concrete user handle to serve specific needs of client code
0031    *  which requires access to the base functionality not served
0032    *  by the super-class Segmentation.
0033    *
0034    *  Note:
0035    *  We only check the validity of the underlying handle.
0036    *  If for whatever reason the implementation object is not valid
0037    *  This is not checked.
0038    *  In principle this CANNOT happen unless some brain-dead has
0039    *  fiddled with the handled object directly.....
0040    *
0041    *  Note:
0042    *  The handle base corresponding to this object in for
0043    *  conveniance reasons instantiated in dd4hep/src/Segmentations.cpp.
0044    *
0045    *  \author  A. Zaborowska
0046    *  \version 1.0
0047    */
0048   class GridPhiEta : public GridPhiEtaHandle {
0049   public:
0050     /// Default constructor
0051     GridPhiEta() = default;
0052     /// Copy constructor
0053     GridPhiEta(const GridPhiEta& e) = default;
0054     /// Copy Constructor from segmentation base object
0055     GridPhiEta(const Segmentation& e) : Handle<Object>(e) {}
0056     /// Copy constructor from handle
0057     GridPhiEta(const Handle<Object>& e) : Handle<Object>(e) {}
0058     /// Copy constructor from other polymorph/equivalent handle
0059     template <typename Q>
0060     GridPhiEta(const Handle<Q>& e) : Handle<Object>(e) {}
0061     /// Assignment operator
0062     GridPhiEta& operator=(const GridPhiEta& seg) = default;
0063     /// Equality operator
0064     bool operator==(const GridPhiEta& seg) const { return m_element == seg.m_element; }
0065     /// determine the position based on the cell ID
0066     inline Position position(const CellID& id) const { return Position(access()->implementation->position(id)); }
0067 
0068     /// determine the cell ID based on the position
0069     inline dd4hep::CellID cellID(const Position& local, const Position& global, const VolumeID& volID) const {
0070       return access()->implementation->cellID(local, global, volID);
0071     }
0072 
0073     /// access the grid size in Eta
0074     inline double gridSizeEta() const { return access()->implementation->gridSizeEta(); }
0075 
0076     /// access the grid size in Phi
0077     inline int phiBins() const { return access()->implementation->phiBins(); }
0078 
0079     /// access the coordinate offset in Eta
0080     inline double offsetEta() const { return access()->implementation->offsetEta(); }
0081 
0082     /// access the coordinate offset in Phi
0083     inline double offsetPhi() const { return access()->implementation->offsetPhi(); }
0084 
0085     /// set the coordinate offset in Eta
0086     inline void setOffsetEta(double offset) const { access()->implementation->setOffsetEta(offset); }
0087 
0088     /// set the coordinate offset in Phi
0089     inline void setOffsetPhi(double offset) const { access()->implementation->setOffsetPhi(offset); }
0090 
0091     /// set the grid size in Eta
0092     inline void setGridSizeEta(double cellSize) const { access()->implementation->setGridSizeEta(cellSize); }
0093 
0094     /// set the grid size in Phi
0095     inline void setPhiBins(int cellSize) const { access()->implementation->setPhiBins(cellSize); }
0096 
0097     /// access the field name used for Eta
0098     inline const std::string& fieldNameEta() const { return access()->implementation->fieldNameEta(); }
0099 
0100     /// access the field name used for Phi
0101     inline const std::string& fieldNamePhi() const { return access()->implementation->fieldNamePhi(); }
0102 
0103     /** \brief Returns a std::vector<double> of the cellDimensions of the given cell ID
0104         in natural order of dimensions (dPhi, dEta)
0105 
0106         Returns a std::vector of the cellDimensions of the given cell ID
0107         \param cellID is ignored as all cells have the same dimension
0108         \return std::vector<double> size 2:
0109         -# size in phi
0110         -# size in eta
0111     */
0112     inline std::vector<double> cellDimensions(const CellID& /*id*/) const {
0113       return {access()->implementation->gridSizePhi(), access()->implementation->gridSizeEta()};
0114     }
0115   };
0116 }       /* End namespace dd4hep                */
0117 #endif // DD4HEP_GRIDPHIETA_H