Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:07:58

0001 #ifndef EcalEndcapGeometry_h
0002 #define EcalEndcapGeometry_h
0003 
0004 #include "Geometry/CaloGeometry/interface/EZArrayFL.h"
0005 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0006 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0007 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0008 #include "Geometry/Records/interface/EcalEndcapGeometryRecord.h"
0009 #include "CondFormats/AlignmentRecord/interface/EEAlignmentRcd.h"
0010 #include "Geometry/EcalCommonData/interface/EcalEndcapNumberingScheme.h"
0011 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0012 #include "Geometry/Records/interface/PEcalEndcapRcd.h"
0013 #include "FWCore/Utilities/interface/thread_safety_macros.h"
0014 #include <vector>
0015 #include <map>
0016 #include <atomic>
0017 
0018 class TruncatedPyramid;
0019 
0020 class EcalEndcapGeometry final : public CaloSubdetectorGeometry {
0021 public:
0022   typedef std::vector<TruncatedPyramid> CellVec;
0023 
0024   typedef CaloCellGeometry::CCGFloat CCGFloat;
0025   typedef CaloCellGeometry::Pt3D Pt3D;
0026   typedef CaloCellGeometry::Pt3DVec Pt3DVec;
0027 
0028   typedef IdealGeometryRecord IdealRecord;
0029   typedef EcalEndcapGeometryRecord AlignedRecord;
0030   typedef EEAlignmentRcd AlignmentRecord;
0031   typedef PEcalEndcapRcd PGeometryRecord;
0032 
0033   typedef EZArrayFL<EBDetId> OrderedListOfEBDetId;  // like an stl vector: begin(), end(), [i]
0034 
0035   typedef std::vector<OrderedListOfEBDetId*> VecOrdListEBDetIdPtr;
0036 
0037   typedef EcalEndcapNumberingScheme NumberingScheme;
0038 
0039   typedef EEDetId DetIdType;
0040 
0041   enum { k_NumberOfCellsForCorners = EEDetId::kSizeForDenseIndexing };
0042 
0043   enum { k_NumberOfShapes = 1 };
0044 
0045   enum { k_NumberOfParametersPerShape = 11 };
0046 
0047   static std::string dbString() { return "PEcalEndcapRcd"; }
0048 
0049   unsigned int numberOfShapes() const override { return k_NumberOfShapes; }
0050   unsigned int numberOfParametersPerShape() const override { return k_NumberOfParametersPerShape; }
0051 
0052   EcalEndcapGeometry();
0053 
0054   ~EcalEndcapGeometry() override;
0055 
0056   int getNumberOfModules() const { return _nnmods; }
0057 
0058   int getNumberOfCrystalPerModule() const { return _nncrys; }
0059 
0060   void setNumberOfModules(const int nnmods) { _nnmods = nnmods; }
0061 
0062   void setNumberOfCrystalPerModule(const int nncrys) { _nncrys = nncrys; }
0063 
0064   const OrderedListOfEBDetId* getClosestBarrelCells(EEDetId id) const;
0065 
0066   // Get closest cell, etc...
0067   DetId getClosestCell(const GlobalPoint& r) const override;
0068 
0069   CaloSubdetectorGeometry::DetIdSet getCells(const GlobalPoint& r, double dR) const override;
0070 
0071   void initializeParms() override;
0072 
0073   CCGFloat avgAbsZFrontFaceCenter() const;  // average over both endcaps. Positive!
0074 
0075   static std::string hitString() { return "EcalHitsEE"; }
0076 
0077   static std::string producerTag() { return "EcalEndcap"; }
0078 
0079   static unsigned int numberOfAlignments() { return 4; }
0080 
0081   static unsigned int alignmentTransformIndexLocal(const DetId& id);
0082 
0083   static unsigned int alignmentTransformIndexGlobal(const DetId& id);
0084 
0085   static DetId detIdFromLocalAlignmentIndex(unsigned int iLoc);
0086 
0087   static void localCorners(Pt3DVec& lc, const CCGFloat* pv, unsigned int i, Pt3D& ref);
0088 
0089   void newCell(const GlobalPoint& f1,
0090                const GlobalPoint& f2,
0091                const GlobalPoint& f3,
0092                const CCGFloat* parm,
0093                const DetId& detId) override;
0094 
0095   bool present(const DetId& id) const override;
0096 
0097 protected:
0098   // Modify the RawPtr class
0099   const CaloCellGeometry* getGeometryRawPtr(uint32_t index) const override;
0100 
0101 private:
0102   static int myPhi(int i) {
0103     i += 720;
0104     return (1 + (i - 1) % 360);
0105   }
0106 
0107   /// number of modules
0108   int _nnmods;
0109 
0110   /// number of crystals per module
0111   int _nncrys;
0112 
0113   CCGFloat zeP, zeN;
0114 
0115   CCGFloat m_wref, m_xlo[2], m_xhi[2], m_ylo[2], m_yhi[2], m_xoff[2], m_yoff[2], m_del;
0116 
0117   unsigned int m_nref;
0118 
0119   unsigned int xindex(CCGFloat x, CCGFloat z) const;
0120   unsigned int yindex(CCGFloat y, CCGFloat z) const;
0121 
0122   EEDetId gId(float x, float y, float z) const;
0123 
0124   mutable std::atomic<EZMgrFL<EBDetId>*> m_borderMgr;
0125 
0126   mutable std::atomic<VecOrdListEBDetIdPtr*> m_borderPtrVec;
0127 
0128   CMS_THREAD_GUARD(m_check) mutable CCGFloat m_avgZ;
0129   mutable std::atomic<bool> m_check;
0130 
0131   CellVec m_cellVec;
0132 };
0133 
0134 #endif