CMS 3D CMS Logo

CaloCellGeometry.cc
Go to the documentation of this file.
2 #include <CLHEP/Geometry/Plane3D.h>
3 
8 
9 typedef HepGeom::Vector3D<CCGFloat> FVec3D;
10 typedef HepGeom::Plane3D<CCGFloat> Plane3D;
11 
12 typedef HepGeom::Vector3D<double> DVec3D;
13 typedef HepGeom::Plane3D<double> DPlane3D;
14 typedef HepGeom::Point3D<double> DPt3D;
15 typedef std::vector<DPt3D> DPt3DVec;
16 
18 
19 CaloCellGeometry::CaloCellGeometry() : m_refPoint(0., 0., 0.), m_corners(), m_parms((CCGFloat*)nullptr) {}
20 
22 
24  : m_refPoint(gp), m_corners(mgr), m_parms(par), m_rep(gp.perp(), gp.eta(), gp.barePhi()) {}
25 
27  : m_refPoint(0.25 * (cv[0].x() + cv[1].x() + cv[2].x() + cv[3].x()),
28  0.25 * (cv[0].y() + cv[1].y() + cv[2].y() + cv[3].y()),
29  0.25 * (cv[0].z() + cv[1].z() + cv[2].z() + cv[3].z())),
30  m_corners(cv),
31  m_parms(par),
33 
34 std::ostream& operator<<(std::ostream& s, const CaloCellGeometry& cell) {
35  s << ", Center: " << cell.getPosition() << std::endl;
36 
37  if (cell.emptyCorners()) {
38  s << "Corners vector is empty." << std::endl;
39  } else {
40  const CaloCellGeometry::CornersVec& corners(cell.getCorners());
41  for (unsigned int i(0); i != corners.size(); ++i) {
42  s << "Corner: " << corners[i] << std::endl;
43  }
44  }
45  return s;
46 }
47 
50  const Pt3D gFront(p.x(), p.y(), p.z());
51  const DPt3D dgFront(p.x(), p.y(), p.z());
52 
53  Pt3D lFront;
54  assert(nullptr != param());
55  Pt3DVec lc(8, Pt3D(0, 0, 0));
56  vocalCorners(lc, param(), lFront);
57 
58  DPt3D dlFront(lFront.x(), lFront.y(), lFront.z());
59 
60  const Pt3D lBack(0.25 * (lc[4] + lc[5] + lc[6] + lc[7]));
61  const DPt3D dlBack(lBack.x(), lBack.y(), lBack.z());
62 
63  const Pt3D dlOne(lc[0].x(), lc[0].y(), lc[0].z());
64 
65  const CornersVec& cor(getCorners());
66  DPt3DVec dkor(8, DPt3D(0, 0, 0));
67  for (unsigned int i(0); i != 8; ++i) {
68  dkor[i] = DPt3D(cor[i].x(), cor[i].y(), cor[i].z());
69  }
70 
71  DPt3D dgBack(0.25 * (dkor[4] + dkor[5] + dkor[6] + dkor[7]));
72 
73  const DVec3D dgAxis((dgBack - dgFront).unit());
74 
75  dgBack = (dgFront + (dlBack - dlFront).mag() * dgAxis);
76  const DPt3D dgOneT(dgFront + (dlOne - dlFront).mag() * (dkor[0] - dgFront).unit());
77 
78  const double dlangle((dlBack - dlFront).angle(dlOne - dlFront));
79  const double dgangle((dgBack - dgFront).angle(dgOneT - dgFront));
80  const double ddangle(dlangle - dgangle);
81 
82  const DPlane3D dgPl(dgFront, dgOneT, dgBack);
83  const DPt3D dp2(dgFront + dgPl.normal().unit());
84 
85  const DPt3D dgOne(dgFront + HepGeom::Rotate3D(-ddangle, dgFront, dp2) * DVec3D(dgOneT - dgFront));
86 
87  tr = Tr3D(dlFront, dlBack, dlOne, dgFront, dgBack, dgOne);
88 
89  if (nullptr != lptr)
90  (*lptr) = lc;
91 }
92 
93 const float* CaloCellGeometry::checkParmPtr(const std::vector<float>& vv, CaloCellGeometry::ParVecVec& pvv) {
94  const float* pP(nullptr);
95 
96  for (unsigned int ii(0); ii != pvv.size(); ++ii) {
97  const ParVec& v(pvv[ii]);
98  assert(v.size() == vv.size());
99 
100  bool same(true);
101  for (unsigned int j(0); j != vv.size(); ++j) {
102  same = same && (fabs(vv[j] - v[j]) < 1.e-6);
103  if (!same)
104  break;
105  }
106  if (same) {
107  pP = &(*v.begin());
108  break;
109  }
110  }
111  return pP;
112 }
113 
114 const float* CaloCellGeometry::getParmPtr(const std::vector<float>& vv,
117  const float* pP(checkParmPtr(vv, pvv));
118 
119  if (nullptr == pP) {
120  pvv.emplace_back(ParVec(mgr));
121  ParVec& back(pvv.back());
122  for (unsigned int i(0); i != vv.size(); ++i) {
123  back[i] = vv[i];
124  }
125  pP = &(*back.begin());
126  }
127  return pP;
128 }
129 
131  bool ans(false);
132  const Pt3D p(point.x(), point.y(), point.z());
133  const CornersVec& cog(getCorners());
134  Pt3D co[8];
135  for (unsigned int i(0); i != 8; ++i) {
136  co[i] = Pt3D(cog[i].x(), cog[i].y(), cog[i].z());
137  }
138 
139  const Plane3D AA(co[0], co[1], co[2]); // z<0
140  const Plane3D BB(co[6], co[5], co[4]); // z>0
141 
142  if (AA.distance(p) * BB.distance(p) >= 0) {
143  const Plane3D CC(co[0], co[4], co[5]); // x<0
144  const Plane3D DD(co[2], co[6], co[7]); // x>0
145  if (CC.distance(p) * DD.distance(p) >= 0) {
146  const Plane3D EE(co[3], co[7], co[4]); // y<0
147  const Plane3D FF(co[1], co[5], co[6]); // y>0
148  if (EE.distance(p) * FF.distance(p) >= 0) {
149  ans = true;
150  }
151  }
152  }
153  return ans;
154 }
T barePhi() const
std::ostream & operator<<(std::ostream &s, const CaloCellGeometry &cell)
bool emptyCorners() const
EZArrayFL< CCGFloat > ParVec
std::vector< ParVec > ParVecVec
HepGeom::Point3D< double > DPt3D
virtual void vocalCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref) const =0
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
virtual const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
#define nullptr
const CCGFloat * m_parms
T y() const
Definition: PV3DBase.h:60
const_iterator begin() const
Definition: EZArrayFL.h:52
HepGeom::Transform3D Tr3D
cv
Definition: cuy.py:364
std::vector< Pt3D > Pt3DVec
MgrType::const_reference const_reference
Definition: EZArrayFL.h:26
const CCGFloat * param() const
virtual void getTransform(Tr3D &tr, Pt3DVec *lptr) const
--------— only needed by specific utility; overloaded when needed -—
virtual ~CaloCellGeometry()
T z() const
Definition: PV3DBase.h:61
HepGeom::Vector3D< double > DVec3D
CaloCellGeometry::CCGFloat CCGFloat
static const CCGFloat * getParmPtr(const std::vector< CCGFloat > &vd, ParMgr *mgr, ParVecVec &pvv)
GlobalPoint m_refPoint
static const CCGFloat k_ScaleFromDDDtoGeant
ii
Definition: cuy.py:590
CaloCellGeometry::Pt3D Pt3D
bool inside(const GlobalPoint &point) const
Returns true if the specified point is inside this cell.
size_type size() const
Definition: EZArrayFL.h:67
HepGeom::Plane3D< double > DPlane3D
CaloCellGeometry::Pt3DVec Pt3DVec
HepGeom::Point3D< CCGFloat > Pt3D
Definition: EZMgrFL.h:8
DD
single HTRIG enabling on first/second tracks
CornersVec const & getCorners() const
Returns the corner points of this cell&#39;s volume.
CaloCellGeometry::Tr3D Tr3D
T perp() const
Magnitude of transverse component.
std::vector< DPt3D > DPt3DVec
HepGeom::Plane3D< CCGFloat > Plane3D
T x() const
Definition: PV3DBase.h:59
HepGeom::Vector3D< CCGFloat > FVec3D
ROOT::Math::Plane3D Plane3D
*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
Basic3DVector unit() const
static const CCGFloat * checkParmPtr(const std::vector< CCGFloat > &vd, ParVecVec &pvv)
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11