44 #include "TGeoManager.h"
46 #include "TGeoMatrix.h"
63 void AddLeafNode(TGeoVolume* mother, TGeoVolume* daughter,
const char*
name, TGeoMatrix* mtx )
65 int n = mother->GetNdaughters();
66 mother->AddNode(daughter, 1, mtx);
67 mother->GetNode(n)->SetName(name);
71 TGeoCombiTrans* createPlacement(
const GeomDet *det )
78 TGeoTranslation
trans( posx, posy, posz );
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()
89 rotation.SetMatrix( matrix );
91 return new TGeoCombiTrans(
trans, rotation );
101 TGeoTranslation
trans( tr.getTranslation().x(), tr.getTranslation().y(), tr.getTranslation().z());
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()
111 rotation.SetMatrix( matrix );
112 TGeoMatrix* res =
new TGeoCombiTrans(
trans, rotation );
121 if (mother->GetNdaughters()) {
122 TGeoNode* n = mother->FindNode(Form(
"%s_%d_1", prefix,
id));
123 if ( n ) res = n->GetVolume();
127 res =
new TGeoVolumeAssembly( Form(
"%s_%d", prefix,
id ));
129 mother->AddNode(res, 1);
135 boost::shared_ptr<FWTGeoRecoGeometry>
149 TGeoManager*
geom =
new TGeoManager(
"cmsGeo",
"CMS Detector" );
150 if( 0 == gGeoIdentity )
152 gGeoIdentity =
new TGeoIdentity(
"Identity" );
158 TGeoMaterial *vacuum =
new TGeoMaterial(
"Vacuum", 0 ,0 ,0 );
165 return boost::shared_ptr<FWTGeoRecoGeometry>();
169 top->SetVisibility( kFALSE );
170 top->SetLineColor( kBlue );
186 <<
"addGEMGeometry() Exception caught while building GEM geometry: " << exception.
what()
191 geom->CloseGeometry();
205 TGeoShape* shape = 0;
212 std::array< const float, 4 >
const & par = b2->
parameters ();
215 float hBottomEdge = par [0];
216 float hTopEdge = par [1];
217 float thickness = par [2];
218 float apothem = par [3];
222 << hBottomEdge <<
"_"
233 shape =
new TGeoTrap(
250 if( dynamic_cast<const RectangularPlaneBounds *> (b) != 0 )
269 shape =
new TGeoBBox( name.c_str(), width / 2., length / 2., thickness / 2. );
284 std::map<TGeoShape*, TGeoVolume*>::iterator vIt =
m_shapeToVolume.find(solid);
291 medium =
new TGeoMedium( material.c_str(), 0,
createMaterial( material ));
294 TGeoVolume* volume =
new TGeoVolume( name.c_str(),solid, medium);
310 material =
new TGeoMaterial( name.c_str(),
332 TGeoVolume *assembly =
new TGeoVolumeAssembly(
"PXB");
339 unsigned int rawid = detid.
rawId();
344 child->SetLineColor( kGreen );
349 AddLeafNode(holder, child, name.c_str(), createPlacement( *it ));
353 m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
361 TGeoVolume *assembly =
new TGeoVolumeAssembly(
"PXF");
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());
381 AddLeafNode(holder, child, name.c_str(), createPlacement( *it ));
382 child->SetLineColor( kGreen );
387 m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
396 TGeoVolume *assembly =
new TGeoVolumeAssembly(
"TIB");
409 TGeoVolume* holder =
GetDaughter(assembly,
"Module", detid.module());
410 holder =
GetDaughter(holder,
"Order", detid.order());
411 holder =
GetDaughter(holder,
"Side", detid.side());
413 AddLeafNode(holder, child, name.c_str(), createPlacement( *it ));
414 child->SetLineColor( kGreen );
417 m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
426 TGeoVolume *assembly =
new TGeoVolumeAssembly(
"TID");
439 TGeoVolume* holder =
GetDaughter(assembly,
"Side", detid.side());
440 holder =
GetDaughter(holder,
"Wheel", detid.wheel());
441 holder =
GetDaughter(holder,
"Ring", detid.ring());
443 AddLeafNode(holder, child, name.c_str(), createPlacement( *it ));
445 child->SetLineColor( kGreen );
448 m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
456 TGeoVolume *assembly =
new TGeoVolumeAssembly(
"TOB");
469 TGeoVolume* holder =
GetDaughter(assembly,
"Rod", detid.rodNumber());
470 holder =
GetDaughter(holder,
"Side", detid.side());
471 holder =
GetDaughter(holder,
"Module", detid.moduleNumber());
473 AddLeafNode(holder, child, name.c_str(), createPlacement( *it ));
475 child->SetLineColor( kGreen );
478 m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
486 TGeoVolume *assembly =
new TGeoVolumeAssembly(
"TEC");
500 TGeoVolume* holder =
GetDaughter(assembly,
"Order", detid.order());
501 holder =
GetDaughter(holder,
"Ring", detid.ring());
502 holder =
GetDaughter(holder,
"Module", detid.module());
504 AddLeafNode(holder, child, name.c_str(), createPlacement( *it ));
505 child->SetLineColor( kGreen );
508 m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
519 TGeoVolume *assembly =
new TGeoVolumeAssembly(
"DT");
522 for(
auto it = dtChamberGeom.begin(),
523 end = dtChamberGeom.end();
526 if(
auto chamber = dynamic_cast< const DTChamber *>(*it))
534 TGeoVolume* holder =
GetDaughter(assembly,
"Wheel", detid.wheel());
535 holder =
GetDaughter(holder,
"Station", detid.station());
536 holder =
GetDaughter(holder,
"Sector", detid.sector());
539 AddLeafNode(holder, child, name.c_str(), createPlacement( chamber));
540 child->SetLineColor( kRed );
546 for(
auto it = dtSuperLayerGeom.begin(),
547 end = dtSuperLayerGeom.end();
550 if(
auto * superlayer = dynamic_cast<const DTSuperLayer*>(*it))
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());
567 AddLeafNode(holder, child, name.c_str(), createPlacement( superlayer));
569 child->SetLineColor( kBlue );
575 for(
auto it = dtLayerGeom.begin(),
576 end = dtLayerGeom.end();
579 if(
auto layer = dynamic_cast<const DTLayer*>(*it))
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());
597 AddLeafNode(holder, child, name.c_str(), createPlacement( layer));
598 child->SetLineColor( kBlue );
603 m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
611 throw cms::Exception(
"FatalError" ) <<
"Cannnot find CSCGeometry\n";
614 TGeoVolume *assembly =
new TGeoVolumeAssembly(
"CSC");
617 for(
auto it = cscGeom.begin(), itEnd = cscGeom.end(); it != itEnd; ++it )
619 unsigned int rawid = (*it)->geographicalId();
625 TGeoVolume*
child = 0;
627 if(
auto chamber = dynamic_cast<const CSCChamber*>(*it))
629 else if(
auto * layer = dynamic_cast<const CSCLayer*>(*it))
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());
640 child->SetLineColor( kBlue );
642 AddLeafNode(holder, child, name.c_str(), createPlacement(*it));
646 m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
654 TGeoVolume *assembly =
new TGeoVolumeAssembly(
"GEM");
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());
678 AddLeafNode(holder, child, name.c_str(), createPlacement(*it));
680 child->SetLineColor( kYellow );
684 printf(
"ADD GEM!!!\n");
685 m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
694 TGeoVolume *assembly =
new TGeoVolumeAssembly(
"RPC");
698 for(
auto it = rpcGeom->
rolls().begin(),
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());
719 AddLeafNode(holder, child, name.c_str(), createPlacement(*it));
721 child->SetLineColor( kYellow );
754 m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
763 typedef std::map< const float*, TGeoVolume*> CaloVolMap;
764 CaloVolMap m_caloShapeMap;
772 TGeoVolume* volume = 0;
774 CaloVolMap::iterator volIt = m_caloShapeMap.find(cell->
param());
775 if (volIt == m_caloShapeMap.end()) {
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]);
782 std::vector<GlobalPoint> co(8);
783 TruncatedPyramid::createCorners(vpar, idtr, co);
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 )
789 points[
index] = co[arr[
c]].x();
790 points[++
index] = co[arr[
c]].y();
791 points[++
index] = co[arr[
c]].z();
794 TGeoShape* solid =
new TGeoArb8(cell->
param()[0], points);
797 volume =
new TGeoVolume(
"TruncatedPyramid" ,solid,
m_dummyMedium);
798 volume->SetLineColor(kGray);
799 m_caloShapeMap[cell->
param()] = volume;
802 volume = volIt->second;
812 TGeoVolume* volume = 0;
821 TGeoVolume* volume = 0;
884 if (dynamic_cast<const TruncatedPyramid*> (cell))
887 if (dynamic_cast<const IdealZPrism*> (cell))
890 if (dynamic_cast<const IdealObliquePrism*> (cell))
905 TGeoVolume *assembly =
new TGeoVolumeAssembly(
"EcalBarrel");
907 for( std::vector<DetId>::const_iterator it = vid.begin(),
end = vid.end(); it !=
end; ++it)
915 m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
920 TGeoVolume *assembly =
new TGeoVolumeAssembly(
"EcalEndcap");
922 for( std::vector<DetId>::const_iterator it = vid.begin(),
end = vid.end(); it !=
end; ++it)
931 m_fwGeometry->manager()->GetTopVolume()->AddNode( assembly, 1 );
virtual char const * what() const
TGeoMedium * m_dummyMedium
const TrackerGeometry * m_trackerGeom
virtual float length() const =0
virtual const std::array< const float, 4 > parameters() const
edm::ESHandle< CaloGeometry > m_caloGeom
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.
virtual ~FWTGeoRecoGeometryESProducer(void)
const Bounds & bounds() const
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.
int ism() const
get the ECAL/SM id
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
unsigned int layer() const
layer id
uint32_t rawId() const
get the raw id
virtual float thickness() const =0
const DepRecordT & getRecord() 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 -—
void addEcalCaloGeometry()
std::map< std::string, TGeoShape * > m_nameToShape
const DetContainer & detsPXB() const
unsigned int module() const
det id
const std::vector< const GEMEtaPartition * > & etaPartitions() const
Return a vector of all GEM chambers.
DetId geographicalId() const
The label of this GeomDet.
const DetContainer & detsTIB() const
TGeoVolume * getCalloCellVolume(const CaloCellGeometry *cell)
boost::shared_ptr< FWTGeoRecoGeometry > produce(const FWTGeoRecoGeometryRecord &)
boost::shared_ptr< FWTGeoRecoGeometry > m_fwGeometry
void addPixelForwardGeometry()
FWTGeoRecoGeometryESProducer(const edm::ParameterSet &)
const DetContainer & detsPXF() const
TGeoVolume * getIdealZPrismVolume(const CaloCellGeometry *cell)
const DetContainer & detsTOB() const
const RotationType & rotation() const
TGeoVolume * getIdealObliquePrismVolume(const CaloCellGeometry *cell)
TGeoMaterial * createMaterial(const std::string &name)
std::map< std::string, TGeoMaterial * > m_nameToMaterial
virtual float width() const =0
const PositionType & position() const
void addPixelBarrelGeometry()
const DetContainer & detsTID() const
TGeoVolume * GetDaughter(TGeoVolume *mother, const char *prefix, int id)