18 #include "TDirectory.h"
26 declareInterface<IMuonHoughPatternTool>(
this);
44 for (
unsigned int hitid = 0; hitid < hitcontainer.
size(); ++hitid) { phihits += hitcontainer.
getMeasuresPhi(hitid); }
46 ATH_MSG_DEBUG(
"Cosmic event has more than 1000 phi hits: " << phihits <<
" event is not reconstructed!");
64 for (
unsigned int i = 0;
i < hitcontainer.
size(); ++
i) {
65 const std::shared_ptr<MuonHoughHit> hit = hitcontainer.
getHit(
i);
90 std::unique_ptr<MuonHoughHitContainer> event_for_hough{
whichEventHough(id_number,
event, weightmdt)};
95 for (
unsigned int i = 0;
i < event_for_hough->size(); ++
i) {
96 const std::shared_ptr<MuonHoughHit> hit = event_for_hough->getHit(
i);
102 ATH_MSG_VERBOSE(
"Size event association: " << event_for_association->size());
103 for (
unsigned int i = 0;
i < event_for_association->size(); ++
i) {
104 const std::shared_ptr<MuonHoughHit> hit = event_for_association->getHit(
i);
110 ATH_MSG_DEBUG(
"size of event: " << event_for_association->size() <<
" id_number: " << id_number);
112 std::unique_ptr<MuonHoughTransformSteering> houghtransform{
whichHoughTransform(id_number)};
116 bool test_for_next_level =
true;
119 if (test_for_next_level) {
122 houghtransform->resetHisto();
123 ATH_MSG_DEBUG(
"fillHistos size hits not in patterns " << event_for_hough->size());
124 houghtransform->fill(*event_for_hough);
130 for (
int i = 0;
i <
histos.size(); ++
i) {
132 histos.getHisto(
i)->bookAndFillRootHistogram(
hname)->Write();
139 test_for_next_level =
analyseHisto(id_number,
level, event_for_association, houghtransform, houghpattern);
141 if (test_for_next_level) {
142 event_for_hough =
whichEventHough(id_number, *event_for_hough, weightmdt);
143 ATH_MSG_DEBUG(
"New event size for transform: " << event_for_hough->size());
155 m_file = std::make_unique<TFile>(
"HoughPattern.root",
"RECREATE");
180 return StatusCode::SUCCESS;
184 for (
unsigned int i = 0;
i <
event.size(); ++
i) {
185 std::shared_ptr<MuonHoughHit> hit =
event.getHit(
i);
199 return StatusCode::SUCCESS;
208 houghpattern.emplace_back(std::move(which_segment_vector));
213 houghpattern[
i].emplace_back(std::move(level_vector));
216 houghpattern[
i][lvl].emplace_back(
nullptr);
225 std::unique_ptr<MuonHoughTransformSteering>& houghtransform,
237 bool test_for_next_level =
false;
240 double numberofmaxima = 0;
246 for (
unsigned int maximum_number = 0; maximum_number < houghpatterns.size(); ++maximum_number) {
248 std::unique_ptr<MuonHoughPattern>& houghpattern = houghpatterns[maximum_number];
249 if (!houghpattern) {
continue; }
251 ATH_MSG_DEBUG(
"id_number: " << id_number <<
" maximum_number: " << maximum_number <<
" size patternseg: " << houghpattern->
size());
256 if (houghpattern->
size() < numberofmaxima) {
257 ATH_MSG_DEBUG(
"ERROR: houghpattern smaller than maximum, id: " << id_number <<
" houghpattern.size(): " << houghpattern->
size()
258 <<
" numberofmaxima: " << numberofmaxima);
265 if (houghpattern->
size() >= threshold_for_next_houghpattern) {
269 test_for_next_level =
hitsLeft(*event_to_analyse);
271 }
else if (maximum_number == 0) {
272 ATH_MSG_DEBUG(
"houghpattern too small for next level : " <<
level <<
" id: " << id_number);
277 houghpatterns_all[id_number][
level][maximum_number] = std::move(houghpattern);
281 ATH_MSG_DEBUG(
" Test for next level: " << test_for_next_level);
283 return test_for_next_level;
288 int number_of_hits =
event.size();
289 for (
int hitid = 0; hitid < number_of_hits; ++hitid) {
290 if (!
event.getHit(hitid)->getAssociated()) {
return true; }
296 int number_of_hits_left = 0;
297 int number_of_hits =
event.size();
299 for (
int hitid = 0; hitid < number_of_hits; ++hitid) { number_of_hits_left += !
event.getHit(hitid)->getAssociated(); }
305 return number_of_hits_left;
311 for (
unsigned int i = 0;
i < houghpattern.size(); ++
i) {
312 for (
unsigned int j = 0; j < houghpattern[
i].size(); ++j) {
313 if (houghpattern[
i][j]) {
315 ATH_MSG_VERBOSE(
"Hit in hough pattern found level " <<
i <<
" max " << j <<
"hitid: " << hit->
getId());
325 double weight_trigger_hits = 1.;
326 double weight_mdt_hits = 1.;
332 if (weight_trigger_hits > 1) weight_trigger_hits = 1.;
333 weight_mdt_hits = weight_trigger_hits;
342 weight_trigger_hits = 1.;
343 weight_mdt_hits = 1.;
346 weight_trigger_hits = 1.;
347 weight_mdt_hits = 1.;
350 weight_trigger_hits = 1.;
351 weight_mdt_hits = 0.75;
354 weight_trigger_hits = 0.75;
355 weight_mdt_hits = 0.5;
358 weight_trigger_hits = 0.5;
359 weight_mdt_hits = 0.25;
363 weight_trigger_hits = 0.5;
364 weight_mdt_hits = 0.25;
370 for (
unsigned int i = 0;
i <
event.size(); ++
i) {
371 std::shared_ptr<MuonHoughHit> hit =
event.getHit(
i);
373 switch (technology) {
384 if (weightmdt < 0.5)
return;
386 for (
unsigned int i = 0;
i <
event.size(); ++
i) {
387 std::shared_ptr<MuonHoughHit> hit =
event.getHit(
i);
392 double p_calc = 0.25 * p_old * (1. - weightmdt);
393 double p_new = p_calc / (p_calc + weightmdt * (1 - p_old));
394 ATH_MSG_VERBOSE(
" MDT probability old " << p_old <<
" Recalculated " << p_new);
406 for (
unsigned int i = 0;
i < houghpattern1.
size(); ++
i) {
407 while (j < houghpattern2.
size()) {
417 double percentage1 = (1.0 * overlap) / houghpattern1.
size();
418 double percentage2 = (1.0 * overlap) / houghpattern2.
size();
420 ATH_MSG_DEBUG(
"Percentage Overlap: " << percentage1 <<
" " << percentage2);
426 std::unique_ptr<MuonHoughHitContainer> event_to_analyse = std::make_unique<MuonHoughHitContainer>();
431 for (
unsigned int hitid = 0; hitid <
event.size(); ++hitid) {
432 std::shared_ptr<MuonHoughHit> hit =
event.getHit(hitid);
435 event_to_analyse->
addHit(hit);
441 for (
unsigned int hitid = 0; hitid <
event.size(); ++hitid) {
442 std::shared_ptr<MuonHoughHit> hit =
event.getHit(hitid);
443 event_to_analyse->
addHit(hit);
449 for (
unsigned int hitid = 0; hitid <
event.size(); ++hitid) {
450 std::shared_ptr<MuonHoughHit> hit =
event.getHit(hitid);
453 event_to_analyse->
addHit(hit);
460 for (
unsigned int hitid = 0; hitid <
event.size(); ++hitid) {
461 std::shared_ptr<MuonHoughHit> hit =
event.getHit(hitid);
467 for (
unsigned int hitid = 0; hitid <
event.size(); ++hitid) {
468 std::shared_ptr<MuonHoughHit> hit =
event.getHit(hitid);
474 for (
unsigned int hitid = 0; hitid <
event.size(); ++hitid) {
475 std::shared_ptr<MuonHoughHit> hit =
event.getHit(hitid);
482 return event_to_analyse;
486 double weightmdt)
const {
489 ATH_MSG_DEBUG(
"whichEventHough::hitsNotInPattern: " << hits_not_in_patterns->size());
490 std::unique_ptr<MuonHoughHitContainer> event_to_analyse = std::make_unique<MuonHoughHitContainer>();
495 for (
unsigned int hitid = 0; hitid < hits_not_in_patterns->size(); ++hitid) {
496 std::shared_ptr<MuonHoughHit> hit = hits_not_in_patterns->getHit(hitid);
500 event_to_analyse->
addHit(hit);
507 for (
unsigned int hitid = 0; hitid < hits_not_in_patterns->size(); ++hitid) {
508 std::shared_ptr<MuonHoughHit> hit = hits_not_in_patterns->getHit(hitid);
515 for (
unsigned int hitid = 0; hitid < hits_not_in_patterns->size(); ++hitid) {
516 std::shared_ptr<MuonHoughHit> hit = hits_not_in_patterns->getHit(hitid);
520 event_to_analyse->
addHit(hit);
528 for (
unsigned int hitid = 0; hitid < hits_not_in_patterns->size(); ++hitid) {
529 if (hits_not_in_patterns->getDetectorId(hitid) ==
MuonHough::RPC) {
530 std::shared_ptr<MuonHoughHit> hit = hits_not_in_patterns->getHit(hitid);
535 for (
unsigned int hitid = 0; hitid < hits_not_in_patterns->size(); ++hitid) {
536 if (hits_not_in_patterns->getDetectorId(hitid) ==
MuonHough::RPC) {
537 std::shared_ptr<MuonHoughHit> hit = hits_not_in_patterns->getHit(hitid);
538 event_to_analyse->
addHit(hit);
544 for (
unsigned int hitid = 0; hitid < hits_not_in_patterns->size(); ++hitid) {
545 if (hits_not_in_patterns->getDetectorId(hitid) ==
MuonHough::MDT) {
546 std::shared_ptr<MuonHoughHit> hit = hits_not_in_patterns->getHit(hitid);
554 return event_to_analyse;
558 std::unique_ptr<MuonHoughTransformer> houghtransformer;
577 nbins_angle =
static_cast<int>(detectorsize_angle_xy / stepsize_per_angle_xy);
578 houghtransformer = std::make_unique<MuonHoughTransformer_xy>(
nbins, nbins_angle,
m_detectorsize_xy, detectorsize_angle_xy,
601 houghtransformer = std::make_unique<MuonHoughTransformer_rzcosmics>(
608 houghtransformer = std::make_unique<MuonHoughTransformer_CurvedAtACylinder>(
615 if (houghtransformer) {
626 return std::make_unique<MuonHoughTransformSteering>(std::move(houghtransformer));
631 std::vector<int> maxlevel_houghpattern(m_number_of_ids);
633 for (
int id_number = 0; id_number < m_number_of_ids; id_number++) {
634 maxlevel_houghpattern[id_number] = maxLevelHoughPattern(houghpattern, id_number);
636 return maxlevel_houghpattern;
640 int maxlevel = houghpattern[id_number].size();
642 while (maxlevel >= 1 && continu == 1) {
643 unsigned int maximum_number = 0;
645 while (continu && maximum_number < houghpattern[id_number][maxlevel - 1].
size())
648 <<
"maxlevel_houghpattern: " << maxlevel <<
" id: " << id_number);
649 if (!houghpattern[id_number][maxlevel - 1][maximum_number]->
empty()) { continu =
false; }
655 if (continu) { maxlevel--; }
661 double z_true = coordsmaximum.first;
662 double theta_true = coordsmaximum.second;
671 double z_rec = z_true + z_cor;
672 double theta_rec = theta_true + theta_cor;
675 z_rec = z_true - z_cor;
676 theta_rec = theta_true - theta_cor;
679 coordsmaximum.first = z_rec;
680 coordsmaximum.second = theta_rec;
684 std::unique_ptr<MuonPrdPatternCollection> phipatterncollection = std::make_unique<MuonPrdPatternCollection>();
691 std::map<MuonHoughPattern*, int> mergedpatterns;
692 for (
unsigned int i = 0;
i < phipatterns.size(); ++
i) {
693 for (
unsigned int j = 0; j < phipatterns[
i].size(); ++j) {
694 std::unique_ptr<MuonHoughPattern>& houghpattern = phipatterns[
i][j];
695 if (!houghpattern)
continue;
696 mergedpatterns[houghpattern.get()] = 0;
703 for (
unsigned int i = 0;
i < phipatterns.size(); ++
i) {
704 for (
unsigned int j = 0; j < phipatterns[
i].size(); ++j) {
705 std::unique_ptr<MuonHoughPattern>& houghpattern1 = phipatterns[
i][j];
706 if (!houghpattern1)
continue;
709 for (
unsigned int k =
i;
k < phipatterns.size();
k++) {
710 for (
unsigned int l = 0;
l < phipatterns[
k].size();
l++) {
711 std::unique_ptr<MuonHoughPattern>& houghpattern2 = phipatterns[
k][
l];
712 if (!houghpattern2)
continue;
715 if (houghpattern1.get() == houghpattern2.get())
continue;
716 if (mergedpatterns[houghpattern1.get()] == 1)
continue;
717 if (mergedpatterns[houghpattern2.get()] == 1)
continue;
718 const double phi1 = houghpattern1->
getEPhi();
719 const double phi2 = houghpattern2->
getEPhi();
722 double dotprod = scphi1.
cs * scphi2.
cs + scphi1.
sn * scphi2.
sn;
725 else if (dotprod < -1.)
727 double psi = std::acos(dotprod);
728 const double the1 = houghpattern1->
getETheta();
729 const double the2 = houghpattern2->
getETheta();
732 dotprod = scthe1.
cs * scthe2.
cs + scthe1.
sn * scthe2.
sn;
735 else if (dotprod < -1.)
737 double chi = std::acos(dotprod);
738 ATH_MSG_DEBUG(
" patterns phi1 " << phi1 <<
" phi2 " << phi2 <<
" psi " << psi);
739 ATH_MSG_DEBUG(
" patterns the1 " << the1 <<
" the2 " << the2 <<
" chi " << chi);
740 if (chi < 0.5 || psi < 0.5) {
742 ATH_MSG_DEBUG(
" Phi Overlap " << overlap <<
" size1 " << houghpattern1->
size() <<
" size2 "
743 << houghpattern2->
size());
744 int ns1 = houghpattern1->
size();
745 int ns2 = houghpattern2->
size();
746 if (overlap <= ns1 && overlap == ns2) {
748 mergedpatterns[houghpattern2.get()] = 1;
751 if (overlap == ns1 && overlap < ns2) {
753 mergedpatterns[houghpattern1.get()] = 1;
758 std::unique_ptr<Muon::MuonPrdPattern> muonpattern;
759 if ((overlap > 0.8 * ns1 || overlap > 0.8 * ns2) && ns1 >= ns2) {
762 if ((overlap > 0.8 * ns1 || overlap > 0.8 * ns2) && ns1 < ns2) {
767 phipatterncollection->
push_back(std::move(muonpattern));
768 mergedpatterns[houghpattern1.get()] = 1;
769 mergedpatterns[houghpattern2.get()] = 1;
779 for (
unsigned int i = 0;
i < phipatterns.size(); ++
i) {
780 for (
unsigned int j = 0; j < phipatterns[
i].size(); ++j) {
781 std::unique_ptr<MuonHoughPattern>& houghpattern = phipatterns[
i][j];
782 if (!houghpattern) {
continue; }
783 if (mergedpatterns[houghpattern.get()] == 1)
continue;
785 if (!phipatterns[
i][j]->
empty()) {
786 std::unique_ptr<Muon::MuonPrdPattern> muonpattern;
797 phipatterncollection->
push_back(std::move(muonpattern));
803 return phipatterncollection;
807 std::unique_ptr<MuonPrdPatternCollection> etapatterncollection = std::make_unique<MuonPrdPatternCollection>();
811 if (
m_use_curvedhough) maximum_number_of_patterns = 2 * maximum_number_of_patterns;
813 etapatterncollection->
reserve(maximum_number_of_patterns);
818 ATH_MSG_DEBUG(
" GetEtaMuonPatterns Use RZ curved hough patterns ");
821 ATH_MSG_DEBUG(
" GetEtaMuonPatterns Use curved hough patterns ");
830 std::map<MuonHoughPattern*, int> mergedpatterns;
831 for (
unsigned int i = 0;
i < etapatterns.size(); ++
i) {
832 for (
unsigned int j = 0; j < etapatterns[
i].size(); ++j) {
833 std::unique_ptr<MuonHoughPattern>& houghpattern = etapatterns[
i][j];
834 if (!houghpattern)
continue;
835 mergedpatterns[houghpattern.get()] = 0;
842 for (
unsigned int i = 0;
i < etapatterns.size(); ++
i) {
843 for (
unsigned int j = 0; j < etapatterns[
i].size(); ++j) {
844 std::unique_ptr<MuonHoughPattern>& houghpattern1 = etapatterns[
i][j];
845 if (!houghpattern1)
continue;
848 for (
unsigned int k =
i;
k < etapatterns.size();
k++) {
849 for (
unsigned int l = 0;
l < etapatterns[
k].size();
l++) {
850 std::unique_ptr<MuonHoughPattern>& houghpattern2 = etapatterns[
k][
l];
851 if (!houghpattern2)
continue;
854 if (houghpattern1.get() == houghpattern2.get())
continue;
855 if (mergedpatterns[houghpattern1.get()] == 1)
continue;
856 if (mergedpatterns[houghpattern2.get()] == 1)
continue;
863 if (std::abs(curv1) < 1001. || std::abs(curv2) < 1001.) {
864 ATH_MSG_DEBUG(
"Curvature too small, should not be possible: " << curv1 <<
" " << curv2);
868 double angle1 = std::acos((std::abs(curv1) - 1000.) / curv1);
869 double angle2 = std::acos((std::abs(curv2) - 1000.) / curv2);
870 alpha = std::abs(
std::sin(angle1 - angle2));
872 ATH_MSG_DEBUG(
" patterns curv1 " << curv1 <<
" curv2 " << curv2 <<
" alpha " << alpha);
875 double phi1 = houghpattern1->
getEPhi();
876 double phi2 = houghpattern2->
getEPhi();
880 else if (dotprod < -1.)
882 double psi = std::acos(dotprod);
883 double the1 = houghpattern1->
getETheta();
884 double the2 = houghpattern2->
getETheta();
888 else if (dotprod < -1.)
890 double chi = std::acos(dotprod);
892 ATH_MSG_DEBUG(
" patterns phi1 " << phi1 <<
" phi2 " << phi2 <<
" psi " << psi);
893 ATH_MSG_DEBUG(
" patterns the1 " << the1 <<
" the2 " << the2 <<
" chi " << chi);
895 if (chi < 0.5 && psi < 0.5 && alpha < 0.05) {
898 const int ns1 = houghpattern1->
size();
899 const int ns2 = houghpattern2->
size();
901 ATH_MSG_DEBUG(
" Eta Overlap " << overlap <<
" size1 " << ns1 <<
" size2 " << ns2);
903 if (overlap == ns2 && overlap <= ns1) {
905 mergedpatterns[houghpattern2.get()] = 1;
908 if (overlap == ns1 && overlap < ns2) {
910 mergedpatterns[houghpattern1.get()] = 1;
913 std::unique_ptr<Muon::MuonPrdPattern> muonpattern;
915 if ((overlap > 0.8 * ns1 || overlap > 0.8 * ns2) && ns1 >= ns2) {
918 if ((overlap > 0.8 * ns1 || overlap > 0.8 * ns2) && ns1 < ns2) {
922 etapatterncollection->
push_back(std::move(muonpattern));
923 mergedpatterns[houghpattern1.get()] = 1;
924 mergedpatterns[houghpattern2.get()] = 1;
933 for (
unsigned int i = 0;
i < etapatterns.size(); ++
i) {
934 for (
unsigned int j = 0; j < etapatterns[
i].size(); ++j) {
935 std::unique_ptr<MuonHoughPattern>& houghpattern = etapatterns[
i][j];
936 if (!houghpattern) {
continue; }
937 if (mergedpatterns[houghpattern.get()] == 1)
continue;
939 if (!etapatterns[
i][j]->
empty()) {
941 etapatterncollection->
push_back(std::move(muonpattern));
949 return etapatterncollection;
953 std::unique_ptr<MuonPrdPatternCollection> curvedpatterncollection = std::make_unique<MuonPrdPatternCollection>();
957 curvedpatterncollection->
reserve(maximum_number_of_patterns);
960 for (
unsigned int i = 0;
i < curvedpatterns.size(); ++
i) {
961 for (
unsigned int j = 0; j < curvedpatterns[
i].size(); ++j) {
962 std::unique_ptr<MuonHoughPattern>& houghpattern = curvedpatterns[
i][j];
963 if (!houghpattern) {
continue; }
965 if (!curvedpatterns[
i][j]->
empty()) {
967 curvedpatterncollection->
push_back(std::move(muonpattern));
972 return curvedpatterncollection;
982 double charge = curvature < 0 ? -1 : 1.;
983 double pscale = std::abs(curvature);
993 ATH_MSG_DEBUG(
"position: " << x0 <<
" " << y0 <<
" " << position[2]);
994 ATH_MSG_DEBUG(
"direction: " << direction[0] <<
" " << direction[1] <<
" " << direction[2]);
996 ATH_MSG_DEBUG(
" Lift Eta Hough Pattern with charge " <<
charge <<
" Curvature " << pscale);
997 std::unique_ptr<Muon::MuonPrdPattern> muonpattern = std::make_unique<Muon::MuonPrdPattern>(
pos,
dir);
999 for (
unsigned int i = 0;
i < houghpattern.
size(); ++
i) { muonpattern->
addPrd(houghpattern.
getPrd(
i)); }
1011 std::unique_ptr<Muon::MuonPrdPattern> muonpattern = std::make_unique<Muon::MuonPrdPattern>(
pos,
dir);
1013 for (
unsigned int i = 0;
i < houghpattern.
size(); ++
i) {
1026 const int ns1 = houghpattern1.
size();
1027 const int ns2 = houghpattern2.
size();
1029 const double the1 = houghpattern1.
getETheta();
1030 const double the2 = houghpattern2.
getETheta();
1031 const double theta = (ns1 * the1 + ns2 * the2) / (ns1 + ns2);
1033 const double phi1 = houghpattern1.
getEPhi();
1034 const double phi2 = houghpattern2.
getEPhi();
1035 const double cos_phi = (ns1 *
std::cos(phi1) + ns2 *
std::cos(phi2)) / (ns1 + ns2);
1036 const double sin_phi = (ns1 *
std::sin(phi1) + ns2 *
std::sin(phi2)) / (ns1 + ns2);
1037 const double phi = std::atan2(sin_phi, cos_phi);
1044 const double z0 = (ns1 * position1[2] + ns2 * position2[2]) / (ns1 + ns2);
1046 const double invcur = (ns1 * invcur1 + ns2 * invcur2) / (ns1 + ns2);
1048 ATH_MSG_DEBUG(
"Start Making one eta pattern theta " <<
theta <<
" phi " <<
phi <<
" invcur " << invcur);
1050 ATH_MSG_DEBUG(
"eta patterns theta1 " << the1 <<
" theta2 " << the2 <<
" phi1 " << phi1 <<
" phi2 " << phi2 <<
" invcur1 " << invcur1
1051 <<
" invcur2 " << invcur2 <<
" ns1 " << ns1 <<
" ns2 " << ns2);
1053 ATH_MSG_DEBUG(
" z values " <<
z0 <<
" z1 " << position1[2] <<
" z2 " << position2[2]);
1057 if (ns1 + ns2 < 2)
return nullptr;
1059 double invcurvature = invcur;
1061 if (invcurvature < 0)
charge = -1;
1063 if (invcurvature != 0) pscale = 1. / std::abs(invcurvature);
1068 r0 = (ns1 * houghpattern1.
getERPhi() + ns2 * houghpattern2.
getERPhi()) / (ns1 + ns2);
1073 double y0 = -
charge *
r0 * cos_phi;
1081 std::unique_ptr<Muon::MuonPrdPattern> muonpattern = std::make_unique<Muon::MuonPrdPattern>(
pos,
dir);
1084 for (
unsigned int i = 0;
i < houghpattern1.
size(); ++
i) {
1091 for (
unsigned int i = 0;
i < houghpattern2.
size(); ++
i) {
1094 for (
unsigned int j = 0; j < houghpattern1.
size(); ++j) {
1118 double cos_phi{0.}, sin_phi{0.};
1120 for (
unsigned int i = 0;
i < houghpattern1.
size(); ++
i) {
1126 for (
unsigned int i = 0;
i < houghpattern2.
size(); ++
i) {
1129 for (
unsigned int j = 0; j < houghpattern1.
size(); ++j) {
1139 ATH_MSG_VERBOSE(
"Start Merged Phi hits cleaning with " << nphi <<
" hits ");
1142 if (nphi < 2)
return nullptr;
1144 double cphit = cos_phi / nphi;
1145 double sphit = sin_phi / nphi;
1151 for (
unsigned int i = 0;
i < houghpattern1.
size(); ++
i) {
1154 if (dotprod > 0.95) {
1161 for (
unsigned int i = 0;
i < houghpattern2.
size(); ++
i) {
1164 if (dotprod > 0.95) {
1166 for (
unsigned int j = 0; j < houghpattern1.
size(); ++j) {
1177 if (nphi < 2)
return nullptr;
1178 cphit = cos_phi / nphi;
1179 sphit = sin_phi / nphi;
1184 for (
unsigned int i = 0;
i < houghpattern1.
size(); ++
i) {
1187 if (dotprod > 0.99) {
1193 for (
unsigned int i = 0;
i < houghpattern2.
size(); ++
i) {
1196 if (dotprod > 0.99) {
1198 for (
unsigned int j = 0; j < houghpattern1.
size(); ++j) {
1208 if (nphi < 2)
return nullptr;
1209 cphit = cos_phi / nphi;
1210 sphit = sin_phi / nphi;
1216 for (
unsigned int i = 0;
i < houghpattern1.
size(); ++
i) {
1218 double thetah = houghpattern1.
getTheta(
i);
1220 if (dotprod > 0.995) {
1227 for (
unsigned int i = 0;
i < houghpattern2.
size(); ++
i) {
1229 double thetah = houghpattern2.
getTheta(
i);
1231 if (dotprod > 0.995) {
1233 for (
unsigned int j = 0; j < houghpattern1.
size(); ++j) {
1244 if (nphi < 2)
return nullptr;
1245 cphit = cos_phi / nphi;
1246 sphit = sin_phi / nphi;
1250 double x0 =
r0 * sphit;
1251 double y0 = -
r0 * cphit;
1257 std::unique_ptr<Muon::MuonPrdPattern> muonpattern = std::make_unique<Muon::MuonPrdPattern>(
pos,
dir);
1260 for (
unsigned int i = 0;
i < houghpattern1.
size(); ++
i) {
1263 if (dotprod > 0.995) {
1272 for (
unsigned int i = 0;
i < houghpattern2.
size(); ++
i) {
1275 if (dotprod > 0.995) {
1277 for (
unsigned int j = 0; j < houghpattern1.
size(); ++j) {
1305 for (
unsigned int i = 0;
i < houghpattern.
size(); ++
i) {
1306 const std::shared_ptr<MuonHoughHit> hit = houghpattern.
getHit(
i);
1314 unsigned int size = houghpattern.
size();
1319 <<
" theta " <<
theta);
1322 unsigned int newsize = houghpattern.
size();
1328 const int number_of_iterations = 4;
1329 static constexpr std::array<double, number_of_iterations> cutvalues{1000., 500., 250., 125.};
1332 std::unique_ptr<MuonHoughPattern> pat_owner{};
1333 for (
int it = 0;
it < number_of_iterations;
it++) {
1338 double max_dist = 0.;
1339 unsigned int max_i = UINT_MAX;
1340 for (
unsigned int i = 0;
i < newpattern->size(); ++
i) {
1341 double dist = newpattern->getHitx(
i) * scphi.
sn - newpattern->getHity(
i) * scphi.
cs -
r0;
1343 if (dist > max_dist) {
1348 if (max_dist < cutvalues[
it]) {
1351 std::unique_ptr<MuonHoughPattern> newpattern2 = std::make_unique<MuonHoughPattern>(
MuonHough::hough_xy);
1352 for (
unsigned int i = 0;
i < newpattern->size(); ++
i) {
1353 if (
i != max_i) { newpattern2->
addHit(newpattern->getHit(
i)); }
1358 newsize = newpattern2->
size();
1359 pat_owner = std::move(newpattern2);
1360 newpattern = pat_owner.get();
1368 double thetanew = 0.;
1369 for (
unsigned int i = 0;
i < newpattern->size(); ++
i) {
1370 double thetah = newpattern->getTheta(
i);
1374 thetanew = thetanew / (newpattern->size() + 1
e-7);
1377 double x0_new = r0_new * scphi.
sn;
1378 double y0_new = -r0_new * scphi.
cs;
1386 std::unique_ptr<Muon::MuonPrdPattern> muonpattern = std::make_unique<Muon::MuonPrdPattern>(
pos,
dir);
1388 for (
unsigned int i = 0;
i < newpattern->size(); ++
i) { muonpattern->
addPrd(newpattern->getPrd(
i)); }
1390 ATH_MSG_DEBUG(
"END Clean Phi hits " << newsize <<
" theta " << thetanew);
1398 std::unique_ptr<MuonHoughHitContainer> hits_not_in_patterns = std::make_unique<MuonHoughHitContainer>();
1400 for (
unsigned int hitid = 0; hitid <
event.size(); ++hitid) {
1401 if (!
event.getHit(hitid)->getAssociated()) { hits_not_in_patterns->
addHit(
event.getHit(hitid)); }
1403 return hits_not_in_patterns;
1406 unsigned int thresholdpattern = 0;
1407 switch (id_number) {
1417 return thresholdpattern;
1421 double thresholdhisto = 0.;
1422 switch (id_number) {
1432 return thresholdhisto;
1440 int mdthits =
event.getMDThitno();
1441 weightmdt = mdthits > 0. ? 1. - 5. / std::sqrt(mdthits) : 0.;
1461 ATH_MSG_VERBOSE(
"mdt " <<
k <<
" x: " << gpos.x() <<
" y: " << gpos.y() <<
" z: " << gpos.z());
1462 }
else if (!mdtprd) {
1466 ATH_MSG_VERBOSE(
"cluster " <<
k <<
" x: " << gpos.x() <<
" y: " << gpos.y() <<
" z: " << gpos.z());