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 cog, bool debug) const;
74  GlobalPoint getPosition(const DetId& id, bool debug = false) const;
75  GlobalPoint getWaferPosition(const DetId& id) const;
76 
78  double getArea(const DetId& detid) const;
79 
81  CornersVec getCorners(const DetId& id) const;
82  CornersVec get8Corners(const DetId& id) const;
83  CornersVec getNewCorners(const DetId& id, bool debug = false) const;
84 
85  // Get neighbor in z along a direction
86  DetId neighborZ(const DetId& idin, const GlobalVector& p) const;
87  DetId neighborZ(const DetId& idin, const MagneticField* bField, int charge, const GlobalVector& momentum) const;
88 
89  // avoid sorting set in base class
90  const std::vector<DetId>& getValidDetIds(DetId::Detector det = DetId::Detector(0), int subdet = 0) const override {
91  return m_validIds;
92  }
93  const std::vector<DetId>& getValidGeomDetIds(void) const { return m_validGeomIds; }
94 
95  // Get closest cell, etc...
96  DetId getClosestCell(const GlobalPoint& r) const override;
97  DetId getClosestCellHex(const GlobalPoint& r, bool extend) const;
98 
105  DetIdSet getCells(const GlobalPoint& r, double dR) const override;
106 
107  virtual void fillNamedParams(DDFilteredView fv);
108  void initializeParms() override;
109 
110  static std::string producerTag() { return "HGCal"; }
111  std::string cellElement() const;
112 
113  const HGCalTopology& topology() const { return m_topology; }
114  void sortDetIds();
115 
116 protected:
117  unsigned int indexFor(const DetId& id) const override;
119  unsigned int sizeForDenseIndex() const;
120 
121  // Modify the RawPtr class
122  const CaloCellGeometry* getGeometryRawPtr(uint32_t index) const override;
123 
124  std::shared_ptr<const CaloCellGeometry> cellGeomPtr(uint32_t index) const override;
125 
126  void addValidID(const DetId& id);
127  unsigned int getClosestCellIndex(const GlobalPoint& r) const;
128 
129 private:
130  template <class T>
131  unsigned int getClosestCellIndex(const GlobalPoint& r, const std::vector<T>& vec) const;
132  std::shared_ptr<const CaloCellGeometry> cellGeomPtr(uint32_t index, const GlobalPoint& p) const;
134 
135  static constexpr double k_half = 0.5;
136  static constexpr double k_fac1 = 0.5;
137  static constexpr double k_fac2 = 1.0 / 3.0;
138 
142  std::vector<DetId> m_validGeomIds;
145  const double twoBysqrt3_;
146 };
147 
148 #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:93
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
GlobalPoint getPosition(const DetId &id, bool cog, bool debug) const
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:90
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