304 {
306
308
312 Combination combination;
313
314 std::vector<unsigned int> hit_index;
315 unsigned int try_nb_hits;
316
317
319 std::vector<unsigned int> selected_hits_index;
320
322
323 double r_min, r_max{};
324 double sigma2_min, sigma2_max;
325
326 unsigned int counter1;
327
328 unsigned int nb_candidates(0);
329
330 MTStraightLine tangents[4];
331
332 MTStraightLine aux_track;
335
336 MTStraightLine initial_track(r_segment.
position(), r_segment.
direction(), null, null);
337
339
341
343
347 << "fitCallByReference() - Vector with selected hits unequal to the number of hits on the segment! The user selection will "
348 "be "
349 "ignored!"
351 r_selection.clear();
353 }
354
355
357 if (!r_selection[k]) {
358 selected_hits.push_back(r_segment.
mdtHOT()[k]);
359 selected_hits_index.push_back(k);
360 }
361 }
362
364
365
367
368 if (selected_hits.size() < 3) { return false; }
369
371
373
376 initial_track = MTStraightLine(r_segment.
position(), dir, null, null);
377 }
378
380
382
383
385
386 try_nb_hits = selected_hits.size();
387
388 while (nb_candidates == 0) {
389
390
391 if (try_nb_hits < 5 && (selected_hits.size() - try_nb_hits) > 2) return false;
392
393 double best_chi2ndf = -1.0;
394 MTStraightLine best_aux_line(initial_track);
395
396
398
399
401
402
403
405 diff = difftime(end, start);
407
408
409 if (cb == 0) {
411 } else {
413 }
414
415
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; }
419
420
421
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();
433 }
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();
438 }
439 }
440
441
442 if (sigma2_min == 0) { sigma2_min = 0.1; }
443 if (sigma2_max == 0) { sigma2_max = 0.1; }
444
445
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);
448 }
449
450
451
452 for (unsigned int r_case = 1; r_case < 5; r_case++) {
453 counter1 = 0;
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;
459 }
460 }
461
462
464
465 if (counter1 == try_nb_hits) {
466 nb_candidates++;
467 aux_track =
fitCandidate(r_segment, tmp_selection, tangents[r_case - 1]);
468
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; }
474 }
475 }
476 }
477
478 }
479
480
482
484
486 if (nb_candidates > 0) {
487
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]); }
491 }
492
493
494 fitted_track =
fitCandidate(r_segment, final_selection, best_aux_line);
495 fitted_track.setUsedHits(used_hits);
496
498
499 } else {
500 try_nb_hits = try_nb_hits - 1;
501 if (try_nb_hits < 3) { return false; }
502 }
503
504
505 }
506
507
508 return fitted_track.chi2() > 0;
509}
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
void currentCombination(std::vector< unsigned int > &index_array) const
get the current combination; the result is stored in the vector index_array
unsigned int numberOfCombinations() const
get the number of combinations
void setNewParameters(const unsigned int &nb_elements, const unsigned int &wh_class)
set the number of elements = nb_elements; set the class of which the combination is = wh_class
void nextCombination(std::vector< unsigned int > &index_array)
get the next combination; the results is stored in the array index_array
bool m_refine_segment
flags
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::vector< MdtHitPtr > MdtHitVec
unsigned int hitsOnTrack() const
retrieve the sum of all XxxCalibHits assigned to the MuonCalibSegment
double chi2() const
retrieve chi2
const MdtHitVec & mdtHOT() const
retrieve the full set of MdtCalibHitBase s assigned to this segment
const Amg::Vector3D & position() const
retrieve local position of segment (on station level)
MTStraightLine fitCandidate(MuonCalibSegment &r_segment, const std::vector< unsigned int > &r_selection, const MTStraightLine &cand_line) const
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
Eigen::Matrix< double, 3, 1 > Vector3D
IMessageSvc * getMessageSvc(bool quiet=false)
time(flags, cells_name, *args, **kw)