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.) { ; }

◆ ~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.

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 }

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

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

◆ 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.

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 }

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

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

◆ fit()

void LinearFit::fit ( Params fit_params)

Definition at line 37 of file Utility.cc.

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 }

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

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

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.

mps_fire.i
i
Definition: mps_fire.py:428
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
sistrip::LinearFit::sx_
float sx_
Definition: Utility.h:46
sistrip::LinearFit::ss_
float ss_
Definition: Utility.h:45
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
sistrip::LinearFit::x_
std::vector< float > x_
Definition: Utility.h:42
sistrip::LinearFit::sy_
float sy_
Definition: Utility.h:47
b
double b
Definition: hdecay.h:118
sistrip::LinearFit::y_
std::vector< float > y_
Definition: Utility.h:43
genVertex_cff.x
x
Definition: genVertex_cff.py:13
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
sistrip::LinearFit::e_
std::vector< float > e_
Definition: Utility.h:44
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37