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