#include <ParabolaFit.h>
Classes | |
struct | Column |
struct | Point |
struct | Result |
Public Member Functions | |
void | addPoint (double x, double y) |
void | addPoint (double x, double y, double weight) |
double | chi2 () const |
int | dof () const |
void | fixParC (double val) |
double | parA () const |
ParabolaFit () | |
double | parB () const |
double | parC () const |
const Result & | result (bool doErrors) const |
void | skipErrorCalculationByDefault () |
double | varAA () const |
double | varAB () const |
double | varAC () const |
double | varBB () const |
double | varBC () const |
double | varCC () const |
Private Member Functions | |
double | det (const Column &c1, const Column &c2, const Column &c3) const |
double | det (const Column &c1, const Column &c2) const |
double | fun (double x) const |
Private Attributes | |
bool | doErr |
bool | hasErrors |
bool | hasFixedParC |
bool | hasValues |
bool | hasWeights |
std::vector< Point > | points |
Result | theResult |
The parabola fit y = parA + parB * x + parC * x*x see: R.L. Gluckstern, NIM 24 (1963) 381
Definition at line 12 of file ParabolaFit.h.
ParabolaFit::ParabolaFit | ( | ) | [inline] |
Definition at line 16 of file ParabolaFit.h.
: doErr(true), hasFixedParC(false), hasValues(false), hasErrors(false), hasWeights(true) { }
void ParabolaFit::addPoint | ( | double | x, |
double | y | ||
) |
Definition at line 6 of file ParabolaFit.cc.
Referenced by ConformalMappingFit::ConformalMappingFit().
{ hasWeights = false; addPoint(x,y,1.); }
void ParabolaFit::addPoint | ( | double | x, |
double | y, | ||
double | weight | ||
) |
Definition at line 12 of file ParabolaFit.cc.
References AlCaHLTBitMon_ParallelJobs::p, x, and detailsBasic3DVector::y.
double ParabolaFit::chi2 | ( | void | ) | const |
Definition at line 104 of file ParabolaFit.cc.
References funct::sqr().
Referenced by ConformalMappingFit::chi2().
Definition at line 126 of file ParabolaFit.cc.
References ParabolaFit::Column::r1, ParabolaFit::Column::r2, and ParabolaFit::Column::r3.
Definition at line 137 of file ParabolaFit.cc.
References ParabolaFit::Column::r1, and ParabolaFit::Column::r2.
int ParabolaFit::dof | ( | ) | const |
Definition at line 119 of file ParabolaFit.cc.
{ int nPar = 3; if (hasFixedParC) nPar--; int nDof = points.size() - nPar; return (nDof > 0) ? nDof : 0; }
void ParabolaFit::fixParC | ( | double | val | ) | [inline] |
Definition at line 23 of file ParabolaFit.h.
References hasFixedParC, ParabolaFit::Result::parC, and theResult.
Referenced by ConformalMappingFit::fixImpactParmaeter().
{ hasFixedParC = true; theResult.parC = val; }
double ParabolaFit::fun | ( | double | x | ) | const [private] |
double ParabolaFit::parA | ( | ) | const [inline] |
Definition at line 27 of file ParabolaFit.h.
References doErr, hasValues, ParabolaFit::Result::parA, result(), and theResult.
Referenced by ConformalMappingFit::charge(), and ConformalMappingFit::curvature().
double ParabolaFit::parB | ( | ) | const [inline] |
Definition at line 28 of file ParabolaFit.h.
References doErr, hasValues, ParabolaFit::Result::parB, result(), and theResult.
Referenced by ConformalMappingFit::directionPhi().
double ParabolaFit::parC | ( | ) | const [inline] |
Definition at line 29 of file ParabolaFit.h.
References doErr, hasValues, ParabolaFit::Result::parC, result(), and theResult.
Referenced by ConformalMappingFit::impactParameter().
const ParabolaFit::Result & ParabolaFit::result | ( | bool | doErrors | ) | const |
Definition at line 20 of file ParabolaFit.cc.
References funct::pow(), funct::sqr(), w(), x, and detailsBasic3DVector::y.
Referenced by parA(), parB(), parC(), varAA(), varAB(), varAC(), varBB(), varBC(), and varCC().
{ if (hasErrors) return theResult; if (hasValues && !doErrors) return theResult; double F0, F1, F2, F3, F4, F0y, F1y, F2y; F0 = F1 = F2 = F3 = F4 = F0y = F1y = F2y = 0.; typedef vector<Point>::const_iterator IT; for (IT ip = points.begin(); ip != points.end(); ip++) { double pow; double x = ip->x; double y = ip->y; double w = ip->w; F0 += w; F0y += w*y; F1 += w*x; F1y += w*x*y; pow = x*x; F2 += w*pow; F2y += w*pow*y; // x^2 pow *= x; F3 += w*pow; // x^3 pow *= x; F4 += w*pow; // x^4 } Column cA = { F0, F1, F2 }; Column cB = { F1, F2, F3 }; Column cC = { F2, F3, F4 }; Column cY = { F0y, F1y, F2y }; double det0 = det(cA, cB, cC); if ( !hasFixedParC) { theResult.parA = det(cY, cB, cC) / det0; theResult.parB = det(cA, cY, cC) / det0; theResult.parC = det(cA, cB, cY) / det0; } else { Column cCY = {F0y-theResult.parC*F2, F1y-theResult.parC*F3, F2y-theResult.parC*F4}; double det0C = det(cA, cB); theResult.parA = det(cCY, cB) / det0C; theResult.parB = det(cA, cCY) / det0C; } // std::cout <<" result: A="<<theResult.parA<<" B="<<theResult.parB<<" C="<<theResult.parC<<endl; double vAA, vBB, vCC, vAB, vAC, vBC; vAA = vBB = vCC = vAB = vAC = vBC = 0.; hasValues = true; if (!doErrors) return theResult; if( !hasWeights && dof() > 0) { // cout <<" CHI2: " << chi2() <<" DOF: " << dof() << endl; double scale_w = 1./chi2()/dof(); for (IT ip = points.begin(); ip != points.end(); ip++) ip->w *= scale_w; // cout <<" CHI2: " << chi2() <<" DOF: " << dof() << endl; } for (IT ip = points.begin(); ip != points.end(); ip++) { double w = ip->w; Column cX = {1., ip->x, sqr(ip->x) }; double dXBC = det(cX, cB, cC); double dAXC = det(cA, cX, cC); double dABX = det(cA, cB, cX); vAA += w * sqr(dXBC); vBB += w * sqr(dAXC); vCC += w * sqr(dABX); vAB += w * dXBC * dAXC; vAC += w * dXBC * dABX; vBC += w * dAXC * dABX; } theResult.varAA = vAA/sqr(det0); theResult.varBB = vBB/sqr(det0); theResult.varCC = vCC/sqr(det0); theResult.varAB = vAB/sqr(det0); theResult.varAC = vAC/sqr(det0); theResult.varBC = vBC/sqr(det0); hasErrors = true; return theResult; }
void ParabolaFit::skipErrorCalculationByDefault | ( | ) | [inline] |
Definition at line 22 of file ParabolaFit.h.
References doErr.
Referenced by ConformalMappingFit::skipErrorCalculation().
{ doErr = false; }
double ParabolaFit::varAA | ( | ) | const [inline] |
Definition at line 30 of file ParabolaFit.h.
References hasErrors, result(), theResult, and ParabolaFit::Result::varAA.
Referenced by ConformalMappingFit::curvature().
double ParabolaFit::varAB | ( | ) | const [inline] |
Definition at line 33 of file ParabolaFit.h.
References hasErrors, result(), theResult, and ParabolaFit::Result::varAB.
double ParabolaFit::varAC | ( | ) | const [inline] |
Definition at line 34 of file ParabolaFit.h.
References hasErrors, result(), theResult, and ParabolaFit::Result::varAC.
double ParabolaFit::varBB | ( | ) | const [inline] |
Definition at line 31 of file ParabolaFit.h.
References hasErrors, result(), theResult, and ParabolaFit::Result::varBB.
Referenced by ConformalMappingFit::directionPhi().
double ParabolaFit::varBC | ( | ) | const [inline] |
Definition at line 35 of file ParabolaFit.h.
References hasErrors, result(), theResult, and ParabolaFit::Result::varBC.
double ParabolaFit::varCC | ( | ) | const [inline] |
Definition at line 32 of file ParabolaFit.h.
References hasErrors, result(), theResult, and ParabolaFit::Result::varCC.
Referenced by ConformalMappingFit::impactParameter().
bool ParabolaFit::doErr [private] |
Definition at line 50 of file ParabolaFit.h.
Referenced by parA(), parB(), parC(), and skipErrorCalculationByDefault().
bool ParabolaFit::hasErrors [mutable, private] |
bool ParabolaFit::hasFixedParC [private] |
Definition at line 50 of file ParabolaFit.h.
Referenced by fixParC().
bool ParabolaFit::hasValues [mutable, private] |
Definition at line 51 of file ParabolaFit.h.
bool ParabolaFit::hasWeights [private] |
Definition at line 52 of file ParabolaFit.h.
std::vector<Point> ParabolaFit::points [mutable, private] |
Definition at line 49 of file ParabolaFit.h.