File indexing completed on 2024-04-06 12:28:39
0001 #ifndef RecoTracker_PixelTrackFitting_src_ParabolaFit_h
0002 #define RecoTracker_PixelTrackFitting_src_ParabolaFit_h
0003
0004 #include <vector>
0005
0006
0007
0008
0009
0010
0011 class ParabolaFit {
0012 public:
0013 struct Result {
0014 double parA, parB, parC;
0015 double varAA, varBB, varCC, varAB, varAC, varBC;
0016 };
0017 ParabolaFit() : doErr(true), hasFixedParC(false), hasValues(false), hasErrors(false), hasWeights(true) {}
0018
0019 void addPoint(double x, double y);
0020 void addPoint(double x, double y, double weight);
0021
0022 void skipErrorCalculationByDefault() { doErr = false; }
0023 void fixParC(double val) {
0024 hasFixedParC = true;
0025 theResult.parC = val;
0026 }
0027
0028 const Result& result(bool doErrors) const;
0029
0030 double parA() const {
0031 if (!hasValues)
0032 result(doErr);
0033 return theResult.parA;
0034 }
0035 double parB() const {
0036 if (!hasValues)
0037 result(doErr);
0038 return theResult.parB;
0039 }
0040 double parC() const {
0041 if (!hasValues)
0042 result(doErr);
0043 return theResult.parC;
0044 }
0045 double varAA() const {
0046 if (!hasErrors)
0047 result(true);
0048 return theResult.varAA;
0049 }
0050 double varBB() const {
0051 if (!hasErrors)
0052 result(true);
0053 return theResult.varBB;
0054 }
0055 double varCC() const {
0056 if (!hasErrors)
0057 result(true);
0058 return theResult.varCC;
0059 }
0060 double varAB() const {
0061 if (!hasErrors)
0062 result(true);
0063 return theResult.varAB;
0064 }
0065 double varAC() const {
0066 if (!hasErrors)
0067 result(true);
0068 return theResult.varAC;
0069 }
0070 double varBC() const {
0071 if (!hasErrors)
0072 result(true);
0073 return theResult.varBC;
0074 }
0075
0076 double chi2() const;
0077 int dof() const;
0078
0079 private:
0080 struct Column {
0081 double r1;
0082 double r2;
0083 double r3;
0084 };
0085 double det(const Column& c1, const Column& c2, const Column& c3) const;
0086 double det(const Column& c1, const Column& c2) const;
0087
0088 double fun(double x) const;
0089
0090 private:
0091 struct Point {
0092 double x;
0093 double y;
0094 mutable double w;
0095 };
0096 std::vector<Point> points;
0097 bool doErr, hasFixedParC;
0098 mutable bool hasValues, hasErrors;
0099 bool hasWeights;
0100 mutable Result theResult;
0101 };
0102
0103 #endif