Go to the documentation of this file.00001
00008 #include <Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h>
00009 #include <FWCore/Utilities/interface/Exception.h>
00010
00011 GlobalTrackingGeometry::GlobalTrackingGeometry(std::vector<const TrackingGeometry*>& geos)
00012 : theGeometries(geos)
00013 {}
00014
00015 GlobalTrackingGeometry::~GlobalTrackingGeometry()
00016 {}
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&
00055 GlobalTrackingGeometry::detTypes( void ) const
00056 {
00057 if ( ! theDetTypes.empty() ) return theDetTypes;
00058 for( std::vector<const TrackingGeometry*>::const_iterator geom = theGeometries.begin(), geomEnd = theGeometries.end();
00059 geom != geomEnd; ++geom )
00060 {
00061 if( *geom == 0 ) continue;
00062 DetTypeContainer detTypes(( *geom )->detTypes());
00063 if( detTypes.size() + theDetTypes.size() < theDetTypes.capacity()) theDetTypes.resize( detTypes.size() + theDetTypes.size());
00064 for( DetTypeContainer::const_iterator detType = detTypes.begin(), detTypeEnd = detTypes.end(); detType != detTypeEnd; ++detType )
00065 theDetTypes.push_back( *detType );
00066 }
00067 return theDetTypes;
00068 }
00069
00070 const TrackingGeometry::DetUnitContainer&
00071 GlobalTrackingGeometry::detUnits( void ) const
00072 {
00073 if( ! theDetUnits.empty()) return theDetUnits;
00074 for( std::vector<const TrackingGeometry*>::const_iterator geom = theGeometries.begin(), geomEnd = theGeometries.end();
00075 geom != geomEnd; ++geom )
00076 {
00077 if( *geom == 0 ) continue;
00078 DetUnitContainer detUnits(( *geom )->detUnits());
00079 if( detUnits.size() + theDetUnits.size() < theDetUnits.capacity()) theDetUnits.resize( detUnits.size() + theDetUnits.size());
00080 for( DetUnitContainer::const_iterator detUnit = detUnits.begin(), detUnitEnd = detUnits.end(); detUnit != detUnitEnd; ++detUnit )
00081 theDetUnits.push_back( *detUnit );
00082 }
00083 return theDetUnits;
00084 }
00085
00086 const TrackingGeometry::DetContainer&
00087 GlobalTrackingGeometry::dets( void ) const
00088 {
00089 if( ! theDets.empty()) return theDets;
00090 for( std::vector<const TrackingGeometry*>::const_iterator geom = theGeometries.begin(), geomEnd = theGeometries.end();
00091 geom != geomEnd; ++geom )
00092 {
00093 if( *geom == 0 ) continue;
00094 DetContainer dets(( *geom )->dets());
00095 if( dets.size() + theDets.size() < theDets.capacity()) theDets.resize( dets.size() + theDets.size());
00096 for( DetContainer::const_iterator det = dets.begin(), detEnd = dets.end(); det != detEnd; ++det )
00097 theDets.push_back( *det );
00098 }
00099 return theDets;
00100 }
00101
00102 const TrackingGeometry::DetIdContainer&
00103 GlobalTrackingGeometry::detUnitIds( void ) const
00104 {
00105 if( ! theDetUnitIds.empty()) return theDetUnitIds;
00106 for( std::vector<const TrackingGeometry*>::const_iterator geom = theGeometries.begin(), geomEnd = theGeometries.end();
00107 geom != geomEnd; ++geom )
00108 {
00109 if( *geom == 0 ) continue;
00110 DetIdContainer detUnitIds(( *geom )->detUnitIds());
00111 if( detUnitIds.size() + theDetUnitIds.size() < theDetUnitIds.capacity()) theDetUnitIds.resize( detUnitIds.size() + theDetUnitIds.size());
00112 for( DetIdContainer::const_iterator detUnitId = detUnitIds.begin(), detUnitIdEnd = detUnitIds.end(); detUnitId != detUnitIdEnd; ++detUnitId )
00113 theDetUnitIds.push_back( *detUnitId );
00114 }
00115 return theDetUnitIds;
00116 }
00117
00118 const TrackingGeometry::DetIdContainer&
00119 GlobalTrackingGeometry::detIds( void ) const
00120 {
00121 if( ! theDetIds.empty() ) return theDetIds;
00122 for( std::vector<const TrackingGeometry*>::const_iterator geom = theGeometries.begin(), geomEnd = theGeometries.end();
00123 geom != geomEnd; ++geom )
00124 {
00125 if( *geom == 0 ) continue;
00126 DetIdContainer detIds(( *geom )->detIds());
00127 if( detIds.size() + theDetIds.size() < theDetIds.capacity()) theDetIds.resize( detIds.size() + theDetIds.size());
00128 for( DetIdContainer::const_iterator detId = detIds.begin(), detIdEnd = detIds.end(); detId != detIdEnd; ++detId )
00129 theDetIds.push_back( *detId );
00130 }
00131 return theDetIds;
00132 }