CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ParabolaFit.h
Go to the documentation of this file.
1 #ifndef ParabolaFit_H
2 #define ParabolaFit_H
3 
4 #include <vector>
5 
11 class ParabolaFit {
12 public:
13  struct Result {
14  double parA, parB, parC;
16  };
18 
19  void addPoint(double x, double y);
20  void addPoint(double x, double y, double weight);
21 
23  void fixParC(double val) {
24  hasFixedParC = true;
25  theResult.parC = val;
26  }
27 
28  const Result& result(bool doErrors) const;
29 
30  double parA() const {
31  if (!hasValues)
32  result(doErr);
33  return theResult.parA;
34  }
35  double parB() const {
36  if (!hasValues)
37  result(doErr);
38  return theResult.parB;
39  }
40  double parC() const {
41  if (!hasValues)
42  result(doErr);
43  return theResult.parC;
44  }
45  double varAA() const {
46  if (!hasErrors)
47  result(true);
48  return theResult.varAA;
49  }
50  double varBB() const {
51  if (!hasErrors)
52  result(true);
53  return theResult.varBB;
54  }
55  double varCC() const {
56  if (!hasErrors)
57  result(true);
58  return theResult.varCC;
59  }
60  double varAB() const {
61  if (!hasErrors)
62  result(true);
63  return theResult.varAB;
64  }
65  double varAC() const {
66  if (!hasErrors)
67  result(true);
68  return theResult.varAC;
69  }
70  double varBC() const {
71  if (!hasErrors)
72  result(true);
73  return theResult.varBC;
74  }
75 
76  double chi2() const;
77  int dof() const;
78 
79 private:
80  struct Column {
81  double r1;
82  double r2;
83  double r3;
84  };
85  double det(const Column& c1, const Column& c2, const Column& c3) const;
86  double det(const Column& c1, const Column& c2) const;
87 
88  double fun(double x) const;
89 
90 private:
91  struct Point {
92  double x;
93  double y;
94  mutable double w;
95  };
96  std::vector<Point> points;
98  mutable bool hasValues, hasErrors;
99  bool hasWeights;
100  mutable Result theResult;
101 };
102 
103 #endif
double parC() const
Definition: ParabolaFit.h:40
int dof() const
Definition: ParabolaFit.cc:121
const Result & result(bool doErrors) const
Definition: ParabolaFit.cc:21
bool hasValues
Definition: ParabolaFit.h:98
double varCC() const
Definition: ParabolaFit.h:55
bool hasFixedParC
Definition: ParabolaFit.h:97
std::vector< Point > points
Definition: ParabolaFit.h:96
double det(const Column &c1, const Column &c2, const Column &c3) const
Definition: ParabolaFit.cc:129
double varBB() const
Definition: ParabolaFit.h:50
void skipErrorCalculationByDefault()
Definition: ParabolaFit.h:22
double varBC() const
Definition: ParabolaFit.h:70
bool hasErrors
Definition: ParabolaFit.h:98
double chi2() const
Definition: ParabolaFit.cc:111
void addPoint(double x, double y)
Definition: ParabolaFit.cc:9
double fun(double x) const
Definition: ParabolaFit.cc:119
double varAC() const
Definition: ParabolaFit.h:65
void fixParC(double val)
Definition: ParabolaFit.h:23
double parB() const
Definition: ParabolaFit.h:35
bool hasWeights
Definition: ParabolaFit.h:99
double parA() const
Definition: ParabolaFit.h:30
double varAB() const
Definition: ParabolaFit.h:60
int weight
Definition: histoStyle.py:51
double varAA() const
Definition: ParabolaFit.h:45
Result theResult
Definition: ParabolaFit.h:100