File indexing completed on 2024-10-25 23:57:07
0001 #ifndef HcalGeometry_h
0002 #define HcalGeometry_h
0003
0004 #include "DataFormats/Common/interface/AtomicPtrCache.h"
0005
0006 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0007 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0008 #include "Geometry/CaloGeometry/interface/IdealObliquePrism.h"
0009 #include "Geometry/CaloGeometry/interface/IdealZPrism.h"
0010 #include "Geometry/CaloTopology/interface/HcalTopology.h"
0011 #include "CondFormats/AlignmentRecord/interface/HcalAlignmentRcd.h"
0012 #include "Geometry/Records/interface/HcalGeometryRecord.h"
0013
0014 class HcalFlexiHardcodeGeometryLoader;
0015 class HcalHardcodeGeometryLoader;
0016
0017 class HcalGeometry : public CaloSubdetectorGeometry {
0018 friend class HcalGeometryPlan1Tester;
0019
0020 public:
0021 friend class HcalFlexiHardcodeGeometryLoader;
0022 friend class HcalHardcodeGeometryLoader;
0023
0024 typedef std::vector<IdealObliquePrism> HBCellVec;
0025 typedef std::vector<IdealObliquePrism> HECellVec;
0026 typedef std::vector<IdealObliquePrism> HOCellVec;
0027 typedef std::vector<IdealZPrism> HFCellVec;
0028
0029 typedef CaloCellGeometry::CCGFloat CCGFloat;
0030 typedef CaloCellGeometry::Pt3D Pt3D;
0031 typedef CaloCellGeometry::Pt3DVec Pt3DVec;
0032
0033 typedef HcalAlignmentRcd AlignmentRecord;
0034 typedef HcalGeometryRecord AlignedRecord;
0035 typedef PHcalRcd PGeometryRecord;
0036 typedef HcalDetId DetIdType;
0037
0038 enum { k_NumberOfParametersPerShape = 5 };
0039
0040 static std::string dbString() { return "PHcalRcd"; }
0041
0042 unsigned int numberOfShapes() const override { return m_topology.getNumberOfShapes(); }
0043 unsigned int numberOfParametersPerShape() const override { return k_NumberOfParametersPerShape; }
0044
0045 explicit HcalGeometry(const HcalTopology& topology);
0046
0047
0048 ~HcalGeometry() override;
0049
0050 const std::vector<DetId>& getValidDetIds(DetId::Detector det = DetId::Detector(0), int subdet = 0) const override;
0051
0052 CaloCellGeometryMayOwnPtr getGeometry(const DetId& id) const override;
0053
0054 DetId getClosestCell(const GlobalPoint& r) const override;
0055 DetId getClosestCell(const GlobalPoint& r, bool ignoreCorrect) const;
0056
0057 CaloSubdetectorGeometry::DetIdSet getCells(const GlobalPoint& r, double dR) const override;
0058
0059 GlobalPoint getPosition(const DetId& id) const;
0060 GlobalPoint getPosition(uint32_t id, bool type) const;
0061 GlobalPoint getBackPosition(const DetId& id) const;
0062 GlobalPoint getBackPosition(uint32_t id, bool type) const;
0063 CaloCellGeometry::CornersVec getCorners(const DetId& id) const;
0064
0065 static std::string producerTag() { return "HCAL"; }
0066
0067 static unsigned int numberOfBarrelAlignments() { return 36; }
0068
0069 static unsigned int numberOfEndcapAlignments() { return 36; }
0070
0071 static unsigned int numberOfForwardAlignments() { return 36; }
0072
0073 static unsigned int numberOfOuterAlignments() { return 60; }
0074
0075 unsigned int getHxSize(const int type) const;
0076
0077 static unsigned int numberOfAlignments() {
0078 return (numberOfBarrelAlignments() + numberOfEndcapAlignments() + numberOfOuterAlignments() +
0079 numberOfForwardAlignments());
0080 }
0081
0082 static unsigned int alignmentBarrelIndexLocal(const DetId& id);
0083 static unsigned int alignmentEndcapIndexLocal(const DetId& id);
0084 static unsigned int alignmentForwardIndexLocal(const DetId& id);
0085 static unsigned int alignmentOuterIndexLocal(const DetId& id);
0086 static unsigned int alignmentTransformIndexLocal(const DetId& id);
0087
0088 static unsigned int alignmentBarEndForIndexLocal(const DetId& id, unsigned int nD);
0089
0090 static unsigned int alignmentTransformIndexGlobal(const DetId& id);
0091
0092 static DetId detIdFromLocalAlignmentIndex(unsigned int i);
0093 static DetId detIdFromBarrelAlignmentIndex(unsigned int i);
0094 static DetId detIdFromEndcapAlignmentIndex(unsigned int i);
0095 static DetId detIdFromForwardAlignmentIndex(unsigned int i);
0096 static DetId detIdFromOuterAlignmentIndex(unsigned int i);
0097
0098 void localCorners(Pt3DVec& lc, const CCGFloat* pv, unsigned int i, Pt3D& ref);
0099
0100 void newCell(const GlobalPoint& f1,
0101 const GlobalPoint& f2,
0102 const GlobalPoint& f3,
0103 const CCGFloat* parm,
0104 const DetId& detId) override;
0105
0106 void getSummary(CaloSubdetectorGeometry::TrVec& trVector,
0107 CaloSubdetectorGeometry::IVec& iVector,
0108 CaloSubdetectorGeometry::DimVec& dimVector,
0109 CaloSubdetectorGeometry::IVec& dinsVector) const override;
0110
0111 const HcalTopology& topology() const { return m_topology; }
0112
0113 protected:
0114 unsigned int indexFor(const DetId& id) const override { return m_topology.detId2denseId(id); }
0115 unsigned int sizeForDenseIndex(const DetId& id) const override { return m_topology.ncells(); }
0116
0117
0118 CaloCellGeometryPtr getGeometryRawPtr(uint32_t index) const override;
0119
0120 private:
0121
0122 CaloCellGeometryPtr getGeometryBase(const DetId& id) const { return cellGeomPtr(m_topology.detId2denseId(id)); }
0123
0124
0125 unsigned int newCellImpl(
0126 const GlobalPoint& f1, const GlobalPoint& f2, const GlobalPoint& f3, const CCGFloat* parm, const DetId& detId);
0127
0128
0129 void newCellFast(
0130 const GlobalPoint& f1, const GlobalPoint& f2, const GlobalPoint& f3, const CCGFloat* parm, const DetId& detId);
0131
0132 void increaseReserve(unsigned int extra);
0133 void sortValidIds();
0134
0135 void fillDetIds() const;
0136
0137 void init();
0138
0139
0140 int etaRing(HcalSubdetector bc, double abseta) const;
0141 int phiBin(HcalSubdetector bc, int etaring, double phi) const;
0142 DetId correctId(const DetId& id) const;
0143
0144 const HcalTopology& m_topology;
0145 bool m_mergePosition;
0146
0147 mutable edm::AtomicPtrCache<std::vector<DetId>> m_hbIds;
0148 mutable edm::AtomicPtrCache<std::vector<DetId>> m_heIds;
0149 mutable edm::AtomicPtrCache<std::vector<DetId>> m_hoIds;
0150 mutable edm::AtomicPtrCache<std::vector<DetId>> m_hfIds;
0151 mutable edm::AtomicPtrCache<std::vector<DetId>> m_emptyIds;
0152 CaloSubdetectorGeometry::IVec m_dins;
0153
0154 HBCellVec m_hbCellVec;
0155 HECellVec m_heCellVec;
0156 HOCellVec m_hoCellVec;
0157 HFCellVec m_hfCellVec;
0158 };
0159
0160 #endif