Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:26:49

0001 #ifndef ThirdHitPredictionFromInvLine_H
0002 #define ThirdHitPredictionFromInvLine_H
0003 #include "DataFormats/GeometryVector/interface/Basic2DVector.h"
0004 #include "DataFormats/GeometryVector/interface/Basic3DVector.h"
0005 #include "DataFormats/GeometrySurface/interface/TkRotation.h"
0006 
0007 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0008 #include "RecoTracker/TkMSParametrization/interface/PixelRecoRange.h"
0009 
0010 #include "DataFormats/GeometryVector/interface/Basic2DVector.h"
0011 #include "DataFormats/GeometryVector/interface/Basic3DVector.h"
0012 #include "DataFormats/GeometrySurface/interface/TkRotation.h"
0013 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0014 #include "RecoTracker/TkMSParametrization/interface/PixelRecoRange.h"
0015 
0016 #include <cassert>
0017 
0018 class ThirdHitPredictionFromInvLine {
0019 public:
0020   typedef TkRotation<double> Rotation;
0021   typedef PixelRecoRange<float> Range;
0022 
0023   ThirdHitPredictionFromInvLine(const GlobalPoint& P1,
0024                                 const GlobalPoint& P2,
0025                                 double errorRPhiP1 = 1.,
0026                                 double errorRPhiP2 = 1.);
0027 
0028   int size() const { return nPoints; }
0029 
0030   void add(const GlobalPoint& p, double erroriRPhi = 1.);
0031 
0032   void remove(const GlobalPoint& p, double erroriRPhi = 1.);
0033 
0034   GlobalPoint crossing(double radius) const;
0035 
0036   double curvature() const {
0037     assert(hasParameters);
0038     return theCurvatureValue;
0039   }
0040 
0041   double errorCurvature() const {
0042     assert(hasParameters);
0043     return theCurvatureError;
0044   }
0045 
0046   double chi2() const {
0047     assert(hasParameters);
0048     return theChi2;
0049   }
0050 
0051   void print() const;
0052 
0053 private:
0054   template <class T>
0055   class MappedPoint {
0056   public:
0057     MappedPoint() : theU(0), theV(0), pRot(0) {}
0058     MappedPoint(const T& aU, const T& aV, const TkRotation<T>* aRot) : theU(aU), theV(aV), pRot(aRot) {}
0059     MappedPoint(const Basic2DVector<T>& point, const TkRotation<T>* aRot) : pRot(aRot) {
0060       T radius2 = point.mag2();
0061       Basic3DVector<T> rotated = (*pRot) * point;
0062       theU = rotated.x() / radius2;
0063       theV = rotated.y() / radius2;
0064     }
0065     T u() const { return theU; }
0066     T v() const { return theV; }
0067     Basic2DVector<T> unmap() const {
0068       T invRadius2 = theU * theU + theV * theV;
0069       Basic3DVector<T> tmp = (*pRot).multiplyInverse(Basic2DVector<T>(theU, theV));
0070       return Basic2DVector<T>(tmp.x() / invRadius2, tmp.y() / invRadius2);
0071     }
0072 
0073   private:
0074     T theU, theV;
0075     const TkRotation<T>* pRot;
0076   };
0077 
0078 private:
0079   typedef MappedPoint<double> PointUV;
0080   void add(const ThirdHitPredictionFromInvLine::PointUV& point, double weight);
0081   void check();
0082 
0083 private:
0084   Rotation theRotation;
0085   int nPoints;
0086   long double theSum, theSumU, theSumUU, theSumV, theSumUV, theSumVV;
0087   bool hasParameters;
0088   double theCurvatureValue, theCurvatureError, theChi2;
0089 };
0090 
0091 #endif