#include <DQM/SiStripCommissioningAnalysis/src/Utility.h>
Public Member Functions | |
void | add (const float &value_x, const float &value_y, const float &error_y) |
void | add (const float &value_x, const float &value_y) |
void | fit (Params &fit_params) |
LinearFit () | |
~LinearFit () | |
Private Attributes | |
std::vector< float > | e_ |
float | ss_ |
float | sx_ |
float | sy_ |
std::vector< float > | x_ |
std::vector< float > | y_ |
Classes | |
class | Params |
Definition at line 11 of file Utility.h.
LinearFit::LinearFit | ( | ) |
void LinearFit::add | ( | const float & | value_x, | |
const float & | value_y, | |||
const float & | error_y | |||
) |
void LinearFit::add | ( | const float & | value_x, | |
const float & | value_y | |||
) |
Definition at line 16 of file Utility.cc.
References e, e_, funct::sqrt(), ss_, sx_, sy_, x_, and y_.
Referenced by OptoScanAlgorithm::analyse().
00017 { 00018 float e = 1.; // default 00019 x_.push_back(x); 00020 y_.push_back(y); 00021 e_.push_back(e); 00022 float wt = 1. / sqrt(e); 00023 ss_ += wt; 00024 sx_ += x*wt; 00025 sy_ += y*wt; 00026 }
Definition at line 46 of file Utility.cc.
References sistrip::LinearFit::Params::a_, b, sistrip::LinearFit::Params::b_, e_, sistrip::LinearFit::Params::erra_, sistrip::LinearFit::Params::errb_, i, sistrip::LinearFit::Params::n_, s2, funct::sqrt(), ss_, sx_, sy_, t, x_, and y_.
Referenced by OptoScanAlgorithm::analyse().
00046 { 00047 00048 float s2 = 0.; 00049 float b = 0; 00050 for ( uint16_t i = 0; i < x_.size(); i++ ) { 00051 float t = ( x_[i] - sx_/ss_ ) / e_[i]; 00052 s2 += t*t; 00053 b += t * y_[i] / e_[i]; 00054 } 00055 00056 // Set parameters 00057 params.n_ = x_.size(); 00058 params.b_ = b / s2; 00059 params.a_ = ( sy_ - sx_ * params.b_ ) / ss_; 00060 params.erra_ = sqrt( ( 1. + (sx_*sx_) / (ss_*s2) ) / ss_ ); 00061 params.errb_ = sqrt( 1. / s2 ); 00062 00063 /* 00064 params.chi2_ = 0.; 00065 *q=1.0; 00066 if (mwt == 0) { 00067 for (i=1;i<=ndata;i++) 00068 *chi2 += SQR(y[i]-(*a)-(*b)*x[i]); 00069 sigdat=sqrt((*chi2)/(ndata-2)); 00070 *sigb *= sigdat; 00071 */ 00072 00073 }
std::vector<float> sistrip::LinearFit::e_ [private] |
float sistrip::LinearFit::ss_ [private] |
float sistrip::LinearFit::sx_ [private] |
float sistrip::LinearFit::sy_ [private] |
std::vector<float> sistrip::LinearFit::x_ [private] |
std::vector<float> sistrip::LinearFit::y_ [private] |