Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 13:02:45

0001 #ifndef EcalBarrelGeometry_h
0002 #define EcalBarrelGeometry_h
0003 
0004 #include "Geometry/CaloGeometry/interface/EZArrayFL.h"
0005 #include "Geometry/EcalCommonData/interface/EcalBarrelNumberingScheme.h"
0006 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0007 #include "Geometry/CaloGeometry/interface/TruncatedPyramid.h"
0008 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0009 #include "Geometry/Records/interface/EcalBarrelGeometryRecord.h"
0010 #include "CondFormats/AlignmentRecord/interface/EBAlignmentRcd.h"
0011 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0012 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0013 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0014 #include "Geometry/Records/interface/PEcalBarrelRcd.h"
0015 #include "FWCore/Utilities/interface/thread_safety_macros.h"
0016 #include <vector>
0017 #include <atomic>
0018 
0019 class EcalBarrelGeometry final : public CaloSubdetectorGeometry {
0020 public:
0021   typedef std::vector<TruncatedPyramid> CellVec;
0022 
0023   typedef CaloCellGeometry::CCGFloat CCGFloat;
0024   typedef CaloCellGeometry::Pt3D Pt3D;
0025   typedef CaloCellGeometry::Pt3DVec Pt3DVec;
0026 
0027   typedef IdealGeometryRecord IdealRecord;
0028   typedef EcalBarrelGeometryRecord AlignedRecord;
0029   typedef EBAlignmentRcd AlignmentRecord;
0030   typedef PEcalBarrelRcd PGeometryRecord;
0031 
0032   typedef EZArrayFL<EEDetId> OrderedListOfEEDetId;  // like an stl vector: begin(), end(), [i]
0033 
0034   typedef std::vector<OrderedListOfEEDetId*> VecOrdListEEDetIdPtr;
0035 
0036   typedef EcalBarrelNumberingScheme NumberingScheme;
0037 
0038   typedef EBDetId DetIdType;
0039 
0040   enum { k_NumberOfCellsForCorners = EBDetId::kSizeForDenseIndexing };
0041 
0042   enum { k_NumberOfShapes = 17 };
0043 
0044   enum { k_NumberOfParametersPerShape = 11 };
0045 
0046   static std::string dbString() { return "PEcalBarrelRcd"; }
0047 
0048   unsigned int numberOfShapes() const override { return k_NumberOfShapes; }
0049   unsigned int numberOfParametersPerShape() const override { return k_NumberOfParametersPerShape; }
0050 
0051   EcalBarrelGeometry();
0052 
0053   ~EcalBarrelGeometry() override;
0054 
0055   int getNumXtalsPhiDirection() const { return _nnxtalPhi; }
0056 
0057   int getNumXtalsEtaDirection() const { return _nnxtalEta; }
0058 
0059   const std::vector<int>& getEtaBaskets() const { return _EtaBaskets; }
0060 
0061   int getBasketSizeInPhi() const { return _PhiBaskets; }
0062 
0063   void setNumXtalsPhiDirection(const int& nnxtalPhi) { _nnxtalPhi = nnxtalPhi; }
0064 
0065   void setNumXtalsEtaDirection(const int& nnxtalEta) { _nnxtalEta = nnxtalEta; }
0066 
0067   void setEtaBaskets(const std::vector<int>& EtaBaskets) { _EtaBaskets = EtaBaskets; }
0068 
0069   void setBasketSizeInPhi(const int& PhiBaskets) { _PhiBaskets = PhiBaskets; }
0070 
0071   const OrderedListOfEEDetId* getClosestEndcapCells(EBDetId id) const;
0072 
0073   // Get closest cell, etc...
0074 
0075   DetId getClosestCell(const GlobalPoint& r) const override;
0076 
0077   CaloSubdetectorGeometry::DetIdSet getCells(const GlobalPoint& r, double dR) const override;
0078 
0079   CCGFloat avgRadiusXYFrontFaceCenter() const;
0080 
0081   static std::string hitString() { return "EcalHitsEB"; }
0082 
0083   static std::string producerTag() { return "EcalBarrel"; }
0084 
0085   static unsigned int numberOfAlignments() { return 36; }
0086 
0087   static unsigned int alignmentTransformIndexLocal(const DetId& id);
0088 
0089   static unsigned int alignmentTransformIndexGlobal(const DetId& id);
0090 
0091   static DetId detIdFromLocalAlignmentIndex(unsigned int iLoc);
0092 
0093   static void localCorners(Pt3DVec& lc, const CCGFloat* pv, unsigned int i, Pt3D& ref);
0094 
0095   void newCell(const GlobalPoint& f1,
0096                const GlobalPoint& f2,
0097                const GlobalPoint& f3,
0098                const CCGFloat* parm,
0099                const DetId& detId) override;
0100 
0101   bool present(const DetId& id) const override;
0102 
0103 protected:
0104   // Modify the RawPtr class
0105   const CaloCellGeometry* getGeometryRawPtr(uint32_t index) const override;
0106 
0107 private:
0108   /** number of crystals in eta direction */
0109   int _nnxtalEta;
0110 
0111   /** number of crystals in phi direction */
0112   int _nnxtalPhi;
0113 
0114   /** size of the baskets in the eta direction. This is needed
0115       to find out whether two adjacent crystals lie in the same
0116       basked ('module') or not (e.g. this can be used for correcting
0117       cluster energies etc.) */
0118   std::vector<int> _EtaBaskets;
0119 
0120   /** size of one basket in phi */
0121   int _PhiBaskets;
0122 
0123   mutable std::atomic<EZMgrFL<EEDetId>*> m_borderMgr;
0124 
0125   mutable std::atomic<VecOrdListEEDetIdPtr*> m_borderPtrVec;
0126   CMS_THREAD_GUARD(m_check) mutable CCGFloat m_radius;
0127   mutable std::atomic<bool> m_check;
0128 
0129   CellVec m_cellVec;
0130 };
0131 
0132 #endif