CMS 3D CMS Logo

HGCalGeometry.cc
Go to the documentation of this file.
1 /* for High Granularity Calorimeter
2  * This geometry is essentially driven by topology,
3  * which is thus encapsulated in this class.
4  * This makes this geometry not suitable to be loaded
5  * by regular CaloGeometryLoader<T>
6  */
12 
13 #include <cmath>
14 
15 #include <Math/Transform3D.h>
16 #include <Math/EulerAngles.h>
17 
19 typedef std::vector<float> ParmVec;
20 
21 //#define EDM_ML_DEBUG
22 
24  : m_topology( topology_ ),
25  m_validGeomIds( topology_.totalGeomModules()),
26  mode_( topology_.geomMode()),
27  m_det( topology_.detector()),
28  m_subdet( topology_.subDetector()),
29  twoBysqrt3_(2.0/std::sqrt(3.0)) {
30 
31  if (m_det == DetId::HGCalHSc) {
32  m_cellVec2 = CellVec2(topology_.totalGeomModules());
33  } else {
34  m_cellVec = CellVec(topology_.totalGeomModules());
35  }
37 #ifdef EDM_ML_DEBUG
38  edm::LogVerbatim("HGCalGeom") << "Expected total # of Geometry Modules "
40 #endif
41 }
42 
44 
46 
48 }
49 
51  const CCGFloat* pv,
52  unsigned int i,
53  Pt3D& ref) {
54  if (m_det == DetId::HGCalHSc) {
55  FlatTrd::localCorners( lc, pv, ref ) ;
56  } else {
57  FlatHexagon::localCorners( lc, pv, ref ) ;
58  }
59 }
60 
62  const GlobalPoint& f2 ,
63  const GlobalPoint& f3 ,
64  const CCGFloat* parm ,
65  const DetId& detId ) {
66 
67  DetId geomId = getGeometryDetId(detId);
68  int cells (0);
72  cells = m_topology.dddConstants().numberCellsHexagon(id.iSec1);
73 #ifdef EDM_ML_DEBUG
74  edm::LogVerbatim("HGCalGeom") << "NewCell " << HGCalDetId(detId)
75  << " GEOM " << HGCalDetId(geomId);
76 #endif
77  } else if (mode_ == HGCalGeometryMode::Trapezoid) {
78  cells = 1;
79 #ifdef EDM_ML_DEBUG
80  edm::LogVerbatim("HGCalGeom") << "NewCell " << HGCScintillatorDetId(detId)
81  << " GEOM " << HGCScintillatorDetId(geomId);
82 #endif
83  } else {
84  cells = m_topology.dddConstants().numberCellsHexagon(id.iLay,id.iSec1,
85  id.iSec2,false);
86 #ifdef EDM_ML_DEBUG
87  edm::LogVerbatim("HGCalGeom") << "NewCell " << HGCSiliconDetId(detId)
88  << " GEOM " << HGCSiliconDetId(geomId);
89 #endif
90  }
91  const uint32_t cellIndex (m_topology.detId2denseGeomId(geomId));
92 
93  if (m_det == DetId::HGCalHSc) {
94  m_cellVec2.at( cellIndex ) = FlatTrd( cornersMgr(), f1, f2, f3, parm ) ;
95  } else {
96  m_cellVec.at( cellIndex ) = FlatHexagon( cornersMgr(), f1, f2, f3, parm ) ;
97  }
98  m_validGeomIds.at( cellIndex ) = geomId ;
99 
100 #ifdef EDM_ML_DEBUG
101  edm::LogVerbatim("HGCalGeom") << "Store for DetId " << std::hex
102  << detId.rawId() << " GeomId "
103  << geomId.rawId() << std::dec << " Index "
104  << cellIndex << " cells " << cells;
105  unsigned int nOld = m_validIds.size();
106 #endif
107  if ((mode_ == HGCalGeometryMode::Hexagon) ||
109  for (int cell = 0; cell < cells; ++cell) {
110  id.iCell1 = cell;
111  DetId idc = m_topology.encode(id);
112  if (m_topology.valid(idc)) {
113  m_validIds.emplace_back(idc);
114 #ifdef EDM_ML_DEBUG
115  edm::LogVerbatim("HGCalGeom") << "Valid Id [" << cell << "] "
116  << HGCalDetId(idc);
117 #endif
118  }
119  }
120  } else if (mode_ == HGCalGeometryMode::Trapezoid) {
121  DetId idc = m_topology.encode(id);
122  if (m_topology.valid(idc)) {
123  m_validIds.emplace_back(idc);
124 #ifdef EDM_ML_DEBUG
125  edm::LogVerbatim("HGCalGeom") << "Valid Id [0] "
126  << HGCScintillatorDetId(idc);
127 #endif
128  } else {
129  edm::LogWarning("HGCalGeom") << "Check " << HGCScintillatorDetId(idc)
130  << " from " << HGCScintillatorDetId(detId)
131  << " ERROR ???";
132  }
133  } else {
134 #ifdef EDM_ML_DEBUG
135  unsigned int cellAll(0), cellSelect(0);
136 #endif
137  for (int u=0; u<2*cells; ++u) {
138  for (int v=0; v<2*cells; ++v) {
139  if (((v-u) < cells) && (u-v) <= cells) {
140  id.iCell1 = u; id.iCell2 = v;
141  DetId idc = m_topology.encode(id);
142 #ifdef EDM_ML_DEBUG
143  ++cellAll;
144 #endif
145  if (m_topology.dddConstants().cellInLayer(id.iSec1,id.iSec2,u,v,
146  id.iLay,true)) {
147  m_validIds.emplace_back(idc);
148 #ifdef EDM_ML_DEBUG
149  ++cellSelect;
150  edm::LogVerbatim("HGCalGeom") << "Valid Id [" << u << ", " << v
151  << "] " << HGCSiliconDetId(idc);
152 #endif
153  }
154  }
155  }
156  }
157 #ifdef EDM_ML_DEBUG
158  edm::LogVerbatim("HGCalGeom") << "HGCalGeometry keeps " << cellSelect
159  << " out of " << cellAll << " for wafer "
160  << id.iSec1 << ":" << id.iSec2 << " in "
161  << " layer " << id.iLay;
162 #endif
163  }
164 #ifdef EDM_ML_DEBUG
165  if (m_det == DetId::HGCalHSc) {
166  edm::LogVerbatim("HGCalGeom") << "HGCalGeometry::newCell-> [" << cellIndex
167  << "]" << " front:" << f1.x() << '/'
168  << f1.y() << '/' << f1.z() << " back:"
169  << f2.x() << '/' << f2.y() << '/' << f2.z()
170  << " eta|phi "
171  << m_cellVec2[cellIndex].etaPos() << ":"
172  << m_cellVec2[cellIndex].phiPos();
173  } else {
174  edm::LogVerbatim("HGCalGeom") << "HGCalGeometry::newCell-> [" << cellIndex
175  << "]" << " front:" << f1.x() << '/'
176  << f1.y() << '/' << f1.z() << " back:"
177  << f2.x() << '/' << f2.y() << '/' << f2.z()
178  << " eta|phi "
179  << m_cellVec[cellIndex].etaPos() << ":"
180  << m_cellVec[cellIndex].phiPos();
181  }
182  unsigned int nNew = m_validIds.size();
183  if ((mode_ == HGCalGeometryMode::Hexagon) ||
185  edm::LogVerbatim("HGCalGeom") << "ID: " << HGCalDetId(detId)
186  << " with valid DetId from " << nOld
187  << " to " << nNew;
188  } else if (mode_ == HGCalGeometryMode::Trapezoid) {
189  edm::LogVerbatim("HGCalGeom") << "ID: " << HGCScintillatorDetId(detId)
190  << " with valid DetId from " << nOld
191  << " to " << nNew;
192  } else if (m_topology.isHFNose()) {
193  edm::LogVerbatim("HGCalGeom") << "ID: " << HFNoseDetId(detId)
194  << " with valid DetId from " << nOld
195  << " to " << nNew;
196  } else {
197  edm::LogVerbatim("HGCalGeom") << "ID: " << HGCSiliconDetId(detId)
198  << " with valid DetId from " << nOld
199  << " to " << nNew;
200  }
201  edm::LogVerbatim("HGCalGeom") << "Cell[" << cellIndex << "] " << std::hex
202  << geomId.rawId() << ":"
203  << m_validGeomIds[cellIndex].rawId()
204  << std::dec;
205 #endif
206 }
207 
208 std::shared_ptr<const CaloCellGeometry> HGCalGeometry::getGeometry(const DetId& detId) const {
209  if (detId == DetId()) return nullptr; // nothing to get
210  DetId geomId = getGeometryDetId(detId);
211  const uint32_t cellIndex (m_topology.detId2denseGeomId(geomId));
212  const GlobalPoint pos = (detId != geomId) ? getPosition(detId) : GlobalPoint();
213  return cellGeomPtr (cellIndex, pos);
214 
215 }
216 
217 bool HGCalGeometry::present(const DetId& detId) const {
218  if (detId == DetId()) return false;
219  DetId geomId = getGeometryDetId(detId);
220  const uint32_t index (m_topology.detId2denseGeomId(geomId));
221  return (nullptr != getGeometryRawPtr(index)) ;
222 }
223 
225 
226  unsigned int cellIndex = indexFor(id);
227  GlobalPoint glob;
228  unsigned int maxSize = ((mode_ == HGCalGeometryMode::Trapezoid) ?
229  m_cellVec2.size() : m_cellVec.size());
230  if (cellIndex < maxSize) {
232  std::pair<float,float> xy;
235  xy = m_topology.dddConstants().locateCellHex(id_.iCell1,id_.iSec1,true);
236  const HepGeom::Point3D<float> lcoord(xy.first,xy.second,0);
237  glob = m_cellVec[cellIndex].getPosition(lcoord);
238 #ifdef EDM_ML_DEBUG
239  edm::LogVerbatim("HGCalGeom") << "getPosition:: index " << cellIndex
240  << " Local " << lcoord.x() << ":"
241  << lcoord.y() << " ID " << id_.iCell1
242  << ":" << id_.iSec1 << " Global " << glob;
243 #endif
244  } else if (mode_ == HGCalGeometryMode::Trapezoid) {
245  const HepGeom::Point3D<float> lcoord(0,0,0);
246  glob = m_cellVec2[cellIndex].getPosition(lcoord);
247 #ifdef EDM_ML_DEBUG
248  edm::LogVerbatim("HGCalGeom") << "getPositionTrap:: index " << cellIndex
249  << " Local " << lcoord.x() << ":"
250  << lcoord.y() << " ID " << id_.iLay << ":"
251  << id_.iSec1 << ":" << id_.iCell1
252  << " Global " << glob;
253 #endif
254  } else {
255  xy = m_topology.dddConstants().locateCell(id_.iLay,id_.iSec1,id_.iSec2,
256  id_.iCell1,id_.iCell2,true,false);
257  const HepGeom::Point3D<float> lcoord(xy.first,xy.second,0);
258  glob = m_cellVec[cellIndex].getPosition(lcoord);
259 #ifdef EDM_ML_DEBUG
260  edm::LogVerbatim("HGCalGeom") << "getPositionWafer:: index " << cellIndex
261  << " Local " << lcoord.x() << ":"
262  << lcoord.y() << " ID " << id_.iLay << ":"
263  << id_.iSec1 << ":" << id_.iSec2 << ":"
264  << id_.iCell1 << ":" << id_.iCell2
265  << " Global " << glob;
266 #endif
267  }
268  }
269  return glob;
270 }
271 
273 
274  unsigned int ncorner = ((m_det == DetId::HGCalHSc) ? FlatTrd::ncorner_ :
276  HGCalGeometry::CornersVec co (ncorner, GlobalPoint(0,0,0));
277  unsigned int cellIndex = indexFor(id);
278  if ((cellIndex < m_cellVec.size() && m_det != DetId::HGCalHSc) ||
279  (cellIndex < m_cellVec2.size() && m_det == DetId::HGCalHSc)) {
281  std::pair<float,float> xy;
284  xy = m_topology.dddConstants().locateCellHex(id_.iCell1,id_.iSec1,true);
285  } else if (mode_ == HGCalGeometryMode::Trapezoid) {
287  id_.iCell1,true);
288  } else {
289  xy = m_topology.dddConstants().locateCell(id_.iLay,id_.iSec1,id_.iSec2,
290  id_.iCell1,id_.iCell2,true,false);
291  }
292  if (m_det == DetId::HGCalHSc) {
293  float dx = 0.5*m_cellVec2[cellIndex].param()[11];
294  float dz = m_cellVec2[cellIndex].param()[0];
295  static const int signx[] = {-1,-1,1,1,-1,-1,1,1};
296  static const int signy[] = {-1,1,1,-1,-1,1,1,-1};
297  static const int signz[] = {-1,-1,-1,-1,1,1,1,1};
298  for (unsigned int i = 0; i < ncorner; ++i) {
299  const HepGeom::Point3D<float> lcoord(xy.first+signx[i]*dx,xy.second+signy[i]*dx,signz[i]*dz);
300  co[i] = m_cellVec2[cellIndex].getPosition(lcoord);
301  }
302  } else {
303  float dx = m_cellVec[cellIndex].param()[1];
304  float dy = m_cellVec[cellIndex].param()[2];
305  float dz = m_cellVec[cellIndex].param()[0];
306  static const int signx[] = {0,-1,-1,0,1,1,0,-1,-1,0,1,1};
307  static const int signy[] = {-2,-1,1,2,1,-1,-2,-1,1,2,1,-1};
308  static const int signz[] = {-1,-1,-1,-1,-1,-1,1,1,1,1,1,1};
309  for (unsigned int i = 0; i < ncorner; ++i) {
310  const HepGeom::Point3D<float> lcoord(xy.first+signx[i]*dx,xy.second+signy[i]*dy,signz[i]*dz);
311  co[i] = m_cellVec[cellIndex].getPosition(lcoord);
312  }
313  }
314  }
315  return co;
316 }
317 
319 
320  unsigned int ncorner = FlatTrd::ncorner_;
321  HGCalGeometry::CornersVec co (ncorner, GlobalPoint(0,0,0));
322  unsigned int cellIndex = indexFor(id);
323  if ((cellIndex < m_cellVec.size() && m_det != DetId::HGCalHSc) ||
324  (cellIndex < m_cellVec2.size() && m_det == DetId::HGCalHSc)) {
326  std::pair<float,float> xy;
329  xy = m_topology.dddConstants().locateCellHex(id_.iCell1,id_.iSec1,true);
330  } else if (mode_ == HGCalGeometryMode::Trapezoid) {
332  id_.iCell1,true);
333  } else {
334  xy = m_topology.dddConstants().locateCell(id_.iLay,id_.iSec1,id_.iSec2,
335  id_.iCell1,id_.iCell2,true,false);
336  }
337  float dx = ((m_det == DetId::HGCalHSc) ? 0.5*m_cellVec2[cellIndex].param()[11] :
338  m_cellVec[cellIndex].param()[1]);
339  float dz = ((m_det == DetId::HGCalHSc) ? m_cellVec2[cellIndex].param()[0] :
340  m_cellVec[cellIndex].param()[0]);
341  static const int signx[] = {-1,-1,1,1,-1,-1,1,1};
342  static const int signy[] = {-1,1,1,-1,-1,1,1,-1};
343  static const int signz[] = {-1,-1,-1,-1,1,1,1,1};
344  for (unsigned int i = 0; i < ncorner; ++i) {
345  const HepGeom::Point3D<float> lcoord(xy.first+signx[i]*dx,
346  xy.second+signy[i]*dx,signz[i]*dz);
347  co[i] = ((m_det == DetId::HGCalHSc) ?
348  (m_cellVec2[cellIndex].getPosition(lcoord)) :
349  (m_cellVec[cellIndex].getPosition(lcoord)));
350  }
351  }
352  return co;
353 }
354 
356  unsigned int cellIndex = getClosestCellIndex(r);
357  if ((cellIndex < m_cellVec.size() && m_det != DetId::HGCalHSc) ||
358  (cellIndex < m_cellVec2.size() && m_det == DetId::HGCalHSc)) {
360  HepGeom::Point3D<float> local;
361  if (r.z() > 0) {
362  local = HepGeom::Point3D<float>(r.x(),r.y(),0);
363  id_.zSide = 1;
364  } else {
365  local = HepGeom::Point3D<float>(-r.x(),r.y(),0);
366  id_.zSide =-1;
367  }
370  const auto & kxy =
371  m_topology.dddConstants().assignCell(local.x(),local.y(),id_.iLay,
372  id_.iType,true);
373  id_.iCell1 = kxy.second;
374  id_.iSec1 = kxy.first;
375  id_.iType = m_topology.dddConstants().waferTypeT(kxy.first);
376  if (id_.iType != 1) id_.iType = -1;
377  } else if (mode_ == HGCalGeometryMode::Trapezoid) {
378  id_.iLay = m_topology.dddConstants().getLayer(r.z(),true);
379  const auto & kxy =
380  m_topology.dddConstants().assignCellTrap(r.x(),r.y(),r.z(),
381  id_.iLay,true);
382  id_.iSec1 = kxy[0];
383  id_.iCell1 = kxy[1];
384  id_.iType = kxy[2];
385  } else {
386  id_.iLay = m_topology.dddConstants().getLayer(r.z(),true);
387  const auto & kxy =
388  m_topology.dddConstants().assignCellHex(local.x(),local.y(),id_.iLay,
389  true);
390  id_.iSec1 = kxy[0]; id_.iSec2 = kxy[1]; id_.iType = kxy[2];
391  id_.iCell1 = kxy[3]; id_.iCell2 = kxy[4];
392  }
393 #ifdef EDM_ML_DEBUG
394  edm::LogVerbatim("HGCalGeom") << "getClosestCell: local " << local
395  << " Id " << id_.zSide << ":" << id_.iLay
396  << ":" << id_.iSec1 << ":" << id_.iSec2
397  << ":" << id_.iType << ":" << id_.iCell1
398  << ":" << id_.iCell2;
399 #endif
400 
401  //check if returned cell is valid
402  if (id_.iCell1>=0) return m_topology.encode(id_);
403  }
404 
405  //if not valid or out of bounds return a null DetId
406  return DetId();
407 }
408 
411  return dss;
412 }
413 
415  if (m_subdet == HGCEE || m_det == DetId::HGCalEE) return "HGCalEE";
416  else if (m_subdet == HGCHEF || m_det == DetId::HGCalHSi) return "HGCalHEFront";
417  else if (m_subdet == HGCHEB || m_det == DetId::HGCalHSc) return "HGCalHEBack";
418  else return "Unknown";
419 }
420 
421 unsigned int HGCalGeometry::indexFor(const DetId& detId) const {
422  unsigned int cellIndex = ((m_det == DetId::HGCalHSc) ? m_cellVec2.size() :
423  m_cellVec.size());
424  if (detId != DetId()) {
425  DetId geomId = getGeometryDetId(detId);
426  cellIndex = m_topology.detId2denseGeomId(geomId);
427 #ifdef EDM_ML_DEBUG
428  edm::LogVerbatim("HGCalGeom") << "indexFor " << std::hex << detId.rawId()
429  << ":" << geomId.rawId() << std::dec
430  << " index " << cellIndex;
431 #endif
432  }
433  return cellIndex;
434 }
435 
436 unsigned int HGCalGeometry::sizeForDenseIndex() const {
437  return m_topology.totalGeomModules();
438 }
439 
441  // Modify the RawPtr class
442  if (m_det == DetId::HGCalHSc) {
443  if (m_cellVec2.size() < index) return nullptr;
444  const CaloCellGeometry* cell(&m_cellVec2[index]);
445  return (nullptr == cell->param() ? nullptr : cell);
446  } else {
447  if (m_cellVec2.size() < index) return nullptr;
448  const CaloCellGeometry* cell(&m_cellVec[index]);
449  return (nullptr == cell->param() ? nullptr : cell);
450  }
451 }
452 
453 std::shared_ptr<const CaloCellGeometry> HGCalGeometry::cellGeomPtr(uint32_t index) const {
454  if ((index >= m_cellVec.size() && m_det != DetId::HGCalHSc) ||
455  (index >= m_cellVec2.size() && m_det == DetId::HGCalHSc) ||
456  (m_validGeomIds[index].rawId() == 0)) return nullptr;
457  static const auto do_not_delete = [](const void*){};
458  if (m_det == DetId::HGCalHSc) {
459  auto cell = std::shared_ptr<const CaloCellGeometry>(&m_cellVec2[index],do_not_delete);
460  if (nullptr == cell->param()) return nullptr;
461  return cell;
462  } else {
463  auto cell = std::shared_ptr<const CaloCellGeometry>(&m_cellVec[index],do_not_delete);
464  if (nullptr == cell->param()) return nullptr;
465  return cell;
466  }
467 }
468 
469 std::shared_ptr<const CaloCellGeometry> HGCalGeometry::cellGeomPtr(uint32_t index, const GlobalPoint& pos) const {
470  if ((index >= m_cellVec.size() && m_det != DetId::HGCalHSc) ||
471  (index >= m_cellVec2.size() && m_det == DetId::HGCalHSc) ||
472  (m_validGeomIds[index].rawId() == 0)) return nullptr;
473  if (pos == GlobalPoint()) return cellGeomPtr(index);
474  if (m_det == DetId::HGCalHSc) {
475  auto cell = std::make_shared<FlatTrd>(m_cellVec2[index]);
476  cell->setPosition(pos);
477 #ifdef EDM_ML_DEBUG
478  edm::LogVerbatim("HGCalGeom") << "cellGeomPtr " << index << ":" << cell;
479 #endif
480  if (nullptr == cell->param()) return nullptr;
481  return cell;
482  } else {
483  auto cell = std::make_shared<FlatHexagon>(m_cellVec[index]);
484  cell->setPosition(pos);
485 #ifdef EDM_ML_DEBUG
486  edm::LogVerbatim("HGCalGeom") << "cellGeomPtr " << index << ":" << cell;
487 #endif
488  if (nullptr == cell->param()) return nullptr;
489  return cell;
490  }
491 }
492 
494  edm::LogError("HGCalGeom") << "HGCalGeometry::addValidID is not implemented";
495 }
496 
497 unsigned int HGCalGeometry::getClosestCellIndex (const GlobalPoint& r) const {
498 
500 }
501 
502 template<class T>
504  const std::vector<T>& vec) const {
505 
506  float phip = r.phi();
507  float zp = r.z();
508  float dzmin(9999), dphimin(9999), dphi10(0.175);
509  unsigned int cellIndex = vec.size();
510  for (unsigned int k=0; k<vec.size(); ++k) {
511  float dphi = phip-vec[k].phiPos();
512  while (dphi > M_PI) dphi -= 2*M_PI;
513  while (dphi <= -M_PI) dphi += 2*M_PI;
514  if (std::abs(dphi) < dphi10) {
515  float dz = std::abs(zp - vec[k].getPosition().z());
516  if (dz < (dzmin+0.001)) {
517  dzmin = dz;
518  if (std::abs(dphi) < (dphimin+0.01)) {
519  cellIndex = k;
520  dphimin = std::abs(dphi);
521  } else {
522  if (cellIndex >= vec.size()) cellIndex = k;
523  }
524  }
525  }
526  }
527 #ifdef EDM_ML_DEBUG
528  edm::LogVerbatim("HGCalGeom") << "getClosestCellIndex::Input " << zp << ":"
529  << phip << " Index " << cellIndex;
530  if (cellIndex < vec.size())
531  edm::LogVerbatim("HGCalGeom") << " Cell z "
532  << vec[cellIndex].getPosition().z()
533  << ":" << dzmin << " phi "
534  << vec[cellIndex].phiPos() << ":" << dphimin;
535 #endif
536  return cellIndex;
537 }
538 
539 
540 // FIXME: Change sorting algorithm if needed
541 namespace {
542  struct rawIdSort {
543  bool operator()( const DetId& a, const DetId& b ) {
544  return( a.rawId() < b.rawId());
545  }
546  };
547 }
548 
550  m_validIds.shrink_to_fit();
551  std::sort( m_validIds.begin(), m_validIds.end(), rawIdSort());
552 }
553 
557  CaloSubdetectorGeometry::IVec& dinsVector ) const {
558 
559  unsigned int numberOfCells = m_topology.totalGeomModules(); // total Geom Modules both sides
560  unsigned int numberOfShapes = k_NumberOfShapes;
561  unsigned int numberOfParametersPerShape =
562  ((m_det == DetId::HGCalHSc) ? (unsigned int)(k_NumberOfParametersPerTrd) :
563  (unsigned int)(k_NumberOfParametersPerHex));
564 
565  trVector.reserve( numberOfCells * numberOfTransformParms());
566  iVector.reserve( numberOfCells );
567  dimVector.reserve( numberOfShapes * numberOfParametersPerShape );
568  dinsVector.reserve( numberOfCells );
569 
570  for (unsigned itr=0; itr<m_topology.dddConstants().getTrFormN(); ++itr) {
572  int layer = mytr.lay;
573 
576  for (int wafer=0; wafer<m_topology.dddConstants().sectors(); ++wafer) {
577  if (m_topology.dddConstants().waferInLayer(wafer,layer,true)) {
578  HGCalParameters::hgtrap vol = m_topology.dddConstants().getModule(wafer, true, true);
579  ParmVec params( numberOfParametersPerShape, 0 );
580  params[0] = vol.dz;
581  params[1] = vol.cellSize;
582  params[2] = twoBysqrt3_*params[1];
583  dimVector.insert( dimVector.end(), params.begin(), params.end());
584  }
585  }
586  } else if (mode_ == HGCalGeometryMode::Trapezoid) {
587  int indx = m_topology.dddConstants().layerIndex(layer,true);
588  for (int md=m_topology.dddConstants().getParameter()->firstModule_[indx];
590  ++md) {
592  ParmVec params( numberOfParametersPerShape, 0 );
593  params[1] = params[2] = 0;
594  params[3] = params[7] = vol.h;
595  params[4] = params[8] = vol.bl;
596  params[5] = params[9] = vol.tl;
597  params[6] = params[10]= vol.alpha;
598  params[11]= vol.cellSize;
599  dimVector.insert( dimVector.end(), params.begin(), params.end());
600  }
601  } else {
602  for (int wafer=0; wafer<m_topology.dddConstants().sectors(); ++wafer) {
603  if (m_topology.dddConstants().waferInLayer(wafer,layer,true)) {
604  HGCalParameters::hgtrap vol = m_topology.dddConstants().getModule(wafer, true, true);
605  ParmVec params( numberOfParametersPerShape, 0 );
606  params[0] = vol.dz;
607  params[1] = vol.cellSize;
608  params[2] = twoBysqrt3_*params[1];
609  dimVector.insert( dimVector.end(), params.begin(), params.end());
610  }
611  }
612  }
613  }
614 
615  for (unsigned int i( 0 ); i < numberOfCells; ++i) {
616  DetId detId = m_validGeomIds[i];
617  int layer(0);
620  layer = HGCalDetId(detId).layer();
621  } else if (mode_ == HGCalGeometryMode::Trapezoid) {
622  layer = HGCScintillatorDetId(detId).layer();
623  } else if (m_topology.isHFNose()) {
624  layer = HFNoseDetId(detId).layer();
625  } else {
626  layer = HGCSiliconDetId(detId).layer();
627  }
628  dinsVector.emplace_back(m_topology.detId2denseGeomId( detId ));
629  iVector.emplace_back( layer );
630 
631  Tr3D tr;
632  auto ptr = cellGeomPtr( i );
633  if ( nullptr != ptr ) {
634  ptr->getTransform( tr, ( Pt3DVec* ) nullptr );
635 
636  if( Tr3D() == tr ) { // there is no rotation
637  const GlobalPoint& gp( ptr->getPosition());
638  tr = HepGeom::Translate3D( gp.x(), gp.y(), gp.z());
639  }
640 
641  const CLHEP::Hep3Vector tt( tr.getTranslation());
642  trVector.emplace_back( tt.x());
643  trVector.emplace_back( tt.y());
644  trVector.emplace_back( tt.z());
645  if (6 == numberOfTransformParms()) {
646  const CLHEP::HepRotation rr( tr.getRotation());
647  const ROOT::Math::Transform3D rtr( rr.xx(), rr.xy(), rr.xz(), tt.x(),
648  rr.yx(), rr.yy(), rr.yz(), tt.y(),
649  rr.zx(), rr.zy(), rr.zz(), tt.z());
651  rtr.GetRotation( ea );
652  trVector.emplace_back( ea.Phi());
653  trVector.emplace_back( ea.Theta());
654  trVector.emplace_back( ea.Psi());
655  }
656  }
657  }
658 }
659 
661  DetId geomId;
662  if ((mode_ == HGCalGeometryMode::Hexagon) ||
664  geomId = static_cast<DetId>(HGCalDetId(detId).geometryCell());
665  } else if (mode_ == HGCalGeometryMode::Trapezoid) {
666  geomId = static_cast<DetId>(HGCScintillatorDetId(detId).geometryCell());
667  } else if (m_topology.isHFNose()) {
668  geomId = static_cast<DetId>(HFNoseDetId(detId).geometryCell());
669  } else {
670  geomId = static_cast<DetId>(HGCSiliconDetId(detId).geometryCell());
671  }
672  return geomId;
673 }
674 
676 
std::vector< DetId > m_validGeomIds
HGCalGeometryMode::GeometryMode mode_
A base class to handle the particular shape of HGCal volumes.
Definition: FlatTrd.h:19
int getLayer(double z, bool reco) const
std::vector< CCGFloat > DimVec
std::vector< FlatHexagon > CellVec
Definition: HGCalGeometry.h:32
virtual unsigned int numberOfParametersPerShape() const
std::string cellElement() const
std::shared_ptr< const CaloCellGeometry > cellGeomPtr(uint32_t index) const override
unsigned int sizeForDenseIndex() const
HGCalParameters::hgtrform getTrForm(unsigned int k) const
unsigned int getClosestCellIndex(const GlobalPoint &r) const
const HGCalParameters * getParameter() const
const HGCalTopology & m_topology
~HGCalGeometry() override
bool cellInLayer(int waferU, int waferV, int cellU, int cellV, int lay, bool reco) const
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:47
std::vector< unsigned int > IVec
T y() const
Definition: PV3DBase.h:63
void newCell(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId) override
std::vector< float > ParmVec
std::vector< GlobalPoint > CornersVec
Definition: HGCalGeometry.h:39
std::vector< CCGFloat > TrVec
GlobalPoint getPosition(const DetId &id) const
HepGeom::Transform3D Tr3D
HFNoseDetId geometryCell() const
Definition: HFNoseDetId.h:49
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
CaloCellGeometry::CCGFloat CCGFloat
CornersVec getCorners(const DetId &id) const
Returns the corner points of this cell&#39;s volume.
CaloCellGeometry::Tr3D Tr3D
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
Definition: FlatHexagon.cc:175
int layerIndex(int lay, bool reco) const
static constexpr unsigned int ncorner_
Definition: FlatHexagon.h:78
CaloCellGeometry::Pt3DVec Pt3DVec
Definition: HGCalGeometry.h:36
std::pair< float, float > locateCellHex(int cell, int wafer, bool reco) const
const double twoBysqrt3_
unsigned int totalGeomModules() const
Definition: HGCalTopology.h:98
HGCalGeometry(const HGCalTopology &topology)
static constexpr unsigned int ncorner_
Definition: FlatTrd.h:76
std::vector< int > firstModule_
static unsigned int k_NumberOfShapes
Definition: HGCalGeometry.h:47
HGCalDetId geometryCell() const
Definition: HGCalDetId.h:36
void initializeParms() override
unsigned int getTrFormN() const
HGCSiliconDetId geometryCell() const
const CCGFloat * param() const
static unsigned int k_NumberOfParametersPerHex
Definition: HGCalGeometry.h:45
virtual uint32_t detId2denseGeomId(const DetId &id) const
int numberCellsHexagon(int wafer) const
int layer() const
get the layer #
Definition: HFNoseDetId.h:58
virtual unsigned int numberOfShapes() const
std::vector< float > ParmVec
DetId encode(const DecodedDetId &id_) const
T sqrt(T t)
Definition: SSEVec.h:18
int layer() const
get the layer #
std::vector< DetId > m_validIds
std::pair< float, float > locateCellTrap(int lay, int ieta, int iphi, bool reco) const
T z() const
Definition: PV3DBase.h:64
A base class to handle the hexagonal shape of HGCal silicon volumes.
Definition: FlatHexagon.h:20
def pv(vc)
Definition: MetAnalyzer.py:7
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::set< DetId > DetIdSet
Definition: HGCalGeometry.h:38
HGCScintillatorDetId geometryCell() const
CornersVec get8Corners(const DetId &id) const
CellVec2 m_cellVec2
int sectors() const
static unsigned int k_NumberOfParametersPerTrd
Definition: HGCalGeometry.h:44
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
Definition: FlatTrd.cc:175
DetIdSet getCells(const GlobalPoint &r, double dR) const override
Get a list of all cells within a dR of the given cell.
void localCorners(Pt3DVec &lc, const CCGFloat *pv, unsigned int i, Pt3D &ref)
#define M_PI
bool isHFNose() const
int k[5][pyjets_maxn]
#define TYPELOOKUP_DATA_REG(_dataclass_)
Definition: typelookup.h:96
DecodedDetId decode(const DetId &id) const
Definition: DetId.h:18
std::vector< int > lastModule_
AlgebraicVector EulerAngles
Definition: Definitions.h:36
ForwardSubdetector m_subdet
std::vector< FlatTrd > CellVec2
Definition: HGCalGeometry.h:33
const HGCalDDDConstants & dddConstants() const
DetId getClosestCell(const GlobalPoint &r) const override
CaloCellGeometry::CornersMgr * cornersMgr()
void getSummary(CaloSubdetectorGeometry::TrVec &trVector, CaloSubdetectorGeometry::IVec &iVector, CaloSubdetectorGeometry::DimVec &dimVector, CaloSubdetectorGeometry::IVec &dinsVector) const override
double b
Definition: hdecay.h:120
unsigned int totalModules() const
Definition: HGCalTopology.h:97
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::Tr3D Tr3D
int layer() const
get the layer #
CaloCellGeometry::Pt3D Pt3D
Definition: HGCalGeometry.h:35
std::array< int, 5 > assignCellHex(float x, float y, int lay, bool reco) const
double a
Definition: hdecay.h:121
virtual void fillNamedParams(DDFilteredView fv)
std::pair< int, int > assignCell(float x, float y, int lay, int subSec, bool reco) const
DetId::Detector m_det
std::array< int, 3 > assignCellTrap(float x, float y, float z, int lay, bool reco) const
const CaloCellGeometry * getGeometryRawPtr(uint32_t index) const override
void addValidID(const DetId &id)
bool valid(const DetId &id) const override
Is this a valid cell id.
virtual unsigned int numberOfTransformParms() const
HGCalParameters::hgtrap getModule(unsigned int k, bool hexType, bool reco) const
T x() const
Definition: PV3DBase.h:62
int waferTypeT(int wafer) const
unsigned int indexFor(const DetId &id) const override
bool present(const DetId &id) const override
is this detid present in the geometry?
int layer() const
get the layer #
Definition: HGCalDetId.h:48
CellVec m_cellVec
bool waferInLayer(int wafer, int lay, bool reco) const
DetId getGeometryDetId(DetId detId) const