CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

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 26 of file LinearFit.h.

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

Referenced by RZLine::fit(), RoadSearchTrackCandidateMakerAlgorithm::initialTrajectory(), and RoadSearchTrackCandidateMakerAlgorithm::initialTrajectoryFromTriplet().

29  {
30  T g1 = 0, g2 = 0;
31  T s11 = 0, s12 = 0, s22 = 0;
32  for (int i = 0; i != ndat; i++) {
33  T sy2 = T(1)/sigy2[i];
34  g1 += y[i] *sy2;
35  g2 += x[i]*y[i] * sy2;
36  s11 += sy2;
37  s12 += x[i] * sy2;
38  s22 += x[i]*x[i] * sy2;
39  }
40 
41  T d = T(1)/(s11*s22 - s12*s12);
42  intercept = (g1*s22 - g2*s12) * d;
43  slope = (g2*s11 - g1*s12) * d;
44 
45  covii = s22 * d;
46  covss = s11 * d;
47  covsi = -s12 * d;
48 }
int i
Definition: DBlmapReader.cc:9
static const double slope[3]
x
Definition: VDTMath.h:216
long double T