CMS 3D CMS Logo

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