CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/RecoTracker/TkNavigation/src/StartingLayerFinder.cc

Go to the documentation of this file.
00001 #include "RecoTracker/TkNavigation/interface/StartingLayerFinder.h"
00002 
00003 #include "DataFormats/DetId/interface/DetId.h"
00004 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
00005 #include "DataFormats/TrackingRecHit/interface/TrackingRecHitFwd.h"
00006 #include "DataFormats/TrajectoryState/interface/PTrajectoryStateOnDet.h"
00007 #include "DataFormats/TrajectorySeed/interface/TrajectorySeed.h"
00008 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00009 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00010 
00011 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
00012 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00013 
00014 
00015 #include <utility>
00016 
00017 using namespace std;
00018 
00019 vector<const DetLayer*> 
00020 StartingLayerFinder::startingLayers(const FTS& aFts, float dr, float dz) const {
00021 
00022 
00023 
00024   
00025   vector<const DetLayer*> mylayers; 
00026   mylayers.reserve(3);
00027 
00028   FTS fastFts(aFts.parameters());
00029   
00030 
00031   //barrel pixel
00032   TSOS pTsos = 
00033     propagator()->propagate(fastFts, firstPixelBarrelLayer()->surface());
00034   
00035   if(pTsos.isValid()) {
00036 
00037     Range barrZRange(firstPixelBarrelLayer()->position().z() - 
00038                     0.5*(firstPixelBarrelLayer()->surface().bounds().length()),
00039                      firstPixelBarrelLayer()->position().z() + 
00040                    0.5*(firstPixelBarrelLayer()->surface().bounds().length()));
00041     Range trajZRange(pTsos.globalPosition().z() - dz,
00042                      pTsos.globalPosition().z() + dz);
00043 
00044     if(rangesIntersect(trajZRange, barrZRange)) {
00045       mylayers.push_back(firstPixelBarrelLayer());
00046 
00047     }
00048   }
00049 
00050 
00051   //negative fwd pixel
00052 
00053   const vector<ForwardDetLayer*> nfwd = firstPosPixelFwdLayer();
00054   for(vector<ForwardDetLayer*>::const_iterator infwd = nfwd.begin();
00055       infwd != nfwd.end(); infwd++) {
00056     pTsos = propagator()->propagate(fastFts, (*infwd)->surface());  
00057     if(pTsos.isValid()) {
00058       Range nfwdRRange((*infwd)->specificSurface().innerRadius(),
00059                        (*infwd)->specificSurface().outerRadius());
00060       Range trajRRange(pTsos.globalPosition().perp() - dr,
00061                        pTsos.globalPosition().perp() + dr);
00062       if(rangesIntersect(trajRRange, nfwdRRange)) {
00063         mylayers.push_back(*infwd);
00064 
00065       }
00066     }
00067   }
00068 
00069   //positive fwd pixel
00070   const vector<ForwardDetLayer*> pfwd = firstPosPixelFwdLayer();
00071   for(vector<ForwardDetLayer*>::const_iterator ipfwd = pfwd.begin();
00072       ipfwd != pfwd.end(); ipfwd++) {
00073     pTsos = propagator()->propagate(fastFts, (*ipfwd)->surface());
00074     if(pTsos.isValid()) {
00075       Range pfwdRRange((*ipfwd)->specificSurface().innerRadius(),
00076                        (*ipfwd)->specificSurface().outerRadius());
00077       Range trajRRange(pTsos.globalPosition().perp() - dr,
00078                        pTsos.globalPosition().perp() + dr);
00079       if(rangesIntersect(trajRRange, pfwdRRange)) {
00080         mylayers.push_back(*ipfwd);
00081 
00082       }
00083     }
00084   }
00085 
00086 
00087 
00088   return mylayers;
00089 
00090 
00091 
00092 
00093 
00094 }
00095 
00096 vector<const DetLayer*> 
00097 StartingLayerFinder::startingLayers(const TrajectorySeed& aSeed) const {
00098 
00099 
00100 
00101   float dr = 0., dz = 0.;
00102 
00103 
00104   if(propagator()->propagationDirection() != aSeed.direction())
00105     return vector<const DetLayer*>();
00106 
00107   if(aSeed.nHits() != 2) return vector<const DetLayer*>();
00108  
00109 
00110   TrackingRecHitCollection::const_iterator firstHit= aSeed.recHits().first;
00111   const TrackingRecHit* recHit1=&(*firstHit);
00112   const DetLayer* hit1Layer = theMeasurementTracker->geometricSearchTracker()->detLayer(recHit1->geographicalId());
00113 
00114   TrackingRecHitCollection::const_iterator secondHit= aSeed.recHits().second;
00115   const TrackingRecHit* recHit2=&(*secondHit);
00116   const DetLayer* hit2Layer = theMeasurementTracker->geometricSearchTracker()->detLayer(recHit2->geographicalId());
00117 
00118   
00119   GeomDetEnumerators::Location p1 =  hit1Layer->location();
00120   GeomDetEnumerators::Location p2 =  hit2Layer->location();
00121 
00122   if(p1 == GeomDetEnumerators::barrel && p2 == GeomDetEnumerators::barrel) {
00123     dr = 0.1; dz = 5.;
00124   } else if(p1 == GeomDetEnumerators::endcap && p2 == GeomDetEnumerators::endcap) {
00125     dr = 5.; dz = 0.1;
00126   } else {
00127     dr = 0.1; dz = 0.1;
00128   }
00129 
00130 
00131   
00132   const GeomDet* gdet = theMeasurementTracker->geomTracker()->idToDet( DetId( aSeed.startingState().detId()));
00133   
00134   
00135   TrajectoryStateOnSurface tsos = trajectoryStateTransform::transientState( aSeed.startingState(), &(gdet->surface()), 
00136                                                               thePropagator->magneticField());
00137 
00138 
00139   FreeTrajectoryState* fts=tsos.freeTrajectoryState();
00140   
00141   return startingLayers(*fts, dr, dz);
00142 }
00143   
00144 const BarrelDetLayer* StartingLayerFinder::firstPixelBarrelLayer() const {
00145   checkPixelLayers();
00146   return theFirstPixelBarrelLayer;  
00147 }
00148 
00149 const vector<ForwardDetLayer*> StartingLayerFinder::firstNegPixelFwdLayer() const {
00150   checkPixelLayers();
00151   return theFirstNegPixelFwdLayer;
00152 }
00153 
00154 const vector<ForwardDetLayer*>  StartingLayerFinder::firstPosPixelFwdLayer() const {
00155   checkPixelLayers();
00156   return theFirstPosPixelFwdLayer;
00157 }
00158 
00159 void StartingLayerFinder::checkPixelLayers() const {
00160 
00161 
00162   if(!thePixelLayersValid) {
00163    
00164     const GeometricSearchTracker* theGeometricSearchTracker=theMeasurementTracker->geometricSearchTracker();
00165 
00166    
00167     theFirstPixelBarrelLayer = theGeometricSearchTracker->pixelBarrelLayers().front();
00168     theFirstNegPixelFwdLayer = theGeometricSearchTracker->negPixelForwardLayers();
00169     theFirstPosPixelFwdLayer = theGeometricSearchTracker->posPixelForwardLayers();
00170     thePixelLayersValid = true;
00171 
00172 
00173  
00174   }
00175 
00176 
00177 }
00178 
00179 
00180