CMS 3D CMS Logo

ParabolaFit.h
Go to the documentation of this file.
1 #ifndef ParabolaFit_H
2 #define ParabolaFit_H
3 
4 #include <vector>
5 
12 class ParabolaFit {
13 public:
14  struct Result { double parA, parB, parC;
15  double varAA, varBB, varCC, varAB, varAC, varBC; } ;
18 
19  void addPoint(double x, double y);
20  void addPoint(double x, double y, double weight);
21 
23  void fixParC(double val) { hasFixedParC = true; theResult.parC = val; }
24 
25  const Result & result(bool doErrors) const;
26 
27  double parA() const { if(!hasValues) result(doErr); return theResult.parA; }
28  double parB() const { if(!hasValues) result(doErr); return theResult.parB; }
29  double parC() const { if(!hasValues) result(doErr); return theResult.parC; }
30  double varAA() const { if(!hasErrors) result(true); return theResult.varAA; }
31  double varBB() const { if(!hasErrors) result(true); return theResult.varBB; }
32  double varCC() const { if(!hasErrors) result(true); return theResult.varCC; }
33  double varAB() const { if(!hasErrors) result(true); return theResult.varAB; }
34  double varAC() const { if(!hasErrors) result(true); return theResult.varAC; }
35  double varBC() const { if(!hasErrors) result(true); return theResult.varBC; }
36 
37  double chi2() const;
38  int dof() const;
39 
40 private:
41  struct Column { double r1; double r2; double r3; };
42  double det(const Column & c1, const Column & c2, const Column & c3) const;
43  double det(const Column & c1, const Column & c2) const;
44 
45  double fun(double x) const;
46 
47 private:
48  struct Point { double x; double y; mutable double w; };
49  mutable std::vector<Point> points;
51  mutable bool hasValues, hasErrors;
52  bool hasWeights;
53  mutable Result theResult;
54 };
55 
56 #endif
double parC() const
Definition: ParabolaFit.h:29
int dof() const
Definition: ParabolaFit.cc:119
const Result & result(bool doErrors) const
Definition: ParabolaFit.cc:20
bool hasValues
Definition: ParabolaFit.h:51
double varCC() const
Definition: ParabolaFit.h:32
bool hasFixedParC
Definition: ParabolaFit.h:50
const double w
Definition: UKUtility.cc:23
Definition: weight.py:1
std::vector< Point > points
Definition: ParabolaFit.h:49
double det(const Column &c1, const Column &c2, const Column &c3) const
Definition: ParabolaFit.cc:126
double varBB() const
Definition: ParabolaFit.h:31
void skipErrorCalculationByDefault()
Definition: ParabolaFit.h:22
double varBC() const
Definition: ParabolaFit.h:35
bool hasErrors
Definition: ParabolaFit.h:51
double chi2() const
Definition: ParabolaFit.cc:104
void addPoint(double x, double y)
Definition: ParabolaFit.cc:6
double fun(double x) const
Definition: ParabolaFit.cc:114
double varAC() const
Definition: ParabolaFit.h:34
void fixParC(double val)
Definition: ParabolaFit.h:23
double parB() const
Definition: ParabolaFit.h:28
bool hasWeights
Definition: ParabolaFit.h:52
double parA() const
Definition: ParabolaFit.h:27
double varAB() const
Definition: ParabolaFit.h:33
double varAA() const
Definition: ParabolaFit.h:30
Result theResult
Definition: ParabolaFit.h:53