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