CMS 3D CMS Logo

HGCalGeometry.h
Go to the documentation of this file.
1 #ifndef GeometryHGCalGeometryHGCalGeometry_h
2 #define GeometryHGCalGeometryHGCalGeometry_h
3 
4 /*
5  * Geometry for High Granularity Calorimeter
6  * This geometry is essentially driven by topology,
7  * which is thus encapsulated in this class.
8  * This makes this geometry not suitable to be loaded
9  * by regular CaloGeometryLoader<T>
10  */
11 
27 #include <vector>
28 
29 class HGCalGeometry final : public CaloSubdetectorGeometry {
30 public:
31  typedef std::vector<FlatHexagon> CellVec;
32  typedef std::vector<FlatTrd> CellVec2;
36 
37  typedef std::set<DetId> DetIdSet;
38  typedef std::vector<GlobalPoint> CornersVec;
39 
40  typedef HGCalGeometryRecord AlignedRecord; // NOTE: not aligned yet
42 
43  static constexpr unsigned int k_NumberOfParametersPerTrd = 12; // FlatTrd
44  static constexpr unsigned int k_NumberOfParametersPerHex = 3; // FlatHexagon
45  static constexpr unsigned int k_NumberOfParametersPerShape = 3; // FlatHexagon
46  static constexpr unsigned int k_NumberOfShapes = 100;
47  static constexpr unsigned int k_NumberOfShapesTrd = 1000;
48 
49  static std::string dbString() { return "PHGCalRcd"; }
50 
52 
53  ~HGCalGeometry() override = default;
54 
55  void localCorners(Pt3DVec& lc, const CCGFloat* pv, unsigned int i, Pt3D& ref);
56 
57  void newCell(const GlobalPoint& f1,
58  const GlobalPoint& f2,
59  const GlobalPoint& f3,
60  const CCGFloat* parm,
61  const DetId& detId) override;
62 
64  std::shared_ptr<const CaloCellGeometry> getGeometry(const DetId& id) const override;
65 
66  bool present(const DetId& id) const override;
67 
71  CaloSubdetectorGeometry::IVec& dinsVector) const override;
72 
73  GlobalPoint getPosition(const DetId& id, bool debug = false) const;
74  GlobalPoint getWaferPosition(const DetId& id) const;
75 
77  double getArea(const DetId& detid) const;
78 
80  CornersVec getCorners(const DetId& id) const;
81  CornersVec get8Corners(const DetId& id) const;
82  CornersVec getNewCorners(const DetId& id, bool debug = false) const;
83 
84  // Get neighbor in z along a direction
85  DetId neighborZ(const DetId& idin, const GlobalVector& p) const;
86  DetId neighborZ(const DetId& idin, const MagneticField* bField, int charge, const GlobalVector& momentum) const;
87 
88  // avoid sorting set in base class
89  const std::vector<DetId>& getValidDetIds(DetId::Detector det = DetId::Detector(0), int subdet = 0) const override {
90  return m_validIds;
91  }
92  const std::vector<DetId>& getValidGeomDetIds(void) const { return m_validGeomIds; }
93 
94  // Get closest cell, etc...
95  DetId getClosestCell(const GlobalPoint& r) const override;
96  DetId getClosestCellHex(const GlobalPoint& r, bool extend) const;
97 
104  DetIdSet getCells(const GlobalPoint& r, double dR) const override;
105 
106  virtual void fillNamedParams(DDFilteredView fv);
107  void initializeParms() override;
108 
109  static std::string producerTag() { return "HGCal"; }
110  std::string cellElement() const;
111 
112  const HGCalTopology& topology() const { return m_topology; }
113  void sortDetIds();
114 
115 protected:
116  unsigned int indexFor(const DetId& id) const override;
118  unsigned int sizeForDenseIndex() const;
119 
120  // Modify the RawPtr class
121  const CaloCellGeometry* getGeometryRawPtr(uint32_t index) const override;
122 
123  std::shared_ptr<const CaloCellGeometry> cellGeomPtr(uint32_t index) const override;
124 
125  void addValidID(const DetId& id);
126  unsigned int getClosestCellIndex(const GlobalPoint& r) const;
127 
128 private:
129  template <class T>
130  unsigned int getClosestCellIndex(const GlobalPoint& r, const std::vector<T>& vec) const;
131  std::shared_ptr<const CaloCellGeometry> cellGeomPtr(uint32_t index, const GlobalPoint& p) const;
133 
134  static constexpr double k_half = 0.5;
135  static constexpr double k_fac1 = 0.5;
136  static constexpr double k_fac2 = 1.0 / 3.0;
137 
141  std::vector<DetId> m_validGeomIds;
144  const double twoBysqrt3_;
145 };
146 
147 #endif
DetId getClosestCellHex(const GlobalPoint &r, bool extend) const
static constexpr unsigned int k_NumberOfShapes
Definition: HGCalGeometry.h:46
std::vector< DetId > m_validGeomIds
DetId neighborZ(const DetId &idin, const GlobalVector &p) const
~HGCalGeometry() override=default
std::vector< CCGFloat > DimVec
std::vector< FlatHexagon > CellVec
Definition: HGCalGeometry.h:31
GlobalPoint getWaferPosition(const DetId &id) const
const HGCalTopology & m_topology
static std::string producerTag()
const std::vector< DetId > & getValidGeomDetIds(void) const
Definition: HGCalGeometry.h:92
std::vector< unsigned int > IVec
bool present(const DetId &id) const override
is this detid present in the geometry?
void newCell(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId) override
std::vector< GlobalPoint > CornersVec
Definition: HGCalGeometry.h:38
std::vector< CCGFloat > TrVec
HGCalGeometryRecord AlignedRecord
Definition: HGCalGeometry.h:40
static constexpr double k_fac2
std::vector< Pt3D > Pt3DVec
ForwardSubdetector
CornersVec getCorners(const DetId &id) const
Returns the corner points of this cell&#39;s volume.
static constexpr double k_half
CornersVec getNewCorners(const DetId &id, bool debug=false) const
CaloCellGeometry::Pt3DVec Pt3DVec
Definition: HGCalGeometry.h:35
static constexpr double k_fac1
const double twoBysqrt3_
HGCalGeometry(const HGCalTopology &topology)
DetId getClosestCell(const GlobalPoint &r) const override
void initializeParms() override
static constexpr unsigned int k_NumberOfParametersPerShape
Definition: HGCalGeometry.h:45
unsigned int getClosestCellIndex(const GlobalPoint &r) const
std::vector< DetId > m_validIds
DetIdSet getCells(const GlobalPoint &r, double dR) const override
Get a list of all cells within a dR of the given cell.
static std::string dbString()
Definition: HGCalGeometry.h:49
static constexpr unsigned int k_NumberOfParametersPerTrd
Definition: HGCalGeometry.h:43
unsigned int indexFor(const DetId &id) const override
unsigned int sizeForDenseIndex() const
std::set< DetId > DetIdSet
Definition: HGCalGeometry.h:37
CaloCellGeometry::CCGFloat CCGFloat
DetId getGeometryDetId(DetId detId) const
const CaloCellGeometry * getGeometryRawPtr(uint32_t index) const override
CellVec2 m_cellVec2
const HGCalTopology & topology() const
void localCorners(Pt3DVec &lc, const CCGFloat *pv, unsigned int i, Pt3D &ref)
CaloCellGeometry::Pt3D Pt3D
static constexpr unsigned int k_NumberOfParametersPerHex
Definition: HGCalGeometry.h:44
Definition: DetId.h:17
ForwardSubdetector m_subdet
#define debug
Definition: HDRShower.cc:19
std::vector< FlatTrd > CellVec2
Definition: HGCalGeometry.h:32
Detector
Definition: DetId.h:24
static constexpr unsigned int k_NumberOfShapesTrd
Definition: HGCalGeometry.h:47
std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const override
Get the cell geometry of a given detector id. Should return false if not found.
CaloCellGeometry::Pt3DVec Pt3DVec
HepGeom::Point3D< CCGFloat > Pt3D
const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const override
Get a list of valid detector ids (for the given subdetector)
Definition: HGCalGeometry.h:89
GlobalPoint getPosition(const DetId &id, bool debug=false) const
CaloCellGeometry::Pt3D Pt3D
Definition: HGCalGeometry.h:34
std::shared_ptr< const CaloCellGeometry > cellGeomPtr(uint32_t index) const override
PHGCalRcd PGeometryRecord
Definition: HGCalGeometry.h:41
virtual void fillNamedParams(DDFilteredView fv)
DetId::Detector m_det
void getSummary(CaloSubdetectorGeometry::TrVec &trVector, CaloSubdetectorGeometry::IVec &iVector, CaloSubdetectorGeometry::DimVec &dimVector, CaloSubdetectorGeometry::IVec &dinsVector) const override
void addValidID(const DetId &id)
std::string cellElement() const
double getArea(const DetId &detid) const
Returns area of a cell.
CellVec m_cellVec
CornersVec get8Corners(const DetId &id) const
CaloCellGeometry::CCGFloat CCGFloat
Definition: HGCalGeometry.h:33
virtual unsigned int sizeForDenseIndex(const DetId &id) const