CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Attributes
sistrip::LinearFit Class Reference

#include <Utility.h>

Classes

class  Params
 

Public Member Functions

void add (const float &value_x, const float &value_y)
 
void add (const float &value_x, const float &value_y, const float &error_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_
 

Detailed Description

Definition at line 11 of file Utility.h.

Constructor & Destructor Documentation

LinearFit::LinearFit ( )

Definition at line 6 of file Utility.cc.

7  : x_(),
8  y_(),
9  e_(),
10  ss_(0.),
11  sx_(0.),
12  sy_(0.)
13 {;}
std::vector< float > x_
Definition: Utility.h:46
std::vector< float > e_
Definition: Utility.h:48
std::vector< float > y_
Definition: Utility.h:47
sistrip::LinearFit::~LinearFit ( )
inline

Definition at line 17 of file Utility.h.

17 {;}

Member Function Documentation

void LinearFit::add ( const float &  value_x,
const float &  value_y 
)

Definition at line 17 of file Utility.cc.

References alignCSCRings::e, and mathSSE::sqrt().

Referenced by OptoScanAlgorithm::analyse(), and counter.Counter::register().

18  {
19  float e = 1.; // default
20  x_.push_back(x);
21  y_.push_back(y);
22  e_.push_back(e);
23  float wt = 1. / sqrt(e);
24  ss_ += wt;
25  sx_ += x*wt;
26  sy_ += y*wt;
27 }
std::vector< float > x_
Definition: Utility.h:46
std::vector< float > e_
Definition: Utility.h:48
T sqrt(T t)
Definition: SSEVec.h:18
std::vector< float > y_
Definition: Utility.h:47
void LinearFit::add ( const float &  value_x,
const float &  value_y,
const float &  error_y 
)

Definition at line 31 of file Utility.cc.

References mathSSE::sqrt().

Referenced by counter.Counter::register().

33  {
34  if ( e > 0. ) {
35  x_.push_back(x);
36  y_.push_back(y);
37  e_.push_back(e);
38  float wt = 1. / sqrt(e);
39  ss_ += wt;
40  sx_ += x*wt;
41  sy_ += y*wt;
42  }
43 }
std::vector< float > x_
Definition: Utility.h:46
std::vector< float > e_
Definition: Utility.h:48
T sqrt(T t)
Definition: SSEVec.h:18
std::vector< float > y_
Definition: Utility.h:47
void LinearFit::fit ( Params fit_params)

Definition at line 47 of file Utility.cc.

References sistrip::LinearFit::Params::a_, b, sistrip::LinearFit::Params::b_, sistrip::LinearFit::Params::erra_, sistrip::LinearFit::Params::errb_, i, sistrip::LinearFit::Params::n_, indexGen::s2, mathSSE::sqrt(), and t.

Referenced by OptoScanAlgorithm::analyse(), and trackingPlots.Iteration::modules().

47  {
48 
49  float s2 = 0.;
50  float b = 0;
51  for ( uint16_t i = 0; i < x_.size(); i++ ) {
52  float t = ( x_[i] - sx_/ss_ ) / e_[i];
53  s2 += t*t;
54  b += t * y_[i] / e_[i];
55  }
56 
57  // Set parameters
58  params.n_ = x_.size();
59  params.b_ = b / s2;
60  params.a_ = ( sy_ - sx_ * params.b_ ) / ss_;
61  params.erra_ = sqrt( ( 1. + (sx_*sx_) / (ss_*s2) ) / ss_ );
62  params.errb_ = sqrt( 1. / s2 );
63 
64  /*
65  params.chi2_ = 0.;
66  *q=1.0;
67  if (mwt == 0) {
68  for (i=1;i<=ndata;i++)
69  *chi2 += SQR(y[i]-(*a)-(*b)*x[i]);
70  sigdat=sqrt((*chi2)/(ndata-2));
71  *sigb *= sigdat;
72  */
73 
74 }
int i
Definition: DBlmapReader.cc:9
std::vector< float > x_
Definition: Utility.h:46
tuple s2
Definition: indexGen.py:106
std::vector< float > e_
Definition: Utility.h:48
T sqrt(T t)
Definition: SSEVec.h:18
std::vector< float > y_
Definition: Utility.h:47
double b
Definition: hdecay.h:120

Member Data Documentation

std::vector<float> sistrip::LinearFit::e_
private

Definition at line 48 of file Utility.h.

float sistrip::LinearFit::ss_
private

Definition at line 49 of file Utility.h.

float sistrip::LinearFit::sx_
private

Definition at line 50 of file Utility.h.

float sistrip::LinearFit::sy_
private

Definition at line 51 of file Utility.h.

std::vector<float> sistrip::LinearFit::x_
private

Definition at line 46 of file Utility.h.

std::vector<float> sistrip::LinearFit::y_
private

Definition at line 47 of file Utility.h.