Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-15 22:40:44

0001 #ifndef ThirdHitRZPrediction_H
0002 #define ThirdHitRZPrediction_H
0003 
0004 /** predicts a range in r-z for the position of third hit.
0005  *  the predicted reange is defined by the template argument, which
0006  *  is a straight line extrapolation/interpolation if PixelRecoLineRZ is used.
0007  */
0008 
0009 #include <algorithm>
0010 
0011 #include "RecoPixelVertexing/PixelTriplets/interface/ThirdHitRZPredictionBase.h"
0012 
0013 template <class Propagator>
0014 class ThirdHitRZPrediction : public ThirdHitRZPredictionBase {
0015 public:
0016   ThirdHitRZPrediction() : ThirdHitRZPredictionBase(), thePropagator(nullptr) {}
0017   ThirdHitRZPrediction(const Propagator *propagator, float tolerance, const DetLayer *layer = nullptr)
0018       : ThirdHitRZPredictionBase(tolerance, layer), thePropagator(propagator) {}
0019 
0020   inline Range operator()(const DetLayer *layer = nullptr);
0021   inline Range operator()(float rORz) const { return (*this)(rORz, *thePropagator); }
0022   inline Range operator()(float rORz, const Propagator &propagator) const;
0023 
0024   void initPropagator(const Propagator *propagator) { thePropagator = propagator; }
0025 
0026 private:
0027   float transform(const Propagator &propagator, float rOrZ) const {
0028     return theBarrel ? propagator.zAtR(rOrZ) : propagator.rAtZ(rOrZ);
0029   }
0030 
0031   const Propagator *thePropagator;
0032 };
0033 
0034 template <class Propagator>
0035 typename ThirdHitRZPrediction<Propagator>::Range ThirdHitRZPrediction<Propagator>::operator()(const DetLayer *layer) {
0036   if (layer)
0037     initLayer(layer);
0038   if (!theBarrel && !theForward)
0039     return Range(0., 0.);
0040   float v1 = transform(*thePropagator, theDetRange.min());
0041   float v2 = transform(*thePropagator, theDetRange.max());
0042   if (v1 > v2)
0043     std::swap(v1, v2);
0044   return Range(v1 - theTolerance.left(), v2 + theTolerance.right());
0045 }
0046 
0047 template <class Propagator>
0048 typename ThirdHitRZPrediction<Propagator>::Range ThirdHitRZPrediction<Propagator>::operator()(
0049     float rOrZ, const Propagator &propagator) const {
0050   float v = transform(propagator, rOrZ);
0051   return Range(v - theTolerance.left(), v + theTolerance.right());
0052 }
0053 
0054 #endif