CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/RecoPixelVertexing/PixelTriplets/plugins/ThirdHitPredictionFromInvParabola.h

Go to the documentation of this file.
00001 #ifndef ThirdHitPredictionFromInvParabola_H
00002 #define ThirdHitPredictionFromInvParabola_H
00003 
00012 #include "DataFormats/GeometryVector/interface/Basic2DVector.h"
00013 #include "DataFormats/GeometryVector/interface/Basic3DVector.h"
00014 #include "DataFormats/GeometrySurface/interface/TkRotation.h"
00015 
00016 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00017 #include "RecoTracker/TkMSParametrization/interface/PixelRecoRange.h"
00018 #include "FWCore/Utilities/interface/Visibility.h"
00019 
00020 
00021 class TrackingRegion;
00022 class OrderedHitPair;
00023 
00024 
00025 class ThirdHitPredictionFromInvParabola {
00026 
00027 public:
00028   using Scalar=double;
00029   typedef TkRotation2D<Scalar> Rotation;
00030   typedef PixelRecoRange<float> Range;
00031   typedef PixelRecoRange<Scalar> RangeD;
00032   typedef Basic2DVector<Scalar> Point2D;
00033 
00034 
00035   ThirdHitPredictionFromInvParabola(){}
00036   ThirdHitPredictionFromInvParabola(Scalar x1,Scalar y1, Scalar x2,Scalar y2,  Scalar ip, Scalar curv,
00037                                     Scalar tolerance): theTolerance(tolerance)
00038   {
00039     init(x1,y1,x2,y2,ip,std::abs(curv));
00040   }
00041 
00042   ThirdHitPredictionFromInvParabola(const GlobalPoint & P1, const GlobalPoint & P2,
00043     Scalar ip, Scalar curv, Scalar tolerance);
00044 
00045 //  inline Range operator()(Scalar radius, int charge) const { return rangeRPhiSlow(radius,charge,1); } 
00046   inline Range operator()(Scalar radius, int charge) const { return rangeRPhi(radius,charge); } 
00047 
00048   Range rangeRPhi(Scalar radius, int charge) const __attribute__ ((optimize(3, "fast-math")));
00049   // Range rangeRPhiSlow(Scalar radius, int charge, int nIter=5) const;
00050 
00051   void init( const GlobalPoint & P1, const GlobalPoint & P2,  Scalar ip, Scalar curv) {
00052      init( P1.x(), P1.y(), P2.x(),P2.y(),ip,curv);
00053   }
00054   void init(Scalar x1,Scalar y1, Scalar x2,Scalar y2,  Scalar ip, Scalar curv);
00055 
00056 private:
00057 
00058   inline Scalar coeffA(Scalar impactParameter) const;
00059   inline Scalar coeffB(Scalar impactParameter) const;
00060   inline Scalar predV(Scalar u, Scalar  ip) const;
00061   inline Scalar ipFromCurvature(Scalar  curvature, bool pos) const;
00062 
00063   Point2D transform(Point2D const & p) const {
00064     return theRotation.rotate(p)/p.mag2();
00065   }
00066 
00067   Point2D transformBack(Point2D const & p) const {
00068     return theRotation.rotateBack(p)/p.mag2();
00069   }
00070 
00071 private:
00072 
00073   Rotation theRotation;
00074   Scalar u1u2, overDu, pv, dv, su;
00075 
00076   // formula is symmetric for (ip,pos) -> (-ip,neg)
00077   inline void findPointAtCurve(Scalar radius, Scalar ip, Scalar &u, Scalar &v) const;
00078 
00079   RangeD theIpRangePlus, theIpRangeMinus; 
00080   Scalar theTolerance;
00081 
00082 };
00083 
00084 
00085 
00086 ThirdHitPredictionFromInvParabola::Scalar  ThirdHitPredictionFromInvParabola::
00087     coeffA(Scalar impactParameter) const
00088 {
00089   auto c = -pv*overDu;
00090   return c - u1u2*impactParameter;
00091 }
00092 
00093 ThirdHitPredictionFromInvParabola::Scalar ThirdHitPredictionFromInvParabola::
00094     coeffB(Scalar impactParameter) const
00095 {
00096   auto c = dv*overDu;
00097   return c - su*impactParameter;
00098 }
00099 
00100 ThirdHitPredictionFromInvParabola::Scalar ThirdHitPredictionFromInvParabola::
00101     ipFromCurvature(Scalar curvature, bool pos) const 
00102 {
00103   Scalar overU1u2 = 1./u1u2;
00104   Scalar inInf = -pv*overDu*overU1u2;
00105   return (pos? inInf : -inInf) -curvature*overU1u2*0.5;
00106 }
00107 
00108 
00109 ThirdHitPredictionFromInvParabola::Scalar ThirdHitPredictionFromInvParabola::
00110 predV( Scalar u, Scalar ip) const
00111 {
00112   auto c =  -( coeffA(ip) - coeffB(ip*u) - ip*u*u);
00113   return c;
00114 }
00115 
00116 
00117 void ThirdHitPredictionFromInvParabola::findPointAtCurve(Scalar r, Scalar ip, 
00118                                                          Scalar & u, Scalar & v) const
00119 {
00120   //
00121   // assume u=(1-alpha^2/2)/r v=alpha/r
00122   // solve qudratic equation neglecting aplha^4 term
00123   //
00124   Scalar A = coeffA(ip);
00125   Scalar B = coeffB(ip);
00126 
00127   // Scalar overR = 1./r;
00128   Scalar ipOverR = ip/r; // *overR;
00129 
00130   Scalar a = 0.5*B+ipOverR;
00131   Scalar c = -B+A*r-ipOverR;
00132 
00133   Scalar delta = 1-4*a*c;
00134   // Scalar sqrtdelta = (delta > 0) ? std::sqrt(delta) : 0.;
00135   Scalar sqrtdelta = std::sqrt(delta);
00136   //  Scalar alpha = (-1+sqrtdelta)/(2*a);
00137   Scalar alpha = (-2*c)/(1+sqrtdelta);
00138 
00139   v = alpha;  // *overR
00140   Scalar d2 = 1. - v*v;  // overR*overR - v*v
00141   // u = (d2 > 0) ? std::sqrt(d2) : 0.;
00142   u = std::sqrt(d2);
00143 
00144   // u,v not rotated! not multiplied by 1/r
00145 }
00146 
00147 
00148 #endif