Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:27:36

0001 #include "RecoTracker/MeasurementDet/interface/StartingLayerFinder.h"
0002 
0003 #include "DataFormats/DetId/interface/DetId.h"
0004 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
0005 #include "DataFormats/TrackingRecHit/interface/TrackingRecHitFwd.h"
0006 #include "DataFormats/TrajectoryState/interface/PTrajectoryStateOnDet.h"
0007 #include "DataFormats/TrajectorySeed/interface/TrajectorySeed.h"
0008 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0009 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
0010 
0011 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
0012 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0013 
0014 #include <utility>
0015 
0016 using namespace std;
0017 
0018 namespace {
0019 
0020   typedef std::pair<float, float> Range;
0021 
0022   inline bool rangesIntersect(const Range& a, const Range& b) {
0023     if (a.first > b.second || b.first > a.second)
0024       return false;
0025     else
0026       return true;
0027   }
0028 };  // namespace
0029 
0030 vector<const DetLayer*> StartingLayerFinder::operator()(const FreeTrajectoryState& aFts, float dr, float dz) const {
0031   vector<const DetLayer*> mylayers;
0032   mylayers.reserve(3);
0033 
0034   FreeTrajectoryState fastFts(aFts.parameters());
0035 
0036   //barrel pixel
0037   TrajectoryStateOnSurface pTsos = thePropagator.propagate(fastFts, firstPixelBarrelLayer()->surface());
0038 
0039   if (pTsos.isValid()) {
0040     Range barrZRange(
0041         firstPixelBarrelLayer()->position().z() - 0.5 * (firstPixelBarrelLayer()->surface().bounds().length()),
0042         firstPixelBarrelLayer()->position().z() + 0.5 * (firstPixelBarrelLayer()->surface().bounds().length()));
0043     Range trajZRange(pTsos.globalPosition().z() - dz, pTsos.globalPosition().z() + dz);
0044 
0045     if (rangesIntersect(trajZRange, barrZRange)) {
0046       mylayers.push_back(firstPixelBarrelLayer());
0047     }
0048   }
0049 
0050   //negative fwd pixel
0051 
0052   for (auto infwd : firstPosPixelFwdLayer()) {
0053     pTsos = thePropagator.propagate(fastFts, infwd->surface());
0054     if (pTsos.isValid()) {
0055       Range nfwdRRange(infwd->specificSurface().innerRadius(), infwd->specificSurface().outerRadius());
0056       Range trajRRange(pTsos.globalPosition().perp() - dr, pTsos.globalPosition().perp() + dr);
0057       if (rangesIntersect(trajRRange, nfwdRRange)) {
0058         mylayers.push_back(infwd);
0059       }
0060     }
0061   }
0062 
0063   //positive fwd pixel
0064   for (auto ipfwd : firstPosPixelFwdLayer()) {
0065     pTsos = thePropagator.propagate(fastFts, ipfwd->surface());
0066     if (pTsos.isValid()) {
0067       Range pfwdRRange(ipfwd->specificSurface().innerRadius(), ipfwd->specificSurface().outerRadius());
0068       Range trajRRange(pTsos.globalPosition().perp() - dr, pTsos.globalPosition().perp() + dr);
0069       if (rangesIntersect(trajRRange, pfwdRRange)) {
0070         mylayers.push_back(ipfwd);
0071       }
0072     }
0073   }
0074 
0075   return mylayers;
0076 }
0077 
0078 const BarrelDetLayer* StartingLayerFinder::firstPixelBarrelLayer() const {
0079   checkPixelLayers();
0080   return theFirstPixelBarrelLayer;
0081 }
0082 
0083 const vector<const ForwardDetLayer*> StartingLayerFinder::firstNegPixelFwdLayer() const {
0084   checkPixelLayers();
0085   return theFirstNegPixelFwdLayer;
0086 }
0087 
0088 const vector<const ForwardDetLayer*> StartingLayerFinder::firstPosPixelFwdLayer() const {
0089   checkPixelLayers();
0090   return theFirstPosPixelFwdLayer;
0091 }
0092 
0093 void StartingLayerFinder::checkPixelLayers() const {
0094   if (!thePixelLayersValid) {
0095     const GeometricSearchTracker* theGeometricSearchTracker = theMeasurementTracker.geometricSearchTracker();
0096 
0097     theFirstPixelBarrelLayer = theGeometricSearchTracker->pixelBarrelLayers().front();
0098     theFirstNegPixelFwdLayer = theGeometricSearchTracker->negPixelForwardLayers();
0099     theFirstPosPixelFwdLayer = theGeometricSearchTracker->posPixelForwardLayers();
0100     thePixelLayersValid = true;
0101   }
0102 }