CMS 3D CMS Logo

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