CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/RecoPixelVertexing/PixelTriplets/interface/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 
00029   typedef TkRotation2D<double> Rotation;
00030   typedef PixelRecoRange<float> Range;
00031   typedef PixelRecoRange<double> RangeD;
00032   typedef Basic2DVector<double> Point2D;
00033 
00034 
00035   ThirdHitPredictionFromInvParabola(const GlobalPoint & P1, const GlobalPoint & P2,
00036     double ip, double curv, double tolerance);
00037 
00038 //  inline Range operator()(double radius, int charge) const { return rangeRPhiSlow(radius,charge,1); } 
00039   inline Range operator()(double radius, int charge) const { return rangeRPhi(radius,charge); } 
00040 
00041   Range rangeRPhi(double radius, int charge) const __attribute__ ((optimize(3, "fast-math")));
00042   // Range rangeRPhiSlow(double radius, int charge, int nIter=5) const;
00043 
00044   void init( const GlobalPoint & P1, const GlobalPoint & P2,  double ip, double curv);
00045 private:
00046 
00047   inline double coeffA(double impactParameter, double charge) const;
00048   inline double coeffB(double impactParameter, double charge) const;
00049   inline double predV(double u, double  ip, double charge) const;
00050   inline double ipFromCurvature(double  curvature, double charge) const;
00051 
00052   Point2D transform(Point2D const & p) const {
00053     return theRotation.rotate(p)/p.mag2();
00054   }
00055 
00056   Point2D transformBack(Point2D const & p) const {
00057     return theRotation.rotateBack(p)/p.mag2();
00058   }
00059 
00060 private:
00061 
00062   Rotation theRotation;
00063   double u1u2, overDu, pv, dv, su;
00064 
00065   inline void findPointAtCurve(double radius, double charge, double ip, double &u, double &v) const;
00066 
00067   RangeD theIpRangePlus, theIpRangeMinus; 
00068   double theTolerance;
00069 
00070 };
00071 
00072 
00073 
00074 double  ThirdHitPredictionFromInvParabola::
00075     coeffA(double impactParameter, double charge) const
00076 {
00077   return -charge*pv*overDu - u1u2*impactParameter;
00078 }
00079 
00080 double ThirdHitPredictionFromInvParabola::
00081     coeffB(double impactParameter, double charge) const
00082 {
00083   return charge*dv*overDu - su*impactParameter;
00084 }
00085 
00086 double ThirdHitPredictionFromInvParabola::
00087     ipFromCurvature(double curvature, double charge) const 
00088 {
00089   double overU1u2 = 1./u1u2;
00090   double inInf = -charge*pv*overDu*overU1u2;
00091   return inInf-curvature*overU1u2*0.5;
00092 }
00093 
00094 double ThirdHitPredictionFromInvParabola::
00095 predV( double u, double ip, double charge) const
00096 {
00097   return -charge*( coeffA(ip,charge) - coeffB(ip,charge)*u - ip*u*u);
00098 }
00099 
00100 void ThirdHitPredictionFromInvParabola::findPointAtCurve(double r, double c, double ip, 
00101                                                          double & u, double & v) const
00102 {
00103   //
00104   // assume u=(1-alpha^2/2)/r v=alpha/r
00105   // solve qudratic equation neglecting aplha^4 term
00106   //
00107   double A = coeffA(ip,c);
00108   double B = coeffB(ip,c);
00109 
00110   // double overR = 1./r;
00111   double ipOverR = ip/r; // *overR;
00112 
00113   double delta = 1-4*(0.5*B+ipOverR)*(-B+A*r-ipOverR);
00114   // double sqrtdelta = (delta > 0) ? std::sqrt(delta) : 0.;
00115   double sqrtdelta = std::sqrt(delta);
00116   double alpha = (c>0)?  (-c+sqrtdelta)/(B+2*ipOverR) :  (-c-sqrtdelta)/(B+2*ipOverR);
00117 
00118   v = alpha;  // *overR
00119   double d2 = 1. - v*v;  // overR*overR - v*v
00120   // u = (d2 > 0) ? std::sqrt(d2) : 0.;
00121   u = std::sqrt(d2);
00122 
00123   // u,v not rotated! not multiplied by 1/r
00124 }
00125 
00126 
00127 #endif