CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/Geometry/CommonDetUnit/src/GlobalTrackingGeometry.cc

Go to the documentation of this file.
00001 
00008 #include <Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h>
00009 #include <FWCore/MessageLogger/interface/MessageLogger.h>
00010 #include <FWCore/Utilities/interface/Exception.h>
00011 
00012 using namespace edm;
00013 
00014 GlobalTrackingGeometry::GlobalTrackingGeometry(std::vector<const TrackingGeometry*>& geos) : theGeometries(geos) {}
00015 
00016 GlobalTrackingGeometry::~GlobalTrackingGeometry() {}
00017 
00018 const GeomDetUnit* GlobalTrackingGeometry::idToDetUnit(DetId id) const {
00019     
00020     const TrackingGeometry* tg = slaveGeometry(id);
00021     
00022     if (tg != 0) {
00023       return tg->idToDetUnit(id);
00024     } else {
00025       return 0;
00026     }
00027 }
00028 
00029 
00030 const GeomDet* GlobalTrackingGeometry::idToDet(DetId id) const{
00031   
00032     const TrackingGeometry* tg = slaveGeometry(id);
00033     
00034     if (tg != 0) {
00035         return tg->idToDet(id);
00036     } else {
00037       return 0;
00038     }
00039 }
00040 
00041 const TrackingGeometry* GlobalTrackingGeometry::slaveGeometry(DetId id) const {  
00042   
00043     int idx = id.det()-1;
00044     if (id.det() == DetId::Muon) {
00045         
00046         idx+=id.subdetId()-1;
00047     }
00048 
00049     if (theGeometries[idx]==0) throw cms::Exception("NoGeometry") << "No Tracking Geometry is available for DetId " << id.rawId() << std::endl;
00050 
00051     return theGeometries[idx];
00052 }
00053 
00054 const TrackingGeometry::DetTypeContainer& GlobalTrackingGeometry::detTypes() const {
00055     
00056    static DetTypeContainer result;
00057    if ( ! result.empty() ) return result; 
00058    for(std::vector<const TrackingGeometry*>::const_iterator geom = theGeometries.begin();
00059        geom != theGeometries.end(); geom++)
00060      {
00061         if (*geom == 0) continue;
00062         DetTypeContainer detTypes((*geom)->detTypes());
00063         if ( detTypes.size()+result.size()<result.capacity() ) result.resize(detTypes.size()+result.size());
00064         for( DetTypeContainer::const_iterator detType = detTypes.begin(); detType!=detTypes.end(); detType++)
00065           result.push_back(*detType);
00066      }
00067    return result;
00068 }
00069 
00070 const TrackingGeometry::DetUnitContainer& GlobalTrackingGeometry::detUnits() const {
00071 
00072    static DetUnitContainer result;
00073    if ( ! result.empty() ) return result; 
00074    for(std::vector<const TrackingGeometry*>::const_iterator geom = theGeometries.begin();
00075        geom != theGeometries.end(); geom++)
00076      {
00077         if (*geom == 0) continue;
00078         DetUnitContainer detUnits((*geom)->detUnits());
00079         if ( detUnits.size()+result.size()<result.capacity() ) result.resize(detUnits.size()+result.size());
00080         for( DetUnitContainer::const_iterator detUnit = detUnits.begin(); detUnit!=detUnits.end(); detUnit++)
00081           result.push_back(*detUnit);
00082      }
00083    return result;
00084 }
00085 
00086 const TrackingGeometry::DetContainer& GlobalTrackingGeometry::dets() const {
00087 
00088    static DetContainer result;
00089    if ( ! result.empty() ) return result; 
00090    for(std::vector<const TrackingGeometry*>::const_iterator geom = theGeometries.begin();
00091        geom != theGeometries.end(); geom++)
00092      {
00093         if (*geom == 0) continue;
00094         DetContainer dets((*geom)->dets());
00095         if ( dets.size()+result.size()<result.capacity() ) result.resize(dets.size()+result.size());
00096         for( DetContainer::const_iterator det = dets.begin(); det!=dets.end(); det++)
00097           result.push_back(*det);
00098      }
00099    return result;
00100 }
00101 
00102 const TrackingGeometry::DetIdContainer& GlobalTrackingGeometry::detUnitIds() const {
00103 
00104    static DetIdContainer result;
00105    if ( ! result.empty() ) return result; 
00106    for(std::vector<const TrackingGeometry*>::const_iterator geom = theGeometries.begin();
00107        geom != theGeometries.end(); geom++)
00108      {
00109         if (*geom == 0) continue;
00110         DetIdContainer detUnitIds((*geom)->detUnitIds());
00111         if ( detUnitIds.size()+result.size()<result.capacity() ) result.resize(detUnitIds.size()+result.size());
00112         for( DetIdContainer::const_iterator detUnitId = detUnitIds.begin(); detUnitId!=detUnitIds.end(); detUnitId++)
00113           result.push_back(*detUnitId);
00114      }
00115    return result;
00116 }
00117 
00118 const TrackingGeometry::DetIdContainer& GlobalTrackingGeometry::detIds() const {
00119 
00120    static DetIdContainer result;
00121    if ( ! result.empty() ) return result; 
00122    for(std::vector<const TrackingGeometry*>::const_iterator geom = theGeometries.begin();
00123        geom != theGeometries.end(); geom++)
00124      {
00125         if (*geom == 0) continue;
00126         DetIdContainer detIds((*geom)->detIds());
00127         if ( detIds.size()+result.size()<result.capacity() ) result.resize(detIds.size()+result.size());
00128         for( DetIdContainer::const_iterator detId = detIds.begin(); detId!=detIds.end(); detId++)
00129           result.push_back(*detId);
00130      }
00131    return result;
00132 }