CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/RecoPixelVertexing/PixelTriplets/interface/ThirdHitPredictionFromInvLine.h

Go to the documentation of this file.
00001 #ifndef ThirdHitPredictionFromInvLine_H
00002 #define ThirdHitPredictionFromInvLine_H
00003 #include "DataFormats/GeometryVector/interface/Basic2DVector.h"
00004 #include "DataFormats/GeometryVector/interface/Basic3DVector.h"
00005 #include "DataFormats/GeometrySurface/interface/TkRotation.h"
00006 
00007 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00008 #include "RecoTracker/TkMSParametrization/interface/PixelRecoRange.h"
00009 
00010 
00011 #include "DataFormats/GeometryVector/interface/Basic2DVector.h"
00012 #include "DataFormats/GeometryVector/interface/Basic3DVector.h"
00013 #include "DataFormats/GeometrySurface/interface/TkRotation.h"
00014 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00015 #include "RecoTracker/TkMSParametrization/interface/PixelRecoRange.h"
00016 
00017 class ThirdHitPredictionFromInvLine {
00018 
00019 public:
00020 
00021   typedef TkRotation<double> Rotation;
00022   typedef PixelRecoRange<float> Range;
00023 
00024   ThirdHitPredictionFromInvLine(const GlobalPoint & P1, const GlobalPoint & P2, double errorRPhiP1 = 1., double errorRPhiP2 = 1. );
00025 
00026   int size() const { return nPoints;}
00027 
00028   void add(const GlobalPoint& p, double erroriRPhi =1.);
00029 
00030   void remove(const GlobalPoint& p, double erroriRPhi =1.);
00031 
00032   GlobalPoint crossing(double radius) const;
00033 
00034   double curvature() const { check(); return theCurvatureValue; }
00035 
00036   double errorCurvature() const { check(); return theCurvatureError; }
00037 
00038   double chi2() const {  check(); return theChi2; }
00039 
00040   void print() const;
00041 private:
00042 
00043   template <class T> class MappedPoint {
00044   public:
00045     MappedPoint() : theU(0), theV(0), pRot(0) { }
00046     MappedPoint(const T & aU, const T & aV, const TkRotation<T> * aRot)
00047         : theU(aU), theV(aV), pRot(aRot) { }
00048     MappedPoint(const Basic2DVector<T> & point, const TkRotation<T> * aRot)
00049         : pRot(aRot) {
00050       T radius2 = point.mag2();
00051       Basic3DVector<T> rotated = (*pRot) * point;
00052       theU = rotated.x() / radius2;
00053       theV = rotated.y() / radius2;
00054     }
00055     T u() const {return theU; }
00056     T v() const {return theV; }
00057     Basic2DVector<T> unmap () const {
00058        T invRadius2 = theU*theU+theV*theV;
00059        Basic3DVector<T> tmp
00060            = (*pRot).multiplyInverse(Basic2DVector<T>(theU,theV));
00061        return Basic2DVector<T>( tmp.x()/invRadius2, tmp.y()/invRadius2);
00062     }
00063   private:
00064     T theU, theV;
00065     const TkRotation<T> * pRot;
00066   };
00067 
00068 private:
00069   typedef MappedPoint<double> PointUV;
00070   void add(const ThirdHitPredictionFromInvLine::PointUV & point, double weight);
00071   void check() const;
00072 
00073 private:
00074   Rotation theRotation;
00075   int    nPoints;
00076   long double theSum, theSumU, theSumUU, theSumV, theSumUV, theSumVV;
00077   mutable bool hasParameters;
00078   mutable double theCurvatureValue, theCurvatureError, theChi2; 
00079 };
00080 
00081 
00082 #endif