9 const std::vector<double>&
y,
13 assert(x.size() == y.size());
22 const unsigned int I = x.size();
23 for(
unsigned int i = 0;
i < I; ++
i) {
30 const double d = I*Sx2 - Sx*Sx;
31 m = (I*Sxy - Sx*Sy)/d;
32 c = (Sy*Sx2 - Sx*Sxy)/d;
36 double LinFit(
const std::vector<double>&
x,
37 const std::vector<double>&
y,
38 const std::vector<double>&
w,
42 assert(x.size() == y.size());
43 assert(x.size() == w.size());
53 for(
unsigned int i = 0;
i < w.size(); ++
i) {
57 Swx2 += w[
i]*x[
i]*x[
i];
58 Swxy += w[
i]*x[
i]*y[
i];
59 Swy2 += w[
i]*y[
i]*y[
i];
61 const double d = Sw*Swx2 - Swx*Swx;
62 m = (Sw*Swxy - Swx*Swy)/d;
63 c = (Swy*Swx2 - Swx*Swxy)/d;
66 Swy2 - 2.0*m*Swxy - 2.0*c*Swy + 2.0*m*c*Swx +
Filter events based on their run/event numbers.
void LinFitUnweighted(const std::vector< double > &x, const std::vector< double > &y, double &m, double &c)
Simplified version of LinFit.
double LinFit(const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &w, double &m, double &c)
Find the best-fit line to a collection of points in 2-D by minimizing the squared vertical distance f...
assert(nhit_max >=nhit_nbins)