CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/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   theDetUnits.push_back(p);  // add to vector
00034   theMapUnit.insert(std::make_pair(p->geographicalId().rawId(),p));
00035 }
00036 
00037 void TrackerGeometry::addDetUnitId(DetId p){
00038   theDetUnitIds.push_back(p);
00039 }
00040 
00041 void TrackerGeometry::addDet(GeomDet* p) {
00042   theDets.push_back(p);  // add to vector
00043   theMap.insert(std::make_pair(p->geographicalId().rawId(),p));
00044   DetId id(p->geographicalId());
00045   switch(id.subdetId()){
00046   case PixelSubdetector::PixelBarrel:
00047     thePXBDets.push_back(p);
00048     break;
00049   case PixelSubdetector::PixelEndcap:
00050     thePXFDets.push_back(p);
00051     break;
00052   case StripSubdetector::TIB:
00053     theTIBDets.push_back(p);
00054     break;
00055   case StripSubdetector::TID:
00056     theTIDDets.push_back(p);
00057     break;
00058   case StripSubdetector::TOB:
00059     theTOBDets.push_back(p);
00060     break;
00061   case StripSubdetector::TEC:
00062     theTECDets.push_back(p);
00063     break;
00064   default:
00065     edm::LogError("TrackerGeometry")<<"ERROR - I was expecting a Tracker Subdetector, I got a "<<id.subdetId();
00066   }
00067 
00068 
00069 }
00070 
00071 void TrackerGeometry::addDetId(DetId p){
00072   theDetIds.push_back(p);
00073 }
00074 
00075 const TrackerGeometry::DetUnitContainer&
00076 TrackerGeometry::detUnits() const
00077 {
00078   return theDetUnits;
00079 }
00080 
00081 const TrackerGeometry::DetContainer&
00082 TrackerGeometry::dets() const
00083 {
00084   return theDets;
00085 }
00086 
00087 const TrackerGeometry::DetContainer&
00088 TrackerGeometry::detsPXB() const
00089 {
00090   return thePXBDets;
00091 }
00092 
00093 const TrackerGeometry::DetContainer&
00094 TrackerGeometry::detsPXF() const
00095 {
00096   return thePXFDets;
00097 }
00098 
00099 const TrackerGeometry::DetContainer&
00100 TrackerGeometry::detsTIB() const
00101 {
00102   return theTIBDets;
00103 }
00104 
00105 const TrackerGeometry::DetContainer&
00106 TrackerGeometry::detsTID() const
00107 {
00108   return theTIDDets;
00109 }
00110 
00111 const TrackerGeometry::DetContainer&
00112 TrackerGeometry::detsTOB() const
00113 {
00114   return theTOBDets;
00115 }
00116 
00117 const TrackerGeometry::DetContainer&
00118 TrackerGeometry::detsTEC() const
00119 {
00120   return theTECDets;
00121 }
00122 
00123 const GeomDetUnit* 
00124 TrackerGeometry::idToDetUnit(DetId s)const
00125 {
00126   mapIdToDetUnit::const_iterator p=theMapUnit.find(s.rawId());
00127   if (p != theMapUnit.end())
00128     return (p)->second;
00129   edm::LogError("TrackerGeometry")<<"Invalid DetID: no GeomDetUnit associated";
00130   GeomDetUnit* geom = 0;
00131   return geom;
00132 }
00133 
00134 const GeomDet* 
00135 TrackerGeometry::idToDet(DetId s)const
00136 {
00137   mapIdToDet::const_iterator p=theMap.find(s.rawId());
00138   if (p != theMap.end())
00139     return (p)->second;
00140   edm::LogError("TrackerGeometry")<<"Invalid DetID: no GeomDet associated";
00141   GeomDet* geom = 0;
00142   return geom;
00143 }
00144 
00145 const TrackerGeometry::DetTypeContainer&  
00146 TrackerGeometry::detTypes()   const 
00147 {
00148   return theDetTypes;
00149 }
00150 
00151 
00152 const TrackerGeometry::DetIdContainer&  
00153 TrackerGeometry::detUnitIds()   const 
00154 {
00155   return theDetUnitIds;
00156 }
00157 
00158 const TrackerGeometry::DetIdContainer&  
00159 TrackerGeometry::detIds()   const 
00160 {
00161   return theDetIds;
00162 }
00163 
00164