#include "LinFitAlg.h"
|
| LinFitAlg () |
|
virtual | ~LinFitAlg () |
|
void | LinFit (std::vector< float > &x, std::vector< float > &y, std::vector< float > &ey2, float &Intercept, float &Slope, float &InterceptError, float &SlopeError, float &ChiDOF) |
|
Definition at line 20 of file LinFitAlg.h.
trkf::LinFitAlg::LinFitAlg |
( |
| ) |
|
trkf::LinFitAlg::~LinFitAlg |
( |
| ) |
|
|
virtual |
void trkf::LinFitAlg::LinFit |
( |
std::vector< float > & |
x, |
|
|
std::vector< float > & |
y, |
|
|
std::vector< float > & |
ey2, |
|
|
float & |
Intercept, |
|
|
float & |
Slope, |
|
|
float & |
InterceptError, |
|
|
float & |
SlopeError, |
|
|
float & |
ChiDOF |
|
) |
| |
Definition at line 26 of file LinFitAlg.cxx.
References B, and weight.
35 if(y.size() < 2)
return;
36 if(x.size() < y.size() || ey2.size() < y.size())
return;
47 for(ii = 0; ii < y.size(); ++ii) {
48 weight = 1. / ey2[ii];
50 sumx += weight * x[ii];
51 sumy += weight * y[ii];
52 sumx2 += weight * x[ii] * x[ii];
53 sumxy += weight * x[ii] * y[ii];
54 sumy2 += weight * y[ii] * y[ii];
57 double delta = sum * sumx2 - sumx * sumx;
58 if(delta == 0.)
return;
59 double A = (sumx2 * sumy - sumx * sumxy) / delta;
60 double B = (sumxy * sum - sumx * sumy) / delta;
67 double ndof = x.size() - 2;
68 double varnce = (sumy2 + A*A*sum + B*B*sumx2 - 2 * (A*sumy + B*sumxy - A*B*sumx)) / ndof;
70 InterceptError = sqrt(varnce * sumx2 / delta);
71 SlopeError = sqrt(varnce * sum / delta);
78 for(ii = 0; ii < y.size(); ++ii) {
79 arg = y[ii] - A - B * x[ii];
80 sum += arg * arg / ey2[ii];
The documentation for this class was generated from the following files:
- /cvmfs/larsoft.opensciencegrid.org/products/larreco/v07_10_02/source/larreco/RecoAlg/LinFitAlg.h
- /cvmfs/larsoft.opensciencegrid.org/products/larreco/v07_10_02/source/larreco/RecoAlg/LinFitAlg.cxx