CMS 3D CMS Logo

FlatHexagon.cc
Go to the documentation of this file.
4 #include <algorithm>
5 #include <iostream>
6 
7 //#define EDM_ML_DEBUG
8 
13 
14 typedef HepGeom::Vector3D<CCGFloat> FVec3D;
15 typedef HepGeom::Plane3D<CCGFloat> Plane3D;
16 
17 typedef HepGeom::Vector3D<double> DVec3D;
18 typedef HepGeom::Plane3D<double> DPlane3D;
19 typedef HepGeom::Point3D<double> DPt3D;
20 
21 static const float tolmin = 1.e-12;
22 
23 //----------------------------------------------------------------------
24 
26  : CaloCellGeometry(), m_axis(0., 0., 0.), m_corOne(0., 0., 0.), m_local(0., 0., 0.), m_global(0., 0., 0.) {}
27 
28 FlatHexagon::FlatHexagon(const FlatHexagon& tr) : CaloCellGeometry(tr) { *this = tr; }
29 
31  CaloCellGeometry::operator=(tr);
32  if (this != &tr) {
33  m_axis = tr.m_axis;
34  m_corOne = tr.m_corOne;
35  m_local = tr.m_local;
36  m_global = tr.m_global;
37  m_tr = tr.m_tr;
38  }
39 #ifdef EDM_ML_DEBUG
40  edm::LogVerbatim("CaloGeometry") << "FlatHexagon(Copy): Local " << m_local << " Global " << m_global << " eta "
41  << etaPos() << " phi " << phiPos() << " Translation " << m_tr.getTranslation()
42  << " and rotation " << m_tr.getRotation();
43 #endif
44  return *this;
45 }
46 
48  CornersMgr* cMgr, const GlobalPoint& fCtr, const GlobalPoint& bCtr, const GlobalPoint& cor1, const CCGFloat* parV)
49  : CaloCellGeometry(fCtr, cMgr, parV),
50  m_axis((bCtr - fCtr).unit()),
51  m_corOne(cor1.x(), cor1.y(), cor1.z()),
52  m_local(0., 0., 0.) {
53  getTransform(m_tr, nullptr);
54  Pt3D glb = m_tr * m_local;
55  m_global = GlobalPoint(glb.x(), glb.y(), glb.z());
56 #ifdef EDM_ML_DEBUG
57  edm::LogVerbatim("CaloGeometry") << "FlatHexagon: Local " << m_local << " Global " << glb << " eta " << etaPos()
58  << " phi " << phiPos() << " Translation " << m_tr.getTranslation()
59  << " and rotation " << m_tr.getRotation();
60 #endif
61 }
62 
64  : CaloCellGeometry(corn, par), m_corOne(corn[0].x(), corn[0].y(), corn[0].z()), m_local(0., 0., 0.) {
65  getTransform(m_tr, nullptr);
66  m_axis = makeAxis();
67  Pt3D glb = m_tr * m_local;
68  m_global = GlobalPoint(glb.x(), glb.y(), glb.z());
69 #ifdef EDM_ML_DEBUG
70  edm::LogVerbatim("CaloGeometry") << "FlatHexagon: Local " << m_local << " Global " << glb << " eta " << etaPos()
71  << " phi " << phiPos() << " Translation " << m_tr.getTranslation()
72  << " and rotation " << m_tr.getRotation();
73 #endif
74 }
75 
77  *this = tr;
78  Pt3D glb = m_tr * m_local;
79  m_global = GlobalPoint(glb.x(), glb.y(), glb.z());
80 #ifdef EDM_ML_DEBUG
81  edm::LogVerbatim("CaloGeometry") << "FlatHexagon: Local " << m_local << " Global " << glb << " eta " << etaPos()
82  << " phi " << phiPos() << " Translation " << m_tr.getTranslation()
83  << " and rotation " << m_tr.getRotation();
84 #endif
85 }
86 
88 
90  Pt3D glb = m_tr * local;
91 #ifdef EDM_ML_DEBUG
92  edm::LogVerbatim("CaloGeometry") << "FlatHexagon::Local " << local.x() << ":" << local.y() << ":" << local.z()
93  << " Global " << glb.x() << ":" << glb.y() << ":" << glb.z() << " TR " << m_tr.xx()
94  << ":" << m_tr.xy() << ":" << m_tr.xz() << ":" << m_tr.yx() << ":" << m_tr.yy()
95  << ":" << m_tr.yz() << ":" << m_tr.zx() << ":" << m_tr.zy() << ":" << m_tr.zz()
96  << ":" << m_tr.dx() << ":" << m_tr.dy() << ":" << m_tr.dz();
97 #endif
98  return GlobalPoint(glb.x(), glb.y(), glb.z());
99 }
100 
101 float FlatHexagon::etaSpan() const {
102  assert(param() != nullptr);
103  float eta1 =
104  -std::log(std::tan(0.5 * std::atan((m_global.perp() + param()[k_R]) / std::max(tolmin, std::abs(m_global.z())))));
105  float eta2 =
106  -std::log(std::tan(0.5 * std::atan((m_global.perp() - param()[k_R]) / std::max(tolmin, std::abs(m_global.z())))));
107  float dEta = std::abs(eta1 - eta2);
108  return dEta;
109 }
110 
111 float FlatHexagon::phiSpan() const {
112  assert(param() != nullptr);
113  float dPhi = 2.0 * std::atan(param()[k_r] / std::max(tolmin, m_global.perp()));
114  return dPhi;
115 }
116 
117 Pt3D FlatHexagon::getLocal(const GlobalPoint& global) const {
118  Pt3D local = m_tr.inverse() * Pt3D(global.x(), global.y(), global.z());
119 #ifdef EDM_ML_DEBUG
120  edm::LogVerbatim("CaloGeometry") << "FlatHexagon::Global " << global.x() << ":" << global.y() << ":" << global.z()
121  << " Local " << local.x() << ":" << local.y() << ":" << local.z();
122 #endif
123  return local;
124 }
125 
127 
129 
130 const GlobalVector& FlatHexagon::axis() const { return m_axis; }
131 
132 void FlatHexagon::vocalCorners(Pt3DVec& vec, const CCGFloat* pv, Pt3D& ref) const { localCorners(vec, pv, ref); }
133 
134 void FlatHexagon::createCorners(const std::vector<CCGFloat>& pv, const Tr3D& tr, std::vector<GlobalPoint>& co) {
135  assert(3 == pv.size());
136  assert(ncorner_ == co.size());
137 
138  Pt3DVec ko(ncorner_, Pt3D(0, 0, 0));
139 
140  Pt3D tmp;
141  Pt3DVec to(ncorner_, Pt3D(0, 0, 0));
142  localCorners(to, &pv.front(), tmp);
143 
144  for (unsigned int i(0); i != ncorner_; ++i) {
145  ko[i] = tr * to[i]; // apply transformation
146  const Pt3D& p(ko[i]);
147  co[i] = GlobalPoint(p.x(), p.y(), p.z());
148 #ifdef EDM_ML_DEBUG
149  edm::LogVerbatim("CaloGeometry") << "Corner[" << i << "] = " << co[i];
150 #endif
151  }
152 }
153 
155  assert(nullptr != pv);
156  assert(ncorner_ == lc.size());
157 
159  const CCGFloat r(pv[FlatHexagon::k_r]);
160  const CCGFloat R(pv[FlatHexagon::k_R]);
161 
162  lc[0] = Pt3D(0, -2 * R, -dz); // (0,-,-)
163  lc[1] = Pt3D(-r, -R, -dz); // (-,-,-)
164  lc[2] = Pt3D(-r, R, -dz); // (-,+,-)
165  lc[3] = Pt3D(0, 2 * R, -dz); // (0,+,-)
166  lc[4] = Pt3D(r, R, -dz); // (+,+,-)
167  lc[5] = Pt3D(r, -R, -dz); // (+,-,-)
168  lc[6] = Pt3D(0, -2 * R, dz); // (0,-,+)
169  lc[7] = Pt3D(-r, -R, dz); // (-,-,+)
170  lc[8] = Pt3D(-r, R, dz); // (-,+,+)
171  lc[9] = Pt3D(0, 2 * R, dz); // (0,+,+)
172  lc[10] = Pt3D(r, R, dz); // (+,+,+)
173  lc[11] = Pt3D(r, -R, dz); // (+,-,+)
174 
175  ref = oneBySix_ * (lc[0] + lc[1] + lc[2] + lc[3] + lc[4] + lc[5]);
176 #ifdef EDM_ML_DEBUG
177  edm::LogVerbatim("CaloGeometry") << "Ref " << ref << " Local Corners " << lc[0] << "|" << lc[1] << "|" << lc[2] << "|"
178  << lc[3] << "|" << lc[4] << "|" << lc[5] << "|" << lc[6] << "|" << lc[7] << "|"
179  << lc[8] << "|" << lc[9] << "|" << lc[10] << "|" << lc[11];
180 #endif
181 }
182 
183 void FlatHexagon::getTransform(Tr3D& tr, Pt3DVec* lptr) const {
185  const Pt3D gFront(p.x(), p.y(), p.z());
186  const DPt3D dgFront(p.x(), p.y(), p.z());
187 
188  Pt3D lFront;
189  assert(nullptr != param());
190  std::vector<Pt3D> lc(ncorner_, Pt3D(0, 0, 0));
191  localCorners(lc, param(), lFront);
192 
193  // figure out if reflction volume or not
194 
195  Pt3D lBack((lc[6] + lc[7] + lc[8] + lc[9] + lc[10] + lc[11]) / 6.0);
196 
197  const DPt3D dlFront(lFront.x(), lFront.y(), lFront.z());
198  const DPt3D dlBack(lBack.x(), lBack.y(), lBack.z());
199  const DPt3D dlOne(lc[0].x(), lc[0].y(), lc[0].z());
200 
201  const FVec3D dgAxis(axis().x(), axis().y(), axis().z());
202 
203  const DPt3D dmOne(m_corOne.x(), m_corOne.y(), m_corOne.z());
204 
205  const DPt3D dgBack(dgFront + (dlBack - dlFront).mag() * dgAxis);
206  DPt3D dgOne(dgFront + (dlOne - dlFront).mag() * (dmOne - dgFront).unit());
207 
208  const double dlangle((dlBack - dlFront).angle(dlOne - dlFront));
209  const double dgangle((dgBack - dgFront).angle(dgOne - dgFront));
210  const double dangle(dlangle - dgangle);
211 
212  if (1.e-6 < fabs(dangle)) { //guard against precision problems
213  const DPlane3D dgPl(dgFront, dgOne, dgBack);
214  const DPt3D dp2(dgFront + dgPl.normal().unit());
215 
216  DPt3D dgOld(dgOne);
217 
218  dgOne = (dgFront + HepGeom::Rotate3D(-dangle, dgFront, dp2) * DVec3D(dgOld - dgFront));
219  }
220 
221  tr = Tr3D(dlFront, dlBack, dlOne, dgFront, dgBack, dgOne);
222 
223  if (nullptr != lptr)
224  (*lptr) = lc;
225 }
226 
228  if (co.uninitialized()) {
229  CornersVec& corners(co);
230  Pt3DVec lc;
231  Tr3D tr;
232  getTransform(tr, &lc);
233 
234  for (unsigned int i(0); i != ncorner_; ++i) {
235  const Pt3D corn(tr * lc[i]);
236  corners[i] = GlobalPoint(corn.x(), corn.y(), corn.z());
237  }
238  }
239 }
240 
242 
244  float dz =
246  Pt3D local_b(m_local.x(), m_local.y(), m_local.z() + dz);
247  Pt3D global_b = m_tr * local_b;
248  GlobalPoint global(global_b.x(), global_b.y(), global_b.z());
249  return global;
250 }
251 
252 //----------------------------------------------------------------------
253 //----------------------------------------------------------------------
254 
255 std::ostream& operator<<(std::ostream& s, const FlatHexagon& cell) {
256  s << "Center: " << cell.getPosition() << " eta " << cell.etaPos() << " phi " << cell.phiPos() << std::endl;
257  s << "Axis: " << cell.getThetaAxis() << " " << cell.getPhiAxis() << std::endl;
258  const CaloCellGeometry::CornersVec& corners(cell.getCorners());
259  for (unsigned int i = 0; i != corners.size(); ++i) {
260  s << "Corner: " << corners[i] << std::endl;
261  }
262  return s;
263 }
CaloCellGeometry::Tr3D
HepGeom::Transform3D Tr3D
Definition: CaloCellGeometry.h:53
Vector3DBase
Definition: Vector3DBase.h:8
CaloCellGeometry::Pt3DVec
std::vector< Pt3D > Pt3DVec
Definition: CaloCellGeometry.h:55
DDAxes::y
Pt3D
FlatHexagon::Pt3D Pt3D
Definition: FlatHexagon.cc:10
FlatHexagon::getLocal
Pt3D getLocal(const GlobalPoint &global) const
Definition: FlatHexagon.cc:117
mps_fire.i
i
Definition: mps_fire.py:428
CaloCellGeometry::CCGFloat
float CCGFloat
Definition: CaloCellGeometry.h:52
MessageLogger.h
FlatHexagon::~FlatHexagon
~FlatHexagon() override
Definition: FlatHexagon.cc:87
detailsBasic3DVector::z
float float float z
Definition: extBasic3DVector.h:14
FlatHexagon::Tr3D
CaloCellGeometry::Tr3D Tr3D
Definition: FlatHexagon.h:25
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
FlatHexagon::m_global
GlobalPoint m_global
Definition: FlatHexagon.h:92
tolmin
static const float tolmin
Definition: FlatHexagon.cc:21
FlatHexagon::phiPos
float phiPos() const override
Definition: FlatHexagon.h:52
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
PV3DBase::theta
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
FlatHexagon::localCorners
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
Definition: FlatHexagon.cc:154
FlatHexagon::m_tr
Tr3D m_tr
Definition: FlatHexagon.h:93
FlatHexagon::m_corOne
Pt3D m_corOne
Definition: FlatHexagon.h:91
to
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
Pt3DVec
FlatHexagon::Pt3DVec Pt3DVec
Definition: FlatHexagon.cc:11
DDAxes::x
GlobalVector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
FlatHexagon::m_local
Pt3D m_local
Definition: FlatHexagon.h:91
HLT_FULL_cff.dPhi
dPhi
Definition: HLT_FULL_cff.py:13765
EZArrayFL< GlobalPoint >
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
FlatHexagon::etaPos
float etaPos() const override
Definition: FlatHexagon.h:51
FlatHexagon::k_r
static constexpr uint32_t k_r
Definition: FlatHexagon.h:28
FlatHexagon::getTransform
void getTransform(Tr3D &tr, Pt3DVec *lptr) const override
--------— only needed by specific utility; overloaded when needed -—
Definition: FlatHexagon.cc:183
FlatHexagon::vocalCorners
void vocalCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref) const override
Definition: FlatHexagon.cc:132
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
DPt3D
HepGeom::Point3D< double > DPt3D
Definition: FlatHexagon.cc:19
alignCSCRings.s
s
Definition: alignCSCRings.py:92
Vector3DBase::unit
Vector3DBase unit() const
Definition: Vector3DBase.h:54
FlatHexagon::makeAxis
GlobalVector makeAxis(void)
Definition: FlatHexagon.cc:241
FlatHexagon::etaSpan
float etaSpan() const override
Definition: FlatHexagon.cc:101
FlatHexagon::ncorner_
static constexpr unsigned int ncorner_
Definition: FlatHexagon.h:81
FlatHexagon::getPhiAxis
CCGFloat getPhiAxis() const
Definition: FlatHexagon.cc:128
TruncatedPyramid.h
FVec3D
HepGeom::Vector3D< CCGFloat > FVec3D
Definition: FlatHexagon.cc:14
FlatHexagon::dz
float dz() const
Definition: FlatHexagon.h:56
HLT_FULL_cff.eta2
eta2
Definition: HLT_FULL_cff.py:9605
FlatHexagon::m_axis
GlobalVector m_axis
Definition: FlatHexagon.h:90
DDAxes::z
FlatHexagon.h
FlatHexagon
A base class to handle the hexagonal shape of HGCal silicon volumes.
Definition: FlatHexagon.h:20
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, GlobalTag >
FlatHexagon::k_R
static constexpr uint32_t k_R
Definition: FlatHexagon.h:29
CaloCellGeometry::Pt3D
HepGeom::Point3D< CCGFloat > Pt3D
Definition: CaloCellGeometry.h:54
FlatHexagon::ncornerBy2_
static constexpr unsigned int ncornerBy2_
Definition: FlatHexagon.h:82
FlatHexagon::Pt3D
CaloCellGeometry::Pt3D Pt3D
Definition: FlatHexagon.h:23
FlatHexagon::initCorners
void initCorners(CornersVec &) override
Definition: FlatHexagon.cc:227
CaloCellGeometry::getPosition
virtual const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
Definition: CaloCellGeometry.h:80
HLT_FULL_cff.eta1
eta1
Definition: HLT_FULL_cff.py:9604
FlatHexagon::operator=
FlatHexagon & operator=(const FlatHexagon &tr)
Definition: FlatHexagon.cc:30
DPt3D
HepGeom::Point3D< double > DPt3D
Definition: CaloCellGeometry.cc:14
FlatHexagon::axis
const GlobalVector & axis() const
Definition: FlatHexagon.cc:130
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
FlatHexagon::CCGFloat
CaloCellGeometry::CCGFloat CCGFloat
Definition: FlatHexagon.h:22
DPlane3D
HepGeom::Plane3D< double > DPlane3D
Definition: CaloCellGeometry.cc:13
CaloCellGeometry
Definition: CaloCellGeometry.h:50
CaloCellGeometry::param
const CCGFloat * param() const
Definition: CaloCellGeometry.h:99
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
FlatHexagon::FlatHexagon
FlatHexagon(void)
Definition: FlatHexagon.cc:25
FVec3D
HepGeom::Vector3D< CCGFloat > FVec3D
Definition: CaloCellGeometry.cc:9
FlatHexagon::getPosition
GlobalPoint const & getPosition() const override
Returns the position of reference for this cell.
Definition: FlatHexagon.h:49
operator<<
std::ostream & operator<<(std::ostream &s, const FlatHexagon &cell)
Definition: FlatHexagon.cc:255
FlatHexagon::Pt3DVec
CaloCellGeometry::Pt3DVec Pt3DVec
Definition: FlatHexagon.h:24
unit
Basic3DVector unit() const
Definition: Basic3DVectorLD.h:162
alignCSCRings.r
r
Definition: alignCSCRings.py:93
mag
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: Basic3DVectorLD.h:127
DPlane3D
HepGeom::Plane3D< double > DPlane3D
Definition: FlatHexagon.cc:18
FlatHexagon::k_dZ
static constexpr uint32_t k_dZ
Definition: FlatHexagon.h:27
Tr3D
FlatHexagon::Tr3D Tr3D
Definition: FlatHexagon.cc:12
FlatHexagon::backCtr
GlobalPoint backCtr(void) const
Definition: FlatHexagon.cc:243
HLT_FULL_cff.dEta
dEta
Definition: HLT_FULL_cff.py:13764
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
CCGFloat
FlatHexagon::CCGFloat CCGFloat
Definition: FlatHexagon.cc:9
genVertex_cff.x
x
Definition: genVertex_cff.py:12
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14
FlatHexagon::oneBySix_
static constexpr double oneBySix_
Definition: FlatHexagon.h:80
angle
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
FlatHexagon::createCorners
static void createCorners(const std::vector< CCGFloat > &pv, const Tr3D &tr, std::vector< GlobalPoint > &co)
Definition: FlatHexagon.cc:134
FlatHexagon::phiSpan
float phiSpan() const override
Definition: FlatHexagon.cc:111
EZMgrFL
Definition: EZMgrFL.h:8
cms::cuda::co
VT * co
Definition: prefixScan.h:46
Plane3D
HepGeom::Plane3D< CCGFloat > Plane3D
Definition: FlatHexagon.cc:15
DTRecHitClients_cfi.local
local
Definition: DTRecHitClients_cfi.py:10
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
glb
double glb
Definition: hdecay.h:103
dttmaxenums::R
Definition: DTTMax.h:29
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
DVec3D
HepGeom::Vector3D< double > DVec3D
Definition: FlatHexagon.cc:17
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
FlatHexagon::getThetaAxis
CCGFloat getThetaAxis() const
Definition: FlatHexagon.cc:126