303 {
305
307
311 Combination combination;
312
313 std::vector<unsigned int> hit_index;
314 unsigned int try_nb_hits;
315
316
318 std::vector<unsigned int> selected_hits_index;
319
321
322 double r_min, r_max{};
323 double sigma2_min, sigma2_max;
324
325 unsigned int counter1;
326
327 unsigned int nb_candidates(0);
328
329 MTStraightLine tangents[4];
330
331 MTStraightLine aux_track;
334
335 MTStraightLine initial_track(r_segment.
position(), r_segment.
direction(), null, null);
336
338
340
342
346 << "fitCallByReference() - Vector with selected hits unequal to the number of hits on the segment! The user selection will "
347 "be "
348 "ignored!"
350 r_selection.clear();
352 }
353
354
356 if (!r_selection[k]) {
357 selected_hits.push_back(r_segment.
mdtHOT()[k]);
358 selected_hits_index.push_back(k);
359 }
360 }
361
363
364
366
367 if (selected_hits.size() < 3) { return false; }
368
370
372
375 initial_track = MTStraightLine(r_segment.
position(), dir, null, null);
376 }
377
379
381
382
384
385 try_nb_hits = selected_hits.size();
386
387 while (nb_candidates == 0) {
388
389
390 if (try_nb_hits < 5 && (selected_hits.size() - try_nb_hits) > 2) return false;
391
392 double best_chi2ndf = -1.0;
393 MTStraightLine best_aux_line(initial_track);
394
395
397
398
400
401
402
404 diff = difftime(end, start);
406
407
408 if (cb == 0) {
410 } else {
412 }
413
414
416 tmp_selection.assign(tmp_selection.size(), 1);
417 for (
unsigned int k = 0;
k < try_nb_hits;
k++) { tmp_selection[selected_hits_index[hit_index[
k] - 1]] = 0; }
418
419
420
421 w_min = selected_hits[hit_index[0] - 1]->localPosition();
422 w_max = selected_hits[hit_index[0] - 1]->localPosition();
423 r_min = selected_hits[hit_index[0] - 1]->driftRadius();
424 r_max = selected_hits[hit_index[0] - 1]->driftRadius();
425 sigma2_min = selected_hits[hit_index[0] - 1]->sigma2DriftRadius();
426 sigma2_max = selected_hits[hit_index[0] - 1]->sigma2DriftRadius();
427 for (
unsigned int k = 1;
k < try_nb_hits;
k++) {
428 if (selected_hits[hit_index[k] - 1]->localPosition().
z() < w_min.z()) {
429 w_min = selected_hits[hit_index[
k] - 1]->localPosition();
430 r_min = selected_hits[hit_index[
k] - 1]->driftRadius();
431 sigma2_min = selected_hits[hit_index[
k] - 1]->sigma2DriftRadius();
432 }
433 if (selected_hits[hit_index[k] - 1]->localPosition().
z() > w_max.z()) {
434 w_max = selected_hits[hit_index[
k] - 1]->localPosition();
435 r_max = selected_hits[hit_index[
k] - 1]->driftRadius();
436 sigma2_max = selected_hits[hit_index[
k] - 1]->sigma2DriftRadius();
437 }
438 }
439
440
441 if (sigma2_min == 0) { sigma2_min = 0.1; }
442 if (sigma2_max == 0) { sigma2_max = 0.1; }
443
444
445 for (unsigned int r_case = 1; r_case < 5; r_case++) {
446 tangents[r_case - 1] =
tangent(w_min, r_min, sigma2_min, w_max, r_max, sigma2_max, r_case);
447 }
448
449
450
451 for (unsigned int r_case = 1; r_case < 5; r_case++) {
452 counter1 = 0;
453 for (
unsigned int n = 0;
n < try_nb_hits;
n++) {
454 MTStraightLine aux_line(selected_hits[hit_index[n] - 1]->localPosition(), xhat, null, null);
455 if (std::abs(std::abs(tangents[r_case - 1].signDistFrom(aux_line)) - selected_hits[hit_index[n] - 1]->
driftRadius()) <=
457 counter1 = counter1 + 1;
458 }
459 }
460
461
463
464 if (counter1 == try_nb_hits) {
465 nb_candidates++;
466 aux_track =
fitCandidate(r_segment, tmp_selection, tangents[r_case - 1]);
467
468 if ((best_chi2ndf == -1) || (best_chi2ndf > r_segment.
chi2())) {
469 best_chi2ndf = r_segment.
chi2();
470 best_aux_line = aux_track;
471 final_selection.assign(final_selection.size(), 1);
472 for (
unsigned int j = 0;
j < try_nb_hits;
j++) { final_selection[selected_hits_index[hit_index[
j] - 1]] = 0; }
473 }
474 }
475 }
476
477 }
478
479
481
483
485 if (nb_candidates > 0) {
486
487 for (
unsigned int k = 0;
k < r_selection.size();
k++) {
488 r_selection[
k] = final_selection[
k];
489 if (!final_selection[k]) { used_hits.push_back(r_segment.
mdtHOT()[k]); }
490 }
491
492
493 fitted_track =
fitCandidate(r_segment, final_selection, best_aux_line);
494 fitted_track.setUsedHits(used_hits);
495
497
498 } else {
499 try_nb_hits = try_nb_hits - 1;
500 if (try_nb_hits < 3) { return false; }
501 }
502
503
504 }
505
506
507 return fitted_track.chi2() > 0;
508}
void diff(const TrigCaloCluster &a, const TrigCaloCluster &b, std::map< std::string, double > &varChange)
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)
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)