CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/Fireworks/Geometry/src/FWTGeoRecoGeometryESProducer.cc

Go to the documentation of this file.
00001 #include "Fireworks/Geometry/interface/FWTGeoRecoGeometryESProducer.h"
00002 #include "Fireworks/Geometry/interface/FWTGeoRecoGeometry.h"
00003 #include "Fireworks/Geometry/interface/FWTGeoRecoGeometryRecord.h"
00004 
00005 #include "DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h"
00006 #include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h"
00007 #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
00008 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00009 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00010 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
00011 #include "Geometry/DTGeometry/interface/DTGeometry.h"
00012 #include "Geometry/CSCGeometry/interface/CSCChamber.h"
00013 #include "Geometry/CSCGeometry/interface/CSCLayer.h"
00014 #include "Geometry/DTGeometry/interface/DTChamber.h"
00015 #include "Geometry/DTGeometry/interface/DTLayer.h"
00016 #include "Geometry/RPCGeometry/interface/RPCGeometry.h"
00017 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00018 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00019 #include "Geometry/TrackerGeometryBuilder/interface/RectangularPixelTopology.h"
00020 #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h"
00021 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
00022 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetType.h"
00023 #include "Geometry/CommonTopologies/interface/StripTopology.h"
00024 #include "Geometry/CommonTopologies/interface/RectangularStripTopology.h"
00025 #include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h"
00026 
00027 #include "TGeoManager.h"
00028 #include "TGeoArb8.h"
00029 #include "TGeoMatrix.h"
00030 #include "TFile.h"
00031 #include "TTree.h"
00032 #include "TError.h"
00033 
00034 # define ADD_PIXEL_TOPOLOGY( rawid, detUnit )                   \
00035   const PixelGeomDetUnit* det = dynamic_cast<const PixelGeomDetUnit*>( detUnit ); \
00036   if( det )                                                     \
00037   {                                                             \
00038     const PixelTopology& topo = det->specificTopology();        \
00039     m_fwGeometry->idToName[rawid].topology[0] = topo.nrows();   \
00040     m_fwGeometry->idToName[rawid].topology[1] = topo.ncolumns(); \
00041   }                                                             \
00042 
00043 # define ADD_SISTRIP_TOPOLOGY( rawid, detUnit )                 \
00044   const StripGeomDetUnit* det = dynamic_cast<const StripGeomDetUnit*>( detUnit ); \
00045   if( det )                                                     \
00046   {                                                             \
00047     const StripTopology* topo = dynamic_cast<const StripTopology*>( &det->specificTopology()); \
00048     m_fwGeometry->idToName[rawid].topology[0] = topo->nstrips();            \
00049     m_fwGeometry->idToName[rawid].topology[1] = topo->stripLength();        \
00050     if( const RadialStripTopology* rtop = dynamic_cast<const RadialStripTopology*>( topo )) \
00051     {                                                                   \
00052       m_fwGeometry->idToName[rawid].topology[2] = rtop->phiPitch();     \
00053     }                                                                   \
00054     else if( dynamic_cast<const RectangularStripTopology*>( topo ))     \
00055     {                                                                   \
00056       m_fwGeometry->idToName[rawid].topology[2] = topo->pitch();        \
00057     }                                                                   \
00058     else if( dynamic_cast<const TrapezoidalStripTopology*>( topo ))     \
00059     {                                                                   \
00060       m_fwGeometry->idToName[rawid].topology[2] = topo->pitch();        \
00061     }                                                                   \
00062 }                                                                       \
00063 
00064 FWTGeoRecoGeometryESProducer::FWTGeoRecoGeometryESProducer( const edm::ParameterSet& /*pset*/ )
00065 {
00066   setWhatProduced( this );
00067 }
00068 
00069 FWTGeoRecoGeometryESProducer::~FWTGeoRecoGeometryESProducer( void )
00070 {}
00071 
00072 namespace
00073 {
00075   TGeoCombiTrans* createPlacement( const GeomDet *det )
00076   {
00077     // Position of the DetUnit's center
00078     float posx = det->surface().position().x();
00079     float posy = det->surface().position().y();
00080     float posz = det->surface().position().z();
00081 
00082     TGeoTranslation trans( posx, posy, posz );
00083 
00084     // Add the coeff of the rotation matrix
00085     // with a projection on the basis vectors
00086     TkRotation<float> detRot = det->surface().rotation();
00087 
00088     TGeoRotation rotation;
00089     const Double_t matrix[9] = { detRot.xx(), detRot.yx(), detRot.zx(),
00090                                  detRot.xy(), detRot.yy(), detRot.zy(),
00091                                  detRot.xz(), detRot.yz(), detRot.zz() 
00092     };
00093     rotation.SetMatrix( matrix );
00094      
00095     return new TGeoCombiTrans( trans, rotation );
00096   }
00097 }
00098 
00099 boost::shared_ptr<FWTGeoRecoGeometry> 
00100 FWTGeoRecoGeometryESProducer::produce( const FWTGeoRecoGeometryRecord& record )
00101 {
00102   using namespace edm;
00103 
00104   m_fwGeometry =  boost::shared_ptr<FWTGeoRecoGeometry>( new FWTGeoRecoGeometry );
00105 
00106   record.getRecord<GlobalTrackingGeometryRecord>().get( m_geomRecord );
00107   
00108   DetId detId( DetId::Tracker, 0 );
00109   m_trackerGeom = (const TrackerGeometry*) m_geomRecord->slaveGeometry( detId );
00110   
00111   record.getRecord<CaloGeometryRecord>().get( m_caloGeom );
00112 
00113   TGeoManager *geom = new TGeoManager( "cmsGeo", "CMS Detector" );
00114   // NOTE: The default constructor does not create an identity matrix
00115   if( 0 == gGeoIdentity )
00116   {
00117     gGeoIdentity = new TGeoIdentity( "Identity" );
00118   }
00119 
00120   m_fwGeometry->manager( geom );
00121   
00122   // Default material is Vacuum
00123   TGeoMaterial *matVacuum = new TGeoMaterial( "Vacuum", 0 ,0 ,0 );
00124   // so is default medium
00125   TGeoMedium *vacuum = new TGeoMedium( "Vacuum", 1, matVacuum );
00126   TGeoVolume *top = geom->MakeBox( "CMS", vacuum, 270., 270., 120. );
00127   
00128   if( 0 == top )
00129   {
00130     return boost::shared_ptr<FWTGeoRecoGeometry>();
00131   }
00132   geom->SetTopVolume( top );
00133   // ROOT chokes unless colors are assigned
00134   top->SetVisibility( kFALSE );
00135   top->SetLineColor( kBlue );
00136 
00137   addPixelBarrelGeometry( top );
00138   addPixelForwardGeometry( top );
00139   addTIBGeometry( top );
00140   addTIDGeometry( top );
00141   addTOBGeometry( top );
00142   addTECGeometry( top );
00143   addDTGeometry( top );
00144   addCSCGeometry( top );
00145   addRPCGeometry( top );
00146 
00147   addCaloGeometry();
00148   
00149   geom->CloseGeometry();
00150   geom->DefaultColors();
00151 
00152   m_nameToShape.clear();
00153   m_nameToVolume.clear();
00154   m_nameToMaterial.clear();
00155   m_nameToMedium.clear();
00156 
00157   return m_fwGeometry;
00158 }
00159 
00161 TGeoShape* 
00162 FWTGeoRecoGeometryESProducer::createShape( const GeomDet *det )
00163 {
00164   TGeoShape* shape = 0;
00165 
00166   // Trapezoidal
00167   const Bounds *b = &((det->surface ()).bounds ());
00168   const TrapezoidalPlaneBounds *b2 = dynamic_cast<const TrapezoidalPlaneBounds *> (b);
00169   if( b2 )
00170   {
00171     std::vector< float > par = b2->parameters ();
00172     
00173     // These parameters are half-lengths, as in CMSIM/GEANT3
00174     float hBottomEdge = par [0];
00175     float hTopEdge    = par [1];
00176     float thickness   = par [2];
00177     float apothem     = par [3];
00178 
00179     std::stringstream s;
00180     s << "T_"
00181       << hBottomEdge << "_"
00182       << hTopEdge << "_"
00183       << thickness << "_"
00184       << apothem;
00185     std::string name = s.str();
00186 
00187     // Do not create identical shape,
00188     // if one already exists
00189     shape = m_nameToShape[name];
00190     if( 0 == shape )
00191     {
00192       shape = new TGeoTrap(
00193         name.c_str(),
00194         thickness,  //dz
00195         0,          //theta
00196         0,          //phi
00197         apothem,    //dy1
00198         hBottomEdge,//dx1
00199         hTopEdge,   //dx2
00200         0,          //alpha1
00201         apothem,    //dy2
00202         hBottomEdge,//dx3
00203         hTopEdge,   //dx4
00204         0);         //alpha2
00205 
00206       m_nameToShape[name] = shape;
00207     }
00208   }
00209   if( dynamic_cast<const RectangularPlaneBounds *> (b) != 0 )
00210   {
00211     // Rectangular
00212     float length = det->surface().bounds().length();
00213     float width = det->surface().bounds ().width();
00214     float thickness = det->surface().bounds().thickness();
00215 
00216     std::stringstream s;
00217     s << "R_"
00218       << width << "_"
00219       << length << "_"
00220       << thickness;
00221     std::string name = s.str();
00222 
00223     // Do not create identical shape,
00224     // if one already exists
00225     shape = m_nameToShape[name];
00226     if( 0 == shape )
00227     {
00228       shape = new TGeoBBox( name.c_str(), width / 2., length / 2., thickness / 2. ); // dx, dy, dz
00229 
00230       m_nameToShape[name] = shape;
00231     }
00232   }
00233   
00234   return shape;
00235 }
00236 
00238 TGeoVolume* 
00239 FWTGeoRecoGeometryESProducer::createVolume( const std::string& name, const GeomDet *det, const std::string& material )
00240 {
00241   TGeoVolume* volume = m_nameToVolume[name];
00242   if( 0 == volume )
00243   { 
00244     TGeoShape* solid = createShape( det );
00245     TGeoMedium* medium = m_nameToMedium[material];
00246     if( 0 == medium )
00247     {
00248       medium = new TGeoMedium( material.c_str(), 0, createMaterial( material ));
00249       m_nameToMedium[material] = medium;
00250     }
00251     if( solid )
00252     {
00253       volume = new TGeoVolume( name.c_str(),
00254                                solid,
00255                                medium );
00256       m_nameToVolume[name] = volume;
00257     }
00258   }  
00259   
00260   return volume;
00261 }
00262 
00264 TGeoMaterial*
00265 FWTGeoRecoGeometryESProducer::createMaterial( const std::string& name )
00266 {
00267   TGeoMaterial *material = m_nameToMaterial[name];
00268 
00269   if( material == 0 )
00270   {
00271     // FIXME: Do we need to set real parameters of the material?
00272     material = new TGeoMaterial( name.c_str(),
00273                                  0, 0, 0 );
00274     m_nameToMaterial[name] = material;
00275   }
00276 
00277   return material;
00278 }
00279 
00280 const std::string
00281 FWTGeoRecoGeometryESProducer::path( TGeoVolume* volume, const std::string& name, int copy )
00282 {
00283   std::stringstream outs;
00284   outs << volume->GetName() << "_" << volume->GetNumber() << "/"
00285        << name << "_" << copy;
00286 
00287   return outs.str();
00288 }
00289 
00290 void
00291 FWTGeoRecoGeometryESProducer::addCSCGeometry( TGeoVolume* top, const std::string& iName, int copy )
00292 {
00293   TGeoVolume *assembly = new TGeoVolumeAssembly( iName.c_str());
00294   if(! m_geomRecord->slaveGeometry( CSCDetId()))
00295     throw cms::Exception( "FatalError" ) << "Cannnot find CSCGeometry\n";
00296 
00297   const std::vector<GeomDet*>& cscGeom = m_geomRecord->slaveGeometry( CSCDetId())->dets();
00298   for( std::vector<GeomDet*>::const_iterator it = cscGeom.begin(), itEnd = cscGeom.end(); it != itEnd; ++it )
00299   {    
00300     if( CSCChamber* chamber = dynamic_cast<CSCChamber*>(*it))
00301     {
00302       unsigned int rawid = chamber->geographicalId();
00303       std::stringstream s;
00304       s << rawid;
00305       std::string name = s.str();
00306       
00307       TGeoVolume* child = createVolume( name, chamber );
00308       assembly->AddNode( child, copy, createPlacement( chamber ));
00309       child->SetLineColor( kBlue );
00310 
00311       std::stringstream p;
00312       p << path( top, iName, copy ) << "/" << name << "_" << copy;
00313       m_fwGeometry->idToName.insert( std::pair<unsigned int, FWTGeoRecoGeometry::Info>( rawid, FWTGeoRecoGeometry::Info( p.str())));
00314     }
00315     else if( CSCLayer* layer = dynamic_cast<CSCLayer*>(*it))
00316     {
00317       unsigned int rawid = layer->geographicalId();
00318       std::stringstream s;
00319       s << rawid;
00320       std::string name = s.str();
00321       
00322       TGeoVolume* child = createVolume( name, layer );
00323       assembly->AddNode( child, copy, createPlacement( layer ));
00324       child->SetLineColor( kBlue );
00325       
00326       std::stringstream p;
00327       p << path( top, iName, copy ) << "/" << name << "_" << copy;
00328       m_fwGeometry->idToName.insert( std::pair<unsigned int, FWTGeoRecoGeometry::Info>( rawid, FWTGeoRecoGeometry::Info( p.str())));
00329 
00330       const CSCStripTopology* stripTopology = layer->geometry()->topology();
00331       m_fwGeometry->idToName[rawid].topology[0] = stripTopology->yAxisOrientation();
00332       m_fwGeometry->idToName[rawid].topology[1] = stripTopology->centreToIntersection();
00333       m_fwGeometry->idToName[rawid].topology[2] = stripTopology->yCentreOfStripPlane();
00334       m_fwGeometry->idToName[rawid].topology[3] = stripTopology->phiOfOneEdge();
00335       m_fwGeometry->idToName[rawid].topology[4] = stripTopology->stripOffset();
00336       m_fwGeometry->idToName[rawid].topology[5] = stripTopology->angularWidth();
00337 
00338       const CSCWireTopology* wireTopology = layer->geometry()->wireTopology();
00339       m_fwGeometry->idToName[rawid].topology[6] = wireTopology->wireSpacing();
00340       m_fwGeometry->idToName[rawid].topology[7] = wireTopology->wireAngle();
00341     }
00342   }
00343 
00344   top->AddNode( assembly, copy );
00345 }
00346 
00347 void
00348 FWTGeoRecoGeometryESProducer::addDTGeometry( TGeoVolume* top, const std::string& iName, int copy )
00349 {
00350   //
00351   // DT chambers geometry
00352   //
00353   TGeoVolume *assembly = new TGeoVolumeAssembly( iName.c_str());
00354   const std::vector<GeomDet*>& dtChamberGeom = m_geomRecord->slaveGeometry( DTChamberId())->dets();
00355   for( std::vector<GeomDet*>::const_iterator it = dtChamberGeom.begin(),
00356                                              end = dtChamberGeom.end(); 
00357        it != end; ++it )
00358   {
00359     if( DTChamber* chamber = dynamic_cast< DTChamber *>(*it))
00360     {      
00361       unsigned int rawid = chamber->geographicalId().rawId();
00362       std::stringstream s;
00363       s << rawid;
00364       std::string name = s.str();
00365       
00366       TGeoVolume* child = createVolume( name, chamber );
00367       assembly->AddNode( child, copy, createPlacement( chamber ));
00368       child->SetLineColor( kRed );
00369       
00370       std::stringstream p;
00371       p << path( top, iName, copy ) << "/" << name << "_" << copy;
00372       m_fwGeometry->idToName.insert( std::pair<unsigned int, FWTGeoRecoGeometry::Info>( rawid, FWTGeoRecoGeometry::Info( p.str())));
00373     }
00374   }
00375   top->AddNode( assembly, copy );
00376 
00377   // Fill in DT super layer parameters
00378   const std::vector<GeomDet*>& dtSuperLayerGeom = m_geomRecord->slaveGeometry( DTLayerId())->dets();
00379   for( std::vector<GeomDet*>::const_iterator it = dtSuperLayerGeom.begin(),
00380                                             end = dtSuperLayerGeom.end(); 
00381        it != end; ++it )
00382   {
00383     if( DTSuperLayer* superlayer = dynamic_cast<DTSuperLayer*>(*it))
00384     {
00385       unsigned int rawid = superlayer->id().rawId();
00386       std::stringstream s;
00387       s << rawid;
00388       std::string name = s.str();
00389       
00390       TGeoVolume* child = createVolume( name, superlayer );
00391       assembly->AddNode( child, copy, createPlacement( superlayer ));
00392       child->SetLineColor( kBlue );
00393       
00394       std::stringstream p;
00395       p << path( top, iName, copy ) << "/" << name << "_" << copy;
00396       m_fwGeometry->idToName.insert( std::pair<unsigned int, FWTGeoRecoGeometry::Info>( rawid, FWTGeoRecoGeometry::Info( p.str())));
00397 
00398       const BoundPlane& surf = superlayer->surface();
00399       // Bounds W/H/L:
00400       m_fwGeometry->idToName[rawid].topology[0] = surf.bounds().width();
00401       m_fwGeometry->idToName[rawid].topology[1] = surf.bounds().thickness();
00402       m_fwGeometry->idToName[rawid].topology[2] = surf.bounds().length();
00403     }
00404   }
00405 
00406   // Fill in DT layer parameters
00407   const std::vector<GeomDet*>& dtLayerGeom = m_geomRecord->slaveGeometry( DTSuperLayerId())->dets();
00408   for( std::vector<GeomDet*>::const_iterator it = dtLayerGeom.begin(),
00409                                             end = dtLayerGeom.end(); 
00410        it != end; ++it )
00411   {
00412     if( DTLayer* layer = dynamic_cast<DTLayer*>(*it))
00413     {
00414       unsigned int rawid = layer->id().rawId();
00415       std::stringstream s;
00416       s << rawid;
00417       std::string name = s.str();
00418       
00419       TGeoVolume* child = createVolume( name, layer );
00420       assembly->AddNode( child, copy, createPlacement( layer ));
00421       child->SetLineColor( kBlue );
00422       
00423       std::stringstream p;
00424       p << path( top, iName, copy ) << "/" << name << "_" << copy;
00425       m_fwGeometry->idToName.insert( std::pair<unsigned int, FWTGeoRecoGeometry::Info>( rawid, FWTGeoRecoGeometry::Info( p.str())));
00426 
00427       const DTTopology& topo = layer->specificTopology();
00428       const BoundPlane& surf = layer->surface();
00429       // Topology W/H/L:
00430       m_fwGeometry->idToName[rawid].topology[0] = topo.cellWidth();
00431       m_fwGeometry->idToName[rawid].topology[1] = topo.cellHeight();
00432       m_fwGeometry->idToName[rawid].topology[2] = topo.cellLenght();
00433       m_fwGeometry->idToName[rawid].topology[3] = topo.firstChannel();
00434       m_fwGeometry->idToName[rawid].topology[4] = topo.lastChannel();
00435       m_fwGeometry->idToName[rawid].topology[5] = topo.channels();
00436 
00437       // Bounds W/H/L:
00438       m_fwGeometry->idToName[rawid].topology[6] = surf.bounds().width();
00439       m_fwGeometry->idToName[rawid].topology[7] = surf.bounds().thickness();
00440       m_fwGeometry->idToName[rawid].topology[8] = surf.bounds().length();
00441     }
00442   }  
00443 }
00444 
00445 void
00446 FWTGeoRecoGeometryESProducer::addRPCGeometry( TGeoVolume* top, const std::string& iName, int copy )
00447 {
00448   //
00449   // RPC chambers geometry
00450   //
00451   TGeoVolume *assembly = new TGeoVolumeAssembly( iName.c_str());
00452   DetId detId( DetId::Muon, 3 );
00453   const RPCGeometry* rpcGeom = (const RPCGeometry*) m_geomRecord->slaveGeometry( detId );
00454   for( std::vector<RPCRoll *>::const_iterator it = rpcGeom->rolls().begin(),
00455                                              end = rpcGeom->rolls().end(); 
00456        it != end; ++it )
00457   {
00458     RPCRoll* roll = (*it);
00459     if( roll )
00460     {
00461       unsigned int rawid = roll->geographicalId().rawId();
00462       std::stringstream s;
00463       s << rawid;
00464       std::string name = s.str();
00465       
00466       TGeoVolume* child = createVolume( name, roll );
00467       assembly->AddNode( child, copy, createPlacement( roll ));
00468       child->SetLineColor( kYellow );
00469       
00470       std::stringstream p;
00471       p << path( top, iName, copy ) << "/" << name << "_" << copy;
00472       m_fwGeometry->idToName.insert( std::pair<unsigned int, FWTGeoRecoGeometry::Info>( rawid, FWTGeoRecoGeometry::Info( p.str())));
00473 
00474       const StripTopology& topo = roll->specificTopology();
00475       m_fwGeometry->idToName[rawid].topology[0] = roll->nstrips();
00476       m_fwGeometry->idToName[rawid].topology[1] = topo.stripLength();
00477       m_fwGeometry->idToName[rawid].topology[2] = topo.pitch();
00478     }
00479   }
00480   top->AddNode( assembly, copy );
00481 }
00482 
00483 void
00484 FWTGeoRecoGeometryESProducer::addPixelBarrelGeometry( TGeoVolume* top, const std::string& iName, int copy )
00485 {
00486   TGeoVolume *assembly = new TGeoVolumeAssembly( iName.c_str());
00487   for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsPXB().begin(),
00488                                                     end = m_trackerGeom->detsPXB().end();
00489        it != end; ++it)
00490   {
00491     DetId detid = ( *it )->geographicalId();
00492     unsigned int rawid = detid.rawId();
00493 
00494     std::stringstream s;
00495     s << rawid;
00496     std::string name = s.str();
00497 
00498     TGeoVolume* child = createVolume( name, *it );
00499     assembly->AddNode( child, copy, createPlacement( *it ));
00500     child->SetLineColor( kGreen );
00501 
00502     std::stringstream p;
00503     p << path( top, iName, copy ) << "/" << name << "_" << copy;
00504     m_fwGeometry->idToName.insert( std::pair<unsigned int, FWTGeoRecoGeometry::Info>( rawid, FWTGeoRecoGeometry::Info( p.str())));
00505 
00506     ADD_PIXEL_TOPOLOGY( rawid, m_trackerGeom->idToDetUnit( detid ));
00507   }
00508   
00509   top->AddNode( assembly, copy );
00510 }
00511 
00512 void
00513 FWTGeoRecoGeometryESProducer::addPixelForwardGeometry( TGeoVolume* top, const std::string& iName, int copy )
00514 {
00515   TGeoVolume *assembly = new TGeoVolumeAssembly( iName.c_str());
00516   for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsPXF().begin(),
00517                                                     end = m_trackerGeom->detsPXF().end();
00518        it != end; ++it )
00519   {
00520     DetId detid = ( *it )->geographicalId();
00521     unsigned int rawid = detid.rawId();
00522 
00523     std::stringstream s;
00524     s << rawid;
00525     std::string name = s.str();
00526 
00527     TGeoVolume* child = createVolume( name, *it );
00528     assembly->AddNode( child, copy, createPlacement( *it ));
00529     child->SetLineColor( kGreen );
00530 
00531     std::stringstream p;
00532     p << path( top, iName, copy ) << "/" << name << "_" << copy;
00533     m_fwGeometry->idToName.insert( std::pair<unsigned int, FWTGeoRecoGeometry::Info>( rawid, FWTGeoRecoGeometry::Info( p.str())));
00534     
00535     ADD_PIXEL_TOPOLOGY( rawid, m_trackerGeom->idToDetUnit( detid ));
00536   }
00537   
00538   top->AddNode( assembly, copy );
00539 }
00540 
00541 void
00542 FWTGeoRecoGeometryESProducer::addTIBGeometry( TGeoVolume* top, const std::string& iName, int copy ) 
00543 {
00544   TGeoVolume *assembly = new TGeoVolumeAssembly( iName.c_str());
00545   for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTIB().begin(),
00546                                                     end = m_trackerGeom->detsTIB().end();
00547        it != end; ++it )
00548   {
00549     DetId detid = ( *it )->geographicalId();
00550     unsigned int rawid = detid.rawId();
00551     std::stringstream s;
00552     s << rawid;
00553     std::string name = s.str();
00554 
00555     TGeoVolume* child = createVolume( name, *it );
00556     assembly->AddNode( child, copy, createPlacement( *it ));
00557     child->SetLineColor( kGreen );
00558 
00559     std::stringstream p;
00560     p << path( top, iName, copy ) << "/" << name << "_" << copy;
00561     m_fwGeometry->idToName.insert( std::pair<unsigned int, FWTGeoRecoGeometry::Info>( rawid, FWTGeoRecoGeometry::Info( p.str())));
00562 
00563     ADD_SISTRIP_TOPOLOGY( rawid, m_trackerGeom->idToDet( detid ));
00564   }
00565   
00566   top->AddNode( assembly, copy );
00567 }
00568 
00569 void
00570 FWTGeoRecoGeometryESProducer::addTOBGeometry( TGeoVolume* top, const std::string& iName, int copy )
00571 {
00572   TGeoVolume *assembly = new TGeoVolumeAssembly( iName.c_str());
00573   for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTOB().begin(),
00574                                                     end = m_trackerGeom->detsTOB().end();
00575        it != end; ++it )
00576   {
00577     DetId detid = ( *it )->geographicalId();
00578     unsigned int rawid = detid.rawId();
00579 
00580     std::stringstream s;
00581     s << rawid;
00582     std::string name = s.str();
00583 
00584     TGeoVolume* child = createVolume( name, *it );
00585     assembly->AddNode( child, copy, createPlacement( *it ));
00586     child->SetLineColor( kGreen );
00587 
00588     std::stringstream p;
00589     p << path( top, iName, copy ) << "/" << name << "_" << copy;
00590     m_fwGeometry->idToName.insert( std::pair<unsigned int, FWTGeoRecoGeometry::Info>( rawid, FWTGeoRecoGeometry::Info( p.str())));
00591 
00592     ADD_SISTRIP_TOPOLOGY( rawid, m_trackerGeom->idToDet( detid ));
00593   }
00594   
00595   top->AddNode( assembly, copy );
00596 }
00597 
00598 void
00599 FWTGeoRecoGeometryESProducer::addTIDGeometry( TGeoVolume* top, const std::string& iName, int copy )
00600 {
00601   TGeoVolume *assembly = new TGeoVolumeAssembly( iName.c_str());
00602   for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTID().begin(),
00603                                                     end = m_trackerGeom->detsTID().end();
00604        it != end; ++it)
00605   {
00606     DetId detid = ( *it )->geographicalId();
00607     unsigned int rawid = detid.rawId();
00608 
00609     std::stringstream s;
00610     s << rawid;
00611     std::string name = s.str();
00612 
00613     TGeoVolume* child = createVolume( name, *it );
00614     assembly->AddNode( child, copy, createPlacement( *it ));
00615     child->SetLineColor( kGreen );
00616 
00617     std::stringstream p;
00618     p << path( top, iName, copy ) << "/" << name << "_" << copy;
00619     m_fwGeometry->idToName.insert( std::pair<unsigned int, FWTGeoRecoGeometry::Info>( rawid, FWTGeoRecoGeometry::Info( p.str())));
00620 
00621     ADD_SISTRIP_TOPOLOGY( rawid, m_trackerGeom->idToDet( detid ));
00622   }
00623   
00624   top->AddNode( assembly, copy );
00625 }
00626 
00627 void
00628 FWTGeoRecoGeometryESProducer::addTECGeometry( TGeoVolume* top, const std::string& iName, int copy )
00629 {
00630   TGeoVolume *assembly = new TGeoVolumeAssembly( iName.c_str());
00631   for( TrackerGeometry::DetContainer::const_iterator it = m_trackerGeom->detsTEC().begin(),
00632                                                     end = m_trackerGeom->detsTEC().end();
00633        it != end; ++it )
00634   {
00635     DetId detid = ( *it )->geographicalId();
00636     unsigned int rawid = detid.rawId();
00637 
00638     std::stringstream s;
00639     s << rawid;
00640     std::string name = s.str();
00641 
00642     TGeoVolume* child = createVolume( name, *it );
00643     assembly->AddNode( child, copy, createPlacement( *it ));
00644     child->SetLineColor( kGreen );
00645 
00646     std::stringstream p;
00647     p << path( top, iName, copy ) << "/" << name << "_" << copy;
00648     m_fwGeometry->idToName.insert( std::pair<unsigned int, FWTGeoRecoGeometry::Info>( rawid, FWTGeoRecoGeometry::Info( p.str())));
00649 
00650     ADD_SISTRIP_TOPOLOGY( rawid, m_trackerGeom->idToDet( detid ));
00651   }
00652   
00653   top->AddNode( assembly, copy );
00654 }
00655 
00656 void
00657 FWTGeoRecoGeometryESProducer::addCaloGeometry( void )
00658 {
00659   std::vector<DetId> vid = m_caloGeom->getValidDetIds(); // Calo
00660   for( std::vector<DetId>::const_iterator it = vid.begin(),
00661                                          end = vid.end();
00662        it != end; ++it )
00663   {
00664     const CaloCellGeometry::CornersVec& cor( m_caloGeom->getGeometry( *it )->getCorners());
00665     m_fwGeometry->idToName[ it->rawId()].fillPoints( cor.begin(), cor.end());
00666   }
00667 }