14 unsigned int N = dcs.size();
24 for (
unsigned int i = 0;
i <
N; ++
i) {
33 double S{0}, Sz{0}, Sy{0};
36 std::vector<FitData>
data;
39 for (
const DCOnTrack&
it : dcs) {
43 datum.r = std::abs(
it.r());
48 Sz += datum.w * datum.z;
49 Sy += datum.w * datum.y;
51 data.push_back(std::move(datum));
62 double Syy{0}, Szy{0}, Syyzz{0};
64 for (
unsigned int i = 0;
i <
N; ++
i) {
65 FitData& datum =
data[
i];
73 datum.rw = datum.r * datum.w;
74 datum.ryw = datum.rw * datum.y;
75 datum.rzw = datum.rw * datum.z;
77 Syy += datum.y * datum.y * datum.w;
78 Szy += datum.y * datum.z * datum.w;
79 Syyzz += (datum.y - datum.z) * (datum.y + datum.z) * datum.w;
82 unsigned int count{0};
83 double R{0}, Ry{0}, Rz{0}, Att{0}, Add{
S}, Bt{0}, Bd{0}, Stt{0}, Sd{0};
93 }
else if (sinus == 0.0 && cosin < 0.0) {
98 double d =
line.y0() + Zc * sinus - Yc * cosin;
100 while (
count < 100) {
103 for (
unsigned int i = 0;
i <
N; ++
i) {
107 FitData& datum =
data[
i];
109 double dist = datum.y * cosin - datum.z * sinus;
120 Att = Syy + cosin * (2 * sinus * Szy - cosin * Syyzz);
121 Bt = -Szy + cosin * (sinus * Syyzz + 2 * cosin * Szy + Rz) + sinus * Ry;
124 if (
data.capacity() > 100) {
126 result.dcs().reserve(100);
136 sinus = std::sqrt(1 - cosin * cosin);
138 if (std::abs(Bt / Att) < 0.001 && std::abs(Bd / Add) < 0.001) {
139 Stt = std::sqrt(1 / Att);
140 Sd = std::sqrt(1 / Add);
150 double yl{0},
chi2{0};
156 result.clusters().clear();
157 result.emptyTubes().clear();
159 unsigned int nhits{0};
163 for (
unsigned int i = 0;
i <
N; ++
i) {
164 FitData& datum =
data[
i];
165 yl = cosin * datum.y - sinus * datum.z -
d;
166 double dth = -(sinus * datum.y + cosin * datum.z) * Stt;
167 double errorResiduals = std::hypot(dth, Sd);
168 double residuals = std::abs(yl) - datum.r;
171 chi2 += residuals * residuals * datum.w;
173 result.dcs().emplace_back(dcs[
i]);
174 result.dcs().back().residual(residuals);
175 result.dcs().back().errorTrack(errorResiduals);
179 result.line().set(LocVec2D(Zc - sinus *
d, Yc + cosin *
d), theta);