Belle II Software development
Linear_fit_of_Hits_t Struct Reference

Public Member Functions

template<typename Container_T >
auto operator() (const Container_T &container) const
 

Detailed Description

Definition at line 102 of file klm_trig_linear_fit.cc.

Member Function Documentation

◆ operator()()

auto operator() ( const Container_T &  container) const
inline

Definition at line 104 of file klm_trig_linear_fit.cc.

105 {
106
107
108
109 int64_t sumX = 0, sumY = 0, sumXX = 0, sumXY = 0, sumYY = 0;
110 for (const auto& e : container) {
111 sumX += e.x_pos;
112 sumXX += e.x_pos * e.x_pos;
113
114 sumY += e.y_pos;
115 sumYY += e.y_pos * e.y_pos;
116
117 sumXY += e.x_pos * e.y_pos;
118 }
119 int64_t nHits = container.size();
120 int denom = sumXX * nHits - sumX * sumX;
121 if (denom == 0) {
122 return nt::ntuple(slopeXY(1e9), interceptXY(1e9), ipXY(1e9), chisqXY(1e9), Nhits(nHits));
123 }
124
125 auto slopeXY_ = slopeXY((double)(sumXY * nHits - sumX * sumY) / (double)denom);
126 auto interceptXY_ = interceptXY((double)(sumXX * sumY - sumX * sumXY) / (double)denom);
127
128 auto ipXY_ = ipXY(interceptXY_ * interceptXY_ * (1.0 - slopeXY_ * slopeXY_));
129
130 auto chisqXY_ = chisqXY(slopeXY_ * slopeXY_ * sumXX
131 + interceptXY_ * interceptXY_ * nHits
132 + sumYY
133 + 2.0 * slopeXY_ * interceptXY_ * sumX
134 - 2.0 * slopeXY_ * sumXY
135 - 2.0 * interceptXY_ * sumY);
136
137 return nt::ntuple(slopeXY_, interceptXY_, ipXY_, chisqXY_, Nhits(nHits));
138 }

The documentation for this struct was generated from the following file: