314 std::vector<unsigned int> hit_index;
315 unsigned int try_nb_hits;
319 std::vector<unsigned int> selected_hits_index;
323 double r_min, r_max{};
324 double sigma2_min, sigma2_max;
326 unsigned int counter1;
328 unsigned int nb_candidates(0);
347 <<
"fitCallByReference() - Vector with selected hits unequal to the number of hits on the segment! The user selection will "
357 if (!r_selection[
k]) {
358 selected_hits.push_back(r_segment.
mdtHOT()[
k]);
359 selected_hits_index.push_back(
k);
368 if (selected_hits.size() < 3) {
return false; }
386 try_nb_hits = selected_hits.size();
388 while (nb_candidates == 0) {
391 if (try_nb_hits < 5 && (selected_hits.size() - try_nb_hits) > 2)
return false;
393 double best_chi2ndf = -1.0;
397 combination.setNewParameters(selected_hits.size(), try_nb_hits);
400 for (
unsigned int cb = 0; cb < combination.numberOfCombinations(); cb++) {
410 combination.currentCombination(hit_index);
412 combination.nextCombination(hit_index);
417 tmp_selection.assign(tmp_selection.size(), 1);
418 for (
unsigned int k = 0;
k < try_nb_hits;
k++) { tmp_selection[selected_hits_index[hit_index[
k] - 1]] = 0; }
422 w_min = selected_hits[hit_index[0] - 1]->localPosition();
423 w_max = selected_hits[hit_index[0] - 1]->localPosition();
424 r_min = selected_hits[hit_index[0] - 1]->driftRadius();
425 r_max = selected_hits[hit_index[0] - 1]->driftRadius();
426 sigma2_min = selected_hits[hit_index[0] - 1]->sigma2DriftRadius();
427 sigma2_max = selected_hits[hit_index[0] - 1]->sigma2DriftRadius();
428 for (
unsigned int k = 1;
k < try_nb_hits;
k++) {
429 if (selected_hits[hit_index[
k] - 1]->localPosition().
z() < w_min.z()) {
430 w_min = selected_hits[hit_index[
k] - 1]->localPosition();
431 r_min = selected_hits[hit_index[
k] - 1]->driftRadius();
432 sigma2_min = selected_hits[hit_index[
k] - 1]->sigma2DriftRadius();
434 if (selected_hits[hit_index[
k] - 1]->localPosition().
z() > w_max.z()) {
435 w_max = selected_hits[hit_index[
k] - 1]->localPosition();
436 r_max = selected_hits[hit_index[
k] - 1]->driftRadius();
437 sigma2_max = selected_hits[hit_index[
k] - 1]->sigma2DriftRadius();
442 if (sigma2_min == 0) { sigma2_min = 0.1; }
443 if (sigma2_max == 0) { sigma2_max = 0.1; }
446 for (
unsigned int r_case = 1; r_case < 5; r_case++) {
447 tangents[r_case - 1] =
tangent(w_min, r_min, sigma2_min, w_max, r_max, sigma2_max, r_case);
452 for (
unsigned int r_case = 1; r_case < 5; r_case++) {
454 for (
unsigned int n = 0;
n < try_nb_hits;
n++) {
455 MTStraightLine aux_line(selected_hits[hit_index[
n] - 1]->localPosition(), xhat,
null,
null);
456 if (std::abs(std::abs(tangents[r_case - 1].signDistFrom(aux_line)) - selected_hits[hit_index[
n] - 1]->
driftRadius()) <=
458 counter1 = counter1 + 1;
465 if (counter1 == try_nb_hits) {
467 aux_track =
fitCandidate(r_segment, tmp_selection, tangents[r_case - 1]);
469 if ((best_chi2ndf == -1) || (best_chi2ndf > r_segment.
chi2())) {
470 best_chi2ndf = r_segment.
chi2();
471 best_aux_line = aux_track;
472 final_selection.assign(final_selection.size(), 1);
473 for (
unsigned int j = 0; j < try_nb_hits; j++) { final_selection[selected_hits_index[hit_index[j] - 1]] = 0; }
486 if (nb_candidates > 0) {
488 for (
unsigned int k = 0;
k < r_selection.size();
k++) {
489 r_selection[
k] = final_selection[
k];
490 if (!final_selection[
k]) { used_hits.push_back(r_segment.
mdtHOT()[
k]); }
494 fitted_track =
fitCandidate(r_segment, final_selection, best_aux_line);
495 fitted_track.setUsedHits(used_hits);
500 try_nb_hits = try_nb_hits - 1;
501 if (try_nb_hits < 3) {
return false; }
508 return fitted_track.chi2() > 0;