CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/RecoPixelVertexing/PixelTrackFitting/src/ParabolaFit.h

Go to the documentation of this file.
00001 #ifndef ParabolaFit_H
00002 #define ParabolaFit_H
00003 
00004 #include <vector>
00005 
00012 class ParabolaFit {
00013 public:
00014   struct Result { double parA, parB, parC; 
00015                   double varAA, varBB, varCC, varAB, varAC, varBC; } ;
00016   ParabolaFit() : 
00017       doErr(true), hasFixedParC(false), hasValues(false), hasErrors(false), hasWeights(true) { }
00018 
00019   void addPoint(double x, double y);
00020   void addPoint(double x, double y, double weight);
00021 
00022   void skipErrorCalculationByDefault() { doErr = false; }
00023   void fixParC(double val) { hasFixedParC = true; theResult.parC = val; }
00024 
00025   const Result & result(bool doErrors) const;
00026 
00027   double parA() const  { if(!hasValues) result(doErr); return theResult.parA; }
00028   double parB() const  { if(!hasValues) result(doErr); return theResult.parB; }
00029   double parC() const  { if(!hasValues) result(doErr); return theResult.parC; }
00030   double varAA() const { if(!hasErrors) result(true); return theResult.varAA; }
00031   double varBB() const { if(!hasErrors) result(true); return theResult.varBB; }
00032   double varCC() const { if(!hasErrors) result(true); return theResult.varCC; }
00033   double varAB() const { if(!hasErrors) result(true); return theResult.varAB; }
00034   double varAC() const { if(!hasErrors) result(true); return theResult.varAC; }
00035   double varBC() const { if(!hasErrors) result(true); return theResult.varBC; }
00036 
00037   double chi2() const;
00038   int    dof() const;
00039 
00040 private:
00041   struct Column { double r1; double r2; double r3; };
00042   double det(const Column & c1, const Column & c2, const Column & c3) const;
00043   double det(const Column & c1, const Column & c2) const;
00044    
00045   double fun(double x) const;
00046 
00047 private:
00048   struct Point { double x; double y; mutable double w; }; 
00049   mutable std::vector<Point> points;
00050   bool doErr, hasFixedParC;
00051   mutable bool hasValues, hasErrors;
00052   bool hasWeights;
00053   mutable Result theResult;  
00054 };
00055 
00056 #endif