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