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;
68  int cells (0);
72  geomId = (DetId)(HGCalDetId(detId).geometryCell());
73  cells = m_topology.dddConstants().numberCellsHexagon(id.iSec1);
74 #ifdef EDM_ML_DEBUG
75  edm::LogVerbatim("HGCalGeom") << "NewCell " << HGCalDetId(detId)
76  << " GEOM " << HGCalDetId(geomId);
77 #endif
78  } else if (mode_ == HGCalGeometryMode::Trapezoid) {
79  geomId = (DetId)(HGCScintillatorDetId(detId).geometryCell());
80  cells = 1;
81 #ifdef EDM_ML_DEBUG
82  edm::LogVerbatim("HGCalGeom") << "NewCell " << HGCScintillatorDetId(detId)
83  << " GEOM " << HGCScintillatorDetId(geomId);
84 #endif
85  } else {
86  geomId = (DetId)(HGCSiliconDetId(detId).geometryCell());
87  cells = m_topology.dddConstants().numberCellsHexagon(id.iLay,id.iSec1,
88  id.iSec2,false);
89 #ifdef EDM_ML_DEBUG
90  edm::LogVerbatim("HGCalGeom") << "NewCell " << HGCSiliconDetId(detId)
91  << " GEOM " << HGCSiliconDetId(geomId);
92 #endif
93  }
94  const uint32_t cellIndex (m_topology.detId2denseGeomId(detId));
95 
96  if (m_det == DetId::HGCalHSc) {
97  m_cellVec2.at( cellIndex ) = FlatTrd( cornersMgr(), f1, f2, f3, parm ) ;
98  } else {
99  m_cellVec.at( cellIndex ) = FlatHexagon( cornersMgr(), f1, f2, f3, parm ) ;
100  }
101  m_validGeomIds.at( cellIndex ) = geomId ;
102 
103 #ifdef EDM_ML_DEBUG
104  edm::LogVerbatim("HGCalGeom") << "Store for DetId " << std::hex
105  << detId.rawId() << " GeomId "
106  << geomId.rawId() << std::dec << " Index "
107  << cellIndex << " cells " << cells;
108  unsigned int nOld = m_validIds.size();
109 #endif
110  if ((mode_ == HGCalGeometryMode::Hexagon) ||
112  for (int cell = 0; cell < cells; ++cell) {
113  id.iCell1 = cell;
114  DetId idc = m_topology.encode(id);
115  if (m_topology.valid(idc)) {
116  m_validIds.emplace_back(idc);
117 #ifdef EDM_ML_DEBUG
118  edm::LogVerbatim("HGCalGeom") << "Valid Id [" << cell << "] "
119  << HGCalDetId(idc);
120 #endif
121  }
122  }
123  } else if (mode_ == HGCalGeometryMode::Trapezoid) {
124  DetId idc = m_topology.encode(id);
125  if (m_topology.valid(idc)) {
126  m_validIds.emplace_back(idc);
127 #ifdef EDM_ML_DEBUG
128  edm::LogVerbatim("HGCalGeom") << "Valid Id [0] "
129  << HGCScintillatorDetId(idc);
130 #endif
131  } else {
132  edm::LogWarning("HGCalGeom") << "Check " << HGCScintillatorDetId(idc)
133  << " from " << HGCScintillatorDetId(detId)
134  << " ERROR ???";
135  }
136  } else {
137 #ifdef EDM_ML_DEBUG
138  unsigned int cellAll(0), cellSelect(0);
139 #endif
140  for (int u=0; u<2*cells; ++u) {
141  for (int v=0; v<2*cells; ++v) {
142  if (((v-u) < cells) && (u-v) <= cells) {
143  id.iCell1 = u; id.iCell2 = v;
144  DetId idc = m_topology.encode(id);
145 #ifdef EDM_ML_DEBUG
146  ++cellAll;
147 #endif
148  if (m_topology.dddConstants().cellInLayer(id.iSec1,id.iSec2,u,v,
149  id.iLay,true)) {
150  m_validIds.emplace_back(idc);
151 #ifdef EDM_ML_DEBUG
152  ++cellSelect;
153  edm::LogVerbatim("HGCalGeom") << "Valid Id [" << u << ", " << v
154  << "] " << HGCSiliconDetId(idc);
155 #endif
156  }
157  }
158  }
159  }
160 #ifdef EDM_ML_DEBUG
161  edm::LogVerbatim("HGCalGeom") << "HGCalGeometry keeps " << cellSelect
162  << " out of " << cellAll << " for wafer "
163  << id.iSec1 << ":" << id.iSec2 << " in "
164  << " layer " << id.iLay;
165 #endif
166  }
167 #ifdef EDM_ML_DEBUG
168  if (m_det == DetId::HGCalHSc) {
169  edm::LogVerbatim("HGCalGeom") << "HGCalGeometry::newCell-> [" << cellIndex
170  << "]" << " front:" << f1.x() << '/'
171  << f1.y() << '/' << f1.z() << " back:"
172  << f2.x() << '/' << f2.y() << '/' << f2.z()
173  << " eta|phi "
174  << m_cellVec2[cellIndex].etaPos() << ":"
175  << m_cellVec2[cellIndex].phiPos();
176  } else {
177  edm::LogVerbatim("HGCalGeom") << "HGCalGeometry::newCell-> [" << cellIndex
178  << "]" << " front:" << f1.x() << '/'
179  << f1.y() << '/' << f1.z() << " back:"
180  << f2.x() << '/' << f2.y() << '/' << f2.z()
181  << " eta|phi "
182  << m_cellVec[cellIndex].etaPos() << ":"
183  << m_cellVec[cellIndex].phiPos();
184  }
185  unsigned int nNew = m_validIds.size();
186  if ((mode_ == HGCalGeometryMode::Hexagon) ||
188  edm::LogVerbatim("HGCalGeom") << "ID: " << HGCalDetId(detId)
189  << " with valid DetId from " << nOld
190  << " to " << nNew;
191  } else if (mode_ == HGCalGeometryMode::Trapezoid) {
192  edm::LogVerbatim("HGCalGeom") << "ID: " << HGCScintillatorDetId(detId)
193  << " with valid DetId from " << nOld
194  << " to " << nNew;
195  } else {
196  edm::LogVerbatim("HGCalGeom") << "ID: " << HGCSiliconDetId(detId)
197  << " with valid DetId from " << nOld
198  << " to " << nNew;
199  }
200  edm::LogVerbatim("HGCalGeom") << "Cell[" << cellIndex << "] " << std::hex
201  << geomId.rawId() << ":"
202  << m_validGeomIds[cellIndex].rawId()
203  << std::dec;
204 #endif
205 }
206 
207 std::shared_ptr<const CaloCellGeometry> HGCalGeometry::getGeometry(const DetId& id) const {
208  if (id == DetId()) return nullptr; // nothing to get
209  DetId geoId;
210  if ((mode_ == HGCalGeometryMode::Hexagon) ||
212  geoId = (DetId)(HGCalDetId(id).geometryCell());
213  } else if (mode_ == HGCalGeometryMode::Trapezoid) {
214  geoId = (DetId)(HGCScintillatorDetId(id).geometryCell());
215  } else {
216  geoId = (DetId)(HGCSiliconDetId(id).geometryCell());
217  }
218  const uint32_t cellIndex (m_topology.detId2denseGeomId(geoId));
219  const GlobalPoint pos = (id != geoId) ? getPosition(id) : GlobalPoint();
220  return cellGeomPtr (cellIndex, pos);
221 
222 }
223 
224 bool HGCalGeometry::present(const DetId& id) const {
225  if (id == DetId()) return false;
226  DetId geoId;
227  if ((mode_ == HGCalGeometryMode::Hexagon) ||
229  geoId = (DetId)(HGCalDetId(id).geometryCell());
230  } else if (mode_ == HGCalGeometryMode::Trapezoid) {
231  geoId = (DetId)(HGCScintillatorDetId(id).geometryCell());
232  } else {
233  geoId = (DetId)(HGCSiliconDetId(id).geometryCell());
234  }
235  const uint32_t index (m_topology.detId2denseGeomId(geoId));
236  return (nullptr != getGeometryRawPtr(index)) ;
237 }
238 
240 
241  unsigned int cellIndex = indexFor(id);
242  GlobalPoint glob;
243  unsigned int maxSize = ((mode_ == HGCalGeometryMode::Trapezoid) ?
244  m_cellVec2.size() : m_cellVec.size());
245  if (cellIndex < maxSize) {
247  std::pair<float,float> xy;
250  xy = m_topology.dddConstants().locateCellHex(id_.iCell1,id_.iSec1,true);
251  const HepGeom::Point3D<float> lcoord(xy.first,xy.second,0);
252  glob = m_cellVec[cellIndex].getPosition(lcoord);
253 #ifdef EDM_ML_DEBUG
254  edm::LogVerbatim("HGCalGeom") << "getPosition:: index " << cellIndex
255  << " Local " << lcoord.x() << ":"
256  << lcoord.y() << " ID " << id_.iCell1
257  << ":" << id_.iSec1 << " Global " << glob;
258 #endif
259  } else if (mode_ == HGCalGeometryMode::Trapezoid) {
260  const HepGeom::Point3D<float> lcoord(0,0,0);
261  glob = m_cellVec2[cellIndex].getPosition(lcoord);
262 #ifdef EDM_ML_DEBUG
263  edm::LogVerbatim("HGCalGeom") << "getPositionTrap:: index " << cellIndex
264  << " Local " << lcoord.x() << ":"
265  << lcoord.y() << " ID " << id_.iLay << ":"
266  << id_.iSec1 << ":" << id_.iCell1
267  << " Global " << glob;
268 #endif
269  } else {
270  xy = m_topology.dddConstants().locateCell(id_.iLay,id_.iSec1,id_.iSec2,
271  id_.iCell1,id_.iCell2,true,false);
272  const HepGeom::Point3D<float> lcoord(xy.first,xy.second,0);
273  glob = m_cellVec[cellIndex].getPosition(lcoord);
274 #ifdef EDM_ML_DEBUG
275  edm::LogVerbatim("HGCalGeom") << "getPositionWafer:: index " << cellIndex
276  << " Local " << lcoord.x() << ":"
277  << lcoord.y() << " ID " << id_.iLay << ":"
278  << id_.iSec1 << ":" << id_.iSec2 << ":"
279  << id_.iCell1 << ":" << id_.iCell2
280  << " Global " << glob;
281 #endif
282  }
283  }
284  return glob;
285 }
286 
288 
289  unsigned int ncorner = ((m_det == DetId::HGCalHSc) ? FlatTrd::ncorner_ :
291  HGCalGeometry::CornersVec co (ncorner, GlobalPoint(0,0,0));
292  unsigned int cellIndex = indexFor(id);
293  if ((cellIndex < m_cellVec.size() && m_det != DetId::HGCalHSc) ||
294  (cellIndex < m_cellVec2.size() && m_det == DetId::HGCalHSc)) {
296  std::pair<float,float> xy;
299  xy = m_topology.dddConstants().locateCellHex(id_.iCell1,id_.iSec1,true);
300  } else if (mode_ == HGCalGeometryMode::Trapezoid) {
302  id_.iCell1,true);
303  } else {
304  xy = m_topology.dddConstants().locateCell(id_.iLay,id_.iSec1,id_.iSec2,
305  id_.iCell1,id_.iCell2,true,false);
306  }
307  if (m_det == DetId::HGCalHSc) {
308  float dx = 0.5*m_cellVec2[cellIndex].param()[11];
309  float dz = m_cellVec2[cellIndex].param()[0];
310  static const int signx[] = {-1,-1,1,1,-1,-1,1,1};
311  static const int signy[] = {-1,1,1,-1,-1,1,1,-1};
312  static const int signz[] = {-1,-1,-1,-1,1,1,1,1};
313  for (unsigned int i = 0; i != ncorner; ++i) {
314  const HepGeom::Point3D<float> lcoord(xy.first+signx[i]*dx,xy.second+signy[i]*dx,signz[i]*dz);
315  co[i] = m_cellVec2[cellIndex].getPosition(lcoord);
316  }
317  } else {
318  float dx = m_cellVec[cellIndex].param()[1];
319  float dy = m_cellVec[cellIndex].param()[2];
320  float dz = m_cellVec[cellIndex].param()[0];
321  static const int signx[] = {0,-1,-1,0,1,1,0,-1,-1,0,1,1};
322  static const int signy[] = {-2,-1,1,2,1,-1,-2,-1,1,2,1,-1};
323  static const int signz[] = {-1,-1,-1,-1,-1,-1,1,1,1,1,1,1};
324  for (unsigned int i = 0; i != ncorner; ++i) {
325  const HepGeom::Point3D<float> lcoord(xy.first+signx[i]*dx,xy.second+signy[i]*dy,signz[i]*dz);
326  co[i] = m_cellVec[cellIndex].getPosition(lcoord);
327  }
328  }
329  }
330  return co;
331 }
332 
334  unsigned int cellIndex = getClosestCellIndex(r);
335  if ((cellIndex < m_cellVec.size() && m_det != DetId::HGCalHSc) ||
336  (cellIndex < m_cellVec2.size() && m_det == DetId::HGCalHSc)) {
338  HepGeom::Point3D<float> local;
339  if (r.z() > 0) {
340  local = HepGeom::Point3D<float>(r.x(),r.y(),0);
341  id_.zSide = 1;
342  } else {
343  local = HepGeom::Point3D<float>(-r.x(),r.y(),0);
344  id_.zSide =-1;
345  }
348  const auto & kxy =
349  m_topology.dddConstants().assignCell(local.x(),local.y(),id_.iLay,
350  id_.iType,true);
351  id_.iCell1 = kxy.second;
352  id_.iSec1 = kxy.first;
353  id_.iType = m_topology.dddConstants().waferTypeT(kxy.first);
354  if (id_.iType != 1) id_.iType = -1;
355  } else if (mode_ == HGCalGeometryMode::Trapezoid) {
356  id_.iLay = m_topology.dddConstants().getLayer(r.z(),true);
357  const auto & kxy =
358  m_topology.dddConstants().assignCellTrap(r.x(),r.y(),r.z(),
359  id_.iLay,true);
360  id_.iSec1 = kxy[0];
361  id_.iCell1 = kxy[1];
362  id_.iType = kxy[2];
363  } else {
364  id_.iLay = m_topology.dddConstants().getLayer(r.z(),true);
365  const auto & kxy =
366  m_topology.dddConstants().assignCellHex(local.x(),local.y(),id_.iLay,
367  true);
368  id_.iSec1 = kxy[0]; id_.iSec2 = kxy[1]; id_.iType = kxy[2];
369  id_.iCell1 = kxy[3]; id_.iCell2 = kxy[4];
370  }
371 #ifdef EDM_ML_DEBUG
372  edm::LogVerbatim("HGCalGeom") << "getClosestCell: local " << local
373  << " Id " << id_.zSide << ":" << id_.iLay
374  << ":" << id_.iSec1 << ":" << id_.iSec2
375  << ":" << id_.iType << ":" << id_.iCell1
376  << ":" << id_.iCell2;
377 #endif
378 
379  //check if returned cell is valid
380  if (id_.iCell1>=0) return m_topology.encode(id_);
381  }
382 
383  //if not valid or out of bounds return a null DetId
384  return DetId();
385 }
386 
389  return dss;
390 }
391 
393  if (m_subdet == HGCEE || m_det == DetId::HGCalEE) return "HGCalEE";
394  else if (m_subdet == HGCHEF || m_det == DetId::HGCalHSi) return "HGCalHEFront";
395  else if (m_subdet == HGCHEB || m_det == DetId::HGCalHSc) return "HGCalHEBack";
396  else return "Unknown";
397 }
398 
399 unsigned int HGCalGeometry::indexFor(const DetId& id) const {
400  unsigned int cellIndex = ((m_det == DetId::HGCalHSc) ? m_cellVec2.size() :
401  m_cellVec.size());
402  if (id != DetId()) {
403  DetId geoId;
406  geoId = (DetId)(HGCalDetId(id).geometryCell());
407  } else if (mode_ == HGCalGeometryMode::Trapezoid) {
408  geoId = (DetId)(HGCScintillatorDetId(id).geometryCell());
409  } else {
410  geoId = (DetId)(HGCSiliconDetId(id).geometryCell());
411  }
412  cellIndex = m_topology.detId2denseGeomId(geoId);
413 #ifdef EDM_ML_DEBUG
414  edm::LogVerbatim("HGCalGeom") << "indexFor " << std::hex << id.rawId()
415  << ":" << geoId.rawId() << std::dec
416  << " index " << cellIndex;
417 #endif
418  }
419  return cellIndex;
420 }
421 
422 unsigned int HGCalGeometry::sizeForDenseIndex() const {
423  return m_topology.totalGeomModules();
424 }
425 
427  // Modify the RawPtr class
428  if (m_det == DetId::HGCalHSc) {
429  if (m_cellVec2.size() < index) return nullptr;
430  const CaloCellGeometry* cell(&m_cellVec2[index]);
431  return (nullptr == cell->param() ? nullptr : cell);
432  } else {
433  if (m_cellVec2.size() < index) return nullptr;
434  const CaloCellGeometry* cell(&m_cellVec[index]);
435  return (nullptr == cell->param() ? nullptr : cell);
436  }
437 }
438 
439 std::shared_ptr<const CaloCellGeometry> HGCalGeometry::cellGeomPtr(uint32_t index) const {
440  if ((index >= m_cellVec.size() && m_det != DetId::HGCalHSc) ||
441  (index >= m_cellVec2.size() && m_det == DetId::HGCalHSc) ||
442  (m_validGeomIds[index].rawId() == 0)) return nullptr;
443  static const auto do_not_delete = [](const void*){};
444  if (m_det == DetId::HGCalHSc) {
445  auto cell = std::shared_ptr<const CaloCellGeometry>(&m_cellVec2[index],do_not_delete);
446  if (nullptr == cell->param()) return nullptr;
447  return cell;
448  } else {
449  auto cell = std::shared_ptr<const CaloCellGeometry>(&m_cellVec[index],do_not_delete);
450  if (nullptr == cell->param()) return nullptr;
451  return cell;
452  }
453 }
454 
455 std::shared_ptr<const CaloCellGeometry> HGCalGeometry::cellGeomPtr(uint32_t index, const GlobalPoint& pos) const {
456  if ((index >= m_cellVec.size() && m_det != DetId::HGCalHSc) ||
457  (index >= m_cellVec2.size() && m_det == DetId::HGCalHSc) ||
458  (m_validGeomIds[index].rawId() == 0)) return nullptr;
459  if (pos == GlobalPoint()) return cellGeomPtr(index);
460  if (m_det == DetId::HGCalHSc) {
461  auto cell = std::make_shared<FlatTrd>(m_cellVec2[index]);
462  cell->setPosition(pos);
463 #ifdef EDM_ML_DEBUG
464  edm::LogVerbatim("HGCalGeom") << "cellGeomPtr " << index << ":" << cell;
465 #endif
466  if (nullptr == cell->param()) return nullptr;
467  return cell;
468  } else {
469  auto cell = std::make_shared<FlatHexagon>(m_cellVec[index]);
470  cell->setPosition(pos);
471 #ifdef EDM_ML_DEBUG
472  edm::LogVerbatim("HGCalGeom") << "cellGeomPtr " << index << ":" << cell;
473 #endif
474  if (nullptr == cell->param()) return nullptr;
475  return cell;
476  }
477 }
478 
480  edm::LogError("HGCalGeom") << "HGCalGeometry::addValidID is not implemented";
481 }
482 
483 unsigned int HGCalGeometry::getClosestCellIndex (const GlobalPoint& r) const {
484 
486 }
487 
488 template<class T>
490  const std::vector<T>& vec) const {
491 
492  float phip = r.phi();
493  float zp = r.z();
494  float dzmin(9999), dphimin(9999), dphi10(0.175);
495  unsigned int cellIndex = vec.size();
496  for (unsigned int k=0; k<vec.size(); ++k) {
497  float dphi = phip-vec[k].phiPos();
498  while (dphi > M_PI) dphi -= 2*M_PI;
499  while (dphi <= -M_PI) dphi += 2*M_PI;
500  if (std::abs(dphi) < dphi10) {
501  float dz = std::abs(zp - vec[k].getPosition().z());
502  if (dz < (dzmin+0.001)) {
503  dzmin = dz;
504  if (std::abs(dphi) < (dphimin+0.01)) {
505  cellIndex = k;
506  dphimin = std::abs(dphi);
507  } else {
508  if (cellIndex >= vec.size()) cellIndex = k;
509  }
510  }
511  }
512  }
513 #ifdef EDM_ML_DEBUG
514  edm::LogVerbatim("HGCalGeom") << "getClosestCellIndex::Input " << zp << ":"
515  << phip << " Index " << cellIndex;
516  if (cellIndex < vec.size())
517  edm::LogVerbatim("HGCalGeom") << " Cell z "
518  << vec[cellIndex].getPosition().z()
519  << ":" << dzmin << " phi "
520  << vec[cellIndex].phiPos() << ":" << dphimin;
521 #endif
522  return cellIndex;
523 }
524 
525 
526 // FIXME: Change sorting algorithm if needed
527 namespace {
528  struct rawIdSort {
529  bool operator()( const DetId& a, const DetId& b ) {
530  return( a.rawId() < b.rawId());
531  }
532  };
533 }
534 
536  m_validIds.shrink_to_fit();
537  std::sort( m_validIds.begin(), m_validIds.end(), rawIdSort());
538 }
539 
543  CaloSubdetectorGeometry::IVec& dinsVector ) const {
544 
545  unsigned int numberOfCells = m_topology.totalGeomModules(); // total Geom Modules both sides
546  unsigned int numberOfShapes = k_NumberOfShapes;
547  unsigned int numberOfParametersPerShape =
548  ((m_det == DetId::HGCalHSc) ? (unsigned int)(k_NumberOfParametersPerTrd) :
549  (unsigned int)(k_NumberOfParametersPerHex));
550 
551  trVector.reserve( numberOfCells * numberOfTransformParms());
552  iVector.reserve( numberOfCells );
553  dimVector.reserve( numberOfShapes * numberOfParametersPerShape );
554  dinsVector.reserve( numberOfCells );
555 
556  for (unsigned itr=0; itr<m_topology.dddConstants().getTrFormN(); ++itr) {
558  int layer = mytr.lay;
559 
562  for (int wafer=0; wafer<m_topology.dddConstants().sectors(); ++wafer) {
563  if (m_topology.dddConstants().waferInLayer(wafer,layer,true)) {
564  HGCalParameters::hgtrap vol = m_topology.dddConstants().getModule(wafer, true, true);
565  ParmVec params( numberOfParametersPerShape, 0 );
566  params[0] = vol.dz;
567  params[1] = vol.cellSize;
568  params[2] = twoBysqrt3_*params[1];
569  dimVector.insert( dimVector.end(), params.begin(), params.end());
570  }
571  }
572  } else if (mode_ == HGCalGeometryMode::Trapezoid) {
573  int indx = m_topology.dddConstants().layerIndex(layer,true);
574  for (int md=m_topology.dddConstants().getParameter()->firstModule_[indx];
576  ++md) {
578  ParmVec params( numberOfParametersPerShape, 0 );
579  params[1] = params[2] = 0;
580  params[3] = params[7] = vol.h;
581  params[4] = params[8] = vol.bl;
582  params[5] = params[9] = vol.tl;
583  params[6] = params[10]= vol.alpha;
584  params[11]= vol.cellSize;
585  dimVector.insert( dimVector.end(), params.begin(), params.end());
586  }
587  } else {
588  for (int wafer=0; wafer<m_topology.dddConstants().sectors(); ++wafer) {
589  if (m_topology.dddConstants().waferInLayer(wafer,layer,true)) {
590  HGCalParameters::hgtrap vol = m_topology.dddConstants().getModule(wafer, true, true);
591  ParmVec params( numberOfParametersPerShape, 0 );
592  params[0] = vol.dz;
593  params[1] = vol.cellSize;
594  params[2] = twoBysqrt3_*params[1];
595  dimVector.insert( dimVector.end(), params.begin(), params.end());
596  }
597  }
598  }
599  }
600 
601  for (unsigned int i( 0 ); i < numberOfCells; ++i) {
602  DetId detId = m_validGeomIds[i];
603  int layer(0);
606  layer = HGCalDetId(detId).layer();
607  } else if (mode_ == HGCalGeometryMode::Trapezoid) {
608  layer = HGCScintillatorDetId(detId).layer();
609  } else {
610  layer = HGCSiliconDetId(detId).layer();
611  }
612  dinsVector.emplace_back(m_topology.detId2denseGeomId( detId ));
613  iVector.emplace_back( layer );
614 
615  Tr3D tr;
616  auto ptr = cellGeomPtr( i );
617  if ( nullptr != ptr ) {
618  ptr->getTransform( tr, ( Pt3DVec* ) nullptr );
619 
620  if( Tr3D() == tr ) { // there is no rotation
621  const GlobalPoint& gp( ptr->getPosition());
622  tr = HepGeom::Translate3D( gp.x(), gp.y(), gp.z());
623  }
624 
625  const CLHEP::Hep3Vector tt( tr.getTranslation());
626  trVector.emplace_back( tt.x());
627  trVector.emplace_back( tt.y());
628  trVector.emplace_back( tt.z());
629  if (6 == numberOfTransformParms()) {
630  const CLHEP::HepRotation rr( tr.getRotation());
631  const ROOT::Math::Transform3D rtr( rr.xx(), rr.xy(), rr.xz(), tt.x(),
632  rr.yx(), rr.yy(), rr.yz(), tt.y(),
633  rr.zx(), rr.zy(), rr.zz(), tt.z());
635  rtr.GetRotation( ea );
636  trVector.emplace_back( ea.Phi());
637  trVector.emplace_back( ea.Theta());
638  trVector.emplace_back( ea.Psi());
639  }
640  }
641  }
642 }
643 
645 
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:31
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:38
std::vector< CCGFloat > TrVec
GlobalPoint getPosition(const DetId &id) const
HepGeom::Transform3D Tr3D
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:35
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:46
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:44
virtual uint32_t detId2denseGeomId(const DetId &id) const
int numberCellsHexagon(int wafer) const
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:6
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::set< DetId > DetIdSet
Definition: HGCalGeometry.h:37
HGCScintillatorDetId geometryCell() const
CellVec2 m_cellVec2
int sectors() const
static unsigned int k_NumberOfParametersPerTrd
Definition: HGCalGeometry.h:43
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
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:32
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:34
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