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 
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
DDAxes::y
ParabolaFit::theResult
Result theResult
Definition: ParabolaFit.h:100
ParabolaFit::doErr
bool doErr
Definition: ParabolaFit.h:97
ParabolaFit
Definition: ParabolaFit.h:11
ParabolaFit::Point::x
double x
Definition: ParabolaFit.h:92
funct::false
false
Definition: Factorize.h:34
ParabolaFit::Result::varAC
double varAC
Definition: ParabolaFit.h:15
ParabolaFit::hasFixedParC
bool hasFixedParC
Definition: ParabolaFit.h:97
ParabolaFit::dof
int dof() const
Definition: ParabolaFit.cc:121
ParabolaFit::Column::r3
double r3
Definition: ParabolaFit.h:83
ParabolaFit::Result::varBB
double varBB
Definition: ParabolaFit.h:15
ParabolaFit::fun
double fun(double x) const
Definition: ParabolaFit.cc:119
ParabolaFit::Column::r2
double r2
Definition: ParabolaFit.h:82
ParabolaFit::points
std::vector< Point > points
Definition: ParabolaFit.h:96
ParabolaFit::varAA
double varAA() const
Definition: ParabolaFit.h:45
DDAxes::x
ParabolaFit::Result::varAB
double varAB
Definition: ParabolaFit.h:15
ParabolaFit::varAC
double varAC() const
Definition: ParabolaFit.h:65
ParabolaFit::Result::parB
double parB
Definition: ParabolaFit.h:14
ParabolaFit::Point::w
double w
Definition: ParabolaFit.h:94
ParabolaFit::Result::varCC
double varCC
Definition: ParabolaFit.h:15
ParabolaFit::varBC
double varBC() const
Definition: ParabolaFit.h:70
ParabolaFit::ParabolaFit
ParabolaFit()
Definition: ParabolaFit.h:17
ParabolaFit::hasErrors
bool hasErrors
Definition: ParabolaFit.h:98
ParabolaFit::parA
double parA() const
Definition: ParabolaFit.h:30
ParabolaFit::Point
Definition: ParabolaFit.h:91
ParabolaFit::skipErrorCalculationByDefault
void skipErrorCalculationByDefault()
Definition: ParabolaFit.h:22
funct::true
true
Definition: Factorize.h:173
ParabolaFit::Result::parA
double parA
Definition: ParabolaFit.h:14
ParabolaFit::addPoint
void addPoint(double x, double y)
Definition: ParabolaFit.cc:9
alignmentValidation.c1
c1
do drawing
Definition: alignmentValidation.py:1025
ParabolaFit::varBB
double varBB() const
Definition: ParabolaFit.h:50
ParabolaFit::varAB
double varAB() const
Definition: ParabolaFit.h:60
ParabolaFit::fixParC
void fixParC(double val)
Definition: ParabolaFit.h:23
ParabolaFit::det
double det(const Column &c1, const Column &c2, const Column &c3) const
Definition: ParabolaFit.cc:129
heppy_batch.val
val
Definition: heppy_batch.py:351
ParabolaFit::parC
double parC() const
Definition: ParabolaFit.h:40
ParabolaFit::Result::varBC
double varBC
Definition: ParabolaFit.h:15
ParabolaFit::hasWeights
bool hasWeights
Definition: ParabolaFit.h:99
ParabolaFit::Point::y
double y
Definition: ParabolaFit.h:93
ParabolaFit::varCC
double varCC() const
Definition: ParabolaFit.h:55
ParabolaFit::Result::parC
double parC
Definition: ParabolaFit.h:14
ParabolaFit::result
const Result & result(bool doErrors) const
Definition: ParabolaFit.cc:21
ParabolaFit::Result
Definition: ParabolaFit.h:13
ParabolaFit::Column
Definition: ParabolaFit.h:80
ParabolaFit::chi2
double chi2() const
Definition: ParabolaFit.cc:111
weight
Definition: weight.py:1
ParabolaFit::hasValues
bool hasValues
Definition: ParabolaFit.h:98
ParabolaFit::parB
double parB() const
Definition: ParabolaFit.h:35
ParabolaFit::Column::r1
double r1
Definition: ParabolaFit.h:81
ParabolaFit::Result::varAA
double varAA
Definition: ParabolaFit.h:15