CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/DataFormats/TrackerCommon/src/TrackerTopology.cc

Go to the documentation of this file.
00001 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
00002 #include "FWCore/Utilities/interface/Exception.h"
00003 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00004 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00005 #include <sstream>
00006 
00007 TrackerTopology::TrackerTopology( const PixelBarrelValues& pxb, const PixelEndcapValues& pxf,
00008                                   const TECValues& tecv, const TIBValues& tibv, 
00009                                   const TIDValues& tidv, const TOBValues& tobv) {
00010   pbVals_=pxb;
00011   pfVals_=pxf;
00012   tecVals_=tecv;
00013   tibVals_=tibv;
00014   tidVals_=tidv;
00015   tobVals_=tobv;
00016 }
00017 
00018 
00019 
00020 unsigned int TrackerTopology::layer(const DetId &id) const {
00021   uint32_t subdet=id.subdetId();
00022   if ( subdet == PixelSubdetector::PixelBarrel )
00023     return pxbLayer(id);
00024   if ( subdet == PixelSubdetector::PixelEndcap )
00025     return pxfDisk(id);
00026   if ( subdet == StripSubdetector::TIB )
00027     return tibLayer(id);
00028   if ( subdet == StripSubdetector::TID )
00029     return tidWheel(id);
00030   if ( subdet == StripSubdetector::TOB )
00031     return tobLayer(id);
00032   if ( subdet == StripSubdetector::TEC )
00033     return tecWheel(id);
00034 
00035   throw cms::Exception("Invalid DetId") << "Unsupported DetId in TrackerTopology::layer";
00036   return 0;
00037 }
00038 
00039 unsigned int TrackerTopology::module(const DetId &id) const {
00040   uint32_t subdet=id.subdetId();
00041   if ( subdet == PixelSubdetector::PixelBarrel )
00042     return pxbModule(id);
00043   if ( subdet == PixelSubdetector::PixelEndcap )
00044     return pxfModule(id);
00045   if ( subdet == StripSubdetector::TIB )
00046     return tibModule(id);
00047   if ( subdet == StripSubdetector::TID )
00048     return tidModule(id);
00049   if ( subdet == StripSubdetector::TOB )
00050     return tobModule(id);
00051   if ( subdet == StripSubdetector::TEC )
00052     return tecModule(id);
00053 
00054   throw cms::Exception("Invalid DetId") << "Unsupported DetId in TrackerTopology::module";
00055   return 0;
00056 }
00057 
00058 std::string TrackerTopology::print(DetId id) const {
00059   uint32_t subdet=id.subdetId();
00060   std::stringstream strstr;
00061 
00062   if ( subdet == PixelSubdetector::PixelBarrel ) {
00063     strstr  << "(PixelBarrel " 
00064             << pxbLayer(id) << ',' 
00065             << pxbLadder(id) << ',' 
00066             << pxbModule(id) << ')'; 
00067     return strstr.str();
00068   }
00069 
00070   if ( subdet == PixelSubdetector::PixelEndcap ) {
00071     strstr << "(PixelEndcap " 
00072            << pxfDisk(id) << ',' 
00073            << pxfBlade(id)  << ',' 
00074            << pxfPanel(id)  << ',' 
00075            << pxfModule(id)   << ')'; 
00076     return strstr.str();
00077   }
00078 
00079   if ( subdet == StripSubdetector::TIB ) {
00080     unsigned int              theLayer  = tibLayer(id);
00081     std::vector<unsigned int> theString = tibStringInfo(id);
00082     unsigned int              theModule = tibModule(id);
00083     std::string side;
00084     std::string part;
00085     side = (theString[0] == 1 ) ? "-" : "+";
00086     part = (theString[1] == 1 ) ? "int" : "ext";
00087     std::string type;
00088     type = (tibStereo(id) == 0) ? "r-phi" : "stereo";
00089     type = (tibGlued(id) == 0) ? type : type+" glued";
00090     type = (tibIsDoubleSide(id)) ? "double side" : type;
00091     strstr << "TIB" << side
00092            << " Layer " << theLayer << " " << part
00093            << " String " << theString[2]
00094            << " Module " << theModule << " " << type
00095            << " (" << id.rawId() << ")";
00096     return strstr.str();
00097   }
00098 
00099   if ( subdet == StripSubdetector::TID ) {
00100     unsigned int         theDisk   = tidWheel(id);
00101     unsigned int         theRing   = tidRing(id);
00102     std::vector<unsigned int> theModule = tidModuleInfo(id);
00103     std::string side;
00104     std::string part;
00105     side = (tidSide(id) == 1 ) ? "-" : "+";
00106     part = (theModule[0] == 1 ) ? "back" : "front";
00107     std::string type;
00108     type = (tidStereo(id) == 0) ? "r-phi" : "stereo";
00109     type = (tidGlued(id) == 0) ? type : type+" glued";
00110     type = (tidIsDoubleSide(id)) ? "double side" : type;
00111     strstr << "TID" << side
00112            << " Disk " << theDisk
00113            << " Ring " << theRing << " " << part
00114            << " Module " << theModule[1] << " " << type
00115            << " (" << id.rawId() << ")";
00116     return strstr.str();
00117   }
00118 
00119   if ( subdet == StripSubdetector::TOB ) {
00120     unsigned int              theLayer  = tobLayer(id);
00121     std::vector<unsigned int> theRod    = tobRodInfo(id);
00122     unsigned int              theModule = tobModule(id);
00123     std::string side;
00124     std::string part;
00125     side = (theRod[0] == 1 ) ? "-" : "+";
00126     std::string type;
00127     type = (tobStereo(id) == 0) ? "r-phi" : "stereo";
00128     type = (tobGlued(id) == 0) ? type : type+" glued";
00129     type = (tobIsDoubleSide(id)) ? "double side" : type;
00130     strstr << "TOB" << side
00131            << " Layer " << theLayer
00132            << " Rod " << theRod[1]
00133            << " Module " << theModule << " " << type
00134            << " (" << id.rawId() << ")";
00135     return strstr.str();
00136   }
00137 
00138   if ( subdet == StripSubdetector::TEC ) {
00139     unsigned int              theWheel  = tecWheel(id);
00140     unsigned int              theModule = tecModule(id);
00141     std::vector<unsigned int> thePetal  = tecPetalInfo(id);
00142     unsigned int              theRing   = tecRing(id);
00143     std::string side;
00144     std::string petal;
00145     side  = (tecSide(id) == 1 ) ? "-" : "+";
00146     petal = (thePetal[0] == 1 ) ? "back" : "front";
00147     std::string type;
00148     type = (tecStereo(id) == 0) ? "r-phi" : "stereo";
00149     type = (tecGlued(id) == 0) ? type : type+" glued";
00150     type = (tecIsDoubleSide(id)) ? "double side" : type;
00151     strstr << "TEC" << side
00152            << " Wheel " << theWheel
00153            << " Petal " << thePetal[1] << " " << petal
00154            << " Ring " << theRing
00155            << " Module " << theModule << " " << type
00156            << " (" << id.rawId() << ")";
00157 
00158     return strstr.str();
00159   }
00160 
00161 
00162   throw cms::Exception("Invalid DetId") << "Unsupported DetId in TrackerTopology::module";
00163   return strstr.str();
00164 }
00165