File indexing completed on 2023-03-17 13:03:38
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 std::shared_ptr<const CaloCellGeometry> 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 debug = false) const;
0074 GlobalPoint getWaferPosition(const DetId& id) const;
0075
0076
0077 double getArea(const DetId& detid) const;
0078
0079
0080 CornersVec getCorners(const DetId& id) const;
0081 CornersVec get8Corners(const DetId& id) const;
0082 CornersVec getNewCorners(const DetId& id, bool debug = false) const;
0083
0084
0085 DetId neighborZ(const DetId& idin, const GlobalVector& p) const;
0086 DetId neighborZ(const DetId& idin, const MagneticField* bField, int charge, const GlobalVector& momentum) const;
0087
0088
0089 const std::vector<DetId>& getValidDetIds(DetId::Detector det = DetId::Detector(0), int subdet = 0) const override {
0090 return m_validIds;
0091 }
0092 const std::vector<DetId>& getValidGeomDetIds(void) const { return m_validGeomIds; }
0093
0094
0095 DetId getClosestCell(const GlobalPoint& r) const override;
0096 DetId getClosestCellHex(const GlobalPoint& r, bool extend) const;
0097
0098
0099
0100
0101
0102
0103
0104 DetIdSet getCells(const GlobalPoint& r, double dR) const override;
0105
0106 virtual void fillNamedParams(DDFilteredView fv);
0107 void initializeParms() override;
0108
0109 static std::string producerTag() { return "HGCal"; }
0110 std::string cellElement() const;
0111
0112 const HGCalTopology& topology() const { return m_topology; }
0113 void sortDetIds();
0114
0115 protected:
0116 unsigned int indexFor(const DetId& id) const override;
0117 using CaloSubdetectorGeometry::sizeForDenseIndex;
0118 unsigned int sizeForDenseIndex() const;
0119
0120
0121 const CaloCellGeometry* getGeometryRawPtr(uint32_t index) const override;
0122
0123 std::shared_ptr<const CaloCellGeometry> cellGeomPtr(uint32_t index) const override;
0124
0125 void addValidID(const DetId& id);
0126 unsigned int getClosestCellIndex(const GlobalPoint& r) const;
0127
0128 private:
0129 template <class T>
0130 unsigned int getClosestCellIndex(const GlobalPoint& r, const std::vector<T>& vec) const;
0131 std::shared_ptr<const CaloCellGeometry> cellGeomPtr(uint32_t index, const GlobalPoint& p) const;
0132 DetId getGeometryDetId(DetId detId) const;
0133
0134 static constexpr double k_half = 0.5;
0135 static constexpr double k_fac1 = 0.5;
0136 static constexpr double k_fac2 = 1.0 / 3.0;
0137
0138 const HGCalTopology& m_topology;
0139 CellVec m_cellVec;
0140 CellVec2 m_cellVec2;
0141 std::vector<DetId> m_validGeomIds;
0142 DetId::Detector m_det;
0143 ForwardSubdetector m_subdet;
0144 const double twoBysqrt3_;
0145 };
0146
0147 #endif