CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWTGeoRecoGeometryESProducer.cc
Go to the documentation of this file.
4 
43 
44 #include "TGeoManager.h"
45 #include "TGeoArb8.h"
46 #include "TGeoMatrix.h"
47 #include "TFile.h"
48 #include "TTree.h"
49 #include "TError.h"
50 
52 m_dummyMedium(0)
53 {
54  setWhatProduced( this );
55 }
56 
58 {}
59 
60 namespace
61 {
62 
63 void AddLeafNode(TGeoVolume* mother, TGeoVolume* daughter, const char* name, TGeoMatrix* mtx )
64 {
65  int n = mother->GetNdaughters();
66  mother->AddNode(daughter, 1, mtx);
67  mother->GetNode(n)->SetName(name);
68 }
69 
71 TGeoCombiTrans* createPlacement( const GeomDet *det )
72 {
73  // Position of the DetUnit's center
74  float posx = det->surface().position().x();
75  float posy = det->surface().position().y();
76  float posz = det->surface().position().z();
77 
78  TGeoTranslation trans( posx, posy, posz );
79 
80  // Add the coeff of the rotation matrix
81  // with a projection on the basis vectors
82  TkRotation<float> detRot = det->surface().rotation();
83 
84  TGeoRotation rotation;
85  const Double_t matrix[9] = { detRot.xx(), detRot.yx(), detRot.zx(),
86  detRot.xy(), detRot.yy(), detRot.zy(),
87  detRot.xz(), detRot.yz(), detRot.zz()
88  };
89  rotation.SetMatrix( matrix );
90 
91  return new TGeoCombiTrans( trans, rotation );
92 }
93 
94 
95 
96 TGeoMatrix* createCaloPlacement( const CaloCellGeometry* cell)
97 {
99  cell->getTransform(tr, 0);
100 
101  TGeoTranslation trans( tr.getTranslation().x(), tr.getTranslation().y(), tr.getTranslation().z());
102 
103  TGeoRotation rotation;
104  CLHEP::HepRotation detRot = tr.getRotation();
105  const Double_t matrix[9] = { detRot.xx(), detRot.yx(), detRot.zx(),
106  detRot.xy(), detRot.yy(), detRot.zy(),
107  detRot.xz(), detRot.yz(), detRot.zz()
108  };
109 
110 
111  rotation.SetMatrix( matrix );
112  TGeoMatrix* res = new TGeoCombiTrans( trans, rotation );
113  res->Print();
114  return res;
115 }
116 }
117 
118 TGeoVolume* FWTGeoRecoGeometryESProducer::GetDaughter(TGeoVolume* mother, const char* prefix, int id)
119 {
120  TGeoVolume* res = 0;
121  if (mother->GetNdaughters()) {
122  TGeoNode* n = mother->FindNode(Form("%s_%d_1", prefix, id));
123  if ( n ) res = n->GetVolume();
124  }
125 
126  if (!res) {
127  res = new TGeoVolumeAssembly( Form("%s_%d", prefix, id ));
128  res->SetMedium(m_dummyMedium);
129  mother->AddNode(res, 1);
130  }
131 
132  return res;
133 }
134 
135 boost::shared_ptr<FWTGeoRecoGeometry>
137 {
138  using namespace edm;
139 
140  m_fwGeometry = boost::shared_ptr<FWTGeoRecoGeometry>( new FWTGeoRecoGeometry );
141 
143 
144  DetId detId( DetId::Tracker, 0 );
145  m_trackerGeom = (const TrackerGeometry*) m_geomRecord->slaveGeometry( detId );
146 
147  record.getRecord<CaloGeometryRecord>().get( m_caloGeom );
148 
149  TGeoManager* geom = new TGeoManager( "cmsGeo", "CMS Detector" );
150  if( 0 == gGeoIdentity )
151  {
152  gGeoIdentity = new TGeoIdentity( "Identity" );
153  }
154 
155  m_fwGeometry->manager( geom );
156 
157  // Default material is Vacuum
158  TGeoMaterial *vacuum = new TGeoMaterial( "Vacuum", 0 ,0 ,0 );
159  m_dummyMedium = new TGeoMedium( "reco", 0, vacuum);
160  // so is default medium
161  TGeoVolume *top = geom->MakeBox( "CMS", m_dummyMedium, 270., 270., 120. );
162 
163  if( 0 == top )
164  {
165  return boost::shared_ptr<FWTGeoRecoGeometry>();
166  }
167  geom->SetTopVolume( top );
168  // ROOT chokes unless colors are assigned
169  top->SetVisibility( kFALSE );
170  top->SetLineColor( kBlue );
171 
174  addTIBGeometry();
175  addTIDGeometry();
176  addTOBGeometry();
177  addTECGeometry();
178  addDTGeometry();
179  addCSCGeometry();
180  addRPCGeometry();
181  try {
182  addGEMGeometry();
183  }
184  catch ( cms::Exception& exception ) {
185  edm::LogWarning("FWRecoGeometryProducerException")
186  << "addGEMGeometry() Exception caught while building GEM geometry: " << exception.what()
187  << std::endl;
188  }
189 
190  // addEcalCaloGeometry();
191  geom->CloseGeometry();
192 
193  m_nameToShape.clear();
194  m_shapeToVolume.clear();
195  m_nameToMaterial.clear();
196  m_nameToMedium.clear();
197 
198  return m_fwGeometry;
199 }
200 
202 TGeoShape*
204 {
205  TGeoShape* shape = 0;
206 
207  // Trapezoidal
208  const Bounds *b = &((det->surface ()).bounds ());
209  const TrapezoidalPlaneBounds *b2 = dynamic_cast<const TrapezoidalPlaneBounds *> (b);
210  if( b2 )
211  {
212  std::array< const float, 4 > const & par = b2->parameters ();
213 
214  // These parameters are half-lengths, as in CMSIM/GEANT3
215  float hBottomEdge = par [0];
216  float hTopEdge = par [1];
217  float thickness = par [2];
218  float apothem = par [3];
219 
220  std::stringstream s;
221  s << "T_"
222  << hBottomEdge << "_"
223  << hTopEdge << "_"
224  << thickness << "_"
225  << apothem;
226  std::string name = s.str();
227 
228  // Do not create identical shape,
229  // if one already exists
230  shape = m_nameToShape[name];
231  if( 0 == shape )
232  {
233  shape = new TGeoTrap(
234  name.c_str(),
235  thickness, //dz
236  0, //theta
237  0, //phi
238  apothem, //dy1
239  hBottomEdge,//dx1
240  hTopEdge, //dx2
241  0, //alpha1
242  apothem, //dy2
243  hBottomEdge,//dx3
244  hTopEdge, //dx4
245  0); //alpha2
246 
247  m_nameToShape[name] = shape;
248  }
249  }
250  if( dynamic_cast<const RectangularPlaneBounds *> (b) != 0 )
251  {
252  // Rectangular
253  float length = det->surface().bounds().length();
254  float width = det->surface().bounds ().width();
255  float thickness = det->surface().bounds().thickness();
256 
257  std::stringstream s;
258  s << "R_"
259  << width << "_"
260  << length << "_"
261  << thickness;
262  std::string name = s.str();
263 
264  // Do not create identical shape,
265  // if one already exists
266  shape = m_nameToShape[name];
267  if( 0 == shape )
268  {
269  shape = new TGeoBBox( name.c_str(), width / 2., length / 2., thickness / 2. ); // dx, dy, dz
270 
271  m_nameToShape[name] = shape;
272  }
273  }
274 
275  return shape;
276 }
277 
279 TGeoVolume*
281 {
282  TGeoShape* solid = createShape( det );
283 
284  std::map<TGeoShape*, TGeoVolume*>::iterator vIt = m_shapeToVolume.find(solid);
285  if (vIt != m_shapeToVolume.end()) return vIt->second;
286 
287 
288  TGeoMedium* medium = m_nameToMedium[material];
289  if( 0 == medium )
290  {
291  medium = new TGeoMedium( material.c_str(), 0, createMaterial( material ));
292  m_nameToMedium[material] = medium;
293  }
294  TGeoVolume* volume = new TGeoVolume( name.c_str(),solid, medium);
295 
296  m_shapeToVolume[solid] = volume;
297 
298  return volume;
299 }
300 
302 TGeoMaterial*
304 {
305  TGeoMaterial *material = m_nameToMaterial[name];
306 
307  if( material == 0 )
308  {
309  // FIXME: Do we need to set real parameters of the material?
310  material = new TGeoMaterial( name.c_str(),
311  0, 0, 0 );
312  m_nameToMaterial[name] = material;
313  }
314 
315  return material;
316 }
317 
318 
327 
328 
329 void
331 {
332  TGeoVolume *assembly = new TGeoVolumeAssembly("PXB");
333 
334  for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsPXB().begin(),
335  end = m_trackerGeom->detsPXB().end();
336  it != end; ++it)
337  {
338  DetId detid = ( *it )->geographicalId();
339  unsigned int rawid = detid.rawId();
340 
341  PXBDetId xx(rawid);
342  std::string name = Form("PXB Ly:%d, Md:%d Ld:%d ", xx.layer(), xx.module(), xx.layer());
343  TGeoVolume* child = createVolume( name, *it );
344  child->SetLineColor( kGreen );
345 
346  TGeoVolume* holder = GetDaughter(assembly, "Layer", xx.layer());
347  holder = GetDaughter(holder, "Module", xx.module());
348 
349  AddLeafNode(holder, child, name.c_str(), createPlacement( *it ));
350  }
351 
352 
353  m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
354 }
355 //______________________________________________________________________________
356 
357 
358 void
360 {
361  TGeoVolume *assembly = new TGeoVolumeAssembly("PXF");
362  for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsPXF().begin(),
363  end = m_trackerGeom->detsPXF().end();
364  it != end; ++it )
365  {
366  PXFDetId detid = ( *it )->geographicalId();
367 
368  std::stringstream s;
369  s << detid;
370  std::string name = s.str();
371 
372  TGeoVolume* child = createVolume( name, *it );
373 
374 
375  TGeoVolume* holder = GetDaughter(assembly, "Side", detid.side());
376  holder = GetDaughter(holder, "Disk", detid.disk());
377  holder = GetDaughter(holder, "Blade", detid.blade());
378  holder = GetDaughter(holder, "Panel", detid.panel());
379 
380  // holder->AddNode( child, 1, createPlacement( *it ));
381  AddLeafNode(holder, child, name.c_str(), createPlacement( *it ));
382  child->SetLineColor( kGreen );
383 
384  }
385 
386 
387  m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
388 }
389 
390 //______________________________________________________________________________
391 
392 
393 void
395 {
396  TGeoVolume *assembly = new TGeoVolumeAssembly("TIB");
397  for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTIB().begin(),
398  end = m_trackerGeom->detsTIB().end();
399  it != end; ++it )
400  {
401  TIBDetId detid(( *it )->geographicalId());
402 
403  std::stringstream s;
404  s << detid;
405  std::string name = s.str();
406 
407  TGeoVolume* child = createVolume( name, *it );
408 
409  TGeoVolume* holder = GetDaughter(assembly, "Module", detid.module());
410  holder = GetDaughter(holder, "Order", detid.order());
411  holder = GetDaughter(holder, "Side", detid.side());
412  // holder->AddNode( child, 1, createPlacement( *it ));
413  AddLeafNode(holder, child, name.c_str(), createPlacement( *it ));
414  child->SetLineColor( kGreen );
415  }
416 
417  m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
418 }
419 
420 //______________________________________________________________________________
421 
422 
423 void
425 {
426  TGeoVolume *assembly = new TGeoVolumeAssembly("TID");
427 
428  for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTID().begin(),
429  end = m_trackerGeom->detsTID().end();
430  it != end; ++it)
431  {
432  TIDDetId detid = ( *it )->geographicalId();
433 
434  std::stringstream s;
435  s << detid;
436  std::string name = s.str();
437 
438  TGeoVolume* child = createVolume( name, *it );
439  TGeoVolume* holder = GetDaughter(assembly, "Side", detid.side());
440  holder = GetDaughter(holder, "Wheel", detid.wheel());
441  holder = GetDaughter(holder, "Ring", detid.ring());
442  // holder->AddNode( child, 1, createPlacement( *it ));
443  AddLeafNode(holder, child, name.c_str(), createPlacement( *it ));
444 
445  child->SetLineColor( kGreen );
446  }
447 
448  m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
449 }
450 
451 //______________________________________________________________________________
452 
453 void
455 {
456  TGeoVolume *assembly = new TGeoVolumeAssembly("TOB");
457 
458  for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTOB().begin(),
459  end = m_trackerGeom->detsTOB().end();
460  it != end; ++it )
461  {
462  TOBDetId detid(( *it )->geographicalId());
463 
464  std::stringstream s;
465  s << detid;
466  std::string name = s.str();
467 
468  TGeoVolume* child = createVolume( name, *it );
469  TGeoVolume* holder = GetDaughter(assembly, "Rod", detid.rodNumber());
470  holder = GetDaughter(holder, "Side", detid.side());
471  holder = GetDaughter(holder, "Module", detid.moduleNumber());
472  //holder->AddNode( child, 1, createPlacement( *it ));
473  AddLeafNode(holder, child, name.c_str(), createPlacement( *it ));
474 
475  child->SetLineColor( kGreen );
476  }
477 
478  m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
479 }
480 //______________________________________________________________________________
481 
482 
483 void
485 {
486  TGeoVolume *assembly = new TGeoVolumeAssembly("TEC");
487 
488  for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTEC().begin(),
489  end = m_trackerGeom->detsTEC().end();
490  it != end; ++it )
491  {
492  TECDetId detid = ( *it )->geographicalId();
493 
494  std::stringstream s;
495  s << detid;
496  std::string name = s.str();
497 
498  TGeoVolume* child = createVolume( name, *it );
499 
500  TGeoVolume* holder = GetDaughter(assembly, "Order", detid.order());
501  holder = GetDaughter(holder, "Ring", detid.ring());
502  holder = GetDaughter(holder, "Module", detid.module());
503  // holder->AddNode( child, 1, createPlacement( *it ));
504  AddLeafNode(holder, child, name.c_str(), createPlacement( *it ));
505  child->SetLineColor( kGreen );
506  }
507 
508  m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
509 }
510 //______________________________________________________________________________
511 
512 
513 void
515 {
516  //
517  // DT chambers geometry
518  //
519  TGeoVolume *assembly = new TGeoVolumeAssembly( "DT");
520 
521  auto const & dtChamberGeom = m_geomRecord->slaveGeometry( DTChamberId())->dets();
522  for( auto it = dtChamberGeom.begin(),
523  end = dtChamberGeom.end();
524  it != end; ++it )
525  {
526  if( auto chamber = dynamic_cast< const DTChamber *>(*it))
527  {
528  DTChamberId detid = chamber->geographicalId();
529  std::stringstream s;
530  s << detid;
531  std::string name = s.str();
532 
533  TGeoVolume* child = createVolume( name, chamber );
534  TGeoVolume* holder = GetDaughter(assembly, "Wheel", detid.wheel());
535  holder = GetDaughter(holder, "Station", detid.station());
536  holder = GetDaughter(holder, "Sector", detid.sector());
537 
538  // holder->AddNode( child, 1, createPlacement( chamber ));
539  AddLeafNode(holder, child, name.c_str(), createPlacement( chamber));
540  child->SetLineColor( kRed );
541  }
542  }
543 
544  // Fill in DT super layer parameters
545  auto const & dtSuperLayerGeom = m_geomRecord->slaveGeometry( DTSuperLayerId())->dets();
546  for( auto it = dtSuperLayerGeom.begin(),
547  end = dtSuperLayerGeom.end();
548  it != end; ++it )
549  {
550  if( auto * superlayer = dynamic_cast<const DTSuperLayer*>(*it))
551  {
552  // DetId detidx = superlayer->geographicalId();
553  DTSuperLayerId detid( DetId(superlayer->geographicalId()));
554  std::stringstream s;
555  s << detid;
556  std::string name = s.str();
557 
558  TGeoVolume* child = createVolume( name, superlayer );
559 
560  TGeoVolume* holder = GetDaughter(assembly, "Wheel", detid.wheel());
561  holder = GetDaughter(holder, "Station", detid.station());
562  holder = GetDaughter(holder, "Sector", detid.sector());
563  holder = GetDaughter(holder, "SuperLayer", detid.superlayer());
564  // holder = GetDaughter(holder, "Layer", detid.layer());
565 
566  //holder->AddNode( child, 1, createPlacement( superlayer ));
567  AddLeafNode(holder, child, name.c_str(), createPlacement( superlayer));
568 
569  child->SetLineColor( kBlue );
570  }
571  }
572 
573  // Fill in DT layer parameters
574  auto const & dtLayerGeom = m_geomRecord->slaveGeometry( DTLayerId())->dets();
575  for( auto it = dtLayerGeom.begin(),
576  end = dtLayerGeom.end();
577  it != end; ++it )
578  {
579  if(auto layer = dynamic_cast<const DTLayer*>(*it))
580  {
581 
582  DTLayerId detid( DetId(layer->geographicalId()));
583 
584  std::stringstream s;
585  s << detid;
586  std::string name = s.str();
587 
588  TGeoVolume* child = createVolume( name, layer );
589 
590  TGeoVolume* holder = GetDaughter(assembly, "Wheel", detid.wheel());
591  holder = GetDaughter(holder, "Station", detid.station());
592  holder = GetDaughter(holder, "Sector", detid.sector());
593  holder = GetDaughter(holder, "SuperLayer", detid.superlayer());
594  holder = GetDaughter(holder, "Layer", detid.layer());
595 
596  // holder->AddNode( child, 1, createPlacement( layer ));
597  AddLeafNode(holder, child, name.c_str(), createPlacement( layer));
598  child->SetLineColor( kBlue );
599  }
600  }
601 
602 
603  m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
604 }
605 //______________________________________________________________________________
606 
607 void
609 {
610  if(! m_geomRecord->slaveGeometry( CSCDetId()))
611  throw cms::Exception( "FatalError" ) << "Cannnot find CSCGeometry\n";
612 
613 
614  TGeoVolume *assembly = new TGeoVolumeAssembly("CSC");
615 
616  auto const & cscGeom = m_geomRecord->slaveGeometry( CSCDetId())->dets();
617  for( auto it = cscGeom.begin(), itEnd = cscGeom.end(); it != itEnd; ++it )
618  {
619  unsigned int rawid = (*it)->geographicalId();
620  CSCDetId detId(rawid);
621  std::stringstream s;
622  s << "CSC" << detId;
623  std::string name = s.str();
624 
625  TGeoVolume* child = 0;
626 
627  if( auto chamber = dynamic_cast<const CSCChamber*>(*it))
628  child = createVolume( name, chamber );
629  else if( auto * layer = dynamic_cast<const CSCLayer*>(*it))
630  child = createVolume( name, layer );
631 
632 
633 
634  if (child) {
635  TGeoVolume* holder = GetDaughter(assembly, "Endcap", detId.endcap());
636  holder = GetDaughter(holder, "Station", detId.station());
637  holder = GetDaughter(holder, "Ring", detId.ring());
638  holder = GetDaughter(holder, "Chamber", detId.chamber());
639 
640  child->SetLineColor( kBlue );
641  // holder->AddNode(child, 1, createPlacement( *it ));
642  AddLeafNode(holder, child, name.c_str(), createPlacement(*it));
643  }
644  }
645 
646  m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
647 }
648 
649 //______________________________________________________________________________
650 
651 void
653 {
654  TGeoVolume *assembly = new TGeoVolumeAssembly("GEM");
655 
657  const GEMGeometry* gemGeom = (const GEMGeometry*) m_geomRecord->slaveGeometry( detId );
658  for( auto it = gemGeom->etaPartitions().begin(),
659  end = gemGeom->etaPartitions().end();
660  it != end; ++it )
661  {
662  const GEMEtaPartition* roll = (*it);
663  if( roll )
664  {
665  GEMDetId detid = roll->geographicalId();
666  std::stringstream s;
667  s << detid;
668  std::string name = s.str();
669 
670  TGeoVolume* child = createVolume( name, roll );
671 
672  TGeoVolume* holder = GetDaughter(assembly, "ROLL Region", detid.region());
673  holder = GetDaughter(holder, "Ring", detid.ring());
674  holder = GetDaughter(holder, "Station", detid.station());
675  holder = GetDaughter(holder, "Layer", detid.layer());
676  holder = GetDaughter(holder, "Chamber", detid.chamber());
677 
678  AddLeafNode(holder, child, name.c_str(), createPlacement(*it));
679 
680  child->SetLineColor( kYellow );
681  }
682  }
683 
684  printf("ADD GEM!!!\n");
685  m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
686 }
687 
688 //______________________________________________________________________________
689 
690 
691 void
693 {
694  TGeoVolume *assembly = new TGeoVolumeAssembly("RPC");
695 
697  const RPCGeometry* rpcGeom = (const RPCGeometry*) m_geomRecord->slaveGeometry( detId );
698  for( auto it = rpcGeom->rolls().begin(),
699  end = rpcGeom->rolls().end();
700  it != end; ++it )
701  {
702  RPCRoll const* roll = (*it);
703  if( roll )
704  {
705  RPCDetId detid = roll->geographicalId();
706  std::stringstream s;
707  s << detid;
708  std::string name = s.str();
709 
710  TGeoVolume* child = createVolume( name, roll );
711 
712  TGeoVolume* holder = GetDaughter(assembly, "ROLL Region", detid.region());
713  holder = GetDaughter(holder, "Ring", detid.ring());
714  holder = GetDaughter(holder, "Station", detid.station());
715  holder = GetDaughter(holder, "Sector", detid.sector());
716  holder = GetDaughter(holder, "Layer", detid.layer());
717  holder = GetDaughter(holder, "Subsector", detid.subsector());
718 
719  AddLeafNode(holder, child, name.c_str(), createPlacement(*it));
720 
721  child->SetLineColor( kYellow );
722  }
723  }
724  /*
725  //AMT why no chamber ???
726  for( auto it = rpcGeom->chambers().begin(),
727  end = rpcGeom->chambers().end();
728  it != end; ++it )
729  {
730  RPCChamber const* chamber = (*it);
731  if( chamber )
732  {
733  RPCDetId detid = chamber->geographicalId();
734  std::stringstream s;
735  s << detid;
736  std::string name = s.str();
737 
738  TGeoVolume* child = createVolume( name, chamber );
739 
740  TGeoVolume* holder = GetDaughter(assembly, "CHANBER Region", detid.region());
741  holder = GetDaughter(holder, "Ring", detid.ring());
742  holder = GetDaughter(holder, "Station", detid.station());
743  holder = GetDaughter(holder, "Sector", detid.sector());
744  holder = GetDaughter(holder, "Layer", detid.layer());
745  holder = GetDaughter(holder, "Subsector", detid.subsector());
746 
747  holder->AddNode( child, 1, createPlacement( chamber ));
748  child->SetLineColor( kYellow );
749  }
750  else printf("NO CHAMBER \n");
751  }
752  */
753 
754  m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
755 }
756 
757 
758 //______________________________________________________________________________
759 
760 
761 //std::map< const CaloCellGeometry::CCGFloat*, TGeoVolume*> m_caloShapeMap;
762 namespace {
763 typedef std::map< const float*, TGeoVolume*> CaloVolMap;
764 CaloVolMap m_caloShapeMap;
765 }
766 //______________________________________________________________________________
767 
768 
769 
771 {
772  TGeoVolume* volume = 0;
773 
774  CaloVolMap::iterator volIt = m_caloShapeMap.find(cell->param());
775  if (volIt == m_caloShapeMap.end()) {
776  double points[24];
777  const HepGeom::Transform3D idtr;
778  std::vector<float> vpar;
779  for (int ip =0; ip < 11; ++ip)
780  vpar.push_back(cell->param()[ip]);
781 
782  std::vector<GlobalPoint> co(8);
783  TruncatedPyramid::createCorners(vpar, idtr, co);
784 
785  unsigned int index( 0 );
786  static const int arr[] = {0, 3, 2, 1, 4, 7, 6, 5};
787  for( int c = 0; c < 8; ++c )
788  {
789  points[index] = co[arr[c]].x();
790  points[++index] = co[arr[c]].y();
791  points[++index] = co[arr[c]].z();
792  }
793 
794  TGeoShape* solid = new TGeoArb8(cell->param()[0], points);
795 
796 
797  volume = new TGeoVolume( "TruncatedPyramid" ,solid, m_dummyMedium);
798  volume->SetLineColor(kGray);
799  m_caloShapeMap[cell->param()] = volume;
800  }
801  else {
802  volume = volIt->second;
803  }
804 
805  return volume;
806 }
807 
808 //______________________________________________________________________________
809 
811 {
812  TGeoVolume* volume = 0;
813 
814  return volume;
815 }
816 
817 //______________________________________________________________________________
818 
820 {
821  TGeoVolume* volume = 0;
822 
823  // AMT code unfinished ...
824  /*
825  CaloVolMap::iterator volIt = m_caloShapeMap.find(cell->param());
826 
827  if (volIt == m_caloShapeMap.end()) {
828  printf("FIREWORKS NEW SHAPE BEGIN >>>>>> \n");
829 
830  double points[24];
831  IdealObliquePrism::Pt3DVec co(8);
832  IdealObliquePrism::Pt3D ref;
833  IdealObliquePrism::localCorners( co, cell->param(), ref);
834 
835  static const int arr[] = {2, 3, 0, 1, 6, 7, 4,5};
836  //static const int arr[] = { 0, 1, 2, 3, 4, 5, 6, 7};
837 
838  unsigned int idx( 0 );
839  for( int c = 0; c < 8; ++c, ++idx )
840  {
841  points[idx*3] = co[arr[c]].x();
842  points[idx*3 + 1] = co[arr[c]].y();
843  points[idx*3 + 2] = co[arr[c]].z();
844  printf("fw oblique lc [%d] = %.4f %.4f %.4f\n", c, points[idx*3], points[idx*3+1], points[idx*3+2]);
845  }
846 
847 
848  if (cell->param()[2] < 0) {
849  printf("negatice height %f\n", cell->param()[2]);
850  }
851 
852  TGeoShape* solid = new TGeoArb8(TMath::Abs(cell->param()[2]), points);
853  volume = new TGeoVolume( "ObliquePrism" ,solid, m_dummyMedium);
854 
855 
856 
857  //volume = m_fwGeometry->manager()->MakeBox( "Z prsim", m_dummyMedium, dz, dz, dz );
858 
859 
860  volume->SetLineColor(kGray);
861  m_caloShapeMap[cell->param()] = volume;
862  CaloCellGeometry::CornersVec const & cv = cell->getCorners();
863  printf(" cell ------------------- \n");
864  for( int c = 0; c < 8; ++c)
865  printf("global cell corners [%d] = %.4f %.4f %.4f\n", c, cv[c].x(),cv[c].y(),cv[c].z() );
866 
867  printf("FIREWORKS NEW SHAPE END >>>>>> \n");
868  }
869  else {
870  volume = volIt->second;
871  }
872 
873  */
874  return volume;
875 }
876 
877 
878 //______________________________________________________________________________
879 
880 
881 
883 {
884  if (dynamic_cast<const TruncatedPyramid*> (cell))
885  return getTruncatedPyramidVolume(cell);
886 
887  if (dynamic_cast<const IdealZPrism*> (cell))
888  return getIdealZPrismVolume(cell);
889 
890  if (dynamic_cast<const IdealObliquePrism*> (cell))
891  return getIdealObliquePrismVolume(cell);
892 
893  return 0;
894 }
895 
896 //______________________________________________________________________________
897 
898 
899 
900 void
902 {
903  if (1)
904  {
905  TGeoVolume *assembly = new TGeoVolumeAssembly("EcalBarrel");
906  std::vector<DetId> vid = m_caloGeom->getValidDetIds(DetId::Ecal, EcalSubdetector::EcalBarrel);
907  for( std::vector<DetId>::const_iterator it = vid.begin(), end = vid.end(); it != end; ++it)
908  {
909  EBDetId detid(*it);
910  const CaloCellGeometry* cell = m_caloGeom->getGeometry( *it );
911  TGeoVolume* holder = GetDaughter(assembly, "ism", detid.ism());
912  holder->AddNode( getCalloCellVolume(cell), 1, createCaloPlacement(cell));
913 
914  }
915  m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
916  }
917 
918 
919  if (1) {
920  TGeoVolume *assembly = new TGeoVolumeAssembly("EcalEndcap");
921  std::vector<DetId> vid = m_caloGeom->getValidDetIds(DetId::Ecal, EcalSubdetector::EcalEndcap);
922  for( std::vector<DetId>::const_iterator it = vid.begin(), end = vid.end(); it != end; ++it)
923  {
924  EEDetId detid(*it);
925  const CaloCellGeometry* cell = m_caloGeom->getGeometry( *it );
926 
927  TGeoVolume* holder = GetDaughter(assembly, "zside", detid.zside());
928  holder = GetDaughter(holder, "sc", detid.sc());
929  holder->AddNode( getCalloCellVolume(cell), 1, createCaloPlacement(cell));
930  }
931  m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
932  }
933 }
934 
935 /*
936 
937 EvePointSet* pointset(Int_t npoints = 512, TEveElement* parent=0)
938 {
939  TEveManager::Create();
940 
941  for (int i = 0; i < 8; ++i) {
942 
943  TEvePointSet* ps = new TEvePointSet(Form("cell %d", i));
944 
945  if (i == 0)
946  ps->SetNextPoint(180.5827, 15.7989, 0.0000);
947  if (i == 1)
948  ps->SetNextPoint(181.2725, -0.0000, 0.0000);
949  if (i == 2)
950  ps->SetNextPoint(181.2725, -0.0000, -15.7906);
951  if (i == 3)
952  ps->SetNextPoint(180.5827, 15.7989, -15.7906);
953  if (i == 4)
954  ps->SetNextPoint(287.9751, 25.1945, 0.0000);
955  if (i == 5)
956  ps->SetNextPoint(289.0751, -0.0000, 0.0000);
957  if (i == 6)
958  ps->SetNextPoint(289.0751, -0.0000, -25.1813);
959  if (i == 7)
960  ps->SetNextPoint(287.9751, 25.1945, -25.1813);
961 
962  if (i > 3)
963  ps->SetMainColor(kOrange);
964  else
965  ps->SetMainColor(kCyan);
966 
967  ps->SetMarkerSize(3);
968  ps->SetMarkerStyle(2);
969  gEve->AddElement(ps);
970  }
971 
972  gEve->Redraw3D();
973  return ps;
974 }
975 
976 void
977 FWTGeoRecoGeometryESProducer::addHcalCaloGeometry( void )
978 {
979 
980  if (1) {
981  TGeoVolume *assembly = new TGeoVolumeAssembly("HcalBarrel");
982  std::vector<DetId> vid = m_caloGeom->getValidDetIds(DetId::Hcal, HcalSubdetector::HcalBarrel);
983  for( std::vector<DetId>::const_iterator it = vid.begin(), end = vid.end(); it != end; ++it)
984  {
985  const CaloCellGeometry* cell = m_caloGeom->getGeometry( *it );
986  TGeoVolume* v = getCalloCellVolume(cell);
987  if (v) assembly->AddNode( getCalloCellVolume(cell), 1, createCaloPlacement(cell));
988  if (++mc > 0) break;
989  }
990  m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
991  }
992  if (0) { TGeoVolume *assembly = new TGeoVolumeAssembly("HcalEndcap");
993  std::vector<DetId> vid = m_caloGeom->getValidDetIds(DetId::Hcal, HcalSubdetector::HcalEndcap);
994  for( std::vector<DetId>::const_iterator it = vid.begin(), end = vid.end(); it != end; ++it)
995  {
996  const CaloCellGeometry* cell = m_caloGeom->getGeometry( *it );
997  TGeoVolume* v = getCalloCellVolume(cell);
998  if (v) assembly->AddNode( getCalloCellVolume(cell), 1, createCaloPlacement(cell));
999 
1000  }
1001  m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
1002  }
1003 
1004 
1005  printf("SHAPE map size %d n", (int)m_caloShapeMap.size());
1006 
1007 }
1008 */
T xx() const
virtual char const * what() const
Definition: Exception.cc:141
virtual float length() const =0
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
TGeoShape * createShape(const GeomDet *det)
std::map< std::string, TGeoMedium * > m_nameToMedium
const std::vector< const RPCRoll * > & rolls() const
Return a vector of all RPC rolls.
Definition: RPCGeometry.cc:67
static const int GEM
Definition: MuonSubdetId.h:15
DTSuperLayerId
T y() const
Definition: PV3DBase.h:63
T yx() const
const Bounds & bounds() const
Definition: Surface.h:128
HepGeom::Transform3D Tr3D
TGeoVolume * createVolume(const std::string &name, const GeomDet *det, const std::string &matname="Air")
std::map< TGeoShape *, TGeoVolume * > m_shapeToVolume
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
int ism() const
get the ECAL/SM id
Definition: EBDetId.h:61
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
unsigned int layer() const
layer id
Definition: PXBDetId.h:35
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
virtual float thickness() const =0
T zx() const
T xy() const
T zz() const
const CCGFloat * param() const
const DetContainer & detsTEC() const
TGeoVolume * getTruncatedPyramidVolume(const CaloCellGeometry *cell)
virtual void getTransform(Tr3D &tr, Pt3DVec *lptr) const
--------— only needed by specific utility; overloaded when needed -—
std::map< std::string, TGeoShape * > m_nameToShape
T z() const
Definition: PV3DBase.h:64
const DetContainer & detsPXB() const
int zside() const
Definition: EEDetId.h:70
unsigned int module() const
det id
Definition: PXBDetId.h:43
T zy() const
const std::vector< const GEMEtaPartition * > & etaPartitions() const
Return a vector of all GEM chambers.
Definition: GEMGeometry.cc:57
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:72
#define end
Definition: vmac.h:37
T yy() const
const DetContainer & detsTIB() const
TGeoVolume * getCalloCellVolume(const CaloCellGeometry *cell)
Definition: DetId.h:18
EcalScDetId sc() const
Definition: EEDetId.h:88
double b
Definition: hdecay.h:120
boost::shared_ptr< FWTGeoRecoGeometry > produce(const FWTGeoRecoGeometryRecord &)
boost::shared_ptr< FWTGeoRecoGeometry > m_fwGeometry
static const int RPC
Definition: MuonSubdetId.h:14
T xz() const
FWTGeoRecoGeometryESProducer(const edm::ParameterSet &)
const DetContainer & detsPXF() const
TGeoVolume * getIdealZPrismVolume(const CaloCellGeometry *cell)
const DetContainer & detsTOB() const
const RotationType & rotation() const
Definition: Bounds.h:22
TGeoVolume * getIdealObliquePrismVolume(const CaloCellGeometry *cell)
TGeoMaterial * createMaterial(const std::string &name)
std::map< std::string, TGeoMaterial * > m_nameToMaterial
T x() const
Definition: PV3DBase.h:62
virtual float width() const =0
const PositionType & position() const
T yz() const
const DetContainer & detsTID() const
TGeoVolume * GetDaughter(TGeoVolume *mother, const char *prefix, int id)