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 )
273  record.getRecord<CaloGeometryRecord>().get( m_caloGeom );
274 
275  TGeoManager* geom = new TGeoManager( "cmsGeo", "CMS Detector" );
276  if( nullptr == gGeoIdentity )
277  {
278  gGeoIdentity = new TGeoIdentity( "Identity" );
279  }
280 
281  m_fwGeometry->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  {
291  return std::shared_ptr<FWTGeoRecoGeometry>();
292  }
293  geom->SetTopVolume( top );
294  // ROOT chokes unless colors are assigned
295  top->SetVisibility( kFALSE );
296  top->SetLineColor( kBlue );
297 
298  if( m_tracker || m_muon )
299  {
301  }
302 
303  if( m_tracker )
304  {
305  DetId detId( DetId::Tracker, 0 );
307 
308  edm::ESHandle<TrackerTopology> trackerTopologyHandle;
309  record.getRecord<TrackerTopologyRcd>().get( trackerTopologyHandle );
310  m_trackerTopology = trackerTopologyHandle.product();
311 
314 
315  addTIBGeometry();
316  addTIDGeometry();
317  addTOBGeometry();
318  addTECGeometry();
319  }
320 
321  if( m_muon )
322  {
323  addDTGeometry();
324  addCSCGeometry();
325  addRPCGeometry();
326  addME0Geometry();
327  addGEMGeometry();
328  }
329 
330  if( m_calo )
331  {
338  }
339 
340  geom->CloseGeometry();
341 
342  geom->DefaultColors();
343  // printf("==== geo manager NNodes = %d \n", geom->GetNNodes());
344  geom->CloseGeometry();
345 
346  return m_fwGeometry;
347 }
348 
350 TGeoShape*
352 {
353  TGeoShape* shape = nullptr;
354 
355  // Trapezoidal
356  const Bounds *b = &((det->surface ()).bounds ());
357  const TrapezoidalPlaneBounds *b2 = dynamic_cast<const TrapezoidalPlaneBounds *> (b);
358  if( b2 )
359  {
360  std::array< const float, 4 > const & par = b2->parameters ();
361 
362  // These parameters are half-lengths, as in CMSIM/GEANT3
363  float hBottomEdge = par [0];
364  float hTopEdge = par [1];
365  float thickness = par [2];
366  float apothem = par [3];
367 
368  std::stringstream s;
369  s << "T_"
370  << hBottomEdge << "_"
371  << hTopEdge << "_"
372  << thickness << "_"
373  << apothem;
374  std::string name = s.str();
375 
376  // Do not create identical shape,
377  // if one already exists
378  shape = m_nameToShape[name];
379  if( nullptr == shape )
380  {
381  shape = new TGeoTrap(
382  name.c_str(),
383  thickness, //dz
384  0, //theta
385  0, //phi
386  apothem, //dy1
387  hBottomEdge,//dx1
388  hTopEdge, //dx2
389  0, //alpha1
390  apothem, //dy2
391  hBottomEdge,//dx3
392  hTopEdge, //dx4
393  0); //alpha2
394 
395  m_nameToShape[name] = shape;
396  }
397  }
398  if( dynamic_cast<const RectangularPlaneBounds *> (b) != nullptr )
399  {
400  // Rectangular
401  float length = det->surface().bounds().length();
402  float width = det->surface().bounds ().width();
403  float thickness = det->surface().bounds().thickness();
404 
405  std::stringstream s;
406  s << "R_"
407  << width << "_"
408  << length << "_"
409  << thickness;
410  std::string name = s.str();
411 
412  // Do not create identical shape,
413  // if one already exists
414  shape = m_nameToShape[name];
415  if( nullptr == shape )
416  {
417  shape = new TGeoBBox( name.c_str(), width / 2., length / 2., thickness / 2. ); // dx, dy, dz
418 
419  m_nameToShape[name] = shape;
420  }
421  }
422 
423  return shape;
424 }
425 
427 TGeoVolume*
429 {
430  TGeoShape* solid = createShape( det );
431 
432  std::map<TGeoShape*, TGeoVolume*>::iterator vIt = m_shapeToVolume.find(solid);
433  if (vIt != m_shapeToVolume.end()) return vIt->second;
434 
435 
436  TGeoVolume* volume = new TGeoVolume( name.c_str(),solid, GetMedium(mid));
437 
438  m_shapeToVolume[solid] = volume;
439 
440  return volume;
441 }
442 
443 
444 
453 
454 void
456 {
457  TGeoVolume* tv = GetTopHolder( "SiPixel", kSiPixel );
458  TGeoVolume *assembly = GetDaughter( tv, "PXB", kSiPixel );
459 
460  for( auto it : m_trackerGeom->detsPXB()) {
461  DetId detid = it->geographicalId();
462  unsigned int layer = m_trackerTopology->pxbLayer( detid );
463  unsigned int module = m_trackerTopology->pxbModule( detid );
464  unsigned int ladder = m_trackerTopology->pxbLadder( detid );
465 
466  std::string name = Form( "PXB Ly:%d, Md:%d Ld:%d ", layer, module, ladder );
467  TGeoVolume* child = createVolume( name, it, kSiPixel );
468 
469  TGeoVolume* holder = GetDaughter( assembly, "Layer", kSiPixel, layer );
470  holder = GetDaughter( holder, "Module", kSiPixel, module );
471 
472  AddLeafNode( holder, child, name.c_str(), createPlacement( it ));
473  }
474 }
475 
476 void
478 {
479  TGeoVolume* tv = GetTopHolder( "SiPixel", kSiPixel );
480  TGeoVolume* assembly = GetDaughter( tv, "PXF", kSiPixel );
481 
482  for( auto it : m_trackerGeom->detsPXF()) {
483  DetId detid = it->geographicalId();
484  unsigned int disk = m_trackerTopology->pxfDisk( detid );
485  unsigned int blade = m_trackerTopology->pxfBlade( detid );
486  unsigned int panel = m_trackerTopology->pxfPanel( detid );
487  unsigned int side = m_trackerTopology->side( detid );
488 
489  std::string name = Form( "PXF D:%d, B:%d, P:%d, S:%d", disk, blade, panel, side );
490  TGeoVolume* child = createVolume( name, it, kSiPixel );
491 
492  TGeoVolume* holder = GetDaughter( assembly, "Side", kSiPixel, side );
493  holder = GetDaughter( holder, "Disk", kSiPixel, disk );
494  holder = GetDaughter( holder, "Blade", kSiPixel, blade );
495  holder = GetDaughter( holder, "Panel", kSiPixel, panel );
496 
497  AddLeafNode( holder, child, name.c_str(), createPlacement( it ));
498  }
499 }
500 
501 void
503 {
504  TGeoVolume* tv = GetTopHolder( "SiStrip", kSiStrip );
505  TGeoVolume *assembly = GetDaughter( tv, "TIB", kSiStrip );
506 
507  for( auto it : m_trackerGeom->detsTIB()) {
508  DetId detid = it->geographicalId();
509  unsigned int module = m_trackerTopology->tibModule( detid );
510  unsigned int order = m_trackerTopology->tibOrder( detid );
511  unsigned int side = m_trackerTopology->tibSide( detid );
512 
513  std::stringstream s;
514  s << TIBDetId( detid );
515  std::string name = s.str();
516 
517  TGeoVolume* child = createVolume( name, it, kSiStrip );
518  TGeoVolume* holder = GetDaughter( assembly, "Module", kSiStrip, module );
519  holder = GetDaughter( holder, "Order", kSiStrip, order );
520  holder = GetDaughter( holder, "Side", kSiStrip, side );
521  AddLeafNode( holder, child, name.c_str(), createPlacement( it ));
522  }
523 }
524 
525 void
527 {
528  TGeoVolume* tv = GetTopHolder( "SiStrip", kSiStrip );
529  TGeoVolume* assembly = GetDaughter( tv, "TID", kSiStrip );
530 
531  for( auto it : m_trackerGeom->detsTID()) {
532  DetId detid = it->geographicalId();
533  unsigned int side = m_trackerTopology->tidSide( detid );
534  unsigned int wheel = m_trackerTopology->tidWheel( detid );
535  unsigned int ring = m_trackerTopology->tidRing( detid );
536 
537  std::stringstream s;
538  s << TIDDetId( detid );
539  std::string name = s.str();
540 
541  TGeoVolume* child = createVolume( name, it, kSiStrip );
542  TGeoVolume* holder = GetDaughter( assembly, "Side", kSiStrip, side );
543  holder = GetDaughter( holder, "Wheel", kSiStrip, wheel );
544  holder = GetDaughter( holder, "Ring", kSiStrip, ring );
545  AddLeafNode( holder, child, name.c_str(), createPlacement( it ));
546  }
547 }
548 
549 void
551 {
552  TGeoVolume* tv = GetTopHolder( "SiStrip", kSiStrip );
553  TGeoVolume* assembly = GetDaughter( tv, "TOB", kSiStrip );
554 
555  for( auto it : m_trackerGeom->detsTOB()) {
556  DetId detid = it->geographicalId();
557  unsigned int rod = m_trackerTopology->tobRod( detid );
558  unsigned int side = m_trackerTopology->tobSide( detid );
559  unsigned int module = m_trackerTopology->tobModule( detid );
560 
561  std::stringstream s;
562  s << TOBDetId( detid );
563  std::string name = s.str();
564 
565  TGeoVolume* child = createVolume( name, it, kSiStrip );
566  TGeoVolume* holder = GetDaughter( assembly, "Rod", kSiStrip, rod );
567  holder = GetDaughter( holder, "Side", kSiStrip, side );
568  holder = GetDaughter( holder, "Module", kSiStrip, module );
569  AddLeafNode( holder, child, name.c_str(), createPlacement( it ));
570  }
571 }
572 
573 void
575 {
576  TGeoVolume* tv = GetTopHolder( "SiStrip", kSiStrip );
577  TGeoVolume* assembly = GetDaughter( tv, "TEC", kSiStrip );
578 
579  for( auto it : m_trackerGeom->detsTEC()) {
580  DetId detid = it->geographicalId();
581  unsigned int order = m_trackerTopology->tecOrder( detid );
582  unsigned int ring = m_trackerTopology->tecRing( detid );
583  unsigned int module = m_trackerTopology->tecModule( detid );
584 
585  std::stringstream s;
586  s << TECDetId( detid );
587  std::string name = s.str();
588 
589  TGeoVolume* child = createVolume( name, it, kSiStrip );
590 
591  TGeoVolume* holder = GetDaughter( assembly, "Order", kSiStrip, order );
592  holder = GetDaughter( holder, "Ring", kSiStrip, ring );
593  holder = GetDaughter( holder, "Module", kSiStrip, module );
594  AddLeafNode( holder, child, name.c_str(), createPlacement( it ));
595  }
596 }
597 
598 //==============================================================================
599 //==============================================================================
600 //=================================== MUON =====================================
601 //==============================================================================
602 
603 
604 
605 void
607 {
608  TGeoVolume* tv = GetTopHolder("Muon", kMuonRPC);
609  TGeoVolume *assemblyTop = GetDaughter(tv, "DT", kMuonDT);
610 
611  //
612  // DT chambers geometry
613  //
614  {
615  TGeoVolume *assembly = GetDaughter(assemblyTop, "DTChamber", kMuonDT);
616  auto const & dtChamberGeom = m_geomRecord->slaveGeometry( DTChamberId())->dets();
617  for( auto it = dtChamberGeom.begin(),
618  end = dtChamberGeom.end();
619  it != end; ++it )
620  {
621  if( auto chamber = dynamic_cast< const DTChamber *>(*it))
622  {
623  DTChamberId detid = chamber->geographicalId();
624  std::stringstream s;
625  s << detid;
626  std::string name = s.str();
627 
628  TGeoVolume* child = createVolume( name, chamber, kMuonDT );
629  TGeoVolume* holder = GetDaughter(assembly, "Wheel", kMuonDT, detid.wheel());
630  holder = GetDaughter(holder, "Station", kMuonDT, detid.station());
631  holder = GetDaughter(holder, "Sector", kMuonDT, detid.sector());
632 
633  AddLeafNode(holder, child, name.c_str(), createPlacement( chamber));
634  }
635  }
636  }
637 
638  // Fill in DT super layer parameters
639  {
640  TGeoVolume *assembly = GetDaughter(assemblyTop, "DTSuperLayer", kMuonDT);
641  auto const & dtSuperLayerGeom = m_geomRecord->slaveGeometry( DTSuperLayerId())->dets();
642  for( auto it = dtSuperLayerGeom.begin(),
643  end = dtSuperLayerGeom.end();
644  it != end; ++it )
645  {
646  if( auto * superlayer = dynamic_cast<const DTSuperLayer*>(*it))
647  {
648  DTSuperLayerId detid( DetId(superlayer->geographicalId()));
649  std::stringstream s;
650  s << detid;
651  std::string name = s.str();
652 
653  TGeoVolume* child = createVolume( name, superlayer, kMuonDT );
654 
655  TGeoVolume* holder = GetDaughter(assembly, "Wheel", kMuonDT, detid.wheel());
656  holder = GetDaughter(holder, "Station", kMuonDT, detid.station());
657  holder = GetDaughter(holder, "Sector", kMuonDT, detid.sector());
658  holder = GetDaughter(holder, "SuperLayer", kMuonDT, detid.superlayer());
659  AddLeafNode(holder, child, name.c_str(), createPlacement( superlayer));
660  }
661  }
662  }
663  // Fill in DT layer parameters
664  {
665  TGeoVolume *assembly = GetDaughter(assemblyTop, "DTLayer", kMuonDT);
666  auto const & dtLayerGeom = m_geomRecord->slaveGeometry( DTLayerId())->dets();
667  for( auto it = dtLayerGeom.begin(),
668  end = dtLayerGeom.end();
669  it != end; ++it )
670  {
671  if(auto layer = dynamic_cast<const DTLayer*>(*it))
672  {
673 
674  DTLayerId detid( DetId(layer->geographicalId()));
675 
676  std::stringstream s;
677  s << detid;
678  std::string name = s.str();
679 
680  TGeoVolume* child = createVolume( name, layer, kMuonDT );
681 
682  TGeoVolume* holder = GetDaughter(assembly, "Wheel", kMuonDT, detid.wheel());
683  holder = GetDaughter(holder, "Station", kMuonDT, detid.station());
684  holder = GetDaughter(holder, "Sector", kMuonDT, detid.sector());
685  holder = GetDaughter(holder, "SuperLayer", kMuonDT, detid.superlayer());
686  holder = GetDaughter(holder, "Layer", kMuonDT, detid.layer());
687  AddLeafNode(holder, child, name.c_str(), createPlacement( layer));
688  }
689  }
690  }
691 }
692 //______________________________________________________________________________
693 
694 void
696 {
698  throw cms::Exception( "FatalError" ) << "Cannnot find CSCGeometry\n";
699 
700 
701  TGeoVolume* tv = GetTopHolder("Muon", kMuonRPC);
702  TGeoVolume *assembly = GetDaughter(tv, "CSC", kMuonCSC);
703 
704  auto const & cscGeom = m_geomRecord->slaveGeometry( CSCDetId())->dets();
705  for( auto it = cscGeom.begin(), itEnd = cscGeom.end(); it != itEnd; ++it )
706  {
707  unsigned int rawid = (*it)->geographicalId();
708  CSCDetId detId(rawid);
709  std::stringstream s;
710  s << "CSC" << detId;
711  std::string name = s.str();
712 
713  TGeoVolume* child = nullptr;
714 
715  if( auto chamber = dynamic_cast<const CSCChamber*>(*it))
716  child = createVolume( name, chamber, kMuonCSC );
717  else if( auto * layer = dynamic_cast<const CSCLayer*>(*it))
718  child = createVolume( name, layer, kMuonCSC );
719 
720 
721 
722  if (child) {
723  TGeoVolume* holder = GetDaughter(assembly, "Endcap", kMuonCSC, detId.endcap());
724  holder = GetDaughter(holder, "Station", kMuonCSC, detId.station());
725  holder = GetDaughter(holder, "Ring", kMuonCSC, detId.ring());
726  holder = GetDaughter(holder, "Chamber", kMuonCSC , detId.chamber());
727 
728  // holder->AddNode(child, 1, createPlacement( *it ));
729  AddLeafNode(holder, child, name.c_str(), createPlacement(*it));
730  }
731  }
732 
733 }
734 
735 //______________________________________________________________________________
736 
737 void
739 {
740  try {
742  const GEMGeometry* gemGeom = (const GEMGeometry*) m_geomRecord->slaveGeometry( detId );
743 
744  TGeoVolume* tv = GetTopHolder("Muon", kMuonRPC);
745  TGeoVolume *assemblyTop = GetDaughter(tv, "GEM", kMuonGEM);
746 
747  {
748  TGeoVolume *assembly = GetDaughter(assemblyTop, "GEMSuperChambers", kMuonGEM);
749  for( auto it = gemGeom->superChambers().begin(),
750  end = gemGeom->superChambers().end();
751  it != end; ++it )
752  {
753  const GEMSuperChamber* sc = (*it);
754  if( sc )
755  {
756  GEMDetId detid = sc->geographicalId();
757  std::stringstream s;
758  s << detid;
759  std::string name = s.str();
760 
761  TGeoVolume* child = createVolume( name, sc, kMuonGEM );
762 
763  TGeoVolume* holder = GetDaughter(assembly, "SuperChamber Region", kMuonGEM , detid.region());
764  holder = GetDaughter(holder, "Ring", kMuonGEM , detid.ring());
765  holder = GetDaughter(holder, "Station", kMuonGEM , detid.station());
766  holder = GetDaughter(holder, "Chamber", kMuonGEM , detid.chamber());
767 
768  AddLeafNode(holder, child, name.c_str(), createPlacement(*it));
769  }
770  }
771  }
772 
773  {
774  TGeoVolume *assembly = GetDaughter(assemblyTop, "GEMetaPartitions", kMuonGEM);
775  for( auto it = gemGeom->etaPartitions().begin(),
776  end = gemGeom->etaPartitions().end();
777  it != end; ++it )
778  {
779  const GEMEtaPartition* roll = (*it);
780  if( roll )
781  {
782  GEMDetId detid = roll->geographicalId();
783  std::stringstream s;
784  s << detid;
785  std::string name = s.str();
786 
787  TGeoVolume* child = createVolume( name, roll, kMuonGEM );
788 
789  TGeoVolume* holder = GetDaughter(assembly, "ROLL Region", kMuonGEM , detid.region());
790  holder = GetDaughter(holder, "Ring", kMuonGEM , detid.ring());
791  holder = GetDaughter(holder, "Station", kMuonGEM , detid.station());
792  holder = GetDaughter(holder, "Layer", kMuonGEM , detid.layer());
793  holder = GetDaughter(holder, "Chamber", kMuonGEM , detid.chamber());
794 
795  AddLeafNode(holder, child, name.c_str(), createPlacement(*it));
796  }
797  }
798  }
799  }catch (cms::Exception &exception) {
800  edm::LogInfo("FWRecoGeometry") << "failed to produce GEM geometry " << exception.what() << std::endl;
801 
802  }
803 }
804 
805 //______________________________________________________________________________
806 
807 
808 void
810 {
811  TGeoVolume* tv = GetTopHolder("Muon", kMuonRPC);
812  TGeoVolume *assembly = GetDaughter(tv, "RPC", kMuonRPC);
813 
815  const RPCGeometry* rpcGeom = (const RPCGeometry*) m_geomRecord->slaveGeometry( detId );
816  for( auto it = rpcGeom->rolls().begin(),
817  end = rpcGeom->rolls().end();
818  it != end; ++it )
819  {
820  RPCRoll const* roll = (*it);
821  if( roll )
822  {
823  RPCDetId detid = roll->geographicalId();
824  std::stringstream s;
825  s << detid;
826  std::string name = s.str();
827 
828  TGeoVolume* child = createVolume( name, roll, kMuonRPC );
829 
830  TGeoVolume* holder = GetDaughter(assembly, "ROLL Region", kMuonRPC, detid.region());
831  holder = GetDaughter(holder, "Ring", kMuonRPC, detid.ring());
832  holder = GetDaughter(holder, "Station", kMuonRPC, detid.station());
833  holder = GetDaughter(holder, "Sector", kMuonRPC, detid.sector());
834  holder = GetDaughter(holder, "Layer", kMuonRPC, detid.layer());
835  holder = GetDaughter(holder, "Subsector", kMuonRPC, detid.subsector());
836 
837  AddLeafNode(holder, child, name.c_str(), createPlacement(*it));
838  }
839  };
840 }
841 
842 void
844 {
845  TGeoVolume* tv = GetTopHolder("Muon", kMuonME0);
846  TGeoVolume *assembly = GetDaughter(tv, "ME0", kMuonME0);
847 
848  DetId detId( DetId::Muon, 5 );
849  try
850  {
851  const ME0Geometry* me0Geom = (const ME0Geometry*) m_geomRecord->slaveGeometry( detId );
852 
853  for(auto roll : me0Geom->etaPartitions())
854  {
855  if( roll )
856  {
857  unsigned int rawid = roll->geographicalId().rawId();
858  //std::cout << "AMT FWTTTTRecoGeometryES\n" << rawid ;
859 
860  ME0DetId detid(rawid);
861  std::stringstream s;
862  s << detid;
863  std::string name = s.str();
864  TGeoVolume* child = createVolume( name, roll, kMuonME0 );
865 
866  TGeoVolume* holder = GetDaughter(assembly, "Region", kMuonME0, detid.region());
867  holder = GetDaughter(holder, "Layer", kMuonME0, detid.layer());
868  holder = GetDaughter(holder, "Chamber", kMuonME0, detid.chamber());
869  AddLeafNode(holder, child, name.c_str(), createPlacement(roll));
870 
871 
872  }
873  }
874  }
875  catch( cms::Exception &exception )
876  {
877  edm::LogInfo("FWRecoGeometry") << "failed to produce ME0 geometry " << exception.what() << std::endl;
878  }
879 }
880 
881 
882 //==============================================================================
883 //================================= CALO =======================================
884 //==============================================================================
885 
886 
887 void
889 {
890  TGeoVolume* tv = GetTopHolder("HCal", kHCal);
891  TGeoVolume *assembly = GetDaughter(tv, "HCalBarrel", kHCal);
892 
894 
895  CaloVolMap caloShapeMapP;
896  CaloVolMap caloShapeMapN;
897  for( std::vector<DetId>::const_iterator it = vid.begin(), end = vid.end(); it != end; ++it)
898  {
899  //HcalDetId detid = HcalDetId(it->rawId());
900  HcalDetId detid(*it);
901  const CaloCellGeometry* cellb= m_caloGeom->getGeometry(*it);
902  const IdealObliquePrism* cell = dynamic_cast<const IdealObliquePrism*> (cellb);
903 
904  if (!cell) { printf ("HB not oblique !!!\n"); continue; }
905 
906  TGeoVolume* volume = nullptr;
907  CaloVolMap& caloShapeMap = (cell->etaPos() > 0) ? caloShapeMapP : caloShapeMapN;
908  CaloVolMap::iterator volIt = caloShapeMap.find(cell->param());
909  if (volIt == caloShapeMap.end())
910  {
911  // printf("FIREWORKS NEW SHAPE BEGIN eta = %f etaPos = %f, phiPos %f >>>>>> \n", cell->eta(), cell->etaPos(), cell->phiPos());
914  IdealObliquePrism::localCorners( lc, cell->param(), ref );
915  HepGeom::Vector3D<float> lCenter;
916  for( int c = 0; c < 8; ++c)
917  lCenter += lc[c];
918  lCenter *= 0.125;
919 
920  static const int arr[] = { 1, 0, 3, 2, 5, 4, 7, 6 };
921  double points[16];
922  for (int c = 0; c < 8; ++c) {
923  if (cell->etaPos() > 0 )
924  points[ c*2 + 0 ] = -(lc[arr[c]].z() - lCenter.z());
925  else
926  points[ c*2 + 0 ] = (lc[arr[c]].z() - lCenter.z());
927  points[ c*2 + 1 ] = (lc[arr[c]].y() - lCenter.y());
928  // printf("AMT xy[%d] <=>[%d] = (%.4f, %.4f) \n", arr[c], c, points[c*2], points[c*2+1]);
929  }
930 
931  float dz = (lc[4].x() -lc[0].x()) * 0.5;
932  TGeoShape* solid = new TGeoArb8(dz, &points[0]);
933  volume = new TGeoVolume("hcal oblique prism", solid, GetMedium(kHCal));
934  caloShapeMap[cell->param()] = volume;
935  }
936  else {
937  volume = volIt->second;
938  }
939 
940  HepGeom::Vector3D<float> gCenter;
941  CaloCellGeometry::CornersVec const & gc = cell->getCorners();
942  for (int c = 0; c < 8; ++c)
943  gCenter += HepGeom::Vector3D<float>(gc[c].x(), gc[c].y(), gc[c].z());
944  gCenter *= 0.125;
945 
946  TGeoTranslation gtr(gCenter.x(), gCenter.y(), gCenter.z());
947  TGeoRotation rot;
948  rot.RotateY(90);
949 
950  TGeoRotation rotPhi;
951  rotPhi.SetAngles(0, -cell->phiPos()*TMath::RadToDeg(), 0);
952  rot.MultiplyBy(&rotPhi);
953 
954  TGeoVolume* holder = GetDaughter(assembly, "side", kHCal, detid.zside());
955  holder = GetDaughter(holder, "ieta", kHCal, detid.ieta());
956  std::stringstream nname;
957  nname << detid;
958  AddLeafNode(holder, volume, nname.str().c_str(), new TGeoCombiTrans(gtr, rot));
959  }
960 
961  // printf("HB map size P = %lu , N = %lu", caloShapeMapP.size(),caloShapeMapN.size() );
962 }
963 //______________________________________________________________________________
964 
965 void
967 {
968 
969  CaloVolMap caloShapeMapP;
970  CaloVolMap caloShapeMapN;
971 
972  TGeoVolume* tv = GetTopHolder("HCal", kHCal);
973  TGeoVolume *assembly = GetDaughter(tv, "HCalEndcap", kHCal);
974 
976 
977  for( std::vector<DetId>::const_iterator it = vid.begin(), end = vid.end(); it != end; ++it)
978  {
979  HcalDetId detid = HcalDetId(it->rawId());
980  const IdealObliquePrism* cell = dynamic_cast<const IdealObliquePrism*> ( m_caloGeom->getGeometry(*it));
981 
982  if (!cell) { printf ("EC not oblique \n"); continue; }
983 
984  TGeoVolume* volume = nullptr;
985  CaloVolMap& caloShapeMap = (cell->etaPos() > 0) ? caloShapeMapP : caloShapeMapN;
986  CaloVolMap::iterator volIt = caloShapeMap.find(cell->param());
987  if ( volIt == caloShapeMap.end())
988  {
991  IdealObliquePrism::localCorners( lc, cell->param(), ref);
992  HepGeom::Vector3D<float> lCenter;
993  for( int c = 0; c < 8; ++c)
994  lCenter += lc[c];
995  lCenter *= 0.125;
996 
997  //for( int c = 0; c < 8; ++c)
998  // printf("lc.push_back(TEveVector(%.4f, %.4f, %.4f));\n", lc[c].x(), lc[c].y(), lc[c].z() );
999 
1000 
1001  static const int arrP[] = { 3, 2, 1, 0, 7, 6, 5, 4 };
1002  static const int arrN[] = { 7, 6, 5, 4 ,3, 2, 1, 0};
1003  const int* arr = (detid.ieta() > 0) ? &arrP[0] : &arrN[0];
1004 
1005  double points[16];
1006  for (int c = 0; c < 8; ++c) {
1007  points[ c*2 + 0 ] = lc[arr[c]].x() - lCenter.x();
1008  points[ c*2 + 1 ] = lc[arr[c]].y() - lCenter.y();
1009  }
1010 
1011  float dz = (lc[4].z() -lc[0].z()) * 0.5;
1012  TGeoShape* solid = new TGeoArb8(dz, &points[0]);
1013  volume = new TGeoVolume("ecal oblique prism", solid, GetMedium(kHCal));
1014  caloShapeMap[cell->param()] = volume;
1015  }
1016  else {
1017 
1018  volume = volIt->second;
1019 
1020  }
1021 
1022  HepGeom::Vector3D<float> gCenter;
1023  CaloCellGeometry::CornersVec const & gc = cell->getCorners();
1024  for (int c = 0; c < 8; ++c) {
1025  gCenter += HepGeom::Vector3D<float>(gc[c].x(), gc[c].y(), gc[c].z());
1026  // printf("gc.push_back(TEveVector(%.4f, %.4f, %.4f));\n", gc[c].x(), gc[c].y(),gc[c].z() );
1027  }
1028  gCenter *= 0.125;
1029 
1030  TGeoTranslation gtr(gCenter.x(), gCenter.y(), gCenter.z());
1031  TGeoRotation rot;
1032  rot.SetAngles(cell->phiPos()*TMath::RadToDeg(), 0, 0);
1033 
1034  TGeoVolume* holder = GetDaughter(assembly, "side", kHCal, detid.zside());
1035  holder = GetDaughter(holder, "ieta", kHCal, detid.ieta());
1036  std::stringstream nname;
1037  nname << detid;
1038  AddLeafNode(holder, volume, nname.str().c_str(), new TGeoCombiTrans(gtr, rot));
1039  }
1040 
1041  // printf("HE map size P = %lu , N = %lu", caloShapeMapP.size(),caloShapeMapN.size() );
1042 }
1043 
1044 void
1046 {
1047  CaloVolMap caloShapeMapP;
1048  CaloVolMap caloShapeMapN;
1049 
1050  TGeoVolume* tv = GetTopHolder("HCal", kHCal);
1051  TGeoVolume *assembly = GetDaughter(tv, "HCalOuter", kHCal);
1052 
1054 
1055  for( std::vector<DetId>::const_iterator it = vid.begin(), end = vid.end(); it != end; ++it)
1056  {
1057  HcalDetId detid = HcalDetId(it->rawId());
1058  const IdealObliquePrism* cell = dynamic_cast<const IdealObliquePrism*> ( m_caloGeom->getGeometry(*it));
1059 
1060  if (!cell) { printf ("EC not oblique \n"); continue; }
1061 
1062  TGeoVolume* volume = nullptr;
1063  CaloVolMap& caloShapeMap = (cell->etaPos() > 0) ? caloShapeMapP : caloShapeMapN;
1064  CaloVolMap::iterator volIt = caloShapeMap.find(cell->param());
1065  if ( volIt == caloShapeMap.end())
1066  {
1069  IdealObliquePrism::localCorners( lc, cell->param(), ref);
1070  HepGeom::Vector3D<float> lCenter;
1071  for( int c = 0; c < 8; ++c)
1072  lCenter += lc[c];
1073  lCenter *= 0.125;
1074  static const int arrP[] = { 3, 2, 1, 0, 7, 6, 5, 4 };
1075  static const int arrN[] = { 7, 6, 5, 4 ,3, 2, 1, 0};
1076  const int* arr = (detid.ieta() > 0) ? &arrP[0] : &arrN[0];
1077 
1078  double points[16];
1079  for (int c = 0; c < 8; ++c) {
1080  points[ c*2 + 0 ] = lc[arr[c]].x() - lCenter.x();
1081  points[ c*2 + 1 ] = lc[arr[c]].y() - lCenter.y();
1082  }
1083 
1084  float dz = (lc[4].z() -lc[0].z()) * 0.5;
1085  TGeoShape* solid = new TGeoArb8(dz, &points[0]);
1086  volume = new TGeoVolume("ecal oblique prism", solid, GetMedium(kHCal));
1087  caloShapeMap[cell->param()] = volume;
1088  }
1089  else {
1090  volume = volIt->second;
1091  }
1092  HepGeom::Vector3D<float> gCenter;
1093  CaloCellGeometry::CornersVec const & gc = cell->getCorners();
1094  for (int c = 0; c < 8; ++c) {
1095  gCenter += HepGeom::Vector3D<float>(gc[c].x(), gc[c].y(), gc[c].z());
1096  }
1097  gCenter *= 0.125;
1098 
1099  TGeoTranslation gtr(gCenter.x(), gCenter.y(), gCenter.z());
1100  TGeoRotation rot;
1101  rot.SetAngles(cell->phiPos()*TMath::RadToDeg(), 0, 0);
1102 
1103  TGeoVolume* holder = GetDaughter(assembly, "side", kHCal, detid.zside());
1104  holder = GetDaughter(holder, "ieta", kHCal, detid.ieta());
1105  std::stringstream nname;
1106  nname << detid;
1107  AddLeafNode(holder, volume, nname.str().c_str(), new TGeoCombiTrans(gtr, rot));
1108  }
1109 }
1110 
1111 void
1113 {
1114  CaloVolMap caloShapeMapP;
1115  CaloVolMap caloShapeMapN;
1116 
1117  TGeoVolume* tv = GetTopHolder("HCal", kHCal);
1118  TGeoVolume *assembly = GetDaughter(tv, "HCalForward", kHCal);
1119 
1121 
1122  for( std::vector<DetId>::const_iterator it = vid.begin(), end = vid.end(); it != end; ++it)
1123  {
1124  HcalDetId detid = HcalDetId(it->rawId());
1125  const IdealZPrism* cell = dynamic_cast<const IdealZPrism*> ( m_caloGeom->getGeometry(*it));
1126 
1127  if (!cell) { printf ("EC not Z prism \n"); continue; }
1128 
1129  TGeoVolume* volume = nullptr;
1130  CaloVolMap& caloShapeMap = (cell->etaPos() > 0) ? caloShapeMapP : caloShapeMapN;
1131  CaloVolMap::iterator volIt = caloShapeMap.find(cell->param());
1132  if ( volIt == caloShapeMap.end())
1133  {
1134  IdealZPrism::Pt3DVec lc(8);
1135  IdealZPrism::Pt3D ref;
1136  IdealZPrism::localCorners( lc, cell->param(), ref);
1137  HepGeom::Vector3D<float> lCenter;
1138  for( int c = 0; c < 8; ++c)
1139  lCenter += lc[c];
1140  lCenter *= 0.125;
1141  static const int arrP[] = { 3, 2, 1, 0, 7, 6, 5, 4 };
1142  static const int arrN[] = { 7, 6, 5, 4 ,3, 2, 1, 0};
1143  const int* arr = (detid.ieta() > 0) ? &arrP[0] : &arrN[0];
1144 
1145  double points[16];
1146  for (int c = 0; c < 8; ++c) {
1147  points[ c*2 + 0 ] = lc[arr[c]].x() - lCenter.x();
1148  points[ c*2 + 1 ] = lc[arr[c]].y() - lCenter.y();
1149  }
1150 
1151  float dz = (lc[4].z() -lc[0].z()) * 0.5;
1152  TGeoShape* solid = new TGeoArb8(dz, &points[0]);
1153  volume = new TGeoVolume("ecal oblique prism", solid, GetMedium(kHCal));
1154  caloShapeMap[cell->param()] = volume;
1155  }
1156  else {
1157  volume = volIt->second;
1158  }
1159  HepGeom::Vector3D<float> gCenter;
1160  CaloCellGeometry::CornersVec const & gc = cell->getCorners();
1161  for (int c = 0; c < 8; ++c) {
1162  gCenter += HepGeom::Vector3D<float>(gc[c].x(), gc[c].y(), gc[c].z());
1163  }
1164  gCenter *= 0.125;
1165 
1166  TGeoTranslation gtr(gCenter.x(), gCenter.y(), gCenter.z());
1167  TGeoRotation rot;
1168  rot.SetAngles(cell->phiPos()*TMath::RadToDeg(), 0, 0);
1169 
1170  TGeoVolume* holder = GetDaughter(assembly, "side", kHCal, detid.zside());
1171  holder = GetDaughter(holder, "ieta", kHCal, detid.ieta());
1172  std::stringstream nname;
1173  nname << detid;
1174  AddLeafNode(holder, volume, nname.str().c_str(), new TGeoCombiTrans(gtr, rot));
1175  }
1176 }
1177 
1178 void
1180 {
1181  CaloVolMap caloShapeMapP;
1182  CaloVolMap caloShapeMapN;
1183 
1184  TGeoVolume* tv = GetTopHolder("CaloTower", kCaloTower);
1185  TGeoVolume *assembly = GetDaughter(tv, "CaloTower", kCaloTower);
1186 
1188  for( std::vector<DetId>::const_iterator it = vid.begin(), end = vid.end(); it != end; ++it)
1189  {
1190  CaloTowerDetId detid = CaloTowerDetId(it->rawId());
1191  const IdealObliquePrism* cell = dynamic_cast<const IdealObliquePrism*> ( m_caloGeom->getGeometry(*it));
1192  if (!cell) { printf ("EC not oblique \n"); continue; }
1193  TGeoVolume* volume = nullptr;
1194  CaloVolMap& caloShapeMap = (cell->etaPos() > 0) ? caloShapeMapP : caloShapeMapN;
1195  CaloVolMap::iterator volIt = caloShapeMap.find(cell->param());
1196  if ( volIt == caloShapeMap.end())
1197  {
1200  IdealObliquePrism::localCorners( lc, cell->param(), ref);
1201  HepGeom::Vector3D<float> lCenter;
1202  for( int c = 0; c < 8; ++c)
1203  lCenter += lc[c];
1204  lCenter *= 0.125;
1205 
1206  static const int arrP[] = { 3, 2, 1, 0, 7, 6, 5, 4 };
1207  static const int arrN[] = { 7, 6, 5, 4 ,3, 2, 1, 0};
1208  const int* arr = (detid.ieta() > 0) ? &arrP[0] : &arrN[0];
1209 
1210  double points[16];
1211  for (int c = 0; c < 8; ++c) {
1212  points[ c*2 + 0 ] = lc[arr[c]].x() - lCenter.x();
1213  points[ c*2 + 1 ] = lc[arr[c]].y() - lCenter.y();
1214  }
1215 
1216  float dz = (lc[4].z() -lc[0].z()) * 0.5;
1217  TGeoShape* solid = new TGeoArb8(dz, &points[0]);
1218  volume = new TGeoVolume("ecal oblique prism", solid, GetMedium(kCaloTower));
1219  caloShapeMap[cell->param()] = volume;
1220  }
1221  else {
1222  volume = volIt->second;
1223  }
1224 
1225  HepGeom::Vector3D<float> gCenter;
1226  CaloCellGeometry::CornersVec const & gc = cell->getCorners();
1227  for (int c = 0; c < 8; ++c) {
1228  gCenter += HepGeom::Vector3D<float>(gc[c].x(), gc[c].y(), gc[c].z());
1229  }
1230  gCenter *= 0.125;
1231 
1232  TGeoTranslation gtr(gCenter.x(), gCenter.y(), gCenter.z());
1233  TGeoRotation rot;
1234  rot.SetAngles(cell->phiPos()*TMath::RadToDeg(), 0, 0);
1235 
1236  TGeoVolume* holder = GetDaughter(assembly, "side", kCaloTower, detid.zside());
1237  holder = GetDaughter(holder, "ieta", kCaloTower, detid.ieta());
1238  std::stringstream nname;
1239  nname << detid;
1240  AddLeafNode(holder, volume, nname.str().c_str(), new TGeoCombiTrans(gtr, rot));
1241  }
1242 }
1243 
1244 //______________________________________________________________________________
1245 
1247 {
1248 
1249  TEveVector gCenter;
1250  for (int i = 0; i < 8; ++i)
1251  gCenter += TEveVector(gc[i].x(), gc[i].y(), gc[i].z());
1252  gCenter *= 0.125;
1253 
1254  TEveVector tgCenter; // top center 4 corners
1255  for (int i = 4; i < 8; ++i)
1256  tgCenter += TEveVector(gc[i].x(), gc[i].y(), gc[i].z());
1257  tgCenter *= 0.25;
1258 
1259 
1260  TEveVector axis = tgCenter - gCenter;
1261  axis.Normalize();
1262 
1263  TEveTrans tr;
1264  TVector3 v1t;
1265  tr.GetBaseVec(1, v1t);
1266 
1267 
1268  TEveVector v1(v1t.x(), v1t.y(), v1t.z());
1269  double dot13 = axis.Dot(v1);
1270  TEveVector gd = axis;
1271  gd*= dot13;
1272  v1 -= gd;
1273  v1.Normalize();
1274  TEveVector v2;
1275  TMath::Cross(v1.Arr(), axis.Arr(), v2.Arr());
1276  TMath::Cross(axis.Arr(), v1.Arr(), v2.Arr());
1277  v2.Normalize();
1278 
1279  tr.SetBaseVec(1, v1.fX, v1.fY, v1.fZ);
1280  tr.SetBaseVec(2, v2.fX, v2.fY, v2.fZ);
1281  tr.SetBaseVec(3, axis.fX, axis.fY, axis.fZ);
1282  tr.Move3PF(gCenter.fX, gCenter.fY, gCenter.fZ);
1283 
1284  TGeoHMatrix* out = new TGeoHMatrix();
1285  tr.SetGeoHMatrix(*out);
1286  return out;
1287 }
1288 
1289 TGeoShape* makeEcalShape(const TruncatedPyramid* cell)
1290 {
1291  // printf("BEGIN EE SHAPE --------------------------------\n");
1292  // std::cout << detid << std::endl;
1293  const HepGeom::Transform3D idtr;
1296  TruncatedPyramid::localCorners( co, cell->param(), ref);
1297  //for( int c = 0; c < 8; ++c)
1298  // printf("lc.push_back(TEveVector(%.4f, %.4f, %.4f));\n", co[c].x(),co[c].y(),co[c].z() );
1299 
1300  double points[16];
1301  for( int c = 0; c < 8; ++c )
1302  {
1303  points[c*2 ] = co[c].x();
1304  points[c*2+1] = co[c].y();
1305  }
1306  TGeoShape* solid = new TGeoArb8(cell->param()[0], points);
1307  return solid;
1308 }
1309 
1310 //______________________________________________________________________________
1311 
1312 
1313 
1314 void
1316 {
1317 
1318  TGeoVolume* tv = GetTopHolder("ECal", kECal);
1319  CaloVolMap caloShapeMap;
1320 
1321  {
1322  TGeoVolume *assembly = GetDaughter(tv, "ECalBarrel", kECal);
1323 
1325  for( std::vector<DetId>::const_iterator it = vid.begin(), end = vid.end(); it != end; ++it)
1326  {
1327  EBDetId detid(*it);
1328  const TruncatedPyramid* cell = dynamic_cast<const TruncatedPyramid*> ( m_caloGeom->getGeometry( *it ));
1329  if (!cell) { printf("ecalBarrel cell not a TruncatedPyramid !!\n"); return; }
1330 
1331  TGeoVolume* volume = nullptr;
1332  CaloVolMap::iterator volIt = caloShapeMap.find(cell->param());
1333  if ( volIt == caloShapeMap.end())
1334  {
1335  volume = new TGeoVolume( "EE TruncatedPyramid" , makeEcalShape(cell), GetMedium(kECal));
1336  caloShapeMap[cell->param()] = volume;
1337  }
1338  else {
1339  volume = volIt->second;
1340  }
1341  TGeoHMatrix* mtx= getEcalTrans(cell->getCorners());
1342  TGeoVolume* holder = GetDaughter(assembly, "side", kECal, detid.zside());
1343  holder = GetDaughter(holder, "ieta", kECal, detid.ieta());
1344  std::stringstream nname;
1345  nname << detid;
1346  AddLeafNode(holder, volume, nname.str().c_str(), mtx);
1347  }
1348  }
1349 
1350 
1351  {
1352  TGeoVolume *assembly = GetDaughter(tv, "ECalEndcap", kECal);
1353 
1355  for( std::vector<DetId>::const_iterator it = vid.begin(), end = vid.end(); it != end; ++it)
1356  {
1357  EEDetId detid(*it);
1358  const TruncatedPyramid* cell = dynamic_cast<const TruncatedPyramid*> (m_caloGeom->getGeometry( *it ));
1359  if (!cell) { printf("ecalEndcap cell not a TruncatedPyramid !!\n"); continue;}
1360 
1361  TGeoVolume* volume = nullptr;
1362  CaloVolMap::iterator volIt = caloShapeMap.find(cell->param());
1363  if ( volIt == caloShapeMap.end())
1364  {
1365 
1366  volume = new TGeoVolume( "EE TruncatedPyramid" , makeEcalShape(cell), GetMedium(kECal));
1367  caloShapeMap[cell->param()] = volume;
1368  }
1369  else {
1370  volume = volIt->second;
1371  }
1372  TGeoHMatrix* mtx= getEcalTrans(cell->getCorners());
1373  TGeoVolume* holder = GetDaughter(assembly, "side", kECal, detid.zside());
1374  holder = GetDaughter(holder, "ix", kECal, detid.ix());
1375  std::stringstream nname;
1376  nname << detid;
1377  AddLeafNode(holder, volume, nname.str().c_str(), mtx);
1378  }
1379  }
1380 }
1381 
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
edm::ESHandle< CaloGeometry > m_caloGeom
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:114
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:4
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:37
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:92
HLT enums.
static const int RPC
Definition: MuonSubdetId.h:14
T xz() const
FWTGeoRecoGeometryESProducer(const edm::ParameterSet &)
const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id.
Definition: CaloGeometry.cc:78
const DetContainer & detsPXF() const
const DetContainer & detsTOB() const
float etaPos() const
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