CMS 3D CMS Logo

Classes | Functions
LinearFit.h File Reference
#include <vector>

Go to the source code of this file.

Classes

class  LinearFit
 

Functions

template<typename T >
void linearFit (T const *__restrict__ x, T const *__restrict__ y, int ndat, T const *__restrict__ sigy2, T &slope, T &intercept, T &covss, T &covii, T &covsi)
 

Function Documentation

◆ linearFit()

template<typename T >
void linearFit ( T const *__restrict__  x,
T const *__restrict__  y,
int  ndat,
T const *__restrict__  sigy2,
T slope,
T intercept,
T covss,
T covii,
T covsi 
)

Definition at line 29 of file LinearFit.h.

37  {
38  T g1 = 0, g2 = 0;
39  T s11 = 0, s12 = 0, s22 = 0;
40  for (int i = 0; i != ndat; i++) {
41  T sy2 = T(1) / sigy2[i];
42  g1 += y[i] * sy2;
43  g2 += x[i] * y[i] * sy2;
44  s11 += sy2;
45  s12 += x[i] * sy2;
46  s22 += x[i] * x[i] * sy2;
47  }
48 
49  T d = T(1) / (s11 * s22 - s12 * s12);
50  intercept = (g1 * s22 - g2 * s12) * d;
51  slope = (g2 * s11 - g1 * s12) * d;
52 
53  covii = s22 * d;
54  covss = s11 * d;
55  covsi = -s12 * d;
56 }

References ztail::d, diffTwoXMLs::g1, diffTwoXMLs::g2, mps_fire::i, slope, vertices_cff::x, and detailsBasic3DVector::y.

Referenced by RZLine::calculate().

mps_fire.i
i
Definition: mps_fire.py:355
diffTwoXMLs.g1
g1
Definition: diffTwoXMLs.py:52
vertices_cff.x
x
Definition: vertices_cff.py:29
diffTwoXMLs.g2
g2
Definition: diffTwoXMLs.py:71
T
long double T
Definition: Basic3DVectorLD.h:48
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14
ztail.d
d
Definition: ztail.py:151
slope
static const double slope[3]
Definition: CastorTimeSlew.cc:6