CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/Geometry/DTGeometry/src/DTGeometry.cc

Go to the documentation of this file.
00001 
00008 #include <Geometry/DTGeometry/interface/DTGeometry.h>
00009 #include <Geometry/CommonDetUnit/interface/GeomDetUnit.h>
00010 
00011 #include <algorithm>
00012 #include <iostream>
00013 
00014 DTGeometry::DTGeometry() {}
00015 
00016 DTGeometry::~DTGeometry(){
00017   // delete all the chambers (which will delete the SL which will delete the
00018   // layers)
00019   for (std::vector<DTChamber*>::const_iterator ich=theChambers.begin();
00020        ich!=theChambers.end(); ++ich) delete (*ich);
00021 }
00022 
00023 const DTGeometry::DetTypeContainer&  DTGeometry::detTypes() const{
00024   static DetTypeContainer  theDetTypes;
00025   // FIXME - fill it at runtime
00026   return theDetTypes;
00027 }
00028 
00029 
00030 void DTGeometry::add(DTChamber* ch) {
00031   theDets.push_back(ch);
00032   theChambers.push_back(ch);
00033   theMap.insert(DTDetMap::value_type(ch->geographicalId(),ch));
00034 }
00035 
00036 
00037 void DTGeometry::add(DTSuperLayer* sl) {
00038   theDets.push_back(sl);
00039   theSuperLayers.push_back(sl);
00040   theMap.insert(DTDetMap::value_type(sl->geographicalId(),sl));
00041 }
00042 
00043 
00044 void DTGeometry::add(DTLayer* l) {
00045   theDetUnits.push_back(l);
00046   theDets.push_back(l);
00047   theLayers.push_back(l); 
00048   theMap.insert(DTDetMap::value_type(l->geographicalId(),l));
00049 }
00050 
00051 
00052 const DTGeometry::DetUnitContainer& DTGeometry::detUnits() const{
00053   return theDetUnits;
00054 }
00055 
00056 
00057 const DTGeometry::DetContainer& DTGeometry::dets() const{
00058   return theDets; 
00059 }
00060 
00061 
00062 const DTGeometry::DetIdContainer& DTGeometry::detUnitIds() const{
00063   static DetIdContainer    theDetUnitIds;
00064   // FIXME - fill it at runtime
00065   return theDetUnitIds;
00066 }
00067 
00068 
00069 const DTGeometry::DetIdContainer& DTGeometry::detIds() const{
00070   static DetIdContainer theDetIds;
00071   // FIXME - fill it at runtime
00072   return theDetIds;
00073 }
00074 
00075 
00076 const GeomDetUnit* DTGeometry::idToDetUnit(DetId id) const{
00077   return dynamic_cast<const GeomDetUnit*>(idToDet(id));
00078 }
00079 
00080 
00081 const GeomDet* DTGeometry::idToDet(DetId id) const{
00082   // Strip away wire#, if any!
00083   DTLayerId lId(id.rawId());
00084   DTDetMap::const_iterator i = theMap.find(lId);
00085   return (i != theMap.end()) ?
00086     i->second : 0 ;
00087 }
00088 
00089 
00090 const std::vector<DTChamber*>& DTGeometry::chambers() const{
00091   return theChambers;
00092 }
00093 
00094 
00095 const std::vector<DTSuperLayer*>& DTGeometry::superLayers() const{
00096   return theSuperLayers;
00097 }
00098 
00099 
00100 const std::vector<DTLayer*>& DTGeometry::layers() const{
00101   return theLayers;
00102 }
00103 
00104 
00105 const DTChamber* DTGeometry::chamber(DTChamberId id) const {
00106   return (const DTChamber*)(idToDet(id));
00107 }
00108 
00109 
00110 const DTSuperLayer* DTGeometry::superLayer(DTSuperLayerId id) const {
00111   return (const DTSuperLayer*)(idToDet(id));
00112 }
00113 
00114 
00115 const DTLayer* DTGeometry::layer(DTLayerId id) const {
00116   return (const DTLayer*)(idToDet(id));
00117 }