CMS 3D CMS Logo

CaloCellGeometry.h
Go to the documentation of this file.
1 #ifndef GEOMETRY_CALOGEOMETRY_CALOCELLGEOMETRY_H
2 #define GEOMETRY_CALOGEOMETRY_CALOCELLGEOMETRY_H 1
3 
7 #include <CLHEP/Geometry/Point3D.h>
8 #include <CLHEP/Geometry/Transform3D.h>
10 
11 #include <vector>
12 #include <array>
13 #include <string>
14 #include <cassert>
15 #include <atomic>
16 
52 public:
53  typedef float CCGFloat;
54  typedef HepGeom::Transform3D Tr3D;
55  typedef HepGeom::Point3D<CCGFloat> Pt3D;
56  typedef std::vector<Pt3D> Pt3DVec;
57 
60 
62  typedef std::vector<ParVec> ParVecVec;
64 
66 
67  static constexpr unsigned int k_cornerSize = 8;
68 
69  using RepCorners = std::array<RhoEtaPhi, k_cornerSize>;
70 
72 
73  virtual ~CaloCellGeometry();
74 
76  CornersVec const& getCorners() const {
78  return m_corners;
79  }
80  RepCorners const& getCornersREP() const { return m_repCorners; }
81 
83  virtual const GlobalPoint& getPosition() const { return m_refPoint; }
84  virtual GlobalPoint getPosition(CCGFloat) const { return m_refPoint; }
85  virtual GlobalPoint getPosition(const Pt3D&) const { return m_refPoint; }
86 
87  GlobalPoint const& getBackPoint() const { return m_backPoint; }
88 
89  RhoEtaPhi const& repPos() const { return m_rep; }
90  virtual float rhoPos() const { return m_rep.rho(); }
91  virtual float etaPos() const { return m_rep.eta(); }
92  virtual float phiPos() const { return m_rep.phi(); }
93 
94  virtual float etaSpan() const { return m_dEta; }
95  virtual float phiSpan() const { return m_dPhi; }
96 
98  bool inside(const GlobalPoint& point) const;
99 
100  bool emptyCorners() const { return m_corners.empty(); }
101 
102  const CCGFloat* param() const { return m_parms; }
103 
104  static const CCGFloat* checkParmPtr(const std::vector<CCGFloat>& vd, ParVecVec& pvv);
105 
106  static const CCGFloat* getParmPtr(const std::vector<CCGFloat>& vd, ParMgr* mgr, ParVecVec& pvv);
107 
109  virtual void getTransform(Tr3D& tr, Pt3DVec* lptr) const;
110  //------------------------------------------------------------------------
112 
113  virtual void vocalCorners(Pt3DVec& vec, const CCGFloat* pv, Pt3D& ref) const = 0;
114 
115 protected:
117 
118  CaloCellGeometry(const CornersVec& cv, const CCGFloat* par);
119 
121 
122  CaloCellGeometry(CaloCellGeometry&&) = default;
123  CaloCellGeometry(CaloCellGeometry const&) = default;
125  CaloCellGeometry& operator=(CaloCellGeometry const&) = default;
126  // MUST be called by children constructors
127  void initSpan() {
129  m_dEta = std::abs(getCorners()[0].eta() - getCorners()[2].eta());
130  m_dPhi = std::abs(getCorners()[0].phi() - getCorners()[2].phi());
131  initBack();
132  initReps();
133  }
134 
135  virtual void initCorners(CornersVec&) = 0;
136 
138  void setCornerVec(const std::vector<GlobalPoint>& cor) {
139  for (unsigned int k = 0; k < cor.size(); ++k)
140  m_corners[k] = cor[k];
141  }
142 
143 private:
144  void initBack() {
145  // from CaloTower code
146  CornersVec const& cv = getCorners();
147  m_backPoint = GlobalPoint(0.25 * (cv[4].x() + cv[5].x() + cv[6].x() + cv[7].x()),
148  0.25 * (cv[4].y() + cv[5].y() + cv[6].y() + cv[7].y()),
149  0.25 * (cv[4].z() + cv[5].z() + cv[6].z() + cv[7].z()));
150  }
151  void initReps() {
152  for (auto i = 0U; i < k_cornerSize; ++i)
153  m_repCorners[i] = {getCorners()[i].perp(), getCorners()[i].eta(), getCorners()[i].barePhi()};
154  }
155 
156  //These methods are ONLY used by CaloCellGeometryMayOwnPtr
157  void increment() const { ++m_ref.m_count; }
158  bool decrement() const { return 0 == --m_ref.m_count; }
159 
165  float m_dEta;
166  float m_dPhi;
167  std::array<RhoEtaPhi, k_cornerSize> m_repCorners;
168  struct RefCount {
169  RefCount() = default;
171  RefCount(RefCount const&) {}
172  RefCount& operator=(RefCount&&) { return *this; }
173  RefCount& operator=(const RefCount&) { return *this; }
174 
175  mutable std::atomic<unsigned int> m_count = 0;
176  } m_ref;
177 };
178 
179 std::ostream& operator<<(std::ostream& s, const CaloCellGeometry& cell);
180 
181 #endif
EZArrayFL< GlobalPoint > CornersVec
EZMgrFL< CCGFloat > ParMgr
EZArrayFL< CCGFloat > ParVec
RefCount & operator=(RefCount &&)
RhoEtaPhi const & repPos() const
virtual float phiPos() const
std::vector< ParVec > ParVecVec
void setRefPoint(const GlobalPoint &pos)
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
const CCGFloat * m_parms
void setCornerVec(const std::vector< GlobalPoint > &cor)
HepGeom::Transform3D Tr3D
cv
Definition: cuy.py:363
std::vector< Pt3D > Pt3DVec
assert(be >=bs)
EZMgrFL< GlobalPoint > CornersMgr
virtual GlobalPoint getPosition(const Pt3D &) const
virtual float etaSpan() const
static constexpr unsigned int k_cornerSize
MgrType::const_reference const_reference
Definition: EZArrayFL.h:26
virtual float etaPos() const
CaloCellGeometry & operator=(CaloCellGeometry &&)=default
virtual float rhoPos() const
std::ostream & operator<<(std::ostream &s, const CaloCellGeometry &cell)
bool decrement() const
GlobalPoint m_backPoint
virtual ~CaloCellGeometry()
std::array< RhoEtaPhi, k_cornerSize > m_repCorners
float phi() const
momentum azimuthal angle
Definition: PtEtaPhiMass.h:54
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
CaloCellGeometry::CCGFloat CCGFloat
std::array< RhoEtaPhi, k_cornerSize > RepCorners
virtual float phiSpan() const
static const CCGFloat * getParmPtr(const std::vector< CCGFloat > &vd, ParMgr *mgr, ParVecVec &pvv)
GlobalPoint m_refPoint
static const CCGFloat k_ScaleFromDDDtoGeant
RefCount & operator=(const RefCount &)
virtual void vocalCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref) const =0
std::vector< DeviationSensor2D * > vd
CaloCellGeometry::Pt3D Pt3D
void increment() const
virtual void initCorners(CornersVec &)=0
RepCorners const & getCornersREP() const
bool emptyCorners() const
CaloCellGeometry::Pt3DVec Pt3DVec
HepGeom::Point3D< CCGFloat > Pt3D
Definition: EZMgrFL.h:8
void setBackPoint(const GlobalPoint &pos)
virtual GlobalPoint getPosition(CCGFloat) const
float eta() const
momentum pseudorapidity
Definition: PtEtaPhiMass.h:52
virtual const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
CaloCellGeometry::Tr3D Tr3D
struct CaloCellGeometry::RefCount m_ref
bool inside(const GlobalPoint &point) const
Returns true if the specified point is inside this cell.
CornersVec const & getCorners() const
Returns the corner points of this cell&#39;s volume.
virtual void getTransform(Tr3D &tr, Pt3DVec *lptr) const
--------— only needed by specific utility; overloaded when needed -—
float rho() const
transverse momentum
Definition: PtEtaPhiMass.h:50
bool empty() const
Definition: EZArrayFL.h:63
bool uninitialized() const
Definition: EZArrayFL.h:61
GlobalPoint const & getBackPoint() const
const CCGFloat * param() const
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
std::atomic< unsigned int > m_count
static const CCGFloat * checkParmPtr(const std::vector< CCGFloat > &vd, ParVecVec &pvv)