CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/FastSimulation/Tracking/src/TrackerRecHit.cc

Go to the documentation of this file.
00001 #include "FastSimulation/Tracking/interface/TrackerRecHit.h"
00002 #include "FastSimulation/TrackerSetup/interface/TrackerInteractionGeometry.h"
00003 
00004 TrackerRecHit::TrackerRecHit(const SiTrackerGSMatchedRecHit2D* theHit, 
00005                              const TrackerGeometry* theGeometry,
00006                              const TrackerTopology* tTopo) :
00007   theSplitHit(0),
00008   theMatchedHit(theHit),
00009   theSubDetId(0),
00010   theLayerNumber(0),
00011   theRingNumber(0),
00012   theCylinderNumber(0),
00013   theLocalError(0.),
00014   theLargerError(0.)
00015      
00016 { 
00017   init(theGeometry, tTopo);
00018 }
00019 
00020 TrackerRecHit::TrackerRecHit(const SiTrackerGSRecHit2D* theHit, 
00021                              const TrackerGeometry* theGeometry,
00022                              const TrackerTopology* tTopo ) :
00023   theSplitHit(theHit),
00024   theMatchedHit(0),
00025   theSubDetId(0),
00026   theLayerNumber(0),
00027   theRingNumber(0),
00028   theCylinderNumber(0),
00029   theLocalError(0.),
00030   theLargerError(0.)
00031      
00032 { 
00033   init(theGeometry,tTopo);
00034 }
00035 
00036 void
00037 TrackerRecHit::init(const TrackerGeometry* theGeometry, const TrackerTopology *tTopo) { 
00038 
00039   const DetId& theDetId = hit()->geographicalId();
00040   theGeomDet = theGeometry->idToDet(theDetId);
00041   theSubDetId = theDetId.subdetId(); 
00042   if ( theSubDetId == StripSubdetector::TIB) { 
00043      
00044     theLayerNumber = tTopo->tibLayer(theDetId);
00045     theCylinderNumber = TrackerInteractionGeometry::TIB+theLayerNumber;
00046     forward = false;
00047   } else if ( theSubDetId ==  StripSubdetector::TOB ) { 
00048      
00049     theLayerNumber = tTopo->tobLayer(theDetId);
00050     theCylinderNumber = TrackerInteractionGeometry::TOB+theLayerNumber;
00051     forward = false;
00052   } else if ( theSubDetId ==  StripSubdetector::TID) { 
00053     
00054     theLayerNumber = tTopo->tidWheel(theDetId);
00055     theCylinderNumber = TrackerInteractionGeometry::TID+theLayerNumber;
00056     theRingNumber = tTopo->tidRing(theDetId);
00057     forward = true;
00058   } else if ( theSubDetId ==  StripSubdetector::TEC ) { 
00059      
00060     theLayerNumber = tTopo->tecWheel(theDetId); 
00061     theCylinderNumber = TrackerInteractionGeometry::TEC+theLayerNumber;
00062     theRingNumber = tTopo->tecRing(theDetId);
00063     forward = true;
00064   } else if ( theSubDetId ==  PixelSubdetector::PixelBarrel ) { 
00065      
00066     theLayerNumber = tTopo->pxbLayer(theDetId); 
00067     theCylinderNumber = TrackerInteractionGeometry::PXB+theLayerNumber;
00068     forward = false;
00069   } else if ( theSubDetId ==  PixelSubdetector::PixelEndcap ) { 
00070      
00071     theLayerNumber = tTopo->pxfDisk(theDetId);  
00072     theCylinderNumber = TrackerInteractionGeometry::PXD+theLayerNumber;
00073     forward = true;
00074   }
00075   
00076 }
00077 
00078 
00079 bool
00080 TrackerRecHit::isOnRequestedDet(const std::vector<std::string>& layerList) const { 
00081 
00082   std::cout << "layerList.size() = " << layerList.size()  << std::endl;
00083   bool isOnDet = false;
00084 
00085   int subdet = 0; // 1 = PXB, 2 = PXD, 3 = TIB, 4 = TID, 5 = TOB, 6 = TEC, 0 = not valid
00086   int idLayer = 0;
00087   int side = 0; // 0 = barrel, -1 = neg. endcap, +1 = pos. endcap
00088 
00089   for (unsigned i=0; i<layerList.size();i++) {
00090     std::string name = layerList[i];
00091     std::cout << "------- Name = " << name << std::endl;
00092 
00093     //
00094     // BPIX
00095     //
00096     if (name.substr(0,4) == "BPix") {
00097       subdet = 1;
00098       idLayer = atoi(name.substr(4,1).c_str());
00099       side=0;
00100     }
00101     //
00102     // FPIX
00103     //
00104     else if (name.substr(0,4) == "FPix") {
00105       subdet = 2;
00106       idLayer = atoi(name.substr(4,1).c_str());
00107       if ( name.find("pos") != std::string::npos ) {
00108         side = +1;
00109       } else {
00110         side = -1;
00111       }
00112     }
00113     //
00114     // TIB
00115     //
00116     else if (name.substr(0,3) == "TIB") {
00117       subdet = 3;
00118       idLayer = atoi(name.substr(3,1).c_str());
00119       side=0;
00120     }
00121     //
00122     // TID
00123     //
00124     else if (name.substr(0,3) == "TID") {
00125       subdet = 4;
00126       idLayer = atoi(name.substr(3,1).c_str());
00127       if ( name.find("pos") !=std::string::npos ) {
00128         side = +1;
00129       } else {
00130         side = -1;
00131       }
00132     }
00133     //
00134     // TOB
00135     //
00136     else if (name.substr(0,3) == "TOB") {
00137       subdet = 5;
00138       idLayer = atoi(name.substr(3,1).c_str());
00139       side = 0;
00140     }
00141     //
00142     // TEC
00143     //
00144     else if (name.substr(0,3) == "TEC") {
00145       subdet = 6;
00146       idLayer = atoi(name.substr(3,1).c_str());
00147       if ( name.find("pos") != std::string::npos ) {
00148         side = +1;
00149       } else {
00150         side = -1;
00151       }
00152     }
00153     
00154     std::cout << "subdet = " << subdet << std::endl;
00155     std::cout << "idLayer = " << idLayer << std::endl;
00156     std::cout << "side = " << side << std::endl;
00157 
00158   }
00159 
00161 
00162   
00163 
00164   return isOnDet;
00165 }
00166 
00167 bool
00168 //TrackerRecHit::isOnRequestedDet(const std::vector<unsigned int>& whichDet) const { 
00169 TrackerRecHit::isOnRequestedDet(const std::vector<unsigned int>& whichDet, const std::string& seedingAlgo) const { 
00170   
00171   bool isOnDet = false;
00172   
00173   for ( unsigned idet=0; idet<whichDet.size(); ++idet ) {
00174     
00175     switch ( whichDet[idet] ) { 
00176       
00177     case 1: 
00178       //Pixel Barrel
00179       isOnDet =  theSubDetId==1;
00180       break;
00181       
00182     case 2: 
00183       //Pixel Disks
00184       isOnDet = theSubDetId==2;
00185       break;
00186       
00187     case 3:
00188       //Inner Barrel
00189       isOnDet = theSubDetId==3 && theLayerNumber < 4;
00190       break;
00191       
00192     case 4:
00193       //Inner Disks
00194       isOnDet = theSubDetId==4 && theRingNumber < 3;
00195       break;
00196       
00197     case 5:
00198       //Outer Barrel
00199       if(seedingAlgo == "TobTecLayerPairs"){
00200         isOnDet = theSubDetId==5 && theLayerNumber <3;
00201       }else {
00202         isOnDet = false;
00203       }
00204       break;
00205       
00206     case 6:
00207       //Tracker EndCap
00208       if(seedingAlgo == "PixelLessPairs"){
00209         isOnDet = theSubDetId==6 && theLayerNumber < 6 && theRingNumber < 3;
00210       }else if (seedingAlgo == "TobTecLayerPairs"){
00211         //      isOnDet = theSubDetId==6 && theLayerNumber < 8 && theRingNumber < 5;
00212         isOnDet = theSubDetId==6 && theLayerNumber < 8 && theRingNumber == 5;
00213       } else if (seedingAlgo == "MixedTriplets"){ 
00214         //      isOnDet = theSubDetId==6 && theLayerNumber == 2 && theRingNumber == 1;
00215         isOnDet = theSubDetId==6 && theLayerNumber < 4 && theRingNumber == 1;
00216       } else {
00217         isOnDet = theSubDetId==6;
00218         std::cout << "DEBUG - this should never happen" << std::endl;
00219       }
00220 
00221       break;
00222       
00223     default:
00224       // Should not happen
00225       isOnDet = false;
00226       break;
00227       
00228     }
00229     
00230     if ( isOnDet ) break;
00231     
00232   }
00233   
00234   return isOnDet;
00235 }
00236 
00237 bool
00238 TrackerRecHit::makesAPairWith(const TrackerRecHit& anotherHit) const { 
00239 
00240   bool isAProperPair = false;
00241 
00242   unsigned int anotherSubDetId = anotherHit.subDetId();
00243   unsigned int anotherLayerNumber = anotherHit.layerNumber();
00244   isAProperPair = 
00245     // First hit on PXB1
00246     ( ( theSubDetId == 1 && theLayerNumber == 1 ) && (
00247       ( anotherSubDetId == 1 && anotherLayerNumber == 2) || 
00248       ( anotherSubDetId == 1 && anotherLayerNumber == 3) || 
00249       ( anotherSubDetId == 2 && anotherLayerNumber == 1) || 
00250       ( anotherSubDetId == 2 && anotherLayerNumber == 2) ) ) || 
00251     // First hit on PXB2
00252     ( ( theSubDetId == 1 && theLayerNumber == 2 ) && (
00253       ( anotherSubDetId == 1 && anotherLayerNumber == 3) || 
00254       ( anotherSubDetId == 2 && anotherLayerNumber == 1) || 
00255       ( anotherSubDetId == 2 && anotherLayerNumber == 2) ) ) ||
00256     // First Hit on PXD1
00257     ( ( theSubDetId == 2 && theLayerNumber == 1 ) && 
00258       ( anotherSubDetId == 2 && anotherLayerNumber == 2 ) ) ||
00259     // First Hit on PXD2
00260     ( ( theSubDetId == 2 && theLayerNumber == 2 ) && ( 
00261       ( anotherSubDetId == 6 && anotherLayerNumber == 1 ) ||
00262       ( anotherSubDetId == 6 && anotherLayerNumber == 2 ) ) ) ||
00263     // First Hit on TEC1
00264     ( ( theSubDetId == 6 && theLayerNumber == 1 ) && 
00265       ( anotherSubDetId == 6 && anotherLayerNumber == 2 ) ) ||
00266     // First Hit on TEC2
00267     ( ( theSubDetId == 6 && theLayerNumber == 2 ) && 
00268       ( anotherSubDetId == 6 && anotherLayerNumber == 3 ) ) ||
00269 
00270   //Pixelless Pairs  
00271    // First Hit on TIB1
00272     ( ( theSubDetId == 3 && theLayerNumber == 1 ) && 
00273       (( anotherSubDetId == 3 && anotherLayerNumber == 2 ) ||
00274        ( anotherSubDetId == 4 && anotherLayerNumber == 1 )) ) ||
00275     // First Hit on TID1
00276     ( ( theSubDetId == 4 && theLayerNumber == 1 ) && 
00277       ( anotherSubDetId == 4 && anotherLayerNumber == 2 ) ) ||
00278     // First Hit on TID2
00279     ( ( theSubDetId == 4 && theLayerNumber == 2 ) && 
00280       ( anotherSubDetId == 4 && anotherLayerNumber == 3 ) ) ||
00281     // First Hit on TID3
00282     ( ( theSubDetId == 4 && theLayerNumber == 3 ) && 
00283       ( anotherSubDetId == 6 && anotherLayerNumber == 1 ) ) ||
00284     // First Hit on TEC3
00285     ( ( theSubDetId == 6 && theLayerNumber == 3 ) && 
00286       (      ( anotherSubDetId == 6 && anotherLayerNumber == 4 ) || 
00287              ( anotherSubDetId == 6 && anotherLayerNumber == 5 ))  ) ||
00288     // First Hit on TEC4
00289     ( ( theSubDetId == 6 && theLayerNumber == 4 ) && 
00290       ( anotherSubDetId == 6 && anotherLayerNumber == 5 ) ) ||
00291 
00292   //Tob-Tec pairs
00293   //first hit on TOB1 
00294     ( ( theSubDetId == 5 && theLayerNumber == 1 ) && 
00295       (( anotherSubDetId == 5 && anotherLayerNumber == 2 ) ||
00296        ( anotherSubDetId == 6 && anotherLayerNumber == 1 )) ) ||
00297     // First Hit on TEC1
00298     ( ( theSubDetId == 6 && theLayerNumber == 1 ) && 
00299       ( anotherSubDetId == 6 && anotherLayerNumber == 2 ) ) ||
00300     // First Hit on TEC2
00301     ( ( theSubDetId == 6 && theLayerNumber == 2 ) && 
00302       ( anotherSubDetId == 6 && anotherLayerNumber == 3 ) ) ||
00303     // First Hit on TEC3
00304     ( ( theSubDetId == 6 && theLayerNumber == 3 ) && 
00305       ( anotherSubDetId == 6 && anotherLayerNumber == 4 ) ) || 
00306       // ???     ( anotherSubDetId == 6 && anotherLayerNumber == 5 ) ) ||
00307     // First Hit on TEC4
00308     ( ( theSubDetId == 6 && theLayerNumber == 4 ) && 
00309       ( anotherSubDetId == 6 && anotherLayerNumber == 5 ) ) ||
00310     // First Hit on TEC5
00311     ( ( theSubDetId == 6 && theLayerNumber == 5 ) && 
00312       ( anotherSubDetId == 6 && anotherLayerNumber == 6 ) ) ||
00313     // First Hit on TEC6
00314     ( ( theSubDetId == 6 && theLayerNumber == 6 ) && 
00315       ( anotherSubDetId == 6 && anotherLayerNumber == 7 ) ) ;
00316 
00317   return isAProperPair;
00318 
00319 } 
00320 
00321 bool
00322 TrackerRecHit::makesAPairWith3rd(const TrackerRecHit& anotherHit) const { 
00323 
00324   bool isAProperPair = false;
00325 
00326   unsigned int anotherSubDetId = anotherHit.subDetId();
00327   unsigned int anotherLayerNumber = anotherHit.layerNumber();
00328   isAProperPair = 
00329     // First hit on PXB1
00330     ( ( theSubDetId == 1 && theLayerNumber == 1 ) && (
00331       ( anotherSubDetId == 1 && anotherLayerNumber == 2) || 
00332       ( anotherSubDetId == 2 && anotherLayerNumber == 1) ) ) || 
00333       // First hit on PXB2
00334     ( ( theSubDetId == 1 && theLayerNumber == 2 ) && 
00335       ( anotherSubDetId == 1 && anotherLayerNumber == 3) ) || 
00336     // First Hit on PXD1
00337     ( ( theSubDetId == 2 && theLayerNumber == 1 ) && 
00338       ( anotherSubDetId == 2 && anotherLayerNumber == 2) ) ||
00339     // First Hit on PXD2
00340     ( ( theSubDetId == 2 && theLayerNumber == 2 ) &&  
00341       ( anotherSubDetId == 6 && anotherLayerNumber == 2 ) );
00342 
00343  return isAProperPair;
00344 
00345 }
00346       
00347 bool
00348 TrackerRecHit::makesATripletWith(const TrackerRecHit& anotherHit,
00349                                  const TrackerRecHit& yetAnotherHit ) const { 
00350 
00351   bool isAProperTriplet = false;
00352 
00353   unsigned int anotherSubDetId = anotherHit.subDetId();
00354   unsigned int anotherLayerNumber = anotherHit.layerNumber();
00355   unsigned int yetAnotherSubDetId = yetAnotherHit.subDetId();
00356   unsigned int yetAnotherLayerNumber = yetAnotherHit.layerNumber();
00357   isAProperTriplet = 
00358     // First hit on PXB1, second on PXB2
00359     ( ( theSubDetId == 1 && theLayerNumber == 1 ) && 
00360       ( anotherSubDetId == 1 && anotherLayerNumber == 2) && ( 
00361       ( yetAnotherSubDetId == 1 && yetAnotherLayerNumber == 3) || 
00362       ( yetAnotherSubDetId == 2 && yetAnotherLayerNumber == 1) || 
00363       ( yetAnotherSubDetId == 3 && yetAnotherLayerNumber == 1) ) ) || 
00364     // First hit on PXB1, second on PXB3 
00365     ( ( theSubDetId == 1 && theLayerNumber == 1 ) &&
00366       ( anotherSubDetId == 1 && anotherLayerNumber == 3) && 
00367       ( yetAnotherSubDetId == 3 && yetAnotherLayerNumber == 1) ) || 
00368     // First hit on PXB2, second on PXB3 
00369     ( ( theSubDetId == 1 && theLayerNumber == 2 ) &&
00370       ( anotherSubDetId == 1 && anotherLayerNumber == 3) && 
00371       ( yetAnotherSubDetId == 3 && yetAnotherLayerNumber == 1) ) || 
00372     // First Hit on PXB1, second on PXD1
00373     ( ( theSubDetId == 1 && theLayerNumber == 1 ) &&
00374       ( anotherSubDetId == 2 && anotherLayerNumber == 1) && ( 
00375       ( yetAnotherSubDetId == 2 && yetAnotherLayerNumber == 2) || 
00376       ( yetAnotherSubDetId == 4 && yetAnotherLayerNumber == 1) || 
00377       ( yetAnotherSubDetId == 4 && yetAnotherLayerNumber == 2) ) ) || 
00378     // First Hit on PXD1, second on PXD2
00379     ( ( theSubDetId == 2 && theLayerNumber == 1 ) && 
00380       ( anotherSubDetId == 2 && anotherLayerNumber == 2 ) && (
00381       ( yetAnotherSubDetId == 6 && yetAnotherLayerNumber == 1 ) ||
00382       ( yetAnotherSubDetId == 6 && yetAnotherLayerNumber == 2 ) ) ) ||
00383     // First hit on TIB1 (pixel less)
00384     ( ( theSubDetId == 3 && theLayerNumber == 1 ) && 
00385       ( anotherSubDetId == 3 && anotherLayerNumber == 2 ) && 
00386       ( yetAnotherSubDetId == 3 && yetAnotherLayerNumber == 3 ) );
00387   
00388   return isAProperTriplet;
00389   
00390 }
00391 
00392 
00393 
00394