CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions
DTLinearFit Class Reference

#include <DTLinearFit.h>

Public Member Functions

 DTLinearFit ()
 Constructor. More...
 
void fit (const std::vector< float > &x, const std::vector< float > &y, int ndat, const std::vector< float > &sigy, float &slope, float &intercept, float &covss, float &covii, float &covsi) const
 
 ~DTLinearFit ()
 Destructor. More...
 

Detailed Description

Description:

detailed description

Author
Stefano Lacaprara - INFN Legnaro stefa.nosp@m.no.l.nosp@m.acapr.nosp@m.ara@.nosp@m.pd.in.nosp@m.fn.i.nosp@m.t

Definition at line 25 of file DTLinearFit.h.

Constructor & Destructor Documentation

DTLinearFit::DTLinearFit ( )

Constructor.

Definition at line 17 of file DTLinearFit.cc.

17  {
18 
19 }
DTLinearFit::~DTLinearFit ( )

Destructor.

Definition at line 22 of file DTLinearFit.cc.

22  {
23 }

Member Function Documentation

void DTLinearFit::fit ( const std::vector< float > &  x,
const std::vector< float > &  y,
int  ndat,
const std::vector< float > &  sigy,
float &  slope,
float &  intercept,
float &  covss,
float &  covii,
float &  covsi 
) const

Definition at line 26 of file DTLinearFit.cc.

References diffTwoXMLs::g1, diffTwoXMLs::g2, and i.

Referenced by DTSegmentUpdator::fit().

35 {
36 
37  float g1 = 0, g2 = 0;
38  float s11 = 0, s12 = 0, s22 = 0;
39  for (int i = 0; i != ndat; i++) {
40  float sy2 = sigy[i] * sigy[i];
41  g1 += y[i] / sy2;
42  g2 += x[i]*y[i] / sy2;
43  s11 += 1. / sy2;
44  s12 += x[i] / sy2;
45  s22 += x[i]*x[i] / sy2;
46  }
47 
48  float d = s11*s22 - s12*s12;
49  intercept = (g1*s22 - g2*s12) / d;
50  slope = (g2*s11 - g1*s12) / d;
51 
52  covii = s22 / d;
53  covss = s11 / d;
54  covsi = -s12 / d;
55 
56 }
int i
Definition: DBlmapReader.cc:9
static const double slope[3]
Definition: DDAxes.h:10