27 #include "TGeoManager.h"
29 #include "TGeoMatrix.h"
34 # define ADD_PIXEL_TOPOLOGY( rawid, detUnit ) \
35 const PixelGeomDetUnit* det = dynamic_cast<const PixelGeomDetUnit*>( detUnit ); \
38 const PixelTopology& topo = det->specificTopology(); \
39 m_fwGeometry->idToName[rawid].topology[0] = topo.nrows(); \
40 m_fwGeometry->idToName[rawid].topology[1] = topo.ncolumns(); \
43 # define ADD_SISTRIP_TOPOLOGY( rawid, detUnit ) \
44 const StripGeomDetUnit* det = dynamic_cast<const StripGeomDetUnit*>( detUnit ); \
47 const StripTopology* topo = dynamic_cast<const StripTopology*>( &det->specificTopology()); \
48 m_fwGeometry->idToName[rawid].topology[0] = topo->nstrips(); \
49 m_fwGeometry->idToName[rawid].topology[1] = topo->stripLength(); \
50 if( const RadialStripTopology* rtop = dynamic_cast<const RadialStripTopology*>( topo )) \
52 m_fwGeometry->idToName[rawid].topology[2] = rtop->phiPitch(); \
54 else if( dynamic_cast<const RectangularStripTopology*>( topo )) \
56 m_fwGeometry->idToName[rawid].topology[2] = topo->pitch(); \
58 else if( dynamic_cast<const TrapezoidalStripTopology*>( topo )) \
60 m_fwGeometry->idToName[rawid].topology[2] = topo->pitch(); \
75 TGeoCombiTrans* createPlacement(
const GeomDet *det )
82 TGeoTranslation
trans( posx, posy, posz );
89 const Double_t
matrix[9] = { detRot.
xx(), detRot.
yx(), detRot.
zx(),
90 detRot.
xy(), detRot.
yy(), detRot.
zy(),
91 detRot.
xz(), detRot.
yz(), detRot.
zz()
93 rotation.SetMatrix( matrix );
95 return new TGeoCombiTrans(
trans, rotation );
99 boost::shared_ptr<FWTGeoRecoGeometry>
113 TGeoManager *
geom =
new TGeoManager(
"cmsGeo",
"CMS Detector" );
115 if( 0 == gGeoIdentity )
117 gGeoIdentity =
new TGeoIdentity(
"Identity" );
123 TGeoMaterial *matVacuum =
new TGeoMaterial(
"Vacuum", 0 ,0 ,0 );
125 TGeoMedium *vacuum =
new TGeoMedium(
"Vacuum", 1, matVacuum );
126 TGeoVolume *
top =
geom->MakeBox(
"CMS", vacuum, 270., 270., 120. );
130 return boost::shared_ptr<FWTGeoRecoGeometry>();
134 top->SetVisibility( kFALSE );
135 top->SetLineColor( kBlue );
149 geom->CloseGeometry();
163 TGeoShape* shape = 0;
170 std::array< const float, 4 >
const & par = b2->
parameters ();
173 float hBottomEdge = par [0];
174 float hTopEdge = par [1];
175 float thickness = par [2];
176 float apothem = par [3];
180 << hBottomEdge <<
"_"
191 shape =
new TGeoTrap(
208 if( dynamic_cast<const RectangularPlaneBounds *> (b) != 0 )
227 shape =
new TGeoBBox( name.c_str(), width / 2., length / 2., thickness / 2. );
247 medium =
new TGeoMedium( material.c_str(), 0,
createMaterial( material ));
252 volume =
new TGeoVolume( name.c_str(),
271 material =
new TGeoMaterial( name.c_str(),
282 std::stringstream outs;
283 outs << volume->GetName() <<
"_" << volume->GetNumber() <<
"/"
284 << name <<
"_" <<
copy;
292 TGeoVolume *assembly =
new TGeoVolumeAssembly( iName.c_str());
294 throw cms::Exception(
"FatalError" ) <<
"Cannnot find CSCGeometry\n";
297 for(
auto it = cscGeom.begin(), itEnd = cscGeom.end(); it != itEnd; ++it )
299 if(
auto chamber = dynamic_cast<const CSCChamber*>(*it))
301 unsigned int rawid = chamber->geographicalId();
307 assembly->AddNode( child, copy, createPlacement( chamber ));
308 child->SetLineColor( kBlue );
311 p <<
path( top, iName, copy ) <<
"/" << name <<
"_" <<
copy;
314 else if(
auto * layer = dynamic_cast<const CSCLayer*>(*it))
316 unsigned int rawid = layer->geographicalId();
322 assembly->AddNode( child, copy, createPlacement( layer ));
323 child->SetLineColor( kBlue );
326 p <<
path( top, iName, copy ) <<
"/" << name <<
"_" <<
copy;
337 const CSCWireTopology* wireTopology = layer->geometry()->wireTopology();
343 top->AddNode( assembly, copy );
352 TGeoVolume *assembly =
new TGeoVolumeAssembly( iName.c_str());
354 for(
auto it = dtChamberGeom.begin(),
355 end = dtChamberGeom.end();
358 if(
auto chamber = dynamic_cast< const DTChamber *>(*it))
360 unsigned int rawid = chamber->geographicalId().rawId();
366 assembly->AddNode( child, copy, createPlacement( chamber ));
367 child->SetLineColor( kRed );
370 p <<
path( top, iName, copy ) <<
"/" << name <<
"_" <<
copy;
374 top->AddNode( assembly, copy );
378 for(
auto it = dtSuperLayerGeom.begin(),
379 end = dtSuperLayerGeom.end();
382 if(
auto * superlayer = dynamic_cast<const DTSuperLayer*>(*it))
384 unsigned int rawid = superlayer->id().rawId();
390 assembly->AddNode( child, copy, createPlacement( superlayer ));
391 child->SetLineColor( kBlue );
394 p <<
path( top, iName, copy ) <<
"/" << name <<
"_" <<
copy;
397 const BoundPlane& surf = superlayer->surface();
399 m_fwGeometry->idToName[rawid].topology[0] = surf.bounds().width();
400 m_fwGeometry->idToName[rawid].topology[1] = surf.bounds().thickness();
401 m_fwGeometry->idToName[rawid].topology[2] = surf.bounds().length();
407 for(
auto it = dtLayerGeom.begin(),
408 end = dtLayerGeom.end();
411 if(
auto layer = dynamic_cast<const DTLayer*>(*it))
413 unsigned int rawid = layer->id().rawId();
419 assembly->AddNode( child, copy, createPlacement( layer ));
420 child->SetLineColor( kBlue );
423 p <<
path( top, iName, copy ) <<
"/" << name <<
"_" <<
copy;
426 const DTTopology& topo = layer->specificTopology();
437 m_fwGeometry->idToName[rawid].topology[6] = surf.bounds().width();
438 m_fwGeometry->idToName[rawid].topology[7] = surf.bounds().thickness();
439 m_fwGeometry->idToName[rawid].topology[8] = surf.bounds().length();
450 TGeoVolume *assembly =
new TGeoVolumeAssembly( iName.c_str());
453 for(
auto it = rpcGeom->
rolls().begin(),
466 assembly->AddNode( child, copy, createPlacement( roll ));
467 child->SetLineColor( kYellow );
470 p <<
path( top, iName, copy ) <<
"/" << name <<
"_" <<
copy;
479 top->AddNode( assembly, copy );
485 TGeoVolume *assembly =
new TGeoVolumeAssembly( iName.c_str());
491 unsigned int rawid = detid.
rawId();
498 assembly->AddNode( child, copy, createPlacement( *it ));
499 child->SetLineColor( kGreen );
502 p <<
path( top, iName, copy ) <<
"/" << name <<
"_" <<
copy;
508 top->AddNode( assembly, copy );
514 TGeoVolume *assembly =
new TGeoVolumeAssembly( iName.c_str());
520 unsigned int rawid = detid.
rawId();
527 assembly->AddNode( child, copy, createPlacement( *it ));
528 child->SetLineColor( kGreen );
531 p <<
path( top, iName, copy ) <<
"/" << name <<
"_" <<
copy;
537 top->AddNode( assembly, copy );
543 TGeoVolume *assembly =
new TGeoVolumeAssembly( iName.c_str());
549 unsigned int rawid = detid.
rawId();
555 assembly->AddNode( child, copy, createPlacement( *it ));
556 child->SetLineColor( kGreen );
559 p <<
path( top, iName, copy ) <<
"/" << name <<
"_" <<
copy;
565 top->AddNode( assembly, copy );
571 TGeoVolume *assembly =
new TGeoVolumeAssembly( iName.c_str());
577 unsigned int rawid = detid.
rawId();
584 assembly->AddNode( child, copy, createPlacement( *it ));
585 child->SetLineColor( kGreen );
588 p <<
path( top, iName, copy ) <<
"/" << name <<
"_" <<
copy;
594 top->AddNode( assembly, copy );
600 TGeoVolume *assembly =
new TGeoVolumeAssembly( iName.c_str());
606 unsigned int rawid = detid.
rawId();
613 assembly->AddNode( child, copy, createPlacement( *it ));
614 child->SetLineColor( kGreen );
617 p <<
path( top, iName, copy ) <<
"/" << name <<
"_" <<
copy;
623 top->AddNode( assembly, copy );
629 TGeoVolume *assembly =
new TGeoVolumeAssembly( iName.c_str());
635 unsigned int rawid = detid.
rawId();
642 assembly->AddNode( child, copy, createPlacement( *it ));
643 child->SetLineColor( kGreen );
646 p <<
path( top, iName, copy ) <<
"/" << name <<
"_" <<
copy;
652 top->AddNode( assembly, copy );
658 std::vector<DetId> vid =
m_caloGeom->getValidDetIds();
659 for( std::vector<DetId>::const_iterator it = vid.begin(),
664 m_fwGeometry->idToName[ it->rawId()].fillPoints( cor.begin(), cor.end());
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
float yCentreOfStripPlane() const
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)
void addTOBGeometry(TGeoVolume *top, const std::string &name="TOB", int copy=1)
float cellWidth() const
Returns the cell width.
const Bounds & bounds() const
TGeoVolume * createVolume(const std::string &name, const GeomDet *det, const std::string &matname="Air")
double wireSpacing() const
const StripTopology & specificTopology() const
void addDTGeometry(TGeoVolume *top, const std::string &name="DT", int copy=1)
const Plane & surface() const
The nominal surface of the GeomDet.
void addTIDGeometry(TGeoVolume *top, const std::string &name="TID", int copy=1)
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
#define ADD_SISTRIP_TOPOLOGY(rawid, detUnit)
int firstChannel() const
Returns the wire number of the first wire.
uint32_t rawId() const
get the raw id
virtual float thickness() const =0
const DepRecordT & getRecord() const
int lastChannel() const
Returns the wire number of the last wire.
virtual float stripLength() const =0
const DetContainer & detsTEC() const
void addRPCGeometry(TGeoVolume *top, const std::string &name="RPC", int copy=1)
void addCSCGeometry(TGeoVolume *top, const std::string &name="CSC", int copy=1)
std::map< std::string, TGeoShape * > m_nameToShape
float yAxisOrientation() const
void addCaloGeometry(void)
const DetContainer & detsPXB() const
DetId geographicalId() const
The label of this GeomDet.
float centreToIntersection() const
float phiOfOneEdge() const
float cellHeight() const
Returns the cell height.
float angularWidth() const
virtual const GeomDet * idToDet(DetId) const
void addPixelBarrelGeometry(TGeoVolume *top, const std::string &name="PixelBarrel", int copy=1)
const DetContainer & detsTIB() const
void addTIBGeometry(TGeoVolume *top, const std::string &name="TIB", int copy=1)
std::map< std::string, TGeoVolume * > m_nameToVolume
virtual float stripOffset(void) const
int channels() const
Returns the number of wires in the layer.
#define ADD_PIXEL_TOPOLOGY(rawid, detUnit)
boost::shared_ptr< FWTGeoRecoGeometry > produce(const FWTGeoRecoGeometryRecord &)
boost::shared_ptr< FWTGeoRecoGeometry > m_fwGeometry
virtual const GeomDetUnit * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
void addPixelForwardGeometry(TGeoVolume *top, const std::string &name="PixelForward", int copy=1)
FWTGeoRecoGeometryESProducer(const edm::ParameterSet &)
virtual float pitch() const =0
const DetContainer & detsPXF() const
const DetContainer & detsTOB() const
const RotationType & rotation() const
void addTECGeometry(TGeoVolume *top, const std::string &name="TEC", int copy=1)
TGeoMaterial * createMaterial(const std::string &name)
std::map< std::string, TGeoMaterial * > m_nameToMaterial
virtual float width() const =0
const std::string path(TGeoVolume *top, const std::string &name, int copy)
const PositionType & position() const
const DetContainer & detsTID() const