339 {
341
343
347 unsigned int nb_selected_hits(0);
349
350 std::vector<unsigned> selected_hits_index(r_selection.size());
351
352
353
354 std::vector<Amg::Vector3D>
w;
355 std::vector<double>
r;
356 std::vector<double> sigma2;
357 unsigned int counter1{0}, counter2{0}, counter3{0};
358 unsigned int max_cand_hits{0};
359
360 int max_cand_HOTs{0};
361
362 int nb_candidates;
363 std::vector<int> k_cand, l_cand;
364 std::vector<int> cand_case;
365 std::vector<int> nb_HOTs;
366 int candidate{0};
367 IndexSet aux_set;
368 std::vector<IndexSet> index_set;
369
370 std::vector<double> intercept;
371 MTStraightLine tangents[4];
372
373 MTStraightLine aux_track;
374 double aux_chi2;
377 MTStraightLine initial_track(r_segment.
position(), r_segment.
direction(), null, null);
378
380
382
387 << "Class QuasianalyticLineReconstruction, method fit: Vector with selected hits unequal to the number of hits on the segment! "
388 "The user selection will be ignored!"
390 r_selection.clear();
392 } else {
393 for (unsigned int k : r_selection) {
394 if (k == 0) { nb_selected_hits = nb_selected_hits + 1; }
395 }
396 }
397
399
401
404 initial_track = MTStraightLine(r_segment.
position(), dir, null, null);
405 }
406
408
409
411
412 if (nb_selected_hits < 3) {
414 log << MSG::WARNING <<
"Class QuasianalyticLineReconstruction, method fit: Too few hits for the track reconstructions!" <<
endmsg;
415 return false;
416 }
417
419
421
422
423 selected_hits.clear();
426 sigma2.clear();
427 selected_hits_index.clear();
428
429 counter2 = 0;
431
434
435
436 selected_hits.push_back(hit);
437 selected_hits_index.push_back(k);
441
442 if (sigma2[counter2] == 0) { sigma2[counter2] = std::pow(0.1 * CLHEP::mm, 2); }
443
444 counter2 = counter2 + 1;
445 }
446 nb_selected_hits = selected_hits.size();
447 if (nb_selected_hits < 3) return false;
449
451
452
453 max_cand_hits = 0;
454 max_cand_HOTs = 0;
455 nb_candidates = 0;
456
457 for (
unsigned int k = 0;
k < nb_selected_hits;
k++) {
458 for (
unsigned int l = k + 1;
l < nb_selected_hits;
l++) {
459
461 diff = difftime(end, start);
464 log << MSG::WARNING <<
"Class QuasianalyticLineReconstruction, method fit: time-out for track finding after " <<
m_time_out
466 return false;
467 }
468
469
470 for (unsigned int r_case = 1; r_case < 5; r_case++) {
471 tangents[r_case - 1] =
tangent(w[l],
r[l], sigma2[l], w[k],
r[k], sigma2[k], r_case);
472 }
473
474
475
476 for (unsigned int r_case = 1; r_case < 5; r_case++) {
478 counter1 = 0;
479 counter3 = 0;
481
482 for (
unsigned int n = 0;
n < nb_selected_hits;
n++) {
483 MTStraightLine aux_line(w[n], xhat, null, null);
484 if (std::abs(std::abs(tangents[r_case - 1].signDistFrom(aux_line)) -
r[n]) <
m_r_max) { counter3++; }
485 if (std::abs(std::abs(tangents[r_case - 1].signDistFrom(aux_line)) -
r[n]) <=
m_road_width) {
486 counter1 = counter1 + 1;
488 }
489 }
490 if (counter1 > 2) {
491 aux_set = IndexSet(counter1, indices);
493 for (
int ca = 0;
ca < nb_candidates;
ca++) {
494 if (aux_set == index_set[ca] && std::abs(intercept[ca] - tangents[r_case - 1].b_x2()) <
m_road_width) {
496 break;
497 }
498 }
499 if (same) { continue; }
500 nb_candidates = nb_candidates + 1;
501 k_cand.push_back(k);
502 l_cand.push_back(l);
503 cand_case.push_back(r_case);
504 index_set.push_back(aux_set);
505 intercept.push_back(tangents[r_case - 1].b_x2());
506 nb_HOTs.push_back(counter3);
507 if (counter1 > max_cand_hits) { max_cand_hits = counter1; }
508 }
509 }
510 }
511 }
512
513
514
515
516
518 if (max_cand_hits < 3) { return false; }
519
520 candidate = 0;
521 for (
int ca = 0;
ca < nb_candidates;
ca++) {
522 if (index_set[ca].size() < max_cand_hits) { continue; }
523
524 aux_track =
track_candidate(index_set[ca], k_cand[ca], l_cand[ca], cand_case[ca], w,
r, sigma2, aux_chi2);
525 if (nb_HOTs[ca] >= max_cand_HOTs) {
526 max_cand_HOTs = nb_HOTs[
ca];
527 if (
chi2 == -1.0 ||
chi2 > aux_chi2) {
529 final_track = aux_track;
531 }
532 }
533 }
534
535 MdtHitVec final_track_hits(max_cand_hits);
536 for (
unsigned int k = 0;
k < max_cand_hits;
k++) { final_track_hits[
k] = selected_hits[index_set[candidate][
k]]; }
537
538
541 final_track = MTStraightLine(aux_pos, aux_dir, null, null);
542
543
544 if (std::isnan(
chi2)) {
chi2 = 1.0e6; }
546
547 std::vector<unsigned int> refit_hit_selection(r_selection.size(), 1);
548 for (
unsigned int k = 0;
k < max_cand_hits;
k++) { refit_hit_selection[selected_hits_index[index_set[candidate][
k]]] = 0; }
550
551
553 if (
m_nfitter.fit(r_segment, refit_hit_selection)) {
555 if (
dir.z() == 0.0) {
dir[2] = (1.0e-99); }
559 final_track = MTStraightLine(0.0, 0.0, aux_line.a_x2(), aux_line.b_x2(), 0.0, 0.0, a_err, b_err);
562 final_track = MTStraightLine(aux_pos, aux_dir, null, null);
563
565 for (
unsigned int k = 0;
k < max_cand_hits;
k++) {
566 MTStraightLine wire(
Amg::Vector3D(0.0, final_track_hits[k]->localPosition().
y(), final_track_hits[k]->localPosition().
z()),
567 xhat, null, null);
570 chi2 += std::pow(d -
r, 2) / final_track_hits[
k]->sigma2DriftRadius();
571 }
572 if (std::isnan(
chi2)) {
chi2 = 1.0e6; }
573
576 return true;
577 }
578 return false;
579 }
580
581
583 MdtCalibHitBase& hit = *mdt_hit;
584
586
587 MTStraightLine aux_line(pos, xhat, null, null);
590
592 }
595
596 return true;
597}
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
bool m_refine_segment
flags
void sort()
sort the indices in ascending order
Amg::Vector3D directionVector() const
get the direction vector of the straight line
double b_x2() const
get the intercept of the straight line in the x2-x3 plane
double a_x2() const
get the slope of the straight line in the x2-x3 plane
Amg::Vector3D positionVector() const
get the position vector of the straight line
double b_x2_error() const
get the slope of the intercept of the straight line in the x2-x3 plane
void setUsedHits(const MdtHitVec &hits)
double signDistFrom(const MTStraightLine &h) const
get the signed distance of two lines (if both are parallel, dist>0)
double a_x2_error() const
get the error on the slope of the straight line in the x2-x3 plane
void setChi2(double chi2)
Cache the chi2.
float driftRadius() const
retrieve the radius of the drift circle
float sigma2DriftRadius() const
retrieve the error squared on the radius of the drift circle
float sigmaDriftRadius() const
retrieve the error on the radius of the drift circle
void setDistanceToTrack(float dist, float sigmaDist)
sets the distance to the fitted track and its error
const Amg::Vector3D & localPosition() const
retrieve the position expressed in local (station) coordinates
void refineMdtSelection(const std::vector< unsigned int > &new_selection)
move trck hits to close hits
const Amg::Vector3D & direction() const
retrieve local direction of segment (on station level) retrieve the transformation from local chamber...
std::shared_ptr< MdtCalibHitBase > MdtHitPtr
typedef for a collection of MdtCalibHitBase s
unsigned int hitsOnTrack() const
retrieve the sum of all XxxCalibHits assigned to the MuonCalibSegment
const MdtHitVec & mdtHOT() const
retrieve the full set of MdtCalibHitBase s assigned to this segment
void set(double chi2, const Amg::Vector3D &pos, const Amg::Vector3D &dir)
const Amg::Vector3D & position() const
retrieve local position of segment (on station level)
MuonCalibSegment::MdtHitVec MdtHitVec
MTStraightLine tangent(const Amg::Vector3D &r_w1, const double r_r1, const double r_sigma12, const Amg::Vector3D &r_w2, const double r_r2, const double r_sigma22, const int &r_case) const
MuonCalibSegment::MdtHitPtr MdtHitPtr
MTStraightLine track_candidate(const IndexSet &r_index_set, const int &r_k_cand, const int &r_l_cand, const int &r_cand_case, const std::vector< Amg::Vector3D > &r_w, const std::vector< double > &r_r, const std::vector< double > &r_sigma2, double &r_chi2) const
double chi2(TH1 *h0, TH1 *h1)
Eigen::Matrix< double, 3, 1 > Vector3D
IMessageSvc * getMessageSvc(bool quiet=false)
time(flags, cells_name, *args, **kw)
l
Printing final latex table to .tex output file.
std::pair< long int, long int > indices