CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/Geometry/TrackerGeometryBuilder/src/TrackerGeometry.cc

Go to the documentation of this file.
00001 #include <typeinfo>
00002 
00003 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00004 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00005 #include "Geometry/CommonDetUnit/interface/GeomDetType.h"
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 
00008 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00009 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00010 #include "DataFormats/DetId/interface/DetId.h"
00011 
00012 #include <algorithm>
00013 #include <iostream>
00014 #include <map>
00015 
00016 TrackerGeometry::TrackerGeometry(GeometricDet const* gd) :  theTrackerDet(gd){}
00017 
00018 TrackerGeometry::~TrackerGeometry() {
00019     for (DetContainer::iterator     it = theDets.begin(),     ed = theDets.end();     it != ed; ++it) delete *it;
00020     for (DetTypeContainer::iterator it = theDetTypes.begin(), ed = theDetTypes.end(); it != ed; ++it) delete *it;
00021 }
00022 
00023 GeometricDet const * TrackerGeometry::trackerDet() const {
00024   return  theTrackerDet;
00025 }
00026 
00027 
00028 void TrackerGeometry::addType(GeomDetType* p) {
00029   theDetTypes.push_back(p);  // add to vector
00030 }
00031 
00032 void TrackerGeometry::addDetUnit(GeomDetUnit* p) {
00033   // set index
00034   p->setIndex(theDetUnits.size());
00035   theDetUnits.push_back(p);  // add to vector
00036   theMapUnit.insert(std::make_pair(p->geographicalId().rawId(),p));
00037 }
00038 
00039 void TrackerGeometry::addDetUnitId(DetId p){
00040   theDetUnitIds.push_back(p);
00041 }
00042 
00043 void TrackerGeometry::addDet(GeomDet* p) {
00044   theDets.push_back(p);  // add to vector
00045   theMap.insert(std::make_pair(p->geographicalId().rawId(),p));
00046   DetId id(p->geographicalId());
00047   switch(id.subdetId()){
00048   case PixelSubdetector::PixelBarrel:
00049     thePXBDets.push_back(p);
00050     break;
00051   case PixelSubdetector::PixelEndcap:
00052     thePXFDets.push_back(p);
00053     break;
00054   case StripSubdetector::TIB:
00055     theTIBDets.push_back(p);
00056     break;
00057   case StripSubdetector::TID:
00058     theTIDDets.push_back(p);
00059     break;
00060   case StripSubdetector::TOB:
00061     theTOBDets.push_back(p);
00062     break;
00063   case StripSubdetector::TEC:
00064     theTECDets.push_back(p);
00065     break;
00066   default:
00067     edm::LogError("TrackerGeometry")<<"ERROR - I was expecting a Tracker Subdetector, I got a "<<id.subdetId();
00068   }
00069 
00070 
00071 }
00072 
00073 void TrackerGeometry::addDetId(DetId p){
00074   theDetIds.push_back(p);
00075 }
00076 
00077 const TrackerGeometry::DetUnitContainer&
00078 TrackerGeometry::detUnits() const
00079 {
00080   return theDetUnits;
00081 }
00082 
00083 const TrackerGeometry::DetContainer&
00084 TrackerGeometry::dets() const
00085 {
00086   return theDets;
00087 }
00088 
00089 const TrackerGeometry::DetContainer&
00090 TrackerGeometry::detsPXB() const
00091 {
00092   return thePXBDets;
00093 }
00094 
00095 const TrackerGeometry::DetContainer&
00096 TrackerGeometry::detsPXF() const
00097 {
00098   return thePXFDets;
00099 }
00100 
00101 const TrackerGeometry::DetContainer&
00102 TrackerGeometry::detsTIB() const
00103 {
00104   return theTIBDets;
00105 }
00106 
00107 const TrackerGeometry::DetContainer&
00108 TrackerGeometry::detsTID() const
00109 {
00110   return theTIDDets;
00111 }
00112 
00113 const TrackerGeometry::DetContainer&
00114 TrackerGeometry::detsTOB() const
00115 {
00116   return theTOBDets;
00117 }
00118 
00119 const TrackerGeometry::DetContainer&
00120 TrackerGeometry::detsTEC() const
00121 {
00122   return theTECDets;
00123 }
00124 
00125 const GeomDetUnit* 
00126 TrackerGeometry::idToDetUnit(DetId s)const
00127 {
00128   mapIdToDetUnit::const_iterator p=theMapUnit.find(s.rawId());
00129   if (p != theMapUnit.end())
00130     return (p)->second;
00131   edm::LogError("TrackerGeometry")<<"Invalid DetID: no GeomDetUnit associated";
00132   GeomDetUnit* geom = 0;
00133   return geom;
00134 }
00135 
00136 const GeomDet* 
00137 TrackerGeometry::idToDet(DetId s)const
00138 {
00139   mapIdToDet::const_iterator p=theMap.find(s.rawId());
00140   if (p != theMap.end())
00141     return (p)->second;
00142   edm::LogError("TrackerGeometry")<<"Invalid DetID: no GeomDet associated";
00143   GeomDet* geom = 0;
00144   return geom;
00145 }
00146 
00147 const TrackerGeometry::DetTypeContainer&  
00148 TrackerGeometry::detTypes()   const 
00149 {
00150   return theDetTypes;
00151 }
00152 
00153 
00154 const TrackerGeometry::DetIdContainer&  
00155 TrackerGeometry::detUnitIds()   const 
00156 {
00157   return theDetUnitIds;
00158 }
00159 
00160 const TrackerGeometry::DetIdContainer&  
00161 TrackerGeometry::detIds()   const 
00162 {
00163   return theDetIds;
00164 }
00165 
00166