35 if (
segment->mdtHitsOnTrack() < 3) {
return 0.0; }
48 std::vector<SamplePoint> my_points(3);
66 time = mdt_hit->driftTime();
67 sigma = mdt_hit->sigmaDriftRadius();
68 if (
sigma > 10.0 && std::abs(mdt_hit->driftRadius()) > 14.0) r_selection[
k] = 1;
69 if (
sigma > 10.0 && mdt_hit->driftTime() < 50.0)
sigma = 0.3;
76 if (!
m_cfitter->fit(seg, r_selection, curved_track)) {
81 if (!
m_qfitter->fitCallByReference(seg, r_selection, straight_track)) {
87 my_points[0].set_x1(0.0);
93 my_points[0].set_error(1.0);
99 sigma = mdt_hit->sigmaDriftRadius();
102 if (!segment_fitter->
fit(seg, r_selection)) {
113 my_points[1].set_error(1.0);
117 if (my_points[1].
x2() > my_points[0].
x2()) {
121 time = mdt_hit->driftTime() + 2.0 *
m_delta_t0;
124 sigma = mdt_hit->sigmaDriftRadius();
127 if (!segment_fitter->
fit(seg, r_selection)) {
136 my_points[2].set_error(1.0);
139 if (my_points[1].
x2() > my_points[0].
x2() && my_points[2].
x2() < my_points[0].
x2()) {
140 my_points[1].set_x1(my_points[2].
x1());
141 my_points[1].set_x2(my_points[2].
x2());
146 time = mdt_hit->driftTime() - 2.0 *
m_delta_t0;
147 sigma = mdt_hit->sigmaDriftRadius();
150 if (!segment_fitter->
fit(seg, r_selection)) {
159 my_points[2].set_error(1.0);
163 if (my_points[1].
x1() < 0.0) {
164 for (
unsigned int l = 3; my_points[
l - 1].x2() < my_points[
l - 2].
x2() && std::abs(my_points[
l - 1].
x1()) < 200.0;
l++) {
169 time = mdt_hit->driftTime() + new_point.
x1();
170 sigma = mdt_hit->sigmaDriftRadius();
174 if (!segment_fitter->
fit(seg, r_selection)) {
184 my_points.push_back(new_point);
189 if (my_points[2].
x1() > 0.0) {
190 for (
unsigned int l = 3; my_points[
l - 1].x2() <= my_points[
l - 2].
x2() && std::abs(my_points[
l - 1].
x1()) < 200.0;
l++) {
194 time = mdt_hit->driftTime() + new_point.
x1();
195 sigma = mdt_hit->sigmaDriftRadius();
198 if (!segment_fitter->
fit(seg, r_selection)) {
208 my_points.push_back(new_point);
215 fitter.fit_parameters(my_points, my_points.size() - 2, my_points.size(), pol);
220 if (std::isnan(
error)) {
225 double direction{-0.5}, min_chi2{DBL_MAX};
226 double best_t0 = delta_t0_opt;
227 double current_t0 = delta_t0_opt;
228 std::vector<double>
t0s,
chi2, mchi2;
231 time = mdt_hit->driftTime() + current_t0;
232 sigma = mdt_hit->sigmaDriftRadius();
235 if (!segment_fitter->
fit(seg, r_selection)) {
246 if (chisq < min_chi2) {
248 best_t0 = current_t0;
250 if (direction > 0)
break;
252 current_t0 = delta_t0_opt;
254 current_t0 += direction;
255 t0s.push_back(current_t0);
256 chi2.push_back(chisq);
257 mchi2.push_back(min_chi2);
258 if (
t0s.size() > 100) {
267 delta_t0_opt = best_t0;
269 if (!overwrite) {
return delta_t0_opt; }
270 bool segment_t0_was_applied{
false};
272 segment_t0_was_applied |= mdt_hit->segmentT0Applied();
273 time = mdt_hit->driftTime() + delta_t0_opt;
274 sigma = mdt_hit->sigmaDriftRadius();
276 mdt_hit->setDriftTime(time);
278 mdt_hit->setSegmentT0Applied(
true);
280 if (segment_t0_was_applied) {
283 segment->setFittedT0(-delta_t0_opt);
287 if (segment_fitter->
fit(*
segment, r_selection) == 0.0) {