CMS 3D CMS Logo

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::LinearFit ( )

Definition at line 6 of file Utility.cc.

6 : x_(), y_(), e_(), ss_(0.), sx_(0.), sy_(0.) { ; }
std::vector< float > x_
Definition: Utility.h:42
std::vector< float > e_
Definition: Utility.h:44
std::vector< float > y_
Definition: Utility.h:43

◆ ~LinearFit()

sistrip::LinearFit::~LinearFit ( )
inline

Definition at line 15 of file Utility.h.

15 { ; }

Member Function Documentation

◆ add() [1/2]

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

Definition at line 10 of file Utility.cc.

References MillePedeFileConverter_cfg::e, mathSSE::sqrt(), and x.

Referenced by OptoScanAlgorithm::analyse(), counter.Counter::register(), SequenceTypes._TaskBase::remove(), and SequenceTypes._TaskBase::replace().

10  {
11  float e = 1.; // default
12  x_.push_back(x);
13  y_.push_back(y);
14  e_.push_back(e);
15  float wt = 1. / sqrt(e);
16  ss_ += wt;
17  sx_ += x * wt;
18  sy_ += y * wt;
19 }
std::vector< float > x_
Definition: Utility.h:42
std::vector< float > e_
Definition: Utility.h:44
T sqrt(T t)
Definition: SSEVec.h:19
std::vector< float > y_
Definition: Utility.h:43

◆ add() [2/2]

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

Definition at line 23 of file Utility.cc.

References MillePedeFileConverter_cfg::e, mathSSE::sqrt(), and x.

Referenced by counter.Counter::register(), SequenceTypes._TaskBase::remove(), and SequenceTypes._TaskBase::replace().

23  {
24  if (e > 0.) {
25  x_.push_back(x);
26  y_.push_back(y);
27  e_.push_back(e);
28  float wt = 1. / sqrt(e);
29  ss_ += wt;
30  sx_ += x * wt;
31  sy_ += y * wt;
32  }
33 }
std::vector< float > x_
Definition: Utility.h:42
std::vector< float > e_
Definition: Utility.h:44
T sqrt(T t)
Definition: SSEVec.h:19
std::vector< float > y_
Definition: Utility.h:43

◆ fit()

void LinearFit::fit ( Params fit_params)

Definition at line 37 of file Utility.cc.

References b, mps_fire::i, submitPVValidationJobs::params, mathSSE::sqrt(), and submitPVValidationJobs::t.

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

37  {
38  float s2 = 0.;
39  float b = 0;
40  for (uint16_t i = 0; i < x_.size(); i++) {
41  float t = (x_[i] - sx_ / ss_) / e_[i];
42  s2 += t * t;
43  b += t * y_[i] / e_[i];
44  }
45 
46  // Set parameters
47  params.n_ = x_.size();
48  params.b_ = b / s2;
49  params.a_ = (sy_ - sx_ * params.b_) / ss_;
50  params.erra_ = sqrt((1. + (sx_ * sx_) / (ss_ * s2)) / ss_);
51  params.errb_ = sqrt(1. / s2);
52 
53  /*
54  params.chi2_ = 0.;
55  *q=1.0;
56  if (mwt == 0) {
57  for (i=1;i<=ndata;i++)
58  *chi2 += SQR(y[i]-(*a)-(*b)*x[i]);
59  sigdat=sqrt((*chi2)/(ndata-2));
60  *sigb *= sigdat;
61  */
62 }
std::vector< float > x_
Definition: Utility.h:42
std::vector< float > e_
Definition: Utility.h:44
T sqrt(T t)
Definition: SSEVec.h:19
std::vector< float > y_
Definition: Utility.h:43
double b
Definition: hdecay.h:120

Member Data Documentation

◆ e_

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

Definition at line 44 of file Utility.h.

◆ ss_

float sistrip::LinearFit::ss_
private

Definition at line 45 of file Utility.h.

◆ sx_

float sistrip::LinearFit::sx_
private

Definition at line 46 of file Utility.h.

◆ sy_

float sistrip::LinearFit::sy_
private

Definition at line 47 of file Utility.h.

◆ x_

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

Definition at line 42 of file Utility.h.

◆ y_

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

Definition at line 43 of file Utility.h.