ATLAS Offline Software
Loading...
Searching...
No Matches
MuonHoughPatternTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include "CxxUtils/sincos.h"
18#include "TDirectory.h"
19#include "TFile.h"
20#include "TH2F.h"
21#include "TString.h"
22#include "TrkSurfaces/Surface.h"
23
24MuonHoughPatternTool::MuonHoughPatternTool(const std::string& type, const std::string& name, const IInterface* parent) :
25 AthAlgTool(type, name, parent) {
26 declareInterface<IMuonHoughPatternTool>(this);
27
31}
32
39
43 int phihits{0};
44 for (unsigned int hitid = 0; hitid < hitcontainer.size(); ++hitid) { phihits += hitcontainer.getMeasuresPhi(hitid); }
45 if (phihits > m_maxNumberOfPhiHits) {
46 ATH_MSG_DEBUG("Cosmic event has more than 1000 phi hits: " << phihits << " event is not reconstructed!");
47 return;
48 }
49 }
50
52 double weightmdt{0.};
53 if (m_weightcutmdt) { setWeightMdtCutValue(hitcontainer, weightmdt); }
54
55 ATH_MSG_DEBUG("Mdt Cut Value: " << weightmdt);
56
57 // reset weights, based on rejection factor and weightmdt
58 calculateWeights(hitcontainer, weightmdt);
59
60 if (msgLevel(MSG::VERBOSE)) {
61 ATH_MSG_VERBOSE("Event Info");
62 ATH_MSG_VERBOSE("Size: " << hitcontainer.size());
63
64 for (unsigned int i = 0; i < hitcontainer.size(); ++i) {
65 const std::shared_ptr<MuonHoughHit> hit = hitcontainer.getHit(i);
66 ATH_MSG_VERBOSE(hit->getHitx() << " " << hit->getHity() << " " << hit->getHitz() << " " << hit->getMeasuresPhi() << " "
67 << hit->getWhichDetector() << " " << hit->getProbability() << " " << hit->getWeight() << " "
68 << hit->getAssociated());
69 }
70 }
71 makePatterns(MuonHough::hough_xy, weightmdt, hitcontainer, houghpattern);
72
73 if (m_use_cosmics) {
74 makePatterns(MuonHough::hough_rzcosmics, weightmdt, hitcontainer, houghpattern);
75 } else if (m_use_curvedhough) {
76 makePatterns(MuonHough::hough_curved_at_a_cylinder, weightmdt, hitcontainer, houghpattern);
77 } else {
78 makePatterns(MuonHough::hough_rz, weightmdt, hitcontainer, houghpattern);
79 }
80
81 ATH_MSG_VERBOSE("End makePatterns ");
82}
83
84void MuonHoughPatternTool::makePatterns(int id_number, double weightmdt, const MuonHoughHitContainer& event,
85 MuonHoughPatternContainerShip& houghpattern) const {
86 ATH_MSG_DEBUG("makePatterns");
87
88 resetAssociation(event); // resets association, for hits that are already assigned to pattern in a previous hough
89
90 std::unique_ptr<MuonHoughHitContainer> event_for_hough{whichEventHough(id_number, event, weightmdt)};
91 std::unique_ptr<MuonHoughHitContainer> event_for_association{whichEventAssociation(id_number, event)};
92
93 if (msgLevel(MSG::VERBOSE)) {
94 ATH_MSG_VERBOSE("Size event fill: " << event_for_hough->size());
95 for (unsigned int i = 0; i < event_for_hough->size(); ++i) {
96 const std::shared_ptr<MuonHoughHit> hit = event_for_hough->getHit(i);
97 ATH_MSG_VERBOSE(hit->getHitx() << " " << hit->getHity() << " " << hit->getHitz() << " " << hit->getMeasuresPhi() << " "
98 << hit->getWhichDetector() << " " << hit->getProbability() << " " << hit->getWeight() << " "
99 << hit->getAssociated());
100 }
101
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);
105 ATH_MSG_VERBOSE(hit->getHitx() << " " << hit->getHity() << " " << hit->getHitz() << " " << hit->getMeasuresPhi() << " "
106 << hit->getWhichDetector() << " " << hit->getProbability() << " " << hit->getWeight() << " "
107 << hit->getAssociated());
108 }
109
110 ATH_MSG_DEBUG("size of event: " << event_for_association->size() << " id_number: " << id_number);
111 }
112 std::unique_ptr<MuonHoughTransformSteering> houghtransform{whichHoughTransform(id_number)}; // const?
113
114 ATH_MSG_DEBUG("HoughTransform chosen");
115
116 bool test_for_next_level = true;
117
118 for (int level = 0; level < m_maximum_level; level++) {
119 if (test_for_next_level) {
120 ATH_MSG_DEBUG("Iteration number: " << level);
121
122 houghtransform->resetHisto();
123 ATH_MSG_DEBUG("fillHistos size hits not in patterns " << event_for_hough->size());
124 houghtransform->fill(*event_for_hough);
125
126 if (m_use_histos && level == 0 && id_number == MuonHough::hough_curved_at_a_cylinder) {
127 const MuonHoughHisto2DContainer& histos = houghtransform->histos();
128 TDirectory* dir = gDirectory;
129 m_file->cd();
130 for (int i = 0; i < histos.size(); ++i) {
131 const std::string hname = "hough_call_" + std::to_string(m_ncalls) + "_hist_" + std::to_string(i);
132 histos.getHisto(i)->bookAndFillRootHistogram(hname)->Write();
133 }
134 gDirectory = dir;
135 ++m_ncalls;
136 }
137
138 // hitcontainer for association not updated
139 test_for_next_level = analyseHisto(id_number, level, event_for_association, houghtransform, houghpattern);
140
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());
144 }
145 } else {
146 break;
147 }
148 }
149
150} // id_number
151
153 if (m_use_histos) // debug histos
154 {
155 m_file = std::make_unique<TFile>("HoughPattern.root", "RECREATE");
156 }
157
158 ATH_MSG_DEBUG("Use Cosmic Settings: " << m_use_cosmics);
159
160 if (!m_use_cosmics) {
161 // change histogram sizes:
162 useIPMuons();
163 }
164
165 else {
168 // only 1 maximum search (number of sectors ==1):
170 // no curved hough for cosmics (muons assumed from ip):
171 m_use_curvedhough = false;
172 }
173
174 ATH_MSG_VERBOSE("Thresholds for histo: xyz: " << m_thresholdhisto_xyz << " rz: " << m_thresholdhisto_rz);
175
176 ATH_MSG_VERBOSE("Thresholds for pattern: xyz: " << m_thresholdpattern_xyz << " rz: " << m_thresholdpattern_rz);
177
178 ATH_MSG_DEBUG("Number of iterations: " << m_maximum_level << " Maxima per iteration: " << m_number_of_maxima);
179
180 return StatusCode::SUCCESS;
181}
182
184 for (unsigned int i = 0; i < event.size(); ++i) {
185 std::shared_ptr<MuonHoughHit> hit = event.getHit(i);
186 hit->setAssociated(false);
187 hit->setId(-1); // ugly, to be changed?
188 }
189}
190
192 ATH_MSG_VERBOSE("finalize()");
193
194 if (m_use_histos) {
195 m_file->Write();
196 m_file.reset();
197 }
198
199 return StatusCode::SUCCESS;
200}
201
204 houghpattern.reserve(m_number_of_ids);
205 for (int i = 0; i < m_number_of_ids; ++i) {
206 MuonHoughPatternContainer which_segment_vector;
207 which_segment_vector.reserve(m_maximum_level);
208 houghpattern.emplace_back(std::move(which_segment_vector));
209
210 for (int lvl = 0; lvl < m_maximum_level; lvl++) {
211 MuonHoughPatternCollection level_vector;
212 level_vector.reserve(m_number_of_maxima);
213 houghpattern[i].emplace_back(std::move(level_vector));
214
215 for (int maximum_number = 0; maximum_number < m_number_of_maxima; maximum_number++) {
216 houghpattern[i][lvl].emplace_back(nullptr);
217
218 } // maximum_number
219 } // maximum_level
220 } // number_of_ids
221 return houghpattern;
222} // emptyHoughPattern
223
224bool MuonHoughPatternTool::analyseHisto(int id_number, int level, const std::unique_ptr<MuonHoughHitContainer>& event_to_analyse,
225 std::unique_ptr<MuonHoughTransformSteering>& houghtransform,
226 MuonHoughPatternContainerShip& houghpatterns_all) const {
227 ATH_MSG_VERBOSE("analyseHisto MuonHoughPatternTool (start)");
228
236
237 bool test_for_next_level = false;
238
239 const unsigned int threshold_for_next_houghpattern = getThresholdHoughPattern(id_number);
240 double numberofmaxima = 0;
241 double maximum_residu = m_maximum_residu_mm;
242 if (m_use_cosmics) { maximum_residu = m_maximum_residu_mm_cosmics; }
243 MuonHoughPatternCollection houghpatterns = houghtransform->constructHoughPatterns(
244 *event_to_analyse, maximum_residu, m_maximum_residu_angle, m_number_of_maxima);
245
246 for (unsigned int maximum_number = 0; maximum_number < houghpatterns.size(); ++maximum_number) {
247
248 std::unique_ptr<MuonHoughPattern>& houghpattern = houghpatterns[maximum_number];
249 if (!houghpattern) { continue; }
250 numberofmaxima = houghpattern->getMaximumHistogram();
251 ATH_MSG_DEBUG("id_number: " << id_number << " maximum_number: " << maximum_number << " size patternseg: " << houghpattern->size());
252
253 if (houghpattern->empty()) { ATH_MSG_DEBUG("houghpattern==0"); }
254
255 // some print statements
256 if (houghpattern->size() < numberofmaxima) {
257 ATH_MSG_DEBUG("ERROR: houghpattern smaller than maximum, id: " << id_number << " houghpattern.size(): " << houghpattern->size()
258 << " numberofmaxima: " << numberofmaxima);
259 }
260
261 if (m_printlevel >= 4) { houghpattern->printHoughPattern(); }
262
263 // checks for next level / maximum
264
265 if (houghpattern->size() >= threshold_for_next_houghpattern) {
266 if (level + 1 >= m_maximum_level) {
267 ATH_MSG_DEBUG("possibly more levels");
268 } else {
269 test_for_next_level = hitsLeft(*event_to_analyse);
270 }
271 } else if (maximum_number == 0) {
272 ATH_MSG_DEBUG("houghpattern too small for next level : " << level << " id: " << id_number);
273 }
274
275 // print_of houghpatterns:
276 ATH_MSG_DEBUG("Size of HoughPatterns: " << houghpattern->size());
277 houghpatterns_all[id_number][level][maximum_number] = std::move(houghpattern);
278
279 } // maximum_number
280
281 ATH_MSG_DEBUG(" Test for next level: " << test_for_next_level);
282
283 return test_for_next_level;
284
285} // analyseHisto
286
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; }
291 }
292 return false;
293}
294
296 int number_of_hits_left = 0;
297 int number_of_hits = event.size();
298
299 for (int hitid = 0; hitid < number_of_hits; ++hitid) { number_of_hits_left += !event.getHit(hitid)->getAssociated(); }
300
301 // logically impossible --- if (number_of_hits_left <0) {ATH_MSG_WARNING("number of hits smaller than 0");}
302
303 ATH_MSG_VERBOSE("numberOfHits left: " << number_of_hits_left);
304 ATH_MSG_VERBOSE("number_of_hits: " << number_of_hits);
305 return number_of_hits_left;
306}
307
308bool MuonHoughPatternTool::hitInHoughPattern(const std::shared_ptr<MuonHoughHit>& hit, const MuonHoughPatternContainer& houghpattern) const {
309 // checks if hit is already assigned to a houghpattern
310
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]) {
314 if (houghpattern[i][j]->hitInHoughPattern(hit)) {
315 ATH_MSG_VERBOSE("Hit in hough pattern found level " << i << " max " << j << "hitid: " << hit->getId());
316 return true;
317 }
318 }
319 }
320 }
321 return false;
322}
323
324void MuonHoughPatternTool::weightRescaling(const MuonHoughHitContainer& event, int id_number, int level) const {
325 double weight_trigger_hits = 1.;
326 double weight_mdt_hits = 1.;
327
328 switch (id_number) {
331 weight_trigger_hits = 1 - (level - 1) * (1. / (m_maximum_level + 0.0)); // 1 , 1, 0.8, 0.6 , 0.4
332 if (weight_trigger_hits > 1) weight_trigger_hits = 1.;
333 weight_mdt_hits = weight_trigger_hits;
334 break;
340 switch (level) {
341 case 0:
342 weight_trigger_hits = 1.;
343 weight_mdt_hits = 1.;
344 break;
345 case 1:
346 weight_trigger_hits = 1.;
347 weight_mdt_hits = 1.;
348 break;
349 case 2:
350 weight_trigger_hits = 1.;
351 weight_mdt_hits = 0.75;
352 break;
353 case 3:
354 weight_trigger_hits = 0.75;
355 weight_mdt_hits = 0.5;
356 break;
357 case 4:
358 weight_trigger_hits = 0.5;
359 weight_mdt_hits = 0.25;
360 break;
361 default:
362 ATH_MSG_DEBUG("no weight defined for this level");
363 weight_trigger_hits = 0.5;
364 weight_mdt_hits = 0.25;
365 }
366 break;
367 default: ATH_MSG_WARNING("no valid id (id_number)");
368 }
369
370 for (unsigned int i = 0; i < event.size(); ++i) {
371 std::shared_ptr<MuonHoughHit> hit = event.getHit(i);
372 MuonHough::DetectorTechnology technology = hit->getDetectorId();
373 switch (technology) {
374 case MuonHough::CSC:
375 case MuonHough::RPC:
376 case MuonHough::TGC: hit->setWeight(hit->getOrigWeight() * weight_trigger_hits); break;
377 case MuonHough::MDT: hit->setWeight(hit->getOrigWeight() * weight_mdt_hits); break;
378 default: ATH_MSG_WARNING("no valid detector technology");
379 }
380 }
381}
382
383void MuonHoughPatternTool::calculateWeights(const MuonHoughHitContainer& event, double weightmdt) const {
384 if (weightmdt < 0.5) return;
385 // else do nothing (e.g. cosmics case)
386 for (unsigned int i = 0; i < event.size(); ++i) {
387 std::shared_ptr<MuonHoughHit> hit = event.getHit(i);
388 MuonHough::DetectorTechnology technology = hit->getDetectorId();
389 if (technology == MuonHough::MDT) {
390 // recalculate weight, especially important for cavern background MDT events
391 double p_old = hit->getOrigWeight();
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);
395 hit->setWeight(p_new);
396 }
397 }
398}
399
400int MuonHoughPatternTool::overlapHoughPatterns(const MuonHoughPattern& houghpattern1, const MuonHoughPattern& houghpattern2) const {
401 // both vectors houghpatterns->m_hitid[] are ordered, asked is the percentage of overlap between both vectors
402
403 int overlap = 0;
404 unsigned int j = 0;
405
406 for (unsigned int i = 0; i < houghpattern1.size(); ++i) {
407 while (j < houghpattern2.size()) {
408 if (houghpattern1.getHitId(i) == houghpattern2.getHitId(j)) {
409 ++overlap;
410 ++j; // this j cant be found again
411 break;
412 }
413 if (houghpattern1.getHitId(i) < houghpattern2.getHitId(j)) { break; }
414 ++j;
415 }
416 }
417 double percentage1 = (1.0 * overlap) / houghpattern1.size(); // size() gives double
418 double percentage2 = (1.0 * overlap) / houghpattern2.size();
419
420 ATH_MSG_DEBUG("Percentage Overlap: " << percentage1 << " " << percentage2);
421 return overlap;
422}
423
424std::unique_ptr<MuonHoughHitContainer> MuonHoughPatternTool::whichEventAssociation(int id_number,
425 const MuonHoughHitContainer& event) const {
426 std::unique_ptr<MuonHoughHitContainer> event_to_analyse = std::make_unique<MuonHoughHitContainer>();
427
428 switch (id_number) {
430
431 for (unsigned int hitid = 0; hitid < event.size(); ++hitid) {
432 std::shared_ptr<MuonHoughHit> hit = event.getHit(hitid);
433 if (hit->getMeasuresPhi()) {
434 if (m_use_csc_in_pattern || (!m_use_csc_in_pattern && hit->getDetectorId() != MuonHough::CSC)) {
435 event_to_analyse->addHit(hit);
436 }
437 }
438 }
439 break;
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);
444 }
445 break;
449 for (unsigned int hitid = 0; hitid < event.size(); ++hitid) {
450 std::shared_ptr<MuonHoughHit> hit = event.getHit(hitid);
451 if (!hit->getMeasuresPhi()) {
452 if (m_use_csc_in_pattern || (!m_use_csc_in_pattern && hit->getDetectorId() != MuonHough::CSC)) {
453 event_to_analyse->addHit(hit);
454 }
455 }
456 }
457 break;
459 if (m_use_rpc_measures_eta == 1) {
460 for (unsigned int hitid = 0; hitid < event.size(); ++hitid) {
461 std::shared_ptr<MuonHoughHit> hit = event.getHit(hitid);
462 if (hit->getDetectorId() == MuonHough::RPC) {
463 if (!hit->getMeasuresPhi()) { event_to_analyse->addHit(hit); }
464 }
465 }
466 } else {
467 for (unsigned int hitid = 0; hitid < event.size(); ++hitid) {
468 std::shared_ptr<MuonHoughHit> hit = event.getHit(hitid);
469 if (hit->getDetectorId() == MuonHough::RPC) { event_to_analyse->addHit(hit); }
470 }
471 }
472 break;
474 for (unsigned int hitid = 0; hitid < event.size(); ++hitid) {
475 std::shared_ptr<MuonHoughHit> hit = event.getHit(hitid);
476 if (hit->getDetectorId() == MuonHough::MDT) { event_to_analyse->addHit(hit); }
477 }
478 break;
479 default: ATH_MSG_WARNING(" no valid id");
480 }
481
482 return event_to_analyse;
483}
484
485std::unique_ptr<MuonHoughHitContainer> MuonHoughPatternTool::whichEventHough(int id_number, const MuonHoughHitContainer& event,
486 double weightmdt) const {
487 ATH_MSG_DEBUG("whichEventHough::size of event: " << event.size());
488 std::unique_ptr<MuonHoughHitContainer> hits_not_in_patterns{hitsNotInPattern(event, id_number)};
489 ATH_MSG_DEBUG("whichEventHough::hitsNotInPattern: " << hits_not_in_patterns->size());
490 std::unique_ptr<MuonHoughHitContainer> event_to_analyse = std::make_unique<MuonHoughHitContainer>();
491
492 switch (id_number) {
494
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);
497 if (hit->getMeasuresPhi() == 1) {
498 if (hitThroughCut(hit, weightmdt)) {
499 if (m_use_csc_in_hough || (!m_use_csc_in_hough && hit->getDetectorId() == MuonHough::CSC)) {
500 event_to_analyse->addHit(hit);
501 }
502 }
503 }
504 }
505 break;
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);
509 if (hitThroughCut(hit, weightmdt)) { event_to_analyse->addHit(hit); }
510 }
511 break;
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);
517 if (hitThroughCut(hit, weightmdt)) {
518 if (hit->getMeasuresPhi() == 0) {
519 if (m_use_csc_in_hough || (!m_use_csc_in_hough && hit->getDetectorId() == MuonHough::CSC)) {
520 event_to_analyse->addHit(hit);
521 }
522 }
523 }
524 }
525 break;
527 if (m_use_rpc_measures_eta == 1) {
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);
531 if (hit->getMeasuresPhi() == 0) { event_to_analyse->addHit(hit); }
532 }
533 }
534 } else {
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);
539 }
540 }
541 }
542 break;
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);
547 if (hitThroughCut(hit, weightmdt)) { event_to_analyse->addHit(hit); }
548 }
549 }
550 break;
551 default: ATH_MSG_WARNING(" no valid id");
552 }
553
554 return event_to_analyse;
555}
556
557std::unique_ptr<MuonHoughTransformSteering> MuonHoughPatternTool::whichHoughTransform(int id_number) const {
558 std::unique_ptr<MuonHoughTransformer> houghtransformer;
559
560 int nbins = 0;
561 int nbins_angle = 0;
562 double detectorsize_angle_xy = m_detectorsize_angle_xyz;
563 double stepsize_per_angle_xy = m_stepsize_per_angle_xyz;
564 double detectorsize_curved = m_nbins_curved / 2.;
565 double stepsize_xy = m_stepsize_xy;
566 // additional histograms for overlaps:
567 int number_of_histos_rz = 2 * m_number_of_sectors_rz;
568
569 switch (id_number) {
571 if (m_use_cosmics) {
572 stepsize_xy = m_stepsize_xy_cosmics;
573 stepsize_per_angle_xy = m_stepsize_per_angle_xy_cosmics;
574 detectorsize_angle_xy = (m_detectorsize_angle_xyz / 2.); // patterns not split for cosmics
575 }
576 nbins = static_cast<int>(2 * m_detectorsize_xy / stepsize_xy);
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,
580 break;
581
583 nbins = static_cast<int>(2 * m_detectorsize_yz / m_stepsize_yz);
584 nbins_angle = static_cast<int>(m_detectorsize_angle_xyz / m_stepsize_per_angle_xyz);
585 houghtransformer = std::make_unique<MuonHoughTransformer_yz>(nbins, nbins_angle, m_detectorsize_yz, m_detectorsize_angle_xyz,
587 break;
588
592 nbins = static_cast<int>(2 * m_detectorsize_rz / m_stepsize_rz);
593 nbins_angle = static_cast<int>(m_detectorsize_angle_rz / m_stepsize_per_angle_rz);
594 houghtransformer = std::make_unique<MuonHoughTransformer_rz>(nbins, nbins_angle, m_detectorsize_rz, m_detectorsize_angle_rz,
596 break;
597
599 nbins = static_cast<int>(2 * m_detectorsize_rz / m_stepsize_rz_cosmics);
600 nbins_angle = static_cast<int>(m_detectorsize_angle_rz / m_stepsize_per_angle_rz_cosmics);
601 houghtransformer = std::make_unique<MuonHoughTransformer_rzcosmics>(
603 break;
604
606 nbins = m_nbins_curved;
607 nbins_angle = static_cast<int>(m_detectorsize_angle_rz / (2 * m_stepsize_per_angle_rz));
608 houghtransformer = std::make_unique<MuonHoughTransformer_CurvedAtACylinder>(
609 nbins, nbins_angle, detectorsize_curved, m_detectorsize_angle_rz, m_thresholdhisto_rz, number_of_histos_rz);
610 break;
611
612 default: ATH_MSG_WARNING("no valid id");
613 }
614
615 if (houghtransformer) {
616 houghtransformer->useNegativeWeights(m_use_negative_weights);
617 houghtransformer->setIP(!m_use_cosmics);
618 }
619
620 ATH_MSG_DEBUG("**** histo houghtransformer: ****");
621 ATH_MSG_DEBUG("Id number: " << id_number);
622 ATH_MSG_DEBUG("NBins: " << nbins << " angle: " << nbins_angle);
623 if (m_use_negative_weights) ATH_MSG_DEBUG(" Negative weights are used ");
624 ATH_MSG_DEBUG("IP setting: " << !m_use_cosmics);
625 ATH_MSG_DEBUG("*********************************");
626 return std::make_unique<MuonHoughTransformSteering>(std::move(houghtransformer));
627}
628
629std::vector<int> MuonHoughPatternTool::maxLevelHoughPattern(const MuonHoughPatternContainerShip& houghpattern) const // obsolete?
630{
631 std::vector<int> maxlevel_houghpattern(m_number_of_ids);
632
633 for (int id_number = 0; id_number < m_number_of_ids; id_number++) {
634 maxlevel_houghpattern[id_number] = maxLevelHoughPattern(houghpattern, id_number);
635 } // number_of_ids
636 return maxlevel_houghpattern;
637}
638
640 int maxlevel = houghpattern[id_number].size();
641 bool continu = true;
642 while (maxlevel >= 1 && continu == 1) {
643 unsigned int maximum_number = 0;
644
645 while (continu && maximum_number < houghpattern[id_number][maxlevel - 1].size()) // m_number_of_maxima)
646 {
647 ATH_MSG_DEBUG("maximum_number: " << maximum_number << " "
648 << "maxlevel_houghpattern: " << maxlevel << " id: " << id_number);
649 if (!houghpattern[id_number][maxlevel - 1][maximum_number]->empty()) { continu = false; }
650
651 ++maximum_number;
652
653 } // number_of_maxima
654
655 if (continu) { maxlevel--; }
656 } // while
657 return maxlevel;
658} // maxLevelHoughPattern
659
660void MuonHoughPatternTool::transformCoordsMaximum(std::pair<double, double>& coordsmaximum, double r0_true) {
661 double z_true = coordsmaximum.first;
662 double theta_true = coordsmaximum.second;
663
664 // double theta_cor = - 0.042*(r0_true/4000.)*(r0_true/4000);
665 double theta_cor = m_theta_cor_constant * (r0_true / m_theta_cor_constant2) * (r0_true / m_theta_cor_constant2);
666
667 // double z_cor = - 10000 * (std::cos(theta_true) * r0_true/6000.) * (std::cos(theta_true)*r0_true/6000.);
668 double z_cor =
669 m_z_cor_constant * (std::cos(theta_true) * r0_true / m_z_cor_constant2) * (std::cos(theta_true) * r0_true / m_z_cor_constant2);
670
671 double z_rec = z_true + z_cor;
672 double theta_rec = theta_true + theta_cor;
673
674 if (std::cos(theta_true) < 0) {
675 z_rec = z_true - z_cor;
676 theta_rec = theta_true - theta_cor;
677 }
678
679 coordsmaximum.first = z_rec;
680 coordsmaximum.second = theta_rec;
681} // transformCoordsMaximum
682
683std::unique_ptr<MuonPrdPatternCollection> MuonHoughPatternTool::getPhiMuonPatterns(MuonHoughPatternContainerShip& houghpatterns) const {
684 std::unique_ptr<MuonPrdPatternCollection> phipatterncollection = std::make_unique<MuonPrdPatternCollection>();
685 phipatterncollection->reserve(m_maximum_level * m_number_of_maxima);
686
687 MuonHoughPatternContainer& phipatterns = houghpatterns[MuonHough::hough_xy];
688
689 // Bookkeeping for merged or double phi pattersn
690
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;
697 }
698 }
699
700 // Search for identical phi patterns and remove them
701 // and search for overlapping phi patterns and merge them for IP constraint (10-1-2008, does merging ever happen? JS)
702
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;
707 if (phipatterns[i][j]->size() < m_thresholdpattern_xyz) continue;
708 ATH_MSG_DEBUG(" patterns size before Merge " << phipatterns[i][j]->size());
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;
713 if (phipatterns[k][l]->size() < m_thresholdpattern_xyz) continue;
714 //cppcheck-suppress mismatchingContainers
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();
720 CxxUtils::sincos scphi1(phi1);
721 CxxUtils::sincos scphi2(phi2);
722 double dotprod = scphi1.cs * scphi2.cs + scphi1.sn * scphi2.sn;
723 if (dotprod > 1.)
724 dotprod = 1.;
725 else if (dotprod < -1.)
726 dotprod = -1.;
727 double psi = std::acos(dotprod);
728 const double the1 = houghpattern1->getETheta();
729 const double the2 = houghpattern2->getETheta();
730 CxxUtils::sincos scthe1(the1);
731 CxxUtils::sincos scthe2(the2);
732 dotprod = scthe1.cs * scthe2.cs + scthe1.sn * scthe2.sn;
733 if (dotprod > 1.)
734 dotprod = 1.;
735 else if (dotprod < -1.)
736 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) {
741 int overlap = overlapHoughPatterns(*houghpattern1, *houghpattern2);
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) {
747 ATH_MSG_DEBUG(" DROP patterns same hits ");
748 mergedpatterns[houghpattern2.get()] = 1;
749 continue;
750 }
751 if (overlap == ns1 && overlap < ns2) {
752 ATH_MSG_DEBUG(" DROP patterns same hits ");
753 mergedpatterns[houghpattern1.get()] = 1;
754 continue;
755 }
756 if (m_use_ip) {
757 // Merge and do cleaning (IP constraint)
758 std::unique_ptr<Muon::MuonPrdPattern> muonpattern;
759 if ((overlap > 0.8 * ns1 || overlap > 0.8 * ns2) && ns1 >= ns2) {
760 muonpattern = houghPatternsToOnePhiPattern(*phipatterns[i][j], *phipatterns[k][l]);
761 }
762 if ((overlap > 0.8 * ns1 || overlap > 0.8 * ns2) && ns1 < ns2) {
763 // Merge and do cleaning (IP constraint)
764 muonpattern = houghPatternsToOnePhiPattern(*phipatterns[k][l], *phipatterns[i][j]);
765 }
766 if (muonpattern) {
767 phipatterncollection->push_back(std::move(muonpattern));
768 mergedpatterns[houghpattern1.get()] = 1;
769 mergedpatterns[houghpattern2.get()] = 1;
770 continue;
771 }
772 } // use IP
773 } // angular cut
774 }
775 } // end k
776 }
777 } // end i
778
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;
784
785 if (!phipatterns[i][j]->empty()) {
786 std::unique_ptr<Muon::MuonPrdPattern> muonpattern;
787
788 if (!m_use_ip) {
789 muonpattern = houghPatternToPhiPattern(*phipatterns[i][j]);
790 } else {
791 muonpattern = houghPatternToCleanPhiPattern(*phipatterns[i][j]);
792 }
793
794 if (muonpattern) {
795 ATH_MSG_DEBUG(" Lift MuonPhiPattern size " << muonpattern->numberOfContainedPrds());
796 if (msgLvl(MSG::VERBOSE)) { printPattern(muonpattern.get()); }
797 phipatterncollection->push_back(std::move(muonpattern));
798 }
799 }
800 }
801 }
802
803 return phipatterncollection;
804}
805
806std::unique_ptr<MuonPrdPatternCollection> MuonHoughPatternTool::getEtaMuonPatterns(MuonHoughPatternContainerShip& houghpatterns) const {
807 std::unique_ptr<MuonPrdPatternCollection> etapatterncollection = std::make_unique<MuonPrdPatternCollection>();
808
809 int maximum_number_of_patterns = m_maximum_level * m_number_of_maxima;
810
811 if (m_use_curvedhough) maximum_number_of_patterns = 2 * maximum_number_of_patterns;
812
813 etapatterncollection->reserve(maximum_number_of_patterns);
814
815 int id = MuonHough::hough_rz;
816 if (m_use_cosmics) {
818 ATH_MSG_DEBUG(" GetEtaMuonPatterns Use RZ curved hough patterns ");
819 } else if (m_use_curvedhough) {
821 ATH_MSG_DEBUG(" GetEtaMuonPatterns Use curved hough patterns ");
822 } else {
823 ATH_MSG_DEBUG(" GetEtaMuonPatterns Use RZ hough patterns ");
824 }
825
826 MuonHoughPatternContainer& etapatterns = houghpatterns[id];
827
828 // Bookkeeping for merged or double eta patterns
829
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;
836 }
837 }
838
839 // Search for identical eta patterns and remove them
840 // and search for overlapping eta patterns and merge them (10-1-2008, does merging ever happen? JS, yes it does!)
841
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;
846 if (etapatterns[i][j]->size() < m_thresholdpattern_rz) continue;
847 ATH_MSG_DEBUG(" Eta patterns size before Merge " << etapatterns[i][j]->size());
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;
852 if (etapatterns[k][l]->size() < m_thresholdpattern_rz) continue;
853 //cppcheck-suppress mismatchingContainers
854 if (houghpattern1.get() == houghpattern2.get()) continue;
855 if (mergedpatterns[houghpattern1.get()] == 1) continue;
856 if (mergedpatterns[houghpattern2.get()] == 1) continue;
857
858 // calculate if curvatures are compatible, not done for cosmics
859 double alpha = 0.;
860 if (!m_use_cosmics) {
861 double curv1 = houghpattern1->getECurvature();
862 double curv2 = houghpattern2->getECurvature();
863 if (std::abs(curv1) < 1001. || std::abs(curv2) < 1001.) {
864 ATH_MSG_DEBUG("Curvature too small, should not be possible: " << curv1 << " " << curv2);
865 continue;
866 }
867
868 double angle1 = std::acos((std::abs(curv1) - 1000.) / curv1); // angle change after 1000 (mm)
869 double angle2 = std::acos((std::abs(curv2) - 1000.) / curv2);
870 alpha = std::abs(std::sin(angle1 - angle2));
871
872 ATH_MSG_DEBUG(" patterns curv1 " << curv1 << " curv2 " << curv2 << " alpha " << alpha);
873 }
874
875 double phi1 = houghpattern1->getEPhi();
876 double phi2 = houghpattern2->getEPhi();
877 double dotprod = std::cos(phi1) * std::cos(phi2) + std::sin(phi1) * std::sin(phi2);
878 if (dotprod > 1.)
879 dotprod = 1.;
880 else if (dotprod < -1.)
881 dotprod = -1.;
882 double psi = std::acos(dotprod);
883 double the1 = houghpattern1->getETheta();
884 double the2 = houghpattern2->getETheta();
885 dotprod = std::cos(the1) * std::cos(the2) + std::sin(the1) * std::sin(the2);
886 if (dotprod > 1.)
887 dotprod = 1.;
888 else if (dotprod < -1.)
889 dotprod = -1.;
890 double chi = std::acos(dotprod);
891
892 ATH_MSG_DEBUG(" patterns phi1 " << phi1 << " phi2 " << phi2 << " psi " << psi);
893 ATH_MSG_DEBUG(" patterns the1 " << the1 << " the2 " << the2 << " chi " << chi);
894
895 if (chi < 0.5 && psi < 0.5 && alpha < 0.05) { // 0.05 (rad) corresponds with 3 degrees per m
896
897 int overlap = overlapHoughPatterns(*houghpattern1, *houghpattern2);
898 const int ns1 = houghpattern1->size();
899 const int ns2 = houghpattern2->size();
900
901 ATH_MSG_DEBUG(" Eta Overlap " << overlap << " size1 " << ns1 << " size2 " << ns2);
902
903 if (overlap == ns2 && overlap <= ns1) {
904 ATH_MSG_DEBUG(" DROP patterns overlapping hits ");
905 mergedpatterns[houghpattern2.get()] = 1;
906 continue;
907 }
908 if (overlap == ns1 && overlap < ns2) {
909 ATH_MSG_DEBUG(" DROP patterns overlapping hits ");
910 mergedpatterns[houghpattern1.get()] = 1;
911 continue;
912 }
913 std::unique_ptr<Muon::MuonPrdPattern> muonpattern;
914 // Look for 80% or more overlap
915 if ((overlap > 0.8 * ns1 || overlap > 0.8 * ns2) && ns1 >= ns2) {
916 muonpattern = houghPatternsToOneEtaPattern(*etapatterns[i][j], *etapatterns[k][l]);
917 }
918 if ((overlap > 0.8 * ns1 || overlap > 0.8 * ns2) && ns1 < ns2) {
919 muonpattern = houghPatternsToOneEtaPattern(*etapatterns[k][l], *etapatterns[i][j]);
920 }
921 if (muonpattern) {
922 etapatterncollection->push_back(std::move(muonpattern));
923 mergedpatterns[houghpattern1.get()] = 1;
924 mergedpatterns[houghpattern2.get()] = 1;
925 continue;
926 }
927 } // end angular cut
928 }
929 } // end k
930 }
931 } // end i
932
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;
938
939 if (!etapatterns[i][j]->empty()) {
940 std::unique_ptr<Muon::MuonPrdPattern> muonpattern = houghPatternToEtaPattern(*etapatterns[i][j]);
941 //use muonpattern *before* you move it
942 if (msgLvl(MSG::VERBOSE)) { printPattern(muonpattern.get()); }
943 etapatterncollection->push_back(std::move(muonpattern));
944 ATH_MSG_DEBUG(" Lift MuonEtaPattern size " << etapatterns[i][j]->size());
945
946 }
947 }
948 }
949
950 return etapatterncollection;
951}
952
953std::unique_ptr<MuonPrdPatternCollection> MuonHoughPatternTool::getCurvedMuonPatterns(MuonHoughPatternContainerShip& houghpatterns) const {
954 std::unique_ptr<MuonPrdPatternCollection> curvedpatterncollection = std::make_unique<MuonPrdPatternCollection>();
955
956 int maximum_number_of_patterns = m_maximum_level * m_number_of_maxima;
957
958 curvedpatterncollection->reserve(maximum_number_of_patterns);
959
961 for (unsigned int i = 0; i < curvedpatterns.size(); ++i) {
962 for (unsigned int j = 0; j < curvedpatterns[i].size(); ++j) {
963 std::unique_ptr<MuonHoughPattern>& houghpattern = curvedpatterns[i][j];
964 if (!houghpattern) { continue; }
965
966 if (!curvedpatterns[i][j]->empty()) {
967 std::unique_ptr<Muon::MuonPrdPattern> muonpattern = houghPatternToEtaPattern(*curvedpatterns[i][j]);
968 curvedpatterncollection->push_back(std::move(muonpattern));
969 ATH_MSG_DEBUG(" Lift MuoncurvedPattern size " << curvedpatterns[i][j]->size());
970 }
971 }
972 }
973 return curvedpatterncollection;
974}
975
976std::unique_ptr<Muon::MuonPrdPattern> MuonHoughPatternTool::houghPatternToEtaPattern(const MuonHoughPattern& houghpattern) const {
977 ATH_MSG_VERBOSE("houghPatternToEtaPattern");
978
979 const Amg::Vector3D position = houghpattern.getEPos();
980 const Amg::Vector3D direction = houghpattern.getEDir();
981
982 double curvature = houghpattern.getECurvature();
983 double charge = curvature < 0 ? -1 : 1.;
984 double pscale = std::abs(curvature);
985
986 const double r0 = m_use_cosmics ? houghpattern.getERPhi() : 0.001;
987
988 double x0 = charge * r0 * std::sin(houghpattern.getEPhi());
989 double y0 = -charge * r0 * std::cos(houghpattern.getEPhi());
990
991 const Amg::Vector3D pos = Amg::Vector3D(x0, y0, position[2]);
992 const Amg::Vector3D dir = Amg::Vector3D(pscale * direction[0], pscale * direction[1], pscale * direction[2]);
993
994 ATH_MSG_DEBUG("position: " << x0 << " " << y0 << " " << position[2]);
995 ATH_MSG_DEBUG("direction: " << direction[0] << " " << direction[1] << " " << direction[2]);
996
997 ATH_MSG_DEBUG(" Lift Eta Hough Pattern with charge " << charge << " Curvature " << pscale);
998 std::unique_ptr<Muon::MuonPrdPattern> muonpattern = std::make_unique<Muon::MuonPrdPattern>(pos, dir);
999
1000 for (unsigned int i = 0; i < houghpattern.size(); ++i) { muonpattern->addPrd(houghpattern.getPrd(i)); }
1001
1002 return muonpattern;
1003}
1004std::unique_ptr<Muon::MuonPrdPattern> MuonHoughPatternTool::houghPatternToPhiPattern(const MuonHoughPattern& houghpattern) const {
1005 ATH_MSG_VERBOSE("houghPatternToPhiPattern");
1006
1007 const Amg::Vector3D pos = houghpattern.getEPos();
1008 const Amg::Vector3D dir = houghpattern.getEDir();
1009
1010 ATH_MSG_DEBUG("position: " << pos[0] << " " << pos[1] << " " << pos[2]);
1011 ATH_MSG_DEBUG("direction: " << dir[0] << " " << dir[1] << " " << dir[2]);
1012 std::unique_ptr<Muon::MuonPrdPattern> muonpattern = std::make_unique<Muon::MuonPrdPattern>(pos, dir);
1013
1014 for (unsigned int i = 0; i < houghpattern.size(); ++i) {
1015 muonpattern->addPrd(houghpattern.getPrd(i));
1016
1017 ATH_MSG_VERBOSE("PrepRawData Added " << houghpattern.getPrd(i));
1018 }
1019
1020 return muonpattern;
1021}
1022
1023std::unique_ptr<Muon::MuonPrdPattern> MuonHoughPatternTool::houghPatternsToOneEtaPattern(const MuonHoughPattern& houghpattern1,
1024 const MuonHoughPattern& houghpattern2) const {
1025 ATH_MSG_DEBUG("houghPatternsToOneEtaPattern");
1026
1027 const int ns1 = houghpattern1.size();
1028 const int ns2 = houghpattern2.size();
1029
1030 const double the1 = houghpattern1.getETheta();
1031 const double the2 = houghpattern2.getETheta();
1032 const double theta = (ns1 * the1 + ns2 * the2) / (ns1 + ns2);
1033
1034 const double phi1 = houghpattern1.getEPhi();
1035 const double phi2 = houghpattern2.getEPhi();
1036 const double cos_phi = (ns1 * std::cos(phi1) + ns2 * std::cos(phi2)) / (ns1 + ns2);
1037 const double sin_phi = (ns1 * std::sin(phi1) + ns2 * std::sin(phi2)) / (ns1 + ns2);
1038 const double phi = std::atan2(sin_phi, cos_phi);
1039
1040 const double invcur1 = 1. / houghpattern1.getECurvature();
1041 const double invcur2 = 1. / houghpattern2.getECurvature();
1042
1043 const Amg::Vector3D position1 = houghpattern1.getEPos();
1044 const Amg::Vector3D position2 = houghpattern2.getEPos();
1045 const double z0 = (ns1 * position1[2] + ns2 * position2[2]) / (ns1 + ns2);
1046
1047 const double invcur = (ns1 * invcur1 + ns2 * invcur2) / (ns1 + ns2);
1048
1049 ATH_MSG_DEBUG("Start Making one eta pattern theta " << theta << " phi " << phi << " invcur " << invcur);
1050
1051 ATH_MSG_DEBUG("eta patterns theta1 " << the1 << " theta2 " << the2 << " phi1 " << phi1 << " phi2 " << phi2 << " invcur1 " << invcur1
1052 << " invcur2 " << invcur2 << " ns1 " << ns1 << " ns2 " << ns2);
1053
1054 ATH_MSG_DEBUG(" z values " << z0 << " z1 " << position1[2] << " z2 " << position2[2]);
1055
1056 // require at least two eta hits on muon pattern
1057
1058 if (ns1 + ns2 < 2) return nullptr;
1059
1060 double invcurvature = invcur;
1061 double charge = 1.;
1062 if (invcurvature < 0) charge = -1;
1063 double pscale = 1.;
1064 if (invcurvature != 0) pscale = 1. / std::abs(invcurvature);
1065
1066 double r0 = 0.001;
1067
1068 if (m_use_cosmics) { // calculate new r0
1069 r0 = (ns1 * houghpattern1.getERPhi() + ns2 * houghpattern2.getERPhi()) / (ns1 + ns2);
1070 ATH_MSG_DEBUG("New r0: " << r0);
1071 }
1072
1073 double x0 = charge * r0 * sin_phi;
1074 double y0 = -charge * r0 * cos_phi;
1075
1076 ATH_MSG_DEBUG(" Lift one Eta pattern charge " << charge << " curvature " << pscale);
1077
1078 const Amg::Vector3D pos = Amg::Vector3D(x0, y0, z0);
1079 const Amg::Vector3D dir =
1080 Amg::Vector3D(pscale * std::sin(theta) * cos_phi, pscale * std::sin(theta) * sin_phi, pscale * std::cos(theta));
1081
1082 std::unique_ptr<Muon::MuonPrdPattern> muonpattern = std::make_unique<Muon::MuonPrdPattern>(pos, dir);
1083 int neta = 0;
1084
1085 for (unsigned int i = 0; i < houghpattern1.size(); ++i) {
1086 double the = houghpattern1.getTheta(i);
1087 muonpattern->addPrd(houghpattern1.getPrd(i));
1088 ++neta;
1089 ATH_MSG_VERBOSE("PrepRawData Added theta " << the);
1090 }
1091
1092 for (unsigned int i = 0; i < houghpattern2.size(); ++i) {
1093 bool accept = true;
1094 double the = houghpattern2.getTheta(i);
1095 for (unsigned int j = 0; j < houghpattern1.size(); ++j) {
1096 if (houghpattern2.getPrd(i) == houghpattern1.getPrd(j)) accept = false;
1097 }
1098 if (accept) {
1099 muonpattern->addPrd(houghpattern2.getPrd(i));
1100 ++neta;
1101 ATH_MSG_VERBOSE("PrepRawData Added theta " << the);
1102 } else {
1103 ATH_MSG_VERBOSE(" PrepRawData already there " << the);
1104 }
1105 }
1106
1107 ATH_MSG_VERBOSE(" END make One Eta pattern hits " << neta);
1108
1109 return muonpattern;
1110}
1111
1112std::unique_ptr<Muon::MuonPrdPattern> MuonHoughPatternTool::houghPatternsToOnePhiPattern(const MuonHoughPattern& houghpattern1,
1113 const MuonHoughPattern& houghpattern2) const {
1115
1116 ATH_MSG_DEBUG("houghPatternsToOnePhiPattern");
1117
1118 double theta = (houghpattern1.getETheta() + houghpattern2.getETheta()) / 2.;
1119 double cos_phi{0.}, sin_phi{0.};
1120 int nphi = 0;
1121 for (unsigned int i = 0; i < houghpattern1.size(); ++i) {
1122 double phi = houghpattern1.getPhi(i);
1123 cos_phi += std::cos(phi);
1124 sin_phi += std::sin(phi);
1125 ++nphi;
1126 }
1127 for (unsigned int i = 0; i < houghpattern2.size(); ++i) {
1128 double phi = houghpattern2.getPhi(i);
1129 bool accept = true;
1130 for (unsigned int j = 0; j < houghpattern1.size(); ++j) {
1131 if (houghpattern2.getPrd(i) == houghpattern1.getPrd(j)) accept = false;
1132 }
1133 if (accept) {
1134 cos_phi += std::cos(phi);
1135 sin_phi += std::sin(phi);
1136 ++nphi;
1137 }
1138 }
1139
1140 ATH_MSG_VERBOSE("Start Merged Phi hits cleaning with " << nphi << " hits ");
1141 // require at least two phi hits on muon phi pattern
1142
1143 if (nphi < 2) return nullptr;
1144
1145 double cphit = cos_phi / nphi;
1146 double sphit = sin_phi / nphi;
1147
1148 cos_phi = 0.;
1149 sin_phi = 0.;
1150 nphi = 0;
1151
1152 for (unsigned int i = 0; i < houghpattern1.size(); ++i) {
1153 double phi = houghpattern1.getPhi(i);
1154 double dotprod = cphit * std::cos(phi) + sphit * std::sin(phi);
1155 if (dotprod > 0.95) {
1156 cos_phi += std::cos(phi);
1157 sin_phi += std::sin(phi);
1158 ++nphi;
1159 }
1160 }
1161
1162 for (unsigned int i = 0; i < houghpattern2.size(); ++i) {
1163 double phi = houghpattern2.getPhi(i);
1164 double dotprod = cphit * std::cos(phi) + sphit * std::sin(phi);
1165 if (dotprod > 0.95) {
1166 bool accept = true;
1167 for (unsigned int j = 0; j < houghpattern1.size(); ++j) {
1168 if (houghpattern2.getPrd(i) == houghpattern1.getPrd(j)) accept = false;
1169 }
1170 if (accept) {
1171 cos_phi += std::cos(phi);
1172 sin_phi += std::sin(phi);
1173 ++nphi;
1174 }
1175 }
1176 }
1177
1178 if (nphi < 2) return nullptr;
1179 cphit = cos_phi / nphi;
1180 sphit = sin_phi / nphi;
1181
1182 cos_phi = 0.;
1183 sin_phi = 0.;
1184 nphi = 0;
1185 for (unsigned int i = 0; i < houghpattern1.size(); ++i) {
1186 double phi = houghpattern1.getPhi(i);
1187 double dotprod = cphit * std::cos(phi) + sphit * std::sin(phi);
1188 if (dotprod > 0.99) {
1189 cos_phi += std::cos(phi);
1190 sin_phi += std::sin(phi);
1191 ++nphi;
1192 }
1193 }
1194 for (unsigned int i = 0; i < houghpattern2.size(); ++i) {
1195 double phi = houghpattern2.getPhi(i);
1196 double dotprod = cphit * std::cos(phi) + sphit * std::sin(phi);
1197 if (dotprod > 0.99) {
1198 bool accept = true;
1199 for (unsigned int j = 0; j < houghpattern1.size(); ++j) {
1200 if (houghpattern2.getPrd(i) == houghpattern1.getPrd(j)) accept = false;
1201 }
1202 if (accept) {
1203 cos_phi += std::cos(phi);
1204 sin_phi += std::sin(phi);
1205 ++nphi;
1206 }
1207 }
1208 }
1209 if (nphi < 2) return nullptr;
1210 cphit = cos_phi / nphi;
1211 sphit = sin_phi / nphi;
1212
1213 theta = 0;
1214 cos_phi = 0.;
1215 sin_phi = 0.;
1216 nphi = 0;
1217 for (unsigned int i = 0; i < houghpattern1.size(); ++i) {
1218 double phi = houghpattern1.getPhi(i);
1219 double thetah = houghpattern1.getTheta(i);
1220 double dotprod = cphit * std::cos(phi) + sphit * std::sin(phi);
1221 if (dotprod > 0.995) {
1222 cos_phi += std::cos(phi);
1223 sin_phi += std::sin(phi);
1224 theta += thetah;
1225 ++nphi;
1226 }
1227 }
1228 for (unsigned int i = 0; i < houghpattern2.size(); ++i) {
1229 double phi = houghpattern2.getPhi(i);
1230 double thetah = houghpattern2.getTheta(i);
1231 double dotprod = cphit * std::cos(phi) + sphit * std::sin(phi);
1232 if (dotprod > 0.995) {
1233 bool accept = true;
1234 for (unsigned int j = 0; j < houghpattern1.size(); ++j) {
1235 if (houghpattern2.getPrd(i) == houghpattern1.getPrd(j)) accept = false;
1236 }
1237 if (accept) {
1238 cos_phi += std::cos(phi);
1239 sin_phi += std::sin(phi);
1240 theta += thetah;
1241 ++nphi;
1242 }
1243 }
1244 }
1245 if (nphi < 2) return nullptr;
1246 cphit = cos_phi / nphi;
1247 sphit = sin_phi / nphi;
1248 theta = theta / nphi;
1249
1250 double r0 = 1.; // put 1 mm r0 value
1251 double x0 = r0 * sphit;
1252 double y0 = -r0 * cphit;
1253 double z0 = 0.;
1254
1255 const Amg::Vector3D pos{x0, y0, z0};
1256 const Amg::Vector3D dir{std::sin(theta) * cphit, std::sin(theta) * sphit, std::cos(theta)};
1257
1258 std::unique_ptr<Muon::MuonPrdPattern> muonpattern = std::make_unique<Muon::MuonPrdPattern>(pos, dir);
1259 nphi = 0;
1260
1261 for (unsigned int i = 0; i < houghpattern1.size(); ++i) {
1262 double phi = houghpattern1.getPhi(i);
1263 double dotprod = cphit * std::cos(phi) + sphit * std::sin(phi);
1264 if (dotprod > 0.995) {
1265 muonpattern->addPrd(houghpattern1.getPrd(i));
1266 ++nphi;
1267 ATH_MSG_VERBOSE("PrepRawData Merged Clean Phi Added " << phi);
1268 } else {
1269 ATH_MSG_VERBOSE("PrepRawData Merged Phi Dropped " << phi);
1270 }
1271 }
1272
1273 for (unsigned int i = 0; i < houghpattern2.size(); ++i) {
1274 double phi = houghpattern2.getPhi(i);
1275 double dotprod = cphit * std::cos(phi) + sphit * std::sin(phi);
1276 if (dotprod > 0.995) {
1277 bool accept = true;
1278 for (unsigned int j = 0; j < houghpattern1.size(); ++j) {
1279 if (houghpattern2.getPrd(i) == houghpattern1.getPrd(j)) accept = false;
1280 }
1281 if (accept) {
1282 muonpattern->addPrd(houghpattern2.getPrd(i));
1283 ++nphi;
1284 ATH_MSG_VERBOSE("PrepRawData Merged Clean Phi Added " << phi);
1285 } else {
1286 ATH_MSG_VERBOSE("PrepRawData Merged Phi Dropped " << phi);
1287 }
1288 } else {
1289 ATH_MSG_VERBOSE("PrepRawData Merged Phi Dropped " << phi);
1290 }
1291 }
1292
1293 ATH_MSG_VERBOSE("END Clean Merged Phi hits " << nphi);
1294
1295 return muonpattern;
1296}
1297
1298std::unique_ptr<Muon::MuonPrdPattern> MuonHoughPatternTool::houghPatternToCleanPhiPattern(MuonHoughPattern& houghpattern) const {
1300
1301 // TODO: rewrite with removing hits from patterns, instead of building up
1302
1303 ATH_MSG_DEBUG("houghPatternToCleanPhiPattern");
1304
1305 if (msgLevel(MSG::VERBOSE)) {
1306 for (unsigned int i = 0; i < houghpattern.size(); ++i) {
1307 const std::shared_ptr<MuonHoughHit> hit = houghpattern.getHit(i);
1308 ATH_MSG_VERBOSE(hit->getHitx() << " " << hit->getHity() << " " << hit->getHitz() << " " << hit->getPhi() << " "
1309 << hit->getMeasuresPhi() << " " << hit->getWhichDetector() << " " << hit->getWeight() << " "
1310 << hit->getAssociated());
1311 }
1312 }
1313
1314 double theta = houghpattern.getETheta();
1315 unsigned int size = houghpattern.size();
1316 double phi = houghpattern.getEPhi();
1317 double r0 = houghpattern.getERPhi();
1318
1319 ATH_MSG_DEBUG("Start Phi hits cleaning with " << size << " hits "
1320 << " theta " << theta);
1321 ATH_MSG_DEBUG("Start Phi: " << phi << " r0: " << r0);
1322 houghpattern.updateParametersRPhi();
1323 unsigned int newsize = houghpattern.size();
1324
1325 ATH_MSG_VERBOSE("size: " << newsize << " r0: " << r0 << " phi: " << phi);
1326
1327 CxxUtils::sincos scphi(phi);
1328
1329 const int number_of_iterations = 4;
1330 static constexpr std::array<double, number_of_iterations> cutvalues{1000., 500., 250., 125.};
1331
1332 const MuonHoughPattern* newpattern{&houghpattern};
1333 std::unique_ptr<MuonHoughPattern> pat_owner{};
1334 for (int it = 0; it < number_of_iterations; it++) {
1335 bool change = true;
1336 while (change) {
1337 ATH_MSG_VERBOSE("size: " << newsize << " r0: " << r0 << " phi: " << phi);
1338
1339 double max_dist = 0.;
1340 unsigned int max_i = UINT_MAX;
1341 for (unsigned int i = 0; i < newpattern->size(); ++i) {
1342 double dist = newpattern->getHitx(i) * scphi.sn - newpattern->getHity(i) * scphi.cs - r0;
1343 ATH_MSG_VERBOSE("Dist: " << dist);
1344 if (dist > max_dist) {
1345 max_dist = dist;
1346 max_i = i;
1347 }
1348 }
1349 if (max_dist < cutvalues[it]) {
1350 change = false;
1351 } else {
1352 std::unique_ptr<MuonHoughPattern> newpattern2 = std::make_unique<MuonHoughPattern>(MuonHough::hough_xy);
1353 for (unsigned int i = 0; i < newpattern->size(); ++i) {
1354 if (i != max_i) { newpattern2->addHit(newpattern->getHit(i)); }
1355 }
1356 newpattern2->updateParametersRPhi();
1357 phi = newpattern2->getEPhi();
1358 r0 = newpattern2->getERPhi();
1359 newsize = newpattern2->size();
1360 pat_owner = std::move(newpattern2);
1361 newpattern = pat_owner.get();
1362 scphi = CxxUtils::sincos(phi);
1363 }
1364 }
1365 }
1366
1367 ATH_MSG_DEBUG("Final size: " << newsize << " r0: " << r0 << " phi: " << phi);
1368
1369 double thetanew = 0.;
1370 for (unsigned int i = 0; i < newpattern->size(); ++i) {
1371 double thetah = newpattern->getTheta(i);
1372 thetanew += thetah;
1373 }
1374
1375 thetanew = thetanew / (newpattern->size() + 1e-7);
1376
1377 double r0_new = 1.; // put 1 mm r0 value
1378 double x0_new = r0_new * scphi.sn;
1379 double y0_new = -r0_new * scphi.cs;
1380 double z0_new = 0.;
1381
1382 CxxUtils::sincos sctheta(thetanew);
1383
1384 const Amg::Vector3D pos = Amg::Vector3D(x0_new, y0_new, z0_new);
1385 const Amg::Vector3D dir = Amg::Vector3D(sctheta.sn * scphi.cs, sctheta.sn * scphi.sn, sctheta.cs);
1386
1387 std::unique_ptr<Muon::MuonPrdPattern> muonpattern = std::make_unique<Muon::MuonPrdPattern>(pos, dir);
1388
1389 for (unsigned int i = 0; i < newpattern->size(); ++i) { muonpattern->addPrd(newpattern->getPrd(i)); }
1390
1391 ATH_MSG_DEBUG("END Clean Phi hits " << newsize << " theta " << thetanew);
1392
1393 ATH_MSG_VERBOSE("cleaned pattern: ");
1394 if (msgLvl(MSG::VERBOSE)) { printPattern(muonpattern.get()); }
1395 return muonpattern;
1396}
1397
1398std::unique_ptr<MuonHoughHitContainer> MuonHoughPatternTool::hitsNotInPattern(const MuonHoughHitContainer& event, int /*id_number*/) {
1399 std::unique_ptr<MuonHoughHitContainer> hits_not_in_patterns = std::make_unique<MuonHoughHitContainer>();
1400
1401 for (unsigned int hitid = 0; hitid < event.size(); ++hitid) {
1402 if (!event.getHit(hitid)->getAssociated()) { hits_not_in_patterns->addHit(event.getHit(hitid)); }
1403 }
1404 return hits_not_in_patterns;
1405}
1406unsigned int MuonHoughPatternTool::getThresholdHoughPattern(int id_number) const {
1407 unsigned int thresholdpattern = 0;
1408 switch (id_number) {
1410 case MuonHough::hough_yz: thresholdpattern = m_thresholdpattern_xyz; break;
1415 case MuonHough::hough_curved_at_a_cylinder: thresholdpattern = m_thresholdpattern_rz; break;
1416 default: ATH_MSG_WARNING("no valid id (id_number)");
1417 } // switch
1418 return thresholdpattern;
1419}
1420
1421double MuonHoughPatternTool::getThresholdHisto(int id_number) const {
1422 double thresholdhisto = 0.;
1423 switch (id_number) {
1425 case MuonHough::hough_yz: thresholdhisto = m_thresholdhisto_xyz; break;
1430 case MuonHough::hough_curved_at_a_cylinder: thresholdhisto = m_thresholdhisto_rz; break;
1431 default: ATH_MSG_WARNING("no valid id (id_number)");
1432 } // switch
1433 return thresholdhisto;
1434}
1435
1436void MuonHoughPatternTool::setWeightMdtCutValue(const MuonHoughHitContainer& event, double& weightmdt) const {
1437 if (m_use_cosmics) {
1438 weightmdt = 0.;
1439 return;
1440 }
1441 int mdthits = event.getMDThitno(); // slow function!
1442 weightmdt = mdthits > 0. ? 1. - 5. / std::sqrt(mdthits) : 0.;
1443}
1444
1445bool MuonHoughPatternTool::hitThroughCut(const std::shared_ptr<MuonHoughHit>& hit, double weightmdt) const {
1446 return (!m_weightcutmdt || hit->getDetectorId() != MuonHough::MDT || hit->getProbability() >= weightmdt) &&
1447 (!m_weightcut || hit->getProbability() >= m_weight);
1448}
1449
1451 if (!muonpattern) {
1452 ATH_MSG_VERBOSE("Printout of Pattern: nullptr");
1453 return;
1454 }
1455 ATH_MSG_VERBOSE("Printout of Pattern: ");
1456 for (unsigned int k = 0; k < muonpattern->numberOfContainedPrds(); k++) {
1457 const Trk::PrepRawData* prd = muonpattern->prd(k);
1458 const Muon::MdtPrepData* mdtprd = dynamic_cast<const Muon::MdtPrepData*>(prd);
1459 if (mdtprd) {
1460 const Trk::Surface& surface = mdtprd->detectorElement()->surface(mdtprd->identify());
1461 const Amg::Vector3D& gpos = surface.center();
1462 ATH_MSG_VERBOSE("mdt " << k << " x: " << gpos.x() << " y: " << gpos.y() << " z: " << gpos.z());
1463 } else if (!mdtprd) {
1464 const Muon::MuonCluster* muoncluster = dynamic_cast<const Muon::MuonCluster*>(prd);
1465 if (muoncluster) {
1466 const Amg::Vector3D& gpos = muoncluster->globalPosition();
1467 ATH_MSG_VERBOSE("cluster " << k << " x: " << gpos.x() << " y: " << gpos.y() << " z: " << gpos.z());
1468 }
1469 if (!muoncluster) { ATH_MSG_DEBUG("no muon prd? "); }
1470 }
1471 }
1472}
Scalar phi() const
phi method
Scalar theta() const
theta method
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
double charge(const T &p)
Definition AtlasPID.h:997
std::vector< std::unique_ptr< MuonHoughPattern > > MuonHoughPatternCollection
This typedef represents a collection and container of MuonHoughPattern objects.
std::vector< MuonHoughPatternContainer > MuonHoughPatternContainerShip
std::vector< MuonHoughPatternCollection > MuonHoughPatternContainer
static const Attributes_t empty
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
bool msgLvl(const MSG::Level lvl) const
virtual const Trk::Surface & surface() const override final
Return surface associated with this detector element.
unsigned int size() const
returns size of hitcontainer
double getHitx(unsigned int hitno) const
returns x position of hit hitno
double getPhi(unsigned int hitno) const
returns phi of hit hitno
double getHity(unsigned int hitno) const
returns y position of hit hitno
std::shared_ptr< MuonHoughHit > getHit(int hitno) const
returns Hit at position hitno
int getHitId(unsigned int hitno) const
returns hitid of hit hitno
bool getMeasuresPhi(unsigned int hitno) const
returns if hit hitno measures phi
const Trk::PrepRawData * getPrd(unsigned int hitno) const
returns preprawdata pointer of hit hitno
double getTheta(unsigned int hitno) const
returns theta of hit hitno
std::unique_ptr< MuonHoughHitContainer > whichEventHough(int id, const MuonHoughHitContainer &event, double weightmdt) const
selects the hitcontainer to be used for filling the histograms
static constexpr double m_stepsize_rz_cosmics
bin width for rzcosmics
static constexpr double m_stepsize_yz
bin width for yz
static constexpr double m_theta_cor_constant
constant 1 for theta for hough correction
virtual StatusCode initialize() override
initiates private members
std::unique_ptr< Muon::MuonPrdPattern > houghPatternToCleanPhiPattern(MuonHoughPattern &houghpattern) const
converts hough pattern to EDM phi patterns and cleans it from outliers
Gaudi::Property< double > m_thresholdhisto_rz
threshold histogram in rz
int m_number_of_ids
number of hough transforms currently supported (7)
Gaudi::Property< int > m_number_of_sectors_rz
number of sectors (different regions in which patterns can be found in the same iteration) in rz
Gaudi::Property< int > m_maxNumberOfPhiHits
maximum number of phi hits to do pattern recognition, if small zero no cut is applied
std::unique_ptr< MuonPrdPatternCollection > getCurvedMuonPatterns(MuonHoughPatternContainerShip &houghpatterns) const
returns curvedpattern container in EDM
virtual MuonHoughPatternContainerShip emptyHoughPattern() const override
creates houghpatterns, called from FinderTool
std::unique_ptr< MuonHoughHitContainer > whichEventAssociation(int id, const MuonHoughHitContainer &event) const
selects the hitcontainer to be used to associate to the maxima
static constexpr double m_stepsize_per_angle_xyz
bin width for angle in xyz
static constexpr double m_stepsize_per_angle_rz_cosmics
bin width for angle in rzcosmics
static constexpr int m_maximum_level
// number of maximum iterations over houghtransform
int m_number_of_sectors_rz_cosmics
number of sectors (different regions in which patterns can be found in the same iteration) in rzcosmi...
static constexpr double m_maximum_residu_mm
distance hits are associated with pattern in mm
static constexpr double m_detectorsize_rz_full
size of full detector in rz (eta) in mm, used as acceptancy for cosmics
unsigned int getThresholdHoughPattern(int id_number) const
returns minimum number of hits a hough pattern can contain
int numberOfHits(const MuonHoughHitContainer &event) const
returns number of hits left (unused)
static void transformCoordsMaximum(std::pair< double, double > &coordsmaximum, double r0_true)
corrects the maximum of the histogram with a factor (not in use anymore, used for old rz transform)
static constexpr double m_detectorsize_angle_rz
max range of angle in rz in degrees (180)
static constexpr double m_stepsize_per_angle_xy_cosmics
bin width for angle in xy cosmics
Gaudi::Property< bool > m_use_curvedhough
use curved hough transformation for eta patterns (true)
bool analyseHisto(int id_number, int level, const std::unique_ptr< MuonHoughHitContainer > &event_to_analyse, std::unique_ptr< MuonHoughTransformSteering > &houghtransform, MuonHoughPatternContainerShip &houghpatterns) const
analyses the hough histograms
static constexpr double m_detectorsize_angle_xyz
max range of angle in xyz in degrees (360)
bool m_use_ip
use interaction point constraint (true)
static constexpr double m_z_cor_constant
use hough correction to correct the maximum found in rz-plane slightly as there is a bias in the houg...
Gaudi::Property< bool > m_use_csc_in_pattern
use csc hits in association / pattern (true)
void printPattern(Muon::MuonPrdPattern *muonpattern) const
print out pattern hits
Gaudi::Property< unsigned int > m_thresholdpattern_rz
minimal size for a eta pattern (3)
Gaudi::Property< int > m_number_of_maxima
number of iterations (5)
static constexpr int m_nbins_curved
bin width for 1/sqrt(curvature)
std::unique_ptr< Muon::MuonPrdPattern > houghPatternsToOnePhiPattern(const MuonHoughPattern &houghpattern1, const MuonHoughPattern &houghpattern2) const
converts and combines two hough patterns to one EDM phi pattern
double m_detectorsize_rz
acceptancy of patterns in rz (eta) in mm
std::unique_ptr< MuonHoughTransformSteering > whichHoughTransform(int id) const
returns the Houghtransform for the id
Gaudi::Property< bool > m_weightcutmdt
weight_cut for mdt hits in hough
static constexpr double m_theta_cor_constant2
constant 2 for theta for hough correction
static constexpr double m_detectorsize_yz_ip
acceptancy of patterns for ip in yz (not used) in mm
bool hitThroughCut(const std::shared_ptr< MuonHoughHit > &hit, double weightmdt) const
hit through weight cut?
static constexpr double m_maximum_residu_angle
distance hits are associated with pattern in degrees
static constexpr double m_stepsize_per_angle_rz
bin width for angle in rz
bool hitInHoughPattern(const std::shared_ptr< MuonHoughHit > &hit, const MuonHoughPatternContainer &houghpattern) const
checks if hit is already in one of the found houghpatterns (unused)
virtual void makePatterns(const MuonHoughHitContainer &hitcontainer, MuonHoughPatternContainerShip &houghpatterns) const override
method that builds the patterns
Gaudi::Property< bool > m_weightcut
weight_cut for hits in hough
static constexpr double m_z_cor_constant2
constant 2 for z for hough correction
Gaudi::Property< double > m_weight
value of weight cut
static constexpr double m_stepsize_xy_cosmics
bin width for xy cosmics
std::unique_ptr< TFile > m_file
pointer to the file name for the hough histograms
static void resetAssociation(const MuonHoughHitContainer &event)
reset association flag of hits in m_event
static constexpr double m_stepsize_rz
bin width for rz
virtual std::unique_ptr< MuonPrdPatternCollection > getEtaMuonPatterns(MuonHoughPatternContainerShip &houghpatterns) const override
returns etapattern container in EDM
int overlapHoughPatterns(const MuonHoughPattern &houghpattern1, const MuonHoughPattern &houghpattern2) const
returns number of hits that are in both hough patterns
Gaudi::Property< double > m_thresholdhisto_xyz
threshold histogram in xyz
MuonHoughPatternTool(const std::string &type, const std::string &name, const IInterface *parent)
Default constructor.
Gaudi::Property< int > m_printlevel
output level (range 0-10) (default 0)
std::vector< int > maxLevelHoughPattern(const MuonHoughPatternContainerShip &houghpattern) const
returns the maximum iteration, not in use
static constexpr double m_detectorsize_rz_ip
acceptancy of patterns for ip in rz (eta) in mm
std::unique_ptr< Muon::MuonPrdPattern > houghPatternToEtaPattern(const MuonHoughPattern &houghpattern) const
converts hough pattern to EDM eta patterns
static constexpr double m_detectorsize_yz_full
size of full detector in yz (not used) in mm, used as acceptancy for cosmics
virtual std::unique_ptr< MuonPrdPatternCollection > getPhiMuonPatterns(MuonHoughPatternContainerShip &houghpatterns) const override
returns phipattern container in EDM
void setWeightMdtCutValue(const MuonHoughHitContainer &event, double &weightmdt) const
calculates the mdt weight cut value
double m_detectorsize_xy
acceptancy of patterns in xy (phi) in mm
Gaudi::Property< bool > m_use_csc_in_hough
use csc hits in histogram (false)
virtual StatusCode finalize() override
deletes private members
static constexpr double m_stepsize_xy
max range of 1/sqrt(curvature) for curved transform, corresponds to 0.02 ~ 2,5m ~ 1....
double getThresholdHisto(int id_number) const
returns minimum number for the maximum of a hough transform
static std::unique_ptr< MuonHoughHitContainer > hitsNotInPattern(const MuonHoughHitContainer &event, int id_number)
returns a hitcontainer with hits not yet used in pattern
void calculateWeights(const MuonHoughHitContainer &event, double weightmdt) const
calculates new weights based on rejection factor (1-origweight) and number of hits in event,...
Gaudi::Property< bool > m_use_cosmics
use cosmic settings (false)
void weightRescaling(const MuonHoughHitContainer &event, int id_number, int level) const
rescales hits per iteration to reduce number of patterns when already some have been found
std::unique_ptr< Muon::MuonPrdPattern > houghPatternsToOneEtaPattern(const MuonHoughPattern &houghpattern1, const MuonHoughPattern &houghpattern2) const
converts and combines two hough patterns to one EDM phi pattern
void useIPMuons()
reduces Detector sizes for Hough Histograms to find patterns from muons from the Interaction Point (d...
static constexpr double m_maximum_residu_mm_cosmics
distance hits are associated with pattern in mm for cosmics
Gaudi::Property< int > m_number_of_sectors_xyz
number of sectors (different regions in which patterns can be found in the same iteration) in xyz
Gaudi::Property< bool > m_use_negative_weights
use negative weights (false)
static bool hitsLeft(const MuonHoughHitContainer &event)
returns if there are hits left
static constexpr double m_detectorsize_xy_ip
acceptancy of patterns for ip in xy (phi) in mm
static constexpr bool m_use_rpc_measures_eta
use rpc phi strips in phi-patterns (true)
Gaudi::Property< bool > m_use_histos
output histograms (false)
std::unique_ptr< Muon::MuonPrdPattern > houghPatternToPhiPattern(const MuonHoughPattern &houghpattern) const
converts hough pattern to EDM phi patterns
double m_detectorsize_yz
acceptancy of patterns in yz (not used) in mm
static constexpr double m_detectorsize_xy_full
size of full detector in xy (phi) in mm, used as acceptancy for cosmics
Gaudi::Property< unsigned int > m_thresholdpattern_xyz
minimal size for a phi pattern (1)
Amg::Vector3D getEPos() const
calulates 3d point closest to ip
double getEPhi() const
returns phi of pattern
void updateParametersRPhi(bool cosmics=false)
update parameters in rphi plane based on weighted fit
double getERPhi() const
returns r0/d0 of pattern
Amg::Vector3D getEDir() const
calculates direction at point closest to ip
double getECurvature() const
returns curvature of pattern
double getETheta() const
returns theta of pattern
Class to represent measurements from the Monitored Drift Tubes.
Definition MdtPrepData.h:33
virtual const MuonGM::MdtReadoutElement * detectorElement() const override
Returns the detector element corresponding to this PRD.
virtual const Amg::Vector3D & globalPosition() const =0
Returns the global position of the measurement (calculated on the fly)
Class to store a pattern in the muon system containing PrepRawData pointers.
virtual unsigned int numberOfContainedPrds() const
Number or PrepRawData contained by this Pattern.
virtual const Trk::PrepRawData * prd(unsigned int index) const
returns the PrepRawData objects depending on the integer, return zero if index out of range
Identifier identify() const
return the identifier
Abstract Base Class for tracking surfaces.
const Amg::Vector3D & center() const
Returns the center position of the Surface.
Eigen::Matrix< double, 3, 1 > Vector3D
@ hough_curved_at_a_cylinder
DetectorTechnology
enum to identify the muondetectortechnology
Helper to simultaneously calculate sin and cos of the same angle.
Helper to simultaneously calculate sin and cos of the same angle.
Definition sincos.h:39