File indexing completed on 2024-10-25 23:57:08
0001 #ifndef GeometryHGCalGeometryHGCalGeometry_h
0002 #define GeometryHGCalGeometryHGCalGeometry_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include "DataFormats/Common/interface/AtomicPtrCache.h"
0013 #include "DataFormats/ForwardDetId/interface/HFNoseDetId.h"
0014 #include "DataFormats/ForwardDetId/interface/HGCalDetId.h"
0015 #include "DataFormats/ForwardDetId/interface/HGCScintillatorDetId.h"
0016 #include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h"
0017 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0018 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
0019 #include "DetectorDescription/Core/interface/DDFilteredView.h"
0020 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0021 #include "Geometry/CaloGeometry/interface/FlatHexagon.h"
0022 #include "Geometry/CaloGeometry/interface/FlatTrd.h"
0023 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0024 #include "Geometry/CaloTopology/interface/HGCalTopology.h"
0025 #include "Geometry/Records/interface/HGCalGeometryRecord.h"
0026 #include "MagneticField/Engine/interface/MagneticField.h"
0027 #include <vector>
0028
0029 class HGCalGeometry final : public CaloSubdetectorGeometry {
0030 public:
0031 typedef std::vector<FlatHexagon> CellVec;
0032 typedef std::vector<FlatTrd> CellVec2;
0033 typedef CaloCellGeometry::CCGFloat CCGFloat;
0034 typedef CaloCellGeometry::Pt3D Pt3D;
0035 typedef CaloCellGeometry::Pt3DVec Pt3DVec;
0036
0037 typedef std::set<DetId> DetIdSet;
0038 typedef std::vector<GlobalPoint> CornersVec;
0039
0040 typedef HGCalGeometryRecord AlignedRecord;
0041 typedef PHGCalRcd PGeometryRecord;
0042
0043 static constexpr unsigned int k_NumberOfParametersPerTrd = 12;
0044 static constexpr unsigned int k_NumberOfParametersPerHex = 3;
0045 static constexpr unsigned int k_NumberOfParametersPerShape = 3;
0046 static constexpr unsigned int k_NumberOfShapes = 100;
0047 static constexpr unsigned int k_NumberOfShapesTrd = 1000;
0048
0049 static std::string dbString() { return "PHGCalRcd"; }
0050
0051 HGCalGeometry(const HGCalTopology& topology);
0052
0053 ~HGCalGeometry() override = default;
0054
0055 void localCorners(Pt3DVec& lc, const CCGFloat* pv, unsigned int i, Pt3D& ref);
0056
0057 void newCell(const GlobalPoint& f1,
0058 const GlobalPoint& f2,
0059 const GlobalPoint& f3,
0060 const CCGFloat* parm,
0061 const DetId& detId) override;
0062
0063
0064 CaloCellGeometryMayOwnPtr getGeometry(const DetId& id) const override;
0065
0066 bool present(const DetId& id) const override;
0067
0068 void getSummary(CaloSubdetectorGeometry::TrVec& trVector,
0069 CaloSubdetectorGeometry::IVec& iVector,
0070 CaloSubdetectorGeometry::DimVec& dimVector,
0071 CaloSubdetectorGeometry::IVec& dinsVector) const override;
0072
0073 GlobalPoint getPosition(const DetId& id, bool cog, bool debug) const;
0074 GlobalPoint getPosition(const DetId& id, bool debug = false) const;
0075 GlobalPoint getWaferPosition(const DetId& id) const;
0076
0077
0078 double getArea(const DetId& detid) const;
0079
0080
0081 CornersVec getCorners(const DetId& id) const;
0082 CornersVec get8Corners(const DetId& id) const;
0083 CornersVec getNewCorners(const DetId& id, bool debug = false) const;
0084
0085
0086 DetId neighborZ(const DetId& idin, const GlobalVector& p) const;
0087 DetId neighborZ(const DetId& idin, const MagneticField* bField, int charge, const GlobalVector& momentum) const;
0088
0089
0090 const std::vector<DetId>& getValidDetIds(DetId::Detector det = DetId::Detector(0), int subdet = 0) const override {
0091 return m_validIds;
0092 }
0093 const std::vector<DetId>& getValidGeomDetIds(void) const { return m_validGeomIds; }
0094
0095
0096 DetId getClosestCell(const GlobalPoint& r) const override;
0097 DetId getClosestCellHex(const GlobalPoint& r, bool extend) const;
0098
0099
0100
0101
0102
0103
0104
0105 DetIdSet getCells(const GlobalPoint& r, double dR) const override;
0106
0107 virtual void fillNamedParams(DDFilteredView fv);
0108 void initializeParms() override;
0109
0110 static std::string producerTag() { return "HGCal"; }
0111 std::string cellElement() const;
0112
0113 const HGCalTopology& topology() const { return m_topology; }
0114 void sortDetIds();
0115
0116 protected:
0117 unsigned int indexFor(const DetId& id) const override;
0118 using CaloSubdetectorGeometry::sizeForDenseIndex;
0119 unsigned int sizeForDenseIndex() const;
0120
0121
0122 CaloCellGeometryPtr getGeometryRawPtr(uint32_t index) const override;
0123
0124 CaloCellGeometryPtr cellGeomPtr(uint32_t index) const override;
0125
0126 void addValidID(const DetId& id);
0127 unsigned int getClosestCellIndex(const GlobalPoint& r) const;
0128
0129 private:
0130 template <class T>
0131 unsigned int getClosestCellIndex(const GlobalPoint& r, const std::vector<T>& vec) const;
0132 CaloCellGeometryMayOwnPtr cellGeomPtr(uint32_t index, const GlobalPoint& p) const;
0133 DetId getGeometryDetId(DetId detId) const;
0134
0135 static constexpr double k_half = 0.5;
0136 static constexpr double k_fac1 = 0.5;
0137 static constexpr double k_fac2 = 1.0 / 3.0;
0138
0139 const HGCalTopology& m_topology;
0140 CellVec m_cellVec;
0141 CellVec2 m_cellVec2;
0142 std::vector<DetId> m_validGeomIds;
0143 DetId::Detector m_det;
0144 ForwardSubdetector m_subdet;
0145 const double twoBysqrt3_;
0146 };
0147
0148 #endif