CMS 3D CMS Logo

FWTGeoRecoGeometryESProducer.cc
Go to the documentation of this file.
4 
18 
46 
47 #include "TGeoManager.h"
48 #include "TGeoArb8.h"
49 #include "TGeoMatrix.h"
50 
51 #include "TFile.h"
52 #include "TTree.h"
53 #include "TError.h"
54 #include "TMath.h"
55 
56 #include "TEveVector.h"
57 #include "TEveTrans.h"
58 
59 //std::map< const CaloCellGeometry::CCGFloat*, TGeoVolume*> caloShapeMap;
60 namespace {
61  typedef std::map<const float*, TGeoVolume*> CaloVolMap;
62 }
64  m_tracker = pset.getUntrackedParameter<bool>("Tracker", true);
65  m_muon = pset.getUntrackedParameter<bool>("Muon", true);
66  m_calo = pset.getUntrackedParameter<bool>("Calo", true);
67 
68  setWhatProduced(this);
69 }
70 
72 
73 namespace {
74 
75  void AddLeafNode(TGeoVolume* mother, TGeoVolume* daughter, const char* name, TGeoMatrix* mtx) {
76  int n = mother->GetNdaughters();
77  mother->AddNode(daughter, 1, mtx);
78  mother->GetNode(n)->SetName(name);
79  }
80 
82  TGeoCombiTrans* createPlacement(const GeomDet* det) {
83  // Position of the DetUnit's center
84  float posx = det->surface().position().x();
85  float posy = det->surface().position().y();
86  float posz = det->surface().position().z();
87 
88  TGeoTranslation trans(posx, posy, posz);
89 
90  // Add the coeff of the rotation matrix
91  // with a projection on the basis vectors
92  TkRotation<float> detRot = det->surface().rotation();
93 
94  TGeoRotation rotation;
95  const Double_t matrix[9] = {detRot.xx(),
96  detRot.yx(),
97  detRot.zx(),
98  detRot.xy(),
99  detRot.yy(),
100  detRot.zy(),
101  detRot.xz(),
102  detRot.yz(),
103  detRot.zz()};
104  rotation.SetMatrix(matrix);
105 
106  return new TGeoCombiTrans(trans, rotation);
107  }
108 
109 } // namespace
110 //______________________________________________________________________________
111 
112 TGeoVolume* FWTGeoRecoGeometryESProducer::GetDaughter(TGeoVolume* mother, const char* prefix, ERecoDet cidx, int id) {
113  TGeoVolume* res = nullptr;
114  if (mother->GetNdaughters()) {
115  TGeoNode* n = mother->FindNode(Form("%s_%d_1", prefix, id));
116  if (n)
117  res = n->GetVolume();
118  }
119 
120  if (!res) {
121  res = new TGeoVolumeAssembly(Form("%s_%d", prefix, id));
122  res->SetMedium(GetMedium(cidx));
123  mother->AddNode(res, 1);
124  }
125 
126  return res;
127 }
128 
129 TGeoVolume* FWTGeoRecoGeometryESProducer::GetDaughter(TGeoVolume* mother, const char* prefix, ERecoDet cidx) {
130  TGeoVolume* res = nullptr;
131  if (mother->GetNdaughters()) {
132  TGeoNode* n = mother->FindNode(Form("%s_1", prefix));
133  if (n)
134  res = n->GetVolume();
135  }
136 
137  if (!res) {
138  // printf("GetDau... new holder %s for mother %s \n", mother->GetName(), prefix);
139  res = new TGeoVolumeAssembly(prefix);
140  res->SetMedium(GetMedium(cidx));
141  mother->AddNode(res, 1);
142  }
143 
144  return res;
145 }
146 
148  // printf("GetTopHolder res = %s \n", prefix);
149  TGeoVolume* res = GetDaughter(gGeoManager->GetTopVolume(), prefix, cidx);
150  return res;
151 }
152 
153 namespace {
154 
155  enum GMCol {
156  Green = 4,
157  Blue0 = 13,
158  Blue1 = 24,
159  Blue2 = 6,
160  Yellow0 = 3,
161  Yellow1 = 16,
162  Pink = 10,
163  Red = 29,
164  Orange0 = 79,
165  Orange1 = 14,
166  Magenta = 8,
167  Gray = 12
168  };
169 
170 }
171 
173  std::map<ERecoDet, TGeoMedium*>::iterator it = m_recoMedium.find(det);
174  if (it != m_recoMedium.end())
175  return it->second;
176 
178  int color;
179 
180  switch (det) {
181  // TRACKER
182  case kSiPixel:
183  name = "SiPixel";
184  color = GMCol::Green;
185  break;
186 
187  case kSiStrip:
188  name = "SiStrip";
189  color = GMCol::Gray;
190  break;
191  // MUON
192  case kMuonDT:
193  name = "MuonDT";
194  color = GMCol::Blue2;
195  break;
196 
197  case kMuonRPC:
198  name = "MuonRPC";
199  color = GMCol::Red;
200  break;
201 
202  case kMuonGEM:
203  name = "MuonGEM";
204  color = GMCol::Yellow1;
205  break;
206 
207  case kMuonCSC:
208  name = "MuonCSC";
209  color = GMCol::Gray;
210  break;
211 
212  case kMuonME0:
213  name = "MuonME0";
214  color = GMCol::Yellow0;
215  break;
216 
217  // CALO
218  case kECal:
219  name = "ECal";
220  color = GMCol::Blue2;
221  break;
222  case kHCal:
223  name = "HCal";
224  color = GMCol::Orange1;
225  break;
226  case kCaloTower:
227  name = "CaloTower";
228  color = GMCol::Green;
229  break;
230  case kHGCE:
231  name = "HGCEE";
232  color = GMCol::Blue2;
233  break;
234  case kHGCH:
235  name = "HGCEH";
236  color = GMCol::Blue1;
237  break;
238  default:
239  printf("invalid medium id \n");
240  return m_dummyMedium;
241  }
242 
243  TGeoMaterial* mat = new TGeoMaterial(name.c_str(), 0, 0, 0);
244  mat->SetZ(color);
245  m_recoMedium[det] = new TGeoMedium(name.c_str(), 0, mat);
246  mat->SetFillStyle(3000); // tansparency 3000-3100
247  mat->SetDensity(1); // disable override of transparency in TGeoManager::DefaultColors()
248 
249  return m_recoMedium[det];
250 }
251 
252 //______________________________________________________________________________
253 
254 std::unique_ptr<FWTGeoRecoGeometry> FWTGeoRecoGeometryESProducer::produce(const FWTGeoRecoGeometryRecord& record) {
255  using namespace edm;
256 
257  auto fwTGeoRecoGeometry = std::make_unique<FWTGeoRecoGeometry>();
258 
259  if (m_calo) {
261  record.getRecord<CaloGeometryRecord>().get(caloH);
262  m_caloGeom = caloH.product();
263  }
264 
265  TGeoManager* geom = new TGeoManager("cmsGeo", "CMS Detector");
266  if (nullptr == gGeoIdentity) {
267  gGeoIdentity = new TGeoIdentity("Identity");
268  }
269 
270  fwTGeoRecoGeometry->manager(geom);
271 
272  // Default material is Vacuum
273  TGeoMaterial* vacuum = new TGeoMaterial("Vacuum", 0, 0, 0);
274  m_dummyMedium = new TGeoMedium("reco", 0, vacuum);
275 
276  TGeoVolume* top = geom->MakeBox("CMS", m_dummyMedium, 270., 270., 120.);
277 
278  if (nullptr == top) {
279  return std::unique_ptr<FWTGeoRecoGeometry>();
280  }
281  geom->SetTopVolume(top);
282  // ROOT chokes unless colors are assigned
283  top->SetVisibility(kFALSE);
284  top->SetLineColor(kBlue);
285 
286  if (m_tracker || m_muon) {
288  }
289 
290  if (m_tracker) {
291  DetId detId(DetId::Tracker, 0);
293 
294  edm::ESHandle<TrackerTopology> trackerTopologyHandle;
295  record.getRecord<TrackerTopologyRcd>().get(trackerTopologyHandle);
296  m_trackerTopology = trackerTopologyHandle.product();
297 
300 
301  addTIBGeometry();
302  addTIDGeometry();
303  addTOBGeometry();
304  addTECGeometry();
305  }
306 
307  if (m_muon) {
308  addDTGeometry();
309  addCSCGeometry();
310  addRPCGeometry();
311  addME0Geometry();
312  addGEMGeometry();
313  }
314 
315  if (m_calo) {
322  }
323 
324  geom->CloseGeometry();
325 
326  geom->DefaultColors();
327  // printf("==== geo manager NNodes = %d \n", geom->GetNNodes());
328  geom->CloseGeometry();
329 
330  return fwTGeoRecoGeometry;
331 }
332 
335  TGeoShape* shape = nullptr;
336 
337  // Trapezoidal
338  const Bounds* b = &((det->surface()).bounds());
339  const TrapezoidalPlaneBounds* b2 = dynamic_cast<const TrapezoidalPlaneBounds*>(b);
340  if (b2) {
341  std::array<const float, 4> const& par = b2->parameters();
342 
343  // These parameters are half-lengths, as in CMSIM/GEANT3
344  float hBottomEdge = par[0];
345  float hTopEdge = par[1];
346  float thickness = par[2];
347  float apothem = par[3];
348 
349  std::stringstream s;
350  s << "T_" << hBottomEdge << "_" << hTopEdge << "_" << thickness << "_" << apothem;
351  std::string name = s.str();
352 
353  // Do not create identical shape,
354  // if one already exists
355  shape = m_nameToShape[name];
356  if (nullptr == shape) {
357  shape = new TGeoTrap(name.c_str(),
358  thickness, //dz
359  0, //theta
360  0, //phi
361  apothem, //dy1
362  hBottomEdge, //dx1
363  hTopEdge, //dx2
364  0, //alpha1
365  apothem, //dy2
366  hBottomEdge, //dx3
367  hTopEdge, //dx4
368  0); //alpha2
369 
370  m_nameToShape[name] = shape;
371  }
372  }
373  if (dynamic_cast<const RectangularPlaneBounds*>(b) != nullptr) {
374  // Rectangular
375  float length = det->surface().bounds().length();
376  float width = det->surface().bounds().width();
377  float thickness = det->surface().bounds().thickness();
378 
379  std::stringstream s;
380  s << "R_" << width << "_" << length << "_" << thickness;
381  std::string name = s.str();
382 
383  // Do not create identical shape,
384  // if one already exists
385  shape = m_nameToShape[name];
386  if (nullptr == shape) {
387  shape = new TGeoBBox(name.c_str(), width / 2., length / 2., thickness / 2.); // dx, dy, dz
388 
389  m_nameToShape[name] = shape;
390  }
391  }
392 
393  return shape;
394 }
395 
398  TGeoShape* solid = createShape(det);
399 
400  std::map<TGeoShape*, TGeoVolume*>::iterator vIt = m_shapeToVolume.find(solid);
401  if (vIt != m_shapeToVolume.end())
402  return vIt->second;
403 
404  TGeoVolume* volume = new TGeoVolume(name.c_str(), solid, GetMedium(mid));
405 
406  m_shapeToVolume[solid] = volume;
407 
408  return volume;
409 }
410 
419 
421  TGeoVolume* tv = GetTopHolder("SiPixel", kSiPixel);
422  TGeoVolume* assembly = GetDaughter(tv, "PXB", kSiPixel);
423 
424  for (auto it : m_trackerGeom->detsPXB()) {
425  DetId detid = it->geographicalId();
426  unsigned int layer = m_trackerTopology->pxbLayer(detid);
427  unsigned int module = m_trackerTopology->pxbModule(detid);
428  unsigned int ladder = m_trackerTopology->pxbLadder(detid);
429 
430  std::string name = Form("PXB Ly:%d, Md:%d Ld:%d ", layer, module, ladder);
431  TGeoVolume* child = createVolume(name, it, kSiPixel);
432 
433  TGeoVolume* holder = GetDaughter(assembly, "Layer", kSiPixel, layer);
434  holder = GetDaughter(holder, "Module", kSiPixel, module);
435 
436  AddLeafNode(holder, child, name.c_str(), createPlacement(it));
437  }
438 }
439 
441  TGeoVolume* tv = GetTopHolder("SiPixel", kSiPixel);
442  TGeoVolume* assembly = GetDaughter(tv, "PXF", kSiPixel);
443 
444  for (auto it : m_trackerGeom->detsPXF()) {
445  DetId detid = it->geographicalId();
446  unsigned int disk = m_trackerTopology->pxfDisk(detid);
447  unsigned int blade = m_trackerTopology->pxfBlade(detid);
448  unsigned int panel = m_trackerTopology->pxfPanel(detid);
449  unsigned int side = m_trackerTopology->side(detid);
450 
451  std::string name = Form("PXF D:%d, B:%d, P:%d, S:%d", disk, blade, panel, side);
452  TGeoVolume* child = createVolume(name, it, kSiPixel);
453 
454  TGeoVolume* holder = GetDaughter(assembly, "Side", kSiPixel, side);
455  holder = GetDaughter(holder, "Disk", kSiPixel, disk);
456  holder = GetDaughter(holder, "Blade", kSiPixel, blade);
457  holder = GetDaughter(holder, "Panel", kSiPixel, panel);
458 
459  AddLeafNode(holder, child, name.c_str(), createPlacement(it));
460  }
461 }
462 
464  TGeoVolume* tv = GetTopHolder("SiStrip", kSiStrip);
465  TGeoVolume* assembly = GetDaughter(tv, "TIB", kSiStrip);
466 
467  for (auto it : m_trackerGeom->detsTIB()) {
468  DetId detid = it->geographicalId();
469  unsigned int module = m_trackerTopology->tibModule(detid);
470  unsigned int order = m_trackerTopology->tibOrder(detid);
471  unsigned int side = m_trackerTopology->tibSide(detid);
472 
474 
475  TGeoVolume* child = createVolume(name, it, kSiStrip);
476  TGeoVolume* holder = GetDaughter(assembly, "Module", kSiStrip, module);
477  holder = GetDaughter(holder, "Order", kSiStrip, order);
478  holder = GetDaughter(holder, "Side", kSiStrip, side);
479  AddLeafNode(holder, child, name.c_str(), createPlacement(it));
480  }
481 }
482 
484  TGeoVolume* tv = GetTopHolder("SiStrip", kSiStrip);
485  TGeoVolume* assembly = GetDaughter(tv, "TID", kSiStrip);
486 
487  for (auto it : m_trackerGeom->detsTID()) {
488  DetId detid = it->geographicalId();
489  unsigned int side = m_trackerTopology->tidSide(detid);
490  unsigned int wheel = m_trackerTopology->tidWheel(detid);
491  unsigned int ring = m_trackerTopology->tidRing(detid);
492 
494 
495  TGeoVolume* child = createVolume(name, it, kSiStrip);
496  TGeoVolume* holder = GetDaughter(assembly, "Side", kSiStrip, side);
497  holder = GetDaughter(holder, "Wheel", kSiStrip, wheel);
498  holder = GetDaughter(holder, "Ring", kSiStrip, ring);
499  AddLeafNode(holder, child, name.c_str(), createPlacement(it));
500  }
501 }
502 
504  TGeoVolume* tv = GetTopHolder("SiStrip", kSiStrip);
505  TGeoVolume* assembly = GetDaughter(tv, "TOB", kSiStrip);
506 
507  for (auto it : m_trackerGeom->detsTOB()) {
508  DetId detid = it->geographicalId();
509  unsigned int rod = m_trackerTopology->tobRod(detid);
510  unsigned int side = m_trackerTopology->tobSide(detid);
511  unsigned int module = m_trackerTopology->tobModule(detid);
512 
514 
515  TGeoVolume* child = createVolume(name, it, kSiStrip);
516  TGeoVolume* holder = GetDaughter(assembly, "Rod", kSiStrip, rod);
517  holder = GetDaughter(holder, "Side", kSiStrip, side);
518  holder = GetDaughter(holder, "Module", kSiStrip, module);
519  AddLeafNode(holder, child, name.c_str(), createPlacement(it));
520  }
521 }
522 
524  TGeoVolume* tv = GetTopHolder("SiStrip", kSiStrip);
525  TGeoVolume* assembly = GetDaughter(tv, "TEC", kSiStrip);
526 
527  for (auto it : m_trackerGeom->detsTEC()) {
528  DetId detid = it->geographicalId();
529  unsigned int order = m_trackerTopology->tecOrder(detid);
530  unsigned int ring = m_trackerTopology->tecRing(detid);
531  unsigned int module = m_trackerTopology->tecModule(detid);
532 
534 
535  TGeoVolume* child = createVolume(name, it, kSiStrip);
536 
537  TGeoVolume* holder = GetDaughter(assembly, "Order", kSiStrip, order);
538  holder = GetDaughter(holder, "Ring", kSiStrip, ring);
539  holder = GetDaughter(holder, "Module", kSiStrip, module);
540  AddLeafNode(holder, child, name.c_str(), createPlacement(it));
541  }
542 }
543 
544 //==============================================================================
545 //==============================================================================
546 //=================================== MUON =====================================
547 //==============================================================================
548 
550  TGeoVolume* tv = GetTopHolder("Muon", kMuonRPC);
551  TGeoVolume* assemblyTop = GetDaughter(tv, "DT", kMuonDT);
552 
553  //
554  // DT chambers geometry
555  //
556  {
557  TGeoVolume* assembly = GetDaughter(assemblyTop, "DTChamber", kMuonDT);
558  auto const& dtChamberGeom = m_geomRecord->slaveGeometry(DTChamberId())->dets();
559  for (auto it = dtChamberGeom.begin(), end = dtChamberGeom.end(); it != end; ++it) {
560  if (auto chamber = dynamic_cast<const DTChamber*>(*it)) {
561  DTChamberId detid = chamber->geographicalId();
562  std::stringstream s;
563  s << detid;
564  std::string name = s.str();
565 
566  TGeoVolume* child = createVolume(name, chamber, kMuonDT);
567  TGeoVolume* holder = GetDaughter(assembly, "Wheel", kMuonDT, detid.wheel());
568  holder = GetDaughter(holder, "Station", kMuonDT, detid.station());
569  holder = GetDaughter(holder, "Sector", kMuonDT, detid.sector());
570 
571  AddLeafNode(holder, child, name.c_str(), createPlacement(chamber));
572  }
573  }
574  }
575 
576  // Fill in DT super layer parameters
577  {
578  TGeoVolume* assembly = GetDaughter(assemblyTop, "DTSuperLayer", kMuonDT);
579  auto const& dtSuperLayerGeom = m_geomRecord->slaveGeometry(DTSuperLayerId())->dets();
580  for (auto it = dtSuperLayerGeom.begin(), end = dtSuperLayerGeom.end(); it != end; ++it) {
581  if (auto* superlayer = dynamic_cast<const DTSuperLayer*>(*it)) {
582  DTSuperLayerId detid(DetId(superlayer->geographicalId()));
583  std::stringstream s;
584  s << detid;
585  std::string name = s.str();
586 
587  TGeoVolume* child = createVolume(name, superlayer, kMuonDT);
588 
589  TGeoVolume* holder = GetDaughter(assembly, "Wheel", kMuonDT, detid.wheel());
590  holder = GetDaughter(holder, "Station", kMuonDT, detid.station());
591  holder = GetDaughter(holder, "Sector", kMuonDT, detid.sector());
592  holder = GetDaughter(holder, "SuperLayer", kMuonDT, detid.superlayer());
593  AddLeafNode(holder, child, name.c_str(), createPlacement(superlayer));
594  }
595  }
596  }
597  // Fill in DT layer parameters
598  {
599  TGeoVolume* assembly = GetDaughter(assemblyTop, "DTLayer", kMuonDT);
600  auto const& dtLayerGeom = m_geomRecord->slaveGeometry(DTLayerId())->dets();
601  for (auto it = dtLayerGeom.begin(), end = dtLayerGeom.end(); it != end; ++it) {
602  if (auto layer = dynamic_cast<const DTLayer*>(*it)) {
603  DTLayerId detid(DetId(layer->geographicalId()));
604 
605  std::stringstream s;
606  s << detid;
607  std::string name = s.str();
608 
609  TGeoVolume* child = createVolume(name, layer, kMuonDT);
610 
611  TGeoVolume* holder = GetDaughter(assembly, "Wheel", kMuonDT, detid.wheel());
612  holder = GetDaughter(holder, "Station", kMuonDT, detid.station());
613  holder = GetDaughter(holder, "Sector", kMuonDT, detid.sector());
614  holder = GetDaughter(holder, "SuperLayer", kMuonDT, detid.superlayer());
615  holder = GetDaughter(holder, "Layer", kMuonDT, detid.layer());
616  AddLeafNode(holder, child, name.c_str(), createPlacement(layer));
617  }
618  }
619  }
620 }
621 //______________________________________________________________________________
622 
625  throw cms::Exception("FatalError") << "Cannnot find CSCGeometry\n";
626 
627  TGeoVolume* tv = GetTopHolder("Muon", kMuonRPC);
628  TGeoVolume* assembly = GetDaughter(tv, "CSC", kMuonCSC);
629 
630  auto const& cscGeom = m_geomRecord->slaveGeometry(CSCDetId())->dets();
631  for (auto it = cscGeom.begin(), itEnd = cscGeom.end(); it != itEnd; ++it) {
632  unsigned int rawid = (*it)->geographicalId();
633  CSCDetId detId(rawid);
634  std::stringstream s;
635  s << "CSC" << detId;
636  std::string name = s.str();
637 
638  TGeoVolume* child = nullptr;
639 
640  if (auto chamber = dynamic_cast<const CSCChamber*>(*it))
641  child = createVolume(name, chamber, kMuonCSC);
642  else if (auto* layer = dynamic_cast<const CSCLayer*>(*it))
643  child = createVolume(name, layer, kMuonCSC);
644 
645  if (child) {
646  TGeoVolume* holder = GetDaughter(assembly, "Endcap", kMuonCSC, detId.endcap());
647  holder = GetDaughter(holder, "Station", kMuonCSC, detId.station());
648  holder = GetDaughter(holder, "Ring", kMuonCSC, detId.ring());
649  holder = GetDaughter(holder, "Chamber", kMuonCSC, detId.chamber());
650 
651  // holder->AddNode(child, 1, createPlacement( *it ));
652  AddLeafNode(holder, child, name.c_str(), createPlacement(*it));
653  }
654  }
655 }
656 
657 //______________________________________________________________________________
658 
660  try {
662  const GEMGeometry* gemGeom = (const GEMGeometry*)m_geomRecord->slaveGeometry(detId);
663 
664  TGeoVolume* tv = GetTopHolder("Muon", kMuonRPC);
665  TGeoVolume* assemblyTop = GetDaughter(tv, "GEM", kMuonGEM);
666 
667  {
668  TGeoVolume* assembly = GetDaughter(assemblyTop, "GEMSuperChambers", kMuonGEM);
669  for (auto it = gemGeom->superChambers().begin(), end = gemGeom->superChambers().end(); it != end; ++it) {
670  const GEMSuperChamber* sc = (*it);
671  if (sc) {
672  GEMDetId detid = sc->geographicalId();
673  std::stringstream s;
674  s << detid;
675  std::string name = s.str();
676 
677  TGeoVolume* child = createVolume(name, sc, kMuonGEM);
678 
679  TGeoVolume* holder = GetDaughter(assembly, "SuperChamber Region", kMuonGEM, detid.region());
680  holder = GetDaughter(holder, "Ring", kMuonGEM, detid.ring());
681  holder = GetDaughter(holder, "Station", kMuonGEM, detid.station());
682  holder = GetDaughter(holder, "Chamber", kMuonGEM, detid.chamber());
683 
684  AddLeafNode(holder, child, name.c_str(), createPlacement(*it));
685  }
686  }
687  }
688 
689  {
690  TGeoVolume* assembly = GetDaughter(assemblyTop, "GEMetaPartitions", kMuonGEM);
691  for (auto it = gemGeom->etaPartitions().begin(), end = gemGeom->etaPartitions().end(); it != end; ++it) {
692  const GEMEtaPartition* roll = (*it);
693  if (roll) {
694  GEMDetId detid = roll->geographicalId();
695  std::stringstream s;
696  s << detid;
697  std::string name = s.str();
698 
699  TGeoVolume* child = createVolume(name, roll, kMuonGEM);
700 
701  TGeoVolume* holder = GetDaughter(assembly, "ROLL Region", kMuonGEM, detid.region());
702  holder = GetDaughter(holder, "Ring", kMuonGEM, detid.ring());
703  holder = GetDaughter(holder, "Station", kMuonGEM, detid.station());
704  holder = GetDaughter(holder, "Layer", kMuonGEM, detid.layer());
705  holder = GetDaughter(holder, "Chamber", kMuonGEM, detid.chamber());
706 
707  AddLeafNode(holder, child, name.c_str(), createPlacement(*it));
708  }
709  }
710  }
711  } catch (cms::Exception& exception) {
712  edm::LogInfo("FWRecoGeometry") << "failed to produce GEM geometry " << exception.what() << std::endl;
713  }
714 }
715 
716 //______________________________________________________________________________
717 
719  TGeoVolume* tv = GetTopHolder("Muon", kMuonRPC);
720  TGeoVolume* assembly = GetDaughter(tv, "RPC", kMuonRPC);
721 
723  const RPCGeometry* rpcGeom = (const RPCGeometry*)m_geomRecord->slaveGeometry(detId);
724  for (auto it = rpcGeom->rolls().begin(), end = rpcGeom->rolls().end(); it != end; ++it) {
725  RPCRoll const* roll = (*it);
726  if (roll) {
727  RPCDetId detid = roll->geographicalId();
728  std::stringstream s;
729  s << detid;
730  std::string name = s.str();
731 
732  TGeoVolume* child = createVolume(name, roll, kMuonRPC);
733 
734  TGeoVolume* holder = GetDaughter(assembly, "ROLL Region", kMuonRPC, detid.region());
735  holder = GetDaughter(holder, "Ring", kMuonRPC, detid.ring());
736  holder = GetDaughter(holder, "Station", kMuonRPC, detid.station());
737  holder = GetDaughter(holder, "Sector", kMuonRPC, detid.sector());
738  holder = GetDaughter(holder, "Layer", kMuonRPC, detid.layer());
739  holder = GetDaughter(holder, "Subsector", kMuonRPC, detid.subsector());
740 
741  AddLeafNode(holder, child, name.c_str(), createPlacement(*it));
742  }
743  };
744 }
745 
747  TGeoVolume* tv = GetTopHolder("Muon", kMuonME0);
748  TGeoVolume* assembly = GetDaughter(tv, "ME0", kMuonME0);
749 
750  DetId detId(DetId::Muon, 5);
751  try {
752  const ME0Geometry* me0Geom = (const ME0Geometry*)m_geomRecord->slaveGeometry(detId);
753 
754  for (auto roll : me0Geom->etaPartitions()) {
755  if (roll) {
756  unsigned int rawid = roll->geographicalId().rawId();
757  //std::cout << "AMT FWTTTTRecoGeometryES\n" << rawid ;
758 
759  ME0DetId detid(rawid);
760  std::stringstream s;
761  s << detid;
762  std::string name = s.str();
763  TGeoVolume* child = createVolume(name, roll, kMuonME0);
764 
765  TGeoVolume* holder = GetDaughter(assembly, "Region", kMuonME0, detid.region());
766  holder = GetDaughter(holder, "Layer", kMuonME0, detid.layer());
767  holder = GetDaughter(holder, "Chamber", kMuonME0, detid.chamber());
768  AddLeafNode(holder, child, name.c_str(), createPlacement(roll));
769  }
770  }
771  } catch (cms::Exception& exception) {
772  edm::LogInfo("FWRecoGeometry") << "failed to produce ME0 geometry " << exception.what() << std::endl;
773  }
774 }
775 
776 //==============================================================================
777 //================================= CALO =======================================
778 //==============================================================================
779 
781  TGeoVolume* tv = GetTopHolder("HCal", kHCal);
782  TGeoVolume* assembly = GetDaughter(tv, "HCalBarrel", kHCal);
783 
785 
786  CaloVolMap caloShapeMapP;
787  CaloVolMap caloShapeMapN;
788  for (std::vector<DetId>::const_iterator it = vid.begin(), end = vid.end(); it != end; ++it) {
789  //HcalDetId detid = HcalDetId(it->rawId());
790  HcalDetId detid(*it);
791  const CaloCellGeometry* cellb = (m_caloGeom->getGeometry(*it)).get();
792  const IdealObliquePrism* cell = dynamic_cast<const IdealObliquePrism*>(cellb);
793 
794  if (!cell) {
795  printf("HB not oblique !!!\n");
796  continue;
797  }
798 
799  TGeoVolume* volume = nullptr;
800  CaloVolMap& caloShapeMap = (cell->etaPos() > 0) ? caloShapeMapP : caloShapeMapN;
801  CaloVolMap::iterator volIt = caloShapeMap.find(cell->param());
802  if (volIt == caloShapeMap.end()) {
803  // printf("FIREWORKS NEW SHAPE BEGIN eta = %f etaPos = %f, phiPos %f >>>>>> \n", cell->eta(), cell->etaPos(), cell->phiPos());
806  IdealObliquePrism::localCorners(lc, cell->param(), ref);
807  HepGeom::Vector3D<float> lCenter;
808  for (int c = 0; c < 8; ++c)
809  lCenter += lc[c];
810  lCenter *= 0.125;
811 
812  static const int arr[] = {1, 0, 3, 2, 5, 4, 7, 6};
813  double points[16];
814  for (int c = 0; c < 8; ++c) {
815  if (cell->etaPos() > 0)
816  points[c * 2 + 0] = -(lc[arr[c]].z() - lCenter.z());
817  else
818  points[c * 2 + 0] = (lc[arr[c]].z() - lCenter.z());
819  points[c * 2 + 1] = (lc[arr[c]].y() - lCenter.y());
820  // printf("AMT xy[%d] <=>[%d] = (%.4f, %.4f) \n", arr[c], c, points[c*2], points[c*2+1]);
821  }
822 
823  float dz = (lc[4].x() - lc[0].x()) * 0.5;
824  TGeoShape* solid = new TGeoArb8(dz, &points[0]);
825  volume = new TGeoVolume("hcal oblique prism", solid, GetMedium(kHCal));
826  caloShapeMap[cell->param()] = volume;
827  } else {
828  volume = volIt->second;
829  }
830 
831  HepGeom::Vector3D<float> gCenter;
832  CaloCellGeometry::CornersVec const& gc = cell->getCorners();
833  for (int c = 0; c < 8; ++c)
834  gCenter += HepGeom::Vector3D<float>(gc[c].x(), gc[c].y(), gc[c].z());
835  gCenter *= 0.125;
836 
837  TGeoTranslation gtr(gCenter.x(), gCenter.y(), gCenter.z());
838  TGeoRotation rot;
839  rot.RotateY(90);
840 
841  TGeoRotation rotPhi;
842  rotPhi.SetAngles(0, -cell->phiPos() * TMath::RadToDeg(), 0);
843  rot.MultiplyBy(&rotPhi);
844 
845  TGeoVolume* holder = GetDaughter(assembly, "side", kHCal, detid.zside());
846  holder = GetDaughter(holder, "ieta", kHCal, detid.ieta());
847  std::stringstream nname;
848  nname << detid;
849  AddLeafNode(holder, volume, nname.str().c_str(), new TGeoCombiTrans(gtr, rot));
850  }
851 
852  // printf("HB map size P = %lu , N = %lu", caloShapeMapP.size(),caloShapeMapN.size() );
853 }
854 //______________________________________________________________________________
855 
857  CaloVolMap caloShapeMapP;
858  CaloVolMap caloShapeMapN;
859 
860  TGeoVolume* tv = GetTopHolder("HCal", kHCal);
861  TGeoVolume* assembly = GetDaughter(tv, "HCalEndcap", kHCal);
862 
864 
865  for (std::vector<DetId>::const_iterator it = vid.begin(), end = vid.end(); it != end; ++it) {
866  HcalDetId detid = HcalDetId(it->rawId());
867  const CaloCellGeometry* cellb = (m_caloGeom->getGeometry(*it)).get();
868  const IdealObliquePrism* cell = dynamic_cast<const IdealObliquePrism*>(cellb);
869 
870  if (!cell) {
871  printf("EC not oblique \n");
872  continue;
873  }
874 
875  TGeoVolume* volume = nullptr;
876  CaloVolMap& caloShapeMap = (cell->etaPos() > 0) ? caloShapeMapP : caloShapeMapN;
877  CaloVolMap::iterator volIt = caloShapeMap.find(cell->param());
878  if (volIt == caloShapeMap.end()) {
881  IdealObliquePrism::localCorners(lc, cell->param(), ref);
882  HepGeom::Vector3D<float> lCenter;
883  for (int c = 0; c < 8; ++c)
884  lCenter += lc[c];
885  lCenter *= 0.125;
886 
887  //for( int c = 0; c < 8; ++c)
888  // printf("lc.push_back(TEveVector(%.4f, %.4f, %.4f));\n", lc[c].x(), lc[c].y(), lc[c].z() );
889 
890  static const int arrP[] = {3, 2, 1, 0, 7, 6, 5, 4};
891  static const int arrN[] = {7, 6, 5, 4, 3, 2, 1, 0};
892  const int* arr = (detid.ieta() > 0) ? &arrP[0] : &arrN[0];
893 
894  double points[16];
895  for (int c = 0; c < 8; ++c) {
896  points[c * 2 + 0] = lc[arr[c]].x() - lCenter.x();
897  points[c * 2 + 1] = lc[arr[c]].y() - lCenter.y();
898  }
899 
900  float dz = (lc[4].z() - lc[0].z()) * 0.5;
901  TGeoShape* solid = new TGeoArb8(dz, &points[0]);
902  volume = new TGeoVolume("ecal oblique prism", solid, GetMedium(kHCal));
903  caloShapeMap[cell->param()] = volume;
904  } else {
905  volume = volIt->second;
906  }
907 
908  HepGeom::Vector3D<float> gCenter;
909  CaloCellGeometry::CornersVec const& gc = cell->getCorners();
910  for (int c = 0; c < 8; ++c) {
911  gCenter += HepGeom::Vector3D<float>(gc[c].x(), gc[c].y(), gc[c].z());
912  // printf("gc.push_back(TEveVector(%.4f, %.4f, %.4f));\n", gc[c].x(), gc[c].y(),gc[c].z() );
913  }
914  gCenter *= 0.125;
915 
916  TGeoTranslation gtr(gCenter.x(), gCenter.y(), gCenter.z());
917  TGeoRotation rot;
918  rot.SetAngles(cell->phiPos() * TMath::RadToDeg(), 0, 0);
919 
920  TGeoVolume* holder = GetDaughter(assembly, "side", kHCal, detid.zside());
921  holder = GetDaughter(holder, "ieta", kHCal, detid.ieta());
922  std::stringstream nname;
923  nname << detid;
924  AddLeafNode(holder, volume, nname.str().c_str(), new TGeoCombiTrans(gtr, rot));
925  }
926 
927  // printf("HE map size P = %lu , N = %lu", caloShapeMapP.size(),caloShapeMapN.size() );
928 }
929 
931  CaloVolMap caloShapeMapP;
932  CaloVolMap caloShapeMapN;
933 
934  TGeoVolume* tv = GetTopHolder("HCal", kHCal);
935  TGeoVolume* assembly = GetDaughter(tv, "HCalOuter", kHCal);
936 
938 
939  for (std::vector<DetId>::const_iterator it = vid.begin(), end = vid.end(); it != end; ++it) {
940  HcalDetId detid = HcalDetId(it->rawId());
941  const CaloCellGeometry* cellb = (m_caloGeom->getGeometry(*it)).get();
942  const IdealObliquePrism* cell = dynamic_cast<const IdealObliquePrism*>(cellb);
943 
944  if (!cell) {
945  printf("EC not oblique \n");
946  continue;
947  }
948 
949  TGeoVolume* volume = nullptr;
950  CaloVolMap& caloShapeMap = (cell->etaPos() > 0) ? caloShapeMapP : caloShapeMapN;
951  CaloVolMap::iterator volIt = caloShapeMap.find(cell->param());
952  if (volIt == caloShapeMap.end()) {
955  IdealObliquePrism::localCorners(lc, cell->param(), ref);
956  HepGeom::Vector3D<float> lCenter;
957  for (int c = 0; c < 8; ++c)
958  lCenter += lc[c];
959  lCenter *= 0.125;
960  static const int arrP[] = {3, 2, 1, 0, 7, 6, 5, 4};
961  static const int arrN[] = {7, 6, 5, 4, 3, 2, 1, 0};
962  const int* arr = (detid.ieta() > 0) ? &arrP[0] : &arrN[0];
963 
964  double points[16];
965  for (int c = 0; c < 8; ++c) {
966  points[c * 2 + 0] = lc[arr[c]].x() - lCenter.x();
967  points[c * 2 + 1] = lc[arr[c]].y() - lCenter.y();
968  }
969 
970  float dz = (lc[4].z() - lc[0].z()) * 0.5;
971  TGeoShape* solid = new TGeoArb8(dz, &points[0]);
972  volume = new TGeoVolume("ecal oblique prism", solid, GetMedium(kHCal));
973  caloShapeMap[cell->param()] = volume;
974  } else {
975  volume = volIt->second;
976  }
977  HepGeom::Vector3D<float> gCenter;
978  CaloCellGeometry::CornersVec const& gc = cell->getCorners();
979  for (int c = 0; c < 8; ++c) {
980  gCenter += HepGeom::Vector3D<float>(gc[c].x(), gc[c].y(), gc[c].z());
981  }
982  gCenter *= 0.125;
983 
984  TGeoTranslation gtr(gCenter.x(), gCenter.y(), gCenter.z());
985  TGeoRotation rot;
986  rot.SetAngles(cell->phiPos() * TMath::RadToDeg(), 0, 0);
987 
988  TGeoVolume* holder = GetDaughter(assembly, "side", kHCal, detid.zside());
989  holder = GetDaughter(holder, "ieta", kHCal, detid.ieta());
990  std::stringstream nname;
991  nname << detid;
992  AddLeafNode(holder, volume, nname.str().c_str(), new TGeoCombiTrans(gtr, rot));
993  }
994 }
995 
997  CaloVolMap caloShapeMapP;
998  CaloVolMap caloShapeMapN;
999 
1000  TGeoVolume* tv = GetTopHolder("HCal", kHCal);
1001  TGeoVolume* assembly = GetDaughter(tv, "HCalForward", kHCal);
1002 
1004 
1005  for (std::vector<DetId>::const_iterator it = vid.begin(), end = vid.end(); it != end; ++it) {
1006  HcalDetId detid = HcalDetId(it->rawId());
1007  const CaloCellGeometry* cellb = (m_caloGeom->getGeometry(*it)).get();
1008  const IdealZPrism* cell = dynamic_cast<const IdealZPrism*>(cellb);
1009 
1010  if (!cell) {
1011  printf("EC not Z prism \n");
1012  continue;
1013  }
1014 
1015  TGeoVolume* volume = nullptr;
1016  CaloVolMap& caloShapeMap = (cell->etaPos() > 0) ? caloShapeMapP : caloShapeMapN;
1017  CaloVolMap::iterator volIt = caloShapeMap.find(cell->param());
1018  if (volIt == caloShapeMap.end()) {
1019  IdealZPrism::Pt3DVec lc(8);
1020  IdealZPrism::Pt3D ref;
1021  IdealZPrism::localCorners(lc, cell->param(), ref);
1022  HepGeom::Vector3D<float> lCenter;
1023  for (int c = 0; c < 8; ++c)
1024  lCenter += lc[c];
1025  lCenter *= 0.125;
1026  static const int arrP[] = {3, 2, 1, 0, 7, 6, 5, 4};
1027  static const int arrN[] = {7, 6, 5, 4, 3, 2, 1, 0};
1028  const int* arr = (detid.ieta() > 0) ? &arrP[0] : &arrN[0];
1029 
1030  double points[16];
1031  for (int c = 0; c < 8; ++c) {
1032  points[c * 2 + 0] = lc[arr[c]].x() - lCenter.x();
1033  points[c * 2 + 1] = lc[arr[c]].y() - lCenter.y();
1034  }
1035 
1036  float dz = (lc[4].z() - lc[0].z()) * 0.5;
1037  TGeoShape* solid = new TGeoArb8(dz, &points[0]);
1038  volume = new TGeoVolume("ecal oblique prism", solid, GetMedium(kHCal));
1039  caloShapeMap[cell->param()] = volume;
1040  } else {
1041  volume = volIt->second;
1042  }
1043  HepGeom::Vector3D<float> gCenter;
1044  CaloCellGeometry::CornersVec const& gc = cell->getCorners();
1045  for (int c = 0; c < 8; ++c) {
1046  gCenter += HepGeom::Vector3D<float>(gc[c].x(), gc[c].y(), gc[c].z());
1047  }
1048  gCenter *= 0.125;
1049 
1050  TGeoTranslation gtr(gCenter.x(), gCenter.y(), gCenter.z());
1051  TGeoRotation rot;
1052  rot.SetAngles(cell->phiPos() * TMath::RadToDeg(), 0, 0);
1053 
1054  TGeoVolume* holder = GetDaughter(assembly, "side", kHCal, detid.zside());
1055  holder = GetDaughter(holder, "ieta", kHCal, detid.ieta());
1056  std::stringstream nname;
1057  nname << detid;
1058  AddLeafNode(holder, volume, nname.str().c_str(), new TGeoCombiTrans(gtr, rot));
1059  }
1060 }
1061 
1063  CaloVolMap caloShapeMapP;
1064  CaloVolMap caloShapeMapN;
1065 
1066  TGeoVolume* tv = GetTopHolder("CaloTower", kCaloTower);
1067  TGeoVolume* assembly = GetDaughter(tv, "CaloTower", kCaloTower);
1068 
1070  for (std::vector<DetId>::const_iterator it = vid.begin(), end = vid.end(); it != end; ++it) {
1071  CaloTowerDetId detid = CaloTowerDetId(it->rawId());
1072  const CaloCellGeometry* cellb = (m_caloGeom->getGeometry(*it)).get();
1073  const IdealObliquePrism* cell = dynamic_cast<const IdealObliquePrism*>(cellb);
1074  if (!cell) {
1075  printf("EC not oblique \n");
1076  continue;
1077  }
1078  TGeoVolume* volume = nullptr;
1079  CaloVolMap& caloShapeMap = (cell->etaPos() > 0) ? caloShapeMapP : caloShapeMapN;
1080  CaloVolMap::iterator volIt = caloShapeMap.find(cell->param());
1081  if (volIt == caloShapeMap.end()) {
1084  IdealObliquePrism::localCorners(lc, cell->param(), ref);
1085  HepGeom::Vector3D<float> lCenter;
1086  for (int c = 0; c < 8; ++c)
1087  lCenter += lc[c];
1088  lCenter *= 0.125;
1089 
1090  static const int arrP[] = {3, 2, 1, 0, 7, 6, 5, 4};
1091  static const int arrN[] = {7, 6, 5, 4, 3, 2, 1, 0};
1092  const int* arr = (detid.ieta() > 0) ? &arrP[0] : &arrN[0];
1093 
1094  double points[16];
1095  for (int c = 0; c < 8; ++c) {
1096  points[c * 2 + 0] = lc[arr[c]].x() - lCenter.x();
1097  points[c * 2 + 1] = lc[arr[c]].y() - lCenter.y();
1098  }
1099 
1100  float dz = (lc[4].z() - lc[0].z()) * 0.5;
1101  TGeoShape* solid = new TGeoArb8(dz, &points[0]);
1102  volume = new TGeoVolume("ecal oblique prism", solid, GetMedium(kCaloTower));
1103  caloShapeMap[cell->param()] = volume;
1104  } else {
1105  volume = volIt->second;
1106  }
1107 
1108  HepGeom::Vector3D<float> gCenter;
1109  CaloCellGeometry::CornersVec const& gc = cell->getCorners();
1110  for (int c = 0; c < 8; ++c) {
1111  gCenter += HepGeom::Vector3D<float>(gc[c].x(), gc[c].y(), gc[c].z());
1112  }
1113  gCenter *= 0.125;
1114 
1115  TGeoTranslation gtr(gCenter.x(), gCenter.y(), gCenter.z());
1116  TGeoRotation rot;
1117  rot.SetAngles(cell->phiPos() * TMath::RadToDeg(), 0, 0);
1118 
1119  TGeoVolume* holder = GetDaughter(assembly, "side", kCaloTower, detid.zside());
1120  holder = GetDaughter(holder, "ieta", kCaloTower, detid.ieta());
1121  std::stringstream nname;
1122  nname << detid;
1123  AddLeafNode(holder, volume, nname.str().c_str(), new TGeoCombiTrans(gtr, rot));
1124  }
1125 }
1126 
1127 //______________________________________________________________________________
1128 
1130  TEveVector gCenter;
1131  for (int i = 0; i < 8; ++i)
1132  gCenter += TEveVector(gc[i].x(), gc[i].y(), gc[i].z());
1133  gCenter *= 0.125;
1134 
1135  TEveVector tgCenter; // top center 4 corners
1136  for (int i = 4; i < 8; ++i)
1137  tgCenter += TEveVector(gc[i].x(), gc[i].y(), gc[i].z());
1138  tgCenter *= 0.25;
1139 
1140  TEveVector axis = tgCenter - gCenter;
1141  axis.Normalize();
1142 
1143  TEveTrans tr;
1144  TVector3 v1t;
1145  tr.GetBaseVec(1, v1t);
1146 
1147  TEveVector v1(v1t.x(), v1t.y(), v1t.z());
1148  double dot13 = axis.Dot(v1);
1149  TEveVector gd = axis;
1150  gd *= dot13;
1151  v1 -= gd;
1152  v1.Normalize();
1153  TEveVector v2;
1154  TMath::Cross(v1.Arr(), axis.Arr(), v2.Arr());
1155  TMath::Cross(axis.Arr(), v1.Arr(), v2.Arr());
1156  v2.Normalize();
1157 
1158  tr.SetBaseVec(1, v1.fX, v1.fY, v1.fZ);
1159  tr.SetBaseVec(2, v2.fX, v2.fY, v2.fZ);
1160  tr.SetBaseVec(3, axis.fX, axis.fY, axis.fZ);
1161  tr.Move3PF(gCenter.fX, gCenter.fY, gCenter.fZ);
1162 
1163  TGeoHMatrix* out = new TGeoHMatrix();
1164  tr.SetGeoHMatrix(*out);
1165  return out;
1166 }
1167 
1168 TGeoShape* makeEcalShape(const TruncatedPyramid* cell) {
1169  // printf("BEGIN EE SHAPE --------------------------------\n");
1170  // std::cout << detid << std::endl;
1171  const HepGeom::Transform3D idtr;
1174  TruncatedPyramid::localCorners(co, cell->param(), ref);
1175  //for( int c = 0; c < 8; ++c)
1176  // printf("lc.push_back(TEveVector(%.4f, %.4f, %.4f));\n", co[c].x(),co[c].y(),co[c].z() );
1177 
1178  double points[16];
1179  for (int c = 0; c < 8; ++c) {
1180  points[c * 2] = co[c].x();
1181  points[c * 2 + 1] = co[c].y();
1182  }
1183  TGeoShape* solid = new TGeoArb8(cell->param()[0], points);
1184  return solid;
1185 }
1186 
1187 //______________________________________________________________________________
1188 
1190  TGeoVolume* tv = GetTopHolder("ECal", kECal);
1191  CaloVolMap caloShapeMap;
1192 
1193  {
1194  TGeoVolume* assembly = GetDaughter(tv, "ECalBarrel", kECal);
1195 
1197  for (std::vector<DetId>::const_iterator it = vid.begin(), end = vid.end(); it != end; ++it) {
1198  EBDetId detid(*it);
1199  const CaloCellGeometry* cellb = (m_caloGeom->getGeometry(*it)).get();
1200  const TruncatedPyramid* cell = dynamic_cast<const TruncatedPyramid*>(cellb);
1201  if (!cell) {
1202  printf("ecalBarrel cell not a TruncatedPyramid !!\n");
1203  return;
1204  }
1205 
1206  TGeoVolume* volume = nullptr;
1207  CaloVolMap::iterator volIt = caloShapeMap.find(cell->param());
1208  if (volIt == caloShapeMap.end()) {
1209  volume = new TGeoVolume("EE TruncatedPyramid", makeEcalShape(cell), GetMedium(kECal));
1210  caloShapeMap[cell->param()] = volume;
1211  } else {
1212  volume = volIt->second;
1213  }
1214  TGeoHMatrix* mtx = getEcalTrans(cell->getCorners());
1215  TGeoVolume* holder = GetDaughter(assembly, "side", kECal, detid.zside());
1216  holder = GetDaughter(holder, "ieta", kECal, detid.ieta());
1217  std::stringstream nname;
1218  nname << detid;
1219  AddLeafNode(holder, volume, nname.str().c_str(), mtx);
1220  }
1221  }
1222 
1223  {
1224  TGeoVolume* assembly = GetDaughter(tv, "ECalEndcap", kECal);
1225 
1227  for (std::vector<DetId>::const_iterator it = vid.begin(), end = vid.end(); it != end; ++it) {
1228  EEDetId detid(*it);
1229  const CaloCellGeometry* cellb = (m_caloGeom->getGeometry(*it)).get();
1230  const TruncatedPyramid* cell = dynamic_cast<const TruncatedPyramid*>(cellb);
1231  if (!cell) {
1232  printf("ecalEndcap cell not a TruncatedPyramid !!\n");
1233  continue;
1234  }
1235 
1236  TGeoVolume* volume = nullptr;
1237  CaloVolMap::iterator volIt = caloShapeMap.find(cell->param());
1238  if (volIt == caloShapeMap.end()) {
1239  volume = new TGeoVolume("EE TruncatedPyramid", makeEcalShape(cell), GetMedium(kECal));
1240  caloShapeMap[cell->param()] = volume;
1241  } else {
1242  volume = volIt->second;
1243  }
1244  TGeoHMatrix* mtx = getEcalTrans(cell->getCorners());
1245  TGeoVolume* holder = GetDaughter(assembly, "side", kECal, detid.zside());
1246  holder = GetDaughter(holder, "ix", kECal, detid.ix());
1247  std::stringstream nname;
1248  nname << detid;
1249  AddLeafNode(holder, volume, nname.str().c_str(), mtx);
1250  }
1251  }
1252 }
T xx() const
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:138
T getUntrackedParameter(std::string const &, T const &) const
virtual float length() const =0
static constexpr int GEM
Definition: MuonSubdetId.h:14
int ix() const
Definition: EEDetId.h:77
unsigned int tidRing(const DetId &id) const
virtual const std::array< const float, 4 > parameters() const
JetCorrectorParameters::Record record
Definition: classes.h:7
edm::ESHandle< GlobalTrackingGeometry > m_geomRecord
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalDetId.h:141
TGeoShape * createShape(const GeomDet *det)
unsigned int pxfDisk(const DetId &id) const
float phiPos() const
const std::vector< const RPCRoll * > & rolls() const
Return a vector of all RPC rolls.
Definition: RPCGeometry.cc:44
unsigned int tecRing(const DetId &id) const
ring id
CaloCellGeometry::Pt3D Pt3D
#define nullptr
unsigned int pxbLadder(const DetId &id) const
unsigned int side(const DetId &id) const
T y() const
Definition: PV3DBase.h:60
T yx() const
const Bounds & bounds() const
Definition: Surface.h:89
unsigned int tidWheel(const DetId &id) const
unsigned int pxbModule(const DetId &id) const
char const * what() const override
Definition: Exception.cc:103
TGeoCombiTrans * createPlacement(const Rotation3D &iRot, const Position &iTrans)
std::string print(DetId detid) const
std::map< TGeoShape *, TGeoVolume * > m_shapeToVolume
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
Definition: Electron.h:6
T zx() const
virtual float width() const =0
T xy() const
unsigned int tibSide(const DetId &id) const
T zz() const
const CCGFloat * param() const
unsigned int tidSide(const DetId &id) const
CaloCellGeometry::Pt3D Pt3D
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
const DetContainer & detsTEC() const
TGeoHMatrix * getEcalTrans(CaloCellGeometry::CornersVec const &gc)
static const int SubdetId
std::map< std::string, TGeoShape * > m_nameToShape
T z() const
Definition: PV3DBase.h:61
CaloCellGeometry::Pt3DVec Pt3DVec
unsigned int tobSide(const DetId &id) const
int ieta() const
get the cell ieta
Definition: HcalDetId.h:155
const DetContainer & detsPXB() const
int zside() const
Definition: EEDetId.h:71
T zy() const
const std::vector< const GEMEtaPartition * > & etaPartitions() const
Return a vector of all GEM eta partitions.
Definition: GEMGeometry.cc:40
const TrackingGeometry * slaveGeometry(DetId id) const
Return the pointer to the actual geometry for a given DetId.
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
#define end
Definition: vmac.h:39
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
T yy() const
std::map< ERecoDet, TGeoMedium * > m_recoMedium
virtual const DetContainer & dets() const =0
Returm a vector of all GeomDet (including all GeomDetUnits)
unsigned int tibModule(const DetId &id) const
const DetContainer & detsTIB() const
TGeoShape * makeEcalShape(const TruncatedPyramid *cell)
TGeoVolume * GetDaughter(TGeoVolume *mother, const char *prefix, ERecoDet cidx, int id)
unsigned int pxbLayer(const DetId &id) const
unsigned int tecModule(const DetId &id) const
const std::vector< const GEMSuperChamber * > & superChambers() const
Return a vector of all GEM super chambers.
Definition: GEMGeometry.cc:36
std::unique_ptr< FWTGeoRecoGeometry > produce(const FWTGeoRecoGeometryRecord &)
const std::vector< ME0EtaPartition const * > & etaPartitions() const
Return a vector of all ME0 eta partitions.
Definition: ME0Geometry.cc:33
Definition: DetId.h:17
virtual float thickness() const =0
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
Definition: IdealZPrism.cc:72
static constexpr int RPC
Definition: MuonSubdetId.h:13
int zside() const
get the z-side of the tower (1/-1)
double b
Definition: hdecay.h:118
CaloCellGeometry::Pt3D Pt3D
Definition: IdealZPrism.h:31
unsigned int tecOrder(const DetId &id) const
unsigned int tobModule(const DetId &id) const
CaloCellGeometry::Pt3DVec Pt3DVec
Definition: IdealZPrism.h:32
CornersVec const & getCorners() const
Returns the corner points of this cell&#39;s volume.
A base class to handle the particular shape of Ecal Xtals. Taken from ORCA Calorimetry Code...
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
Definition: CaloGeometry.cc:75
HLT enums.
T xz() const
FWTGeoRecoGeometryESProducer(const edm::ParameterSet &)
const DetContainer & detsPXF() const
const DetContainer & detsTOB() const
float etaPos() const
std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id.
Definition: CaloGeometry.cc:60
const RotationType & rotation() const
Definition: Bounds.h:20
TGeoVolume * GetTopHolder(const char *prefix, ERecoDet cidx)
int ieta() const
get the tower ieta
unsigned int tobRod(const DetId &id) const
T x() const
Definition: PV3DBase.h:59
const PositionType & position() const
T const * product() const
Definition: ESHandle.h:86
Definition: vlib.h:198
T yz() const
unsigned int pxfPanel(const DetId &id) const
unsigned int pxfBlade(const DetId &id) const
CaloCellGeometry::Pt3DVec Pt3DVec
TGeoVolume * createVolume(const std::string &name, const GeomDet *det, ERecoDet=kDummy)
const DetContainer & detsTID() const
int zside() const
get the z-side of the crystal (1/-1)
Definition: EBDetId.h:45
unsigned int tibOrder(const DetId &id) const