ATLAS Offline Software
Loading...
Searching...
No Matches
MuonMatchingTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include <utility>
6#include "MuonMatchingTool.h"
8
9namespace {
10
11 const xAOD::TrackParticle* getMSTrack(const xAOD::Muon& mu){
12 using Type = xAOD::Muon::TrackParticleType;
13 constexpr std::array<Type, 3> tpTypes{Type::ExtrapolatedMuonSpectrometerTrackParticle,
14 Type::MSOnlyExtrapolatedMuonSpectrometerTrackParticle,
15 Type::MuonSpectrometerTrackParticle};
16 for (Type type : tpTypes){
17 const xAOD::TrackParticle* trk = mu.trackParticle(type);
18 if (trk) {
19 return trk;
20 }
21 }
22 return nullptr;
23 }
24}
25
26const static double ZERO_LIMIT = 1.e-5;
27
28MuonMatchingTool::MuonMatchingTool(const std::string& type, const std::string& name, const IInterface* parent)
29 : AthAlgTool(type, name, parent)
30{}
31
32
34
35 ATH_CHECK(m_trigDec.retrieve() );
36 ATH_CHECK(m_thresholdTool.retrieve() );
38 ATH_CHECK(m_extrapolator.retrieve() );
39 }
40 ATH_CHECK(m_MuonKey.initialize(!m_MuonKey.empty()));
41 ATH_CHECK(m_MuonRoIKey.initialize());
42 ATH_CHECK(m_L2SAMuonKey.initialize());
44 ATH_CHECK(m_L2CBMuonKey.initialize());
45 ATH_CHECK(m_EFSAMuonKey.initialize());
48 ATH_CHECK(m_EFCBMuonKey.initialize());
49 ATH_CHECK(m_EFSAFSMuonKey.initialize());
52 ATH_CHECK(m_EFCBFSMuonKey.initialize());
53
54 return StatusCode::SUCCESS;
55}
56
58 const xAOD::Muon& mu) const {
59 const xAOD::TrackParticle* track{mu.trackParticle(xAOD::Muon::TrackParticleType::Primary)};
60 std::unique_ptr<Trk::TrackParameters> extPars{extTrackToPivot(ctx, track)};
61 return extPars ? extPars->position() : Amg::Vector3D::Zero();
62}
63
64template<>
65std::tuple<bool, double,double>
67 return std::forward_as_tuple(true, trig->roiEta(), trig->roiPhi());
68}
69
70std::tuple<bool, double,double>
72 return mu->muonType() == xAOD::Muon::MuonType::MuonStandAlone
73 ? std::forward_as_tuple(true, mu->eta(), mu->phi())
74 : std::forward_as_tuple(false, 0., 0.);
75}
76
77std::tuple<bool, double,double>
79 return mu->muonType() == xAOD::Muon::MuonType::Combined
80 ? std::forward_as_tuple(true, mu->eta(), mu->phi())
81 : std::forward_as_tuple(false, 0., 0.);
82}
83
84std::tuple<bool, double,double>
86 const bool isPhaseII){
87 const xAOD::Muon::TrackParticleType type {isPhaseII
88 ? xAOD::Muon::TrackParticleType::Primary
89 : xAOD::Muon::TrackParticleType::ExtrapolatedMuonSpectrometerTrackParticle};
90 const xAOD::TrackParticle* MuonTrack = mu->trackParticle(type);
91 return MuonTrack
92 ? std::forward_as_tuple(true, MuonTrack->eta(), MuonTrack->phi())
93 : std::forward_as_tuple(false, 0., 0.);
94}
95
96std::tuple<bool, double,double>
98 const xAOD::TrackParticle* MuonTrack = mu->trackParticle(xAOD::Muon::TrackParticleType::CombinedTrackParticle);
99 return MuonTrack
100 ? std::forward_as_tuple(true, MuonTrack->eta(), MuonTrack->phi())
101 : std::forward_as_tuple(false, 0., 0.);
102}
103
104const xAOD::Muon*
106 std::string trig,
107 bool &pass) const {
108 ATH_MSG_DEBUG("MuonMonitoring::matchEFSA()");
109 const xAOD::TrackParticle* MuonTrack = getMSTrack(*mu);
110
111 const std::string& containerKey {trig.contains("newFast")
112 ? m_EFSANewFastMuonKey.key()
113 : (trig.contains("mlbkt") ? m_EFSAMlbktMuonKey.key() : m_EFSAMuonKey.key())};
114
115 return MuonTrack
116 ? match<xAOD::Muon>(MuonTrack, std::move(trig), m_EFreqdR, pass, containerKey + ".*", &MuonMatchingTool::trigPosForMatchSATrack)
117 : nullptr;
118}
119
120const xAOD::Muon*
122 std::string trig,
123 bool &pass) const {
124 ATH_MSG_DEBUG("MuonMonitoring::matchEFSA() for truth particle");
125
126 const std::string& containerKey {trig.contains("newFast")
127 ? m_EFSANewFastMuonKey.key()
128 : (trig.contains("mlbkt") ? m_EFSAMlbktMuonKey.key() : m_EFSAMuonKey.key())};
129
130 return mu
131 ? match<xAOD::Muon>(mu, std::move(trig), m_EFreqdR, pass, containerKey + ".*", &MuonMatchingTool::trigPosForMatchSATrack)
132 : nullptr;
133}
134
137 std::string trig) const {
138 ATH_MSG_DEBUG("MuonMonitoring::matchEFSALinkInfo()");
139 bool pass = false;
140 const xAOD::TrackParticle* MuonTrack = getMSTrack(*mu);
141
142 const std::string& containerKey {trig.contains("newFast")
143 ? m_EFSANewFastMuonKey.key()
144 : (trig.contains("mlbkt") ? m_EFSAMlbktMuonKey.key() : m_EFSAMuonKey.key())};
145
146 return MuonTrack
147 ? matchLinkInfo<xAOD::Muon>(MuonTrack, std::move(trig), m_EFreqdR, pass, containerKey + ".*", &MuonMatchingTool::trigPosForMatchSATrack)
149}
150
151const xAOD::Muon*
153 const xAOD::Muon *mu) const {
154 ATH_MSG_DEBUG("MuonMonitoring::matchEFSAReadHandle()");
155 const xAOD::TrackParticle* MuonTrack = getMSTrack(*mu);
156
157 return MuonTrack
159 : nullptr;
160}
161
162const xAOD::Muon*
164 std::string trig,
165 bool &pass) const {
166 ATH_MSG_DEBUG("MuonMonitoring::matchEFCB() for TruthParticle");
167 return mu
168 ? match<xAOD::Muon>(mu, std::move(trig), m_EFreqdR, pass, m_EFCBMuonKey.key() + "*.*", &MuonMatchingTool::trigPosForMatchCBTrack)
169 : nullptr;
170}
171
172const xAOD::Muon*
174 std::string trig,
175 bool &pass) const {
176 ATH_MSG_DEBUG("MuonMonitoring::matchEFCB()");
177 const xAOD::TrackParticle* MuonTrack = mu->trackParticle(xAOD::Muon::TrackParticleType::Primary);
178
179 return MuonTrack
180 ? match<xAOD::Muon>(MuonTrack, std::move(trig), m_EFreqdR, pass, m_EFCBMuonKey.key() + "*.*", &MuonMatchingTool::trigPosForMatchCBTrack)
181 : nullptr;
182}
183
186 std::string trig) const {
187 ATH_MSG_DEBUG("MuonMonitoring::matchEFCBLinkInfo()");
188 bool pass = false;
189 const xAOD::TrackParticle* MuonTrack = mu->trackParticle(xAOD::Muon::TrackParticleType::Primary);
190
191 return MuonTrack
192 ? matchLinkInfo<xAOD::Muon>(MuonTrack, std::move(trig), m_EFreqdR, pass, m_EFCBMuonKey.key() + "*.*", &MuonMatchingTool::trigPosForMatchCBTrack)
194}
195
196const xAOD::Muon*
198 const xAOD::Muon *mu) const {
199 ATH_MSG_DEBUG("MuonMonitoring::matchEFCBReadHandle()");
200 const xAOD::TrackParticle* MuonTrack = mu->trackParticle(xAOD::Muon::TrackParticleType::Primary);
201
202 return MuonTrack
204 : nullptr;
205}
206
207const xAOD::Muon*
209 std::string trig,
210 bool &pass) const {
211 ATH_MSG_DEBUG("MuonMonitoring::matchEFSAFS()");
212 const xAOD::TrackParticle* MuonTrack = getMSTrack(*mu);
213
214 const std::string& containerKey {trig.contains("newFast")
216 : (trig.contains("mlbkt") ? m_EFSAFSMlbktMuonKey.key() : m_EFSAFSMuonKey.key())};
217
218 return MuonTrack
219 ? match<xAOD::Muon>(MuonTrack, std::move(trig), m_EFreqdR, pass, containerKey + ".*", &MuonMatchingTool::trigPosForMatchSATrack)
220 : nullptr;
221}
222
223const xAOD::Muon*
225 std::string trig,
226 bool &pass) const {
227 ATH_MSG_DEBUG("MuonMonitoring::matchEFSAFS() for truth particle");
228
229 const std::string& containerKey {trig.contains("newFast")
231 : (trig.contains("mlbkt") ? m_EFSAFSMlbktMuonKey.key() : m_EFSAFSMuonKey.key())};
232
233 return mu
234 ? match<xAOD::Muon>(mu, std::move(trig), m_EFreqdR, pass, containerKey + ".*", &MuonMatchingTool::trigPosForMatchSATrack)
235 : nullptr;
236}
237
240 std::string trig) const {
241 ATH_MSG_DEBUG("MuonMonitoring::matchEFSAFSLinkInfo()");
242 bool pass = false;
243 const xAOD::TrackParticle* MuonTrack = getMSTrack(*mu);
244
245 const std::string& containerKey {trig.contains("newFast")
247 : (trig.contains("mlbkt") ? m_EFSAFSMlbktMuonKey.key() : m_EFSAFSMuonKey.key())};
248
249 return MuonTrack
250 ? matchLinkInfo<xAOD::Muon>(MuonTrack, std::move(trig), m_EFreqdR, pass, containerKey + ".*", &MuonMatchingTool::trigPosForMatchSATrack)
252}
253
254const xAOD::Muon*
256 const xAOD::Muon *mu) const {
257 ATH_MSG_DEBUG("MuonMonitoring::matchEFSAFSReadHandle()");
258 const xAOD::TrackParticle* MuonTrack = getMSTrack(*mu);
259 return MuonTrack
261 : nullptr;
262}
263
264const xAOD::Muon*
266 std::string trig,
267 bool &pass) const {
268 ATH_MSG_DEBUG("MuonMonitoring::matchEFCBFS() for TruthParticle");
269 return mu
270 ? match<xAOD::Muon>( mu, std::move(trig), m_EFreqdR, pass, m_EFCBFSMuonKey.key() + ".*", &MuonMatchingTool::trigPosForMatchCBTrack)
271 : nullptr;
272}
273
274const xAOD::Muon*
276 std::string trig,
277 bool &pass) const {
278 ATH_MSG_DEBUG("MuonMonitoring::matchEFCBFS()");
279 const xAOD::TrackParticle* MuonTrack = mu->trackParticle(xAOD::Muon::TrackParticleType::Primary);
280
281 return MuonTrack ?
282 match<xAOD::Muon>( MuonTrack, std::move(trig), m_EFreqdR, pass, m_EFCBFSMuonKey.key() + ".*", &MuonMatchingTool::trigPosForMatchCBTrack)
283 : nullptr;
284}
285
288 std::string trig) const {
289 ATH_MSG_DEBUG("MuonMonitoring::matchEFCBFSLinkInfo()");
290 bool pass = false;
291 const xAOD::TrackParticle* MuonTrack = mu->trackParticle(xAOD::Muon::TrackParticleType::Primary);
292
293 return MuonTrack
294 ? matchLinkInfo<xAOD::Muon>(MuonTrack, std::move(trig), m_EFreqdR, pass, m_EFCBFSMuonKey.key() + ".*", &MuonMatchingTool::trigPosForMatchCBTrack)
296}
297
298const xAOD::Muon*
300 const xAOD::Muon *mu) const {
301 ATH_MSG_DEBUG("MuonMonitoring::matchEFCBFSReadHandle()");
302 const xAOD::TrackParticle* MuonTrack = mu->trackParticle(xAOD::Muon::TrackParticleType::Primary);
303
304 return MuonTrack
306 : nullptr;
307}
308
309const xAOD::Muon*
311 std::string trig,
312 bool &pass) const {
313 ATH_MSG_DEBUG("MuonMonitoring::matchEFIso()");
314 const xAOD::TrackParticle* MuonTrack = mu->trackParticle(xAOD::Muon::TrackParticleType::Primary);
315
316 return MuonTrack
317 ? match<xAOD::Muon>(MuonTrack, std::move(trig), m_EFreqdR, pass, "HLT_MuonsIso", &MuonMatchingTool::trigPosForMatchCBTrack)
318 : nullptr;
319}
320
321const xAOD::Muon*
323 std::string trig,
324 bool &pass) const {
325 ATH_MSG_DEBUG("MuonMonitoring::matchEFIso() for truth particle");
326 return mu
327 ? match<xAOD::Muon>( mu, std::move(trig), m_EFreqdR, pass, "HLT_MuonsIso", &MuonMatchingTool::trigPosForMatchCBTrack)
328 : nullptr;
329}
330
332MuonMatchingTool::SearchEFTrack(const EventContext &ctx,
334 const SG::ReadHandleKey<xAOD::TrackParticleContainer>& ReadHandleKey) const {
335 const xAOD::TrackParticle* MatchedTrack = nullptr;
336 const ElementLink<xAOD::MuonContainer> muEL = muLinkInfo.link;
337 float EFEta = (*muEL)->eta();
338 float EFPhi = (*muEL)->phi();
339 float mindR = 999.;
340
341 SG::ReadHandle<xAOD::TrackParticleContainer> trackHandle(ReadHandleKey, ctx);
342 if ( !trackHandle.isValid() ) return MatchedTrack;
343
344 const auto track = m_trigDec->associateToEventView<xAOD::TrackParticleContainer>(trackHandle, muLinkInfo);
345 const xAOD::TrackParticleContainer::const_iterator begin = track.first;
346 const xAOD::TrackParticleContainer::const_iterator end = track.second;
347
348 for (xAOD::TrackParticleContainer::const_iterator it = begin; it != end; ++it) {
349
350 float deta = EFEta - (*it)->eta();
351 float dphi = xAOD::P4Helpers::deltaPhi(EFPhi, (*it)->phi() );
352 float dR = std::sqrt(deta*deta + dphi*dphi);
353
354 if( dR< mindR ){
355 mindR = dR;
356 MatchedTrack = (*it);
357 }
358 }
359 return MatchedTrack;
360}
361
364 std::string trig) const {
365 ATH_MSG_DEBUG("MuonMonitoring::matchEFCBLinkInfo()");
366 bool pass = false;
367 const xAOD::TrackParticle* MuonTrack = mu->trackParticle(xAOD::Muon::TrackParticleType::Primary);
368
369 return MuonTrack
370 ? matchLinkInfo<xAOD::Muon>(MuonTrack, std::move(trig), m_EFreqdR, pass, "HLT_MuonsIso", &MuonMatchingTool::trigPosForMatchCBTrack)
372}
373
375MuonMatchingTool::matchL2SA(const EventContext& ctx,
376 const xAOD::Muon *mu,
377 const std::string& trig,
378 bool &pass) const {
379 ATH_MSG_DEBUG("MuonMonitoring::matchL2SA()");
380 float reqdR = m_L2SAreqdR;
382 reqdR = reqdRL1byPt(mu->pt());
383 const Amg::Vector3D extPos = offlineMuonAtPivot(ctx, *mu);
384 if(extPos.norm()>ZERO_LIMIT){
385 return match<xAOD::L2StandAloneMuon>( &extPos, trig, reqdR, pass);
386 }
387 }
388 return match<xAOD::L2StandAloneMuon>(mu, trig, reqdR, pass, m_L2SAMuonKey.key());
389}
390
391const xAOD::Muon*
392MuonMatchingTool::matchFastRecoSA(const EventContext& ctx,
393 const xAOD::Muon *mu,
394 const std::string& trig,
395 bool &pass) const {
396 ATH_MSG_DEBUG("MuonMonitoring::matchFastRecoSA()");
397 float reqdR = m_L2SAreqdR;
399 reqdR = reqdRL1byPt(mu->pt());
400 const Amg::Vector3D extPos = offlineMuonAtPivot(ctx, *mu);
401 if(extPos.norm()>ZERO_LIMIT){
402 return match<xAOD::Muon>( &extPos, trig, reqdR, pass);
403 }
404 }
405 return match<xAOD::Muon>( mu, trig, reqdR, pass, m_FastRecoSAMuonKey.key());
406}
407
410 const std::string& trig,
411 bool &pass) const {
412 ATH_MSG_DEBUG("MuonMonitoring::matchL2SA() from TruthParticle");
413 return match<xAOD::L2StandAloneMuon>( mu, trig, m_L2SAreqdR, pass, m_L2SAMuonKey.key());
414}
415
416const xAOD::Muon*
418 const std::string& trig,
419 bool &pass) const {
420 ATH_MSG_DEBUG("MuonMonitoring::matchFastRecoSA() from TruthParticle");
421 return match<xAOD::Muon>( mu, trig, m_L2SAreqdR, pass, m_FastRecoSAMuonKey.key());
422}
423
426 std::string trig) const {
427 ATH_MSG_DEBUG("MuonMonitoring::searchL2SALinkInfo()");
428 bool pass = false;
429 return matchLinkInfo<xAOD::L2StandAloneMuon>(mu, std::move(trig), 1000., pass, m_L2SAMuonKey.key());
430}
431
434 std::string trig) const {
435 ATH_MSG_DEBUG("MuonMonitoring::searchFastRecoLinkInfo()");
436 bool pass = false;
437 return matchLinkInfo<xAOD::Muon>(mu, std::move(trig), 1000., pass, m_FastRecoSAMuonKey.key());
438}
439
442 const xAOD::Muon *mu) const {
443 ATH_MSG_DEBUG("MuonMonitoring::matchL2SAReadHandle()");
444 float reqdR = m_L2SAreqdR;
446 reqdR = reqdRL1byPt(mu->pt());
447 const Amg::Vector3D extPos = offlineMuonAtPivot(ctx, *mu);
448 if(extPos.norm()>ZERO_LIMIT){
449 return matchReadHandle<xAOD::L2StandAloneMuon>(&extPos, reqdR, m_L2SAMuonKey, ctx);
450 }
451 }
452 const xAOD::TrackParticle* MuonTrack = getMSTrack(*mu);
453 return MuonTrack
455 : nullptr;
456}
457
458const xAOD::Muon*
460 const xAOD::Muon *mu) const {
461 ATH_MSG_DEBUG("MuonMonitoring::matchFastRecoSAReadHandle()");
462 float reqdR = m_L2SAreqdR;
464 reqdR = reqdRL1byPt(mu->pt());
465 const Amg::Vector3D extPos = offlineMuonAtPivot(ctx, *mu);
466 if(extPos.norm()>ZERO_LIMIT){
467 return matchReadHandle<xAOD::Muon>(&extPos, reqdR, m_FastRecoSAMuonKey, ctx);
468 }
469 }
470 const xAOD::TrackParticle* MuonTrack = getMSTrack(*mu);
471 return MuonTrack
472 ? matchReadHandle<xAOD::Muon>(MuonTrack, reqdR, m_FastRecoSAMuonKey, ctx)
473 : nullptr;
474}
475
478 std::string trig,
479 bool &pass) const {
480 ATH_MSG_DEBUG("MuonMonitoring::matchL2CB()");
481 return match<xAOD::L2CombinedMuon>(mu, std::move(trig), m_L2CBreqdR, pass, m_L2CBMuonKey.key());
482}
483
486 std::string trig,
487 bool &pass) const {
488 ATH_MSG_DEBUG("MuonMonitoring::matchL2CB() from TruthParticle");
489 return match<xAOD::L2CombinedMuon>(mu, std::move(trig), m_L2CBreqdR, pass, m_L2CBMuonKey.key());
490}
491
494 std::string trig) const {
495 ATH_MSG_DEBUG("MuonMonitoring::searchL2CBLinkInfo()");
496 bool pass = false;
497 return matchLinkInfo<xAOD::L2CombinedMuon>(mu, std::move(trig), 1000., pass, m_L2CBMuonKey.key());
498}
499
502 const xAOD::Muon *mu) const {
503 ATH_MSG_DEBUG("MuonMonitoring::matchL2CBReadHandle()");
504 const xAOD::TrackParticle* MuonTrack = mu->trackParticle(xAOD::Muon::TrackParticleType::Primary);
505
506 return MuonTrack
508 : nullptr;
509}
510
511const xAOD::MuonRoI*
512MuonMatchingTool::matchL1(const EventContext& ctx,
513 double refEta,
514 double refPhi,
515 double reqdR,
516 const std::string& trig,
517 bool &pass) const {
518
520 const TrigConf::HLTChain* chainCfg = m_trigDec->ExperimentalAndExpertMethods().getChainConfigurationDetails(trig);
521 const std::string L1toMatch = chainCfg->lower_chain_name().substr(3);
522
524 const xAOD::MuonRoI* closest = nullptr;
525
526 for (const xAOD::MuonRoI* l1muon : *L1rois){
527
528 // get all L1 thresholds from the L1 menu along with whether the L1roi passed each of those or not
529 const std::vector<std::pair<std::shared_ptr<TrigConf::L1Threshold>, bool> > L1thr_list = m_thresholdTool-> getThresholdDecisions(
530 l1muon->roiWord(), ctx);
531
532 // check the L1 threshold we are looking for
533 bool L1thr_isMatch = false;
534 for(const std::pair<std::shared_ptr<TrigConf::L1Threshold>, bool>& L1thr : L1thr_list){
535 if (L1toMatch == L1thr.first->name()){
536 L1thr_isMatch = L1thr.second;
537 break;
538 }
539 }
540 if (!L1thr_isMatch) continue;
541
542 double l1muonEta = l1muon->eta();
543 double l1muonPhi = l1muon->phi();
544
545 double deta = refEta - l1muonEta;
546 double dphi = xAOD::P4Helpers::deltaPhi(refPhi, l1muonPhi);
547 double dR = std::sqrt(deta*deta + dphi*dphi);
548 ATH_MSG_DEBUG("L1 muon candidate eta=" << l1muonEta << " phi=" << l1muonPhi << " dR=" << dR);
549 if( dR<reqdR ){
550 reqdR = dR;
551 pass = true;
552 closest = l1muon;
553 ATH_MSG_DEBUG("*** L1 muon eta=" << l1muonEta << " phi=" << l1muonPhi << " dR=" << dR << " isPassed=true" );
554 }
555 else{
556 ATH_MSG_DEBUG("*** L1 muon eta=" << l1muonEta << " phi=" << l1muonPhi << " dR=" << dR << " isPassed=false" );
557 }
558 }
559 return closest;
560}
561
562const xAOD::MuonRoI*
563MuonMatchingTool::matchL1(const EventContext& ctx,
564 const xAOD::Muon *mu,
565 const std::string& trig,
566 bool &pass) const {
567 double refEta = mu->eta();
568 double refPhi = mu->phi();
569 double reqdR = 0.25;
570
572 reqdR = reqdRL1byPt(mu->pt());
573 const Amg::Vector3D extPos = offlineMuonAtPivot(ctx, *mu);
574 if(extPos.norm()>ZERO_LIMIT){
575 refEta = extPos.eta();
576 refPhi = extPos.phi();
577 }
578 }
579 return matchL1(ctx, refEta, refPhi, reqdR, trig, pass);
580}
581
582const xAOD::MuonRoI*
583MuonMatchingTool::matchL1(const EventContext& ctx,
584 const xAOD::TruthParticle *mu,
585 const std::string& trig,
586 bool &pass) const {
587 double refEta = mu->eta();
588 double refPhi = mu->phi();
589 double reqdR = 0.25;
590 return matchL1(ctx, refEta, refPhi, reqdR, trig, pass);
591}
592
593const xAOD::Muon*
594MuonMatchingTool::matchL2SAtoOff(const EventContext& ctx,
595 const xAOD::L2StandAloneMuon* samu) const {
596 return matchOff(ctx, samu, m_L2SAreqdR,
597 [this](const xAOD::Muon* mu) {return MuonMatchingTool::PosForMatchSATrack(mu, m_isPhII);});
598}
599
600const xAOD::Muon*
602 const xAOD::Muon* samu) const {
603 return matchOff(ctx, samu, m_L2SAreqdR,
604 [this](const xAOD::Muon* mu) {return MuonMatchingTool::PosForMatchSATrack(mu, m_isPhII);});
605}
606
607const xAOD::Muon*
608MuonMatchingTool::matchL2CBtoOff(const EventContext& ctx,
609 const xAOD::L2CombinedMuon* cbmu) const {
611}
612
613
614bool
616 const xAOD::Muon* mu) const {
617 return xAOD::P4Helpers::deltaR(mu, samu, false) < m_L2SAreqdR;
618}
619
620bool
622 const xAOD::Muon* mu) const {
623 return xAOD::P4Helpers::deltaR(mu, samu, false) < m_L2SAreqdR;
624}
625
626
627bool
629 const xAOD::Muon* mu) const {
630 return xAOD::P4Helpers::deltaR(cbmu, mu, false) < m_L2CBreqdR;
631}
632
633bool
635 const xAOD::Muon* mu) const {
636 return xAOD::P4Helpers::deltaR(cbiomu, mu, false) < m_L2InsideOutreqdR;
637}
638
639std::unique_ptr<Trk::TrackParameters>
640MuonMatchingTool::extTrackToPivot(const EventContext& ctx,
641 const xAOD::TrackParticle* track) const {
642 if (!track) return nullptr;
643
644 double trkEta = track->eta();
645 using Return_t = std::unique_ptr<Trk::TrackParameters>;
646
647 // BARREL REGION
648 if (std::abs(trkEta) < 1.05) {
649 Return_t extRPC = extTrackToRPC(ctx, *track);
650 if (!extRPC) {
651 return extTrackToTGC(ctx, *track);
652 }
653 //If the extrapolated eta is in the endcap region, return the TGC extrapolation
654 if (std::abs(extRPC->position().eta()) >= 1.05){
655 if (Return_t extTGC = extTrackToTGC(ctx, *track)) {
656 return extTGC;
657 }
658 }
659 //If the extrapolated eta is still in the barrel region, or the TGC extrapolation fails, return the RPC extrapolation
660 return extRPC;
661 }
662
663 // ENDCAP REGION (same logic as above, but reversed)
664 Return_t extTGC = extTrackToTGC(ctx, *track);
665 if (!extTGC) {
666 return extTrackToRPC(ctx, *track);
667 }
668 if (std::abs(extTGC->position().eta()) < 1.05) {
669 if (Return_t extRPC = extTrackToRPC(ctx, *track)) {
670 return extRPC;
671 }
672 }
673 return extTGC;
674}
675
676std::unique_ptr<Trk::TrackParameters>
677MuonMatchingTool::extTrackToTGC(const EventContext& ctx,
678 const xAOD::TrackParticle& trk) const {
679 double TGC_Z = ( trk.eta()>0 )? 15153.0:-15153.0;
680 Amg::Transform3D matrix = Amg::Transform3D(Amg::Vector3D( 0.,0.,TGC_Z));
681 Trk::DiscSurface disc{matrix, 0., 15000.};
682 const bool boundaryCheck = true;
683
684 return m_extrapolator->extrapolate(ctx,
685 trk.perigeeParameters(),
686 disc,
688 boundaryCheck,
689 Trk::muon);
690}
691
692std::unique_ptr<Trk::TrackParameters>
693MuonMatchingTool::extTrackToRPC(const EventContext& ctx,
694 const xAOD::TrackParticle& trk) const {
695 Trk::CylinderSurface barrel {7478., 15000.};
696 const bool boundaryCheck = true;
697
698 return m_extrapolator->extrapolate(ctx,
699 trk.perigeeParameters(),
700 barrel,
702 boundaryCheck,
703 Trk::muon);
704}
705
706double
708 double dR = 0.08;
709 if( mupt < 10000. ) {
710 dR = -0.00001*mupt + 0.18;
711 }
712 return dR;
713}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
static const double ZERO_LIMIT
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
SG::ReadHandleKey< xAOD::MuonContainer > m_EFSAFSMuonKey
SG::ReadHandleKey< xAOD::MuonContainer > m_EFSAMuonKey
SG::ReadHandleKey< xAOD::MuonRoIContainer > m_MuonRoIKey
SG::ReadHandleKey< xAOD::MuonContainer > m_EFSAMlbktMuonKey
const xAOD::Muon * matchFastRecoSAtoOff(const EventContext &ctx, const xAOD::Muon *samu) const
Function that searches for an offline muon matched to EF Fast Reco SA muon.
ToolHandle< LVL1::ITrigThresholdDecisionTool > m_thresholdTool
bool isMatchedFastRecoSA(const xAOD::Muon *, const xAOD::Muon *) const
const T * match(const OFFL *offl, std::string trigger, float reqdR, bool &pass, const std::string &containerSGKey="", std::tuple< bool, double, double >(*trigPosForMatchFunc)(const T *)=&MuonMatchingTool::trigPosForMatch< T >) const
Function that searches for an online muon candidate of type T and judges if it is matched to a given ...
SG::ReadHandleKey< xAOD::L2CombinedMuonContainer > m_L2CBMuonKey
SG::ReadHandleKey< xAOD::MuonContainer > m_EFCBMuonKey
const xAOD::Muon * matchEFCBFSReadHandle(const EventContext &ctx, const xAOD::Muon *mu) const
Function that searches for an EF combined muon (EFCBFS) candidate by ReadHandle and judges if it is m...
const float m_L2SAreqdR
const xAOD::Muon * matchOff(const EventContext &ctx, const T *trig, float reqdR, std::function< std::tuple< bool, double, double >(const xAOD::Muon *)> offlinePosForMatchFunc, std::function< std::tuple< bool, double, double >(const T *)> trigPosForMatchFunc=&MuonMatchingTool::trigPosForMatch< T >) const
Function that searches for an offline muon candidate matched to online muon of type T.
static std::tuple< bool, double, double > trigPosForMatch(const T *trig)
const xAOD::Muon * matchEFSAFSReadHandle(const EventContext &ctx, const xAOD::Muon *mu) const
Function that searches for an EF standalone muon (EFSAFS) candidate by ReadHandle and judges if it is...
const float m_L2InsideOutreqdR
MuonMatchingTool(const std::string &type, const std::string &name, const IInterface *parent)
std::unique_ptr< Trk::TrackParameters > extTrackToRPC(const EventContext &ctx, const xAOD::TrackParticle &track) const
const T * matchReadHandle(const OFFL *offl, float reqdR, const SG::ReadHandleKey< DataVector< T > > &ReadHandleKey, const EventContext &ctx, std::tuple< bool, double, double >(*trigPosForMatchFunc)(const T *)=&MuonMatchingTool::trigPosForMatch< T >) const
Function that searches for an online muon candidate of type T by ReadHandle and judges if it is match...
const xAOD::L2StandAloneMuon * matchL2SA(const EventContext &ctx, const xAOD::Muon *mu, const std::string &trigger, bool &pass) const
Function that searches for an L2 standalone muon (L2MuonSA) candidate and judges if it is matched to ...
const xAOD::Muon * matchEFSA(const xAOD::Muon *mu, std::string trigger, bool &pass) const
Function that searches for an EF standalone muon (EFSA) candidate and judges if it is matched to a gi...
SG::ReadHandleKey< xAOD::MuonContainer > m_EFCBFSMuonKey
const xAOD::Muon * matchFastRecoSA(const EventContext &ctx, const xAOD::Muon *mu, const std::string &trigger, bool &pass) const
Function that searches for a EF fast reco muon (PhaseII) candidate and judges if it is matched to a g...
static std::tuple< bool, double, double > trigPosForMatchSATrack(const xAOD::Muon *mu)
const TrigCompositeUtils::LinkInfo< xAOD::L2StandAloneMuonContainer > searchL2SALinkInfo(const xAOD::Muon *mu, std::string trigger) const
Function that searches for the L2 standalone muon (L2MuonSA) candidate closest to a given offline muo...
const xAOD::TrackParticle * SearchEFTrack(const EventContext &ctx, const TrigCompositeUtils::LinkInfo< xAOD::MuonContainer > &muLinkInfo, const SG::ReadHandleKey< xAOD::TrackParticleContainer > &ReadHandleKey) const
Function that searches for an EF muon track (e.g.
static std::tuple< bool, double, double > PosForMatchSATrack(const xAOD::Muon *mu, const bool isPhaseII=false)
const xAOD::Muon * matchL2SAtoOff(const EventContext &ctx, const xAOD::L2StandAloneMuon *samu) const
Function that searches for an offline muon matched to L2SA muon.
const float m_L2CBreqdR
std::unique_ptr< Trk::TrackParameters > extTrackToPivot(const EventContext &ctx, const xAOD::TrackParticle *track) const
Function to extrapolate a Inner Detector track to the pivot plane i.e.
const xAOD::Muon * matchEFSAFS(const xAOD::Muon *mu, std::string trigger, bool &pass) const
Function that searches for an EF FS standalone muon (EFSAFS) candidate and judges if it is matched to...
BooleanProperty m_isPhII
const xAOD::Muon * matchFastRecoSAReadHandle(const EventContext &ctx, const xAOD::Muon *mu) const
Function that searches for a EF fast reco standalone muon (PhaseII) candidate by ReadHandle and judge...
const xAOD::L2StandAloneMuon * matchL2SAReadHandle(const EventContext &ctx, const xAOD::Muon *mu) const
Function that searches for an L2 standalone muon (L2MuonSA) candidate by ReadHandle and judges if it ...
const xAOD::L2CombinedMuon * matchL2CBReadHandle(const EventContext &ctx, const xAOD::Muon *mu) const
Function that searches for an L2 combined muon (L2muComb) candidate by ReadHandle and judges if it is...
const xAOD::L2CombinedMuon * matchL2CB(const xAOD::Muon *mu, std::string trigger, bool &pass) const
Function that searches for an L2 combined muon (L2muComb) candidate and judges if it is matched to a ...
PublicToolHandle< Trig::TrigDecisionTool > m_trigDec
const TrigCompositeUtils::LinkInfo< xAOD::MuonContainer > matchEFCBLinkInfo(const xAOD::Muon *mu, std::string trig) const
Function that searches for an EF combined muon (EFCB) candidate and judges if it is matched to a give...
const TrigCompositeUtils::LinkInfo< DataVector< T > > matchLinkInfo(const OFFL *offl, std::string trigger, float reqdR, bool &pass, const std::string &containerSGKey="", std::tuple< bool, double, double >(*trigPosForMatchFunc)(const T *)=&MuonMatchingTool::trigPosForMatch< T >) const
Function that searches for an online muon candidate of type T closest to a given offline muon.
const xAOD::Muon * matchL2CBtoOff(const EventContext &ctx, const xAOD::L2CombinedMuon *cbmu) const
Function that searches for an offline muon matched to L2CB muon.
const xAOD::Muon * matchEFIso(const xAOD::Muon *mu, std::string trigger, bool &pass) const
Function that searches for an EF isolation muon (EFIso) candidate and judges if it is matched to a gi...
SG::ReadHandleKey< xAOD::MuonContainer > m_MuonKey
SG::ReadHandleKey< xAOD::MuonContainer > m_EFSAFSMlbktMuonKey
const TrigCompositeUtils::LinkInfo< xAOD::MuonContainer > matchEFCBFSLinkInfo(const xAOD::Muon *mu, std::string trig) const
Function that searches for an EF combined muon (EFCBFS) candidate and judges if it is matched to a gi...
SG::ReadHandleKey< xAOD::MuonContainer > m_EFSANewFastMuonKey
const TrigCompositeUtils::LinkInfo< xAOD::L2CombinedMuonContainer > searchL2CBLinkInfo(const xAOD::Muon *mu, std::string trigger) const
Function that searches for the L2 combined muon (L2muComb) candidate closest to a given offline muon.
static std::tuple< bool, double, double > trigPosForMatchCBTrack(const xAOD::Muon *mu)
const TrigCompositeUtils::LinkInfo< xAOD::MuonContainer > matchEFSAFSLinkInfo(const xAOD::Muon *mu, std::string trig) const
Function that searches for an EF standalone muon (EFSAFS) candidate and judges if it is matched to a ...
Amg::Vector3D offlineMuonAtPivot(const EventContext &ctx, const xAOD::Muon &mu) const
static std::tuple< bool, double, double > PosForMatchCBTrack(const xAOD::Muon *mu)
SG::ReadHandleKey< xAOD::L2StandAloneMuonContainer > m_L2SAMuonKey
SG::ReadHandleKey< xAOD::MuonContainer > m_FastRecoSAMuonKey
SG::ReadHandleKey< xAOD::MuonContainer > m_EFSAFSNewFastMuonKey
bool isMatchedL2SA(const xAOD::L2StandAloneMuon *, const xAOD::Muon *) const
const xAOD::Muon * matchEFCB(const xAOD::Muon *mu, std::string trigger, bool &pass) const
Function that searches for an EF combined muon (EFCB) candidate and judges if it is matched to a give...
const xAOD::MuonRoI * matchL1(const EventContext &ctx, const xAOD::Muon *mu, const std::string &trigger, bool &pass) const
Function that searches for a Level 1 muon candidate and judges if it is matched to a given offline mu...
PublicToolHandle< Trk::IExtrapolator > m_extrapolator
const TrigCompositeUtils::LinkInfo< xAOD::MuonContainer > searchFastRecoSALinkInfo(const xAOD::Muon *mu, std::string trigger) const
Function that searches for the EF fast reco standalone candidate closest to a given offline muon.
bool isMatchedL2InsideOut(const xAOD::L2CombinedMuon *, const xAOD::Muon *) const
const xAOD::Muon * matchEFCBReadHandle(const EventContext &ctx, const xAOD::Muon *mu) const
Function that searches for an EF combined muon (EFCB) candidate by ReadHandle and judges if it is mat...
virtual StatusCode initialize() override
std::unique_ptr< Trk::TrackParameters > extTrackToTGC(const EventContext &ctx, const xAOD::TrackParticle &track) const
static double reqdRL1byPt(double mupt)
Function compute dR used for matching offline muons and level 1 RoIs at the pivot plane.
const xAOD::Muon * matchEFCBFS(const xAOD::Muon *mu, std::string trigger, bool &pass) const
Function that searches for an EF combined muon (EFCBFS) candidate and judges if it is matched to a gi...
Gaudi::Property< bool > m_use_extrapolator
bool isMatchedL2CB(const xAOD::L2CombinedMuon *, const xAOD::Muon *) const
const TrigCompositeUtils::LinkInfo< xAOD::MuonContainer > matchEFIsoLinkInfo(const xAOD::Muon *mu, std::string trig) const
Function that searches for an EF isolation muon (EFIso) candidate and judges if it is matched to a gi...
const xAOD::Muon * matchEFSAReadHandle(const EventContext &ctx, const xAOD::Muon *mu) const
Function that searches for an EF standalone muon (EFSA) candidate by ReadHandle and judges if it is m...
const TrigCompositeUtils::LinkInfo< xAOD::MuonContainer > matchEFSALinkInfo(const xAOD::Muon *mu, std::string trig) const
Function that searches for an EF standalone muon (EFSA) candidate and judges if it is matched to a gi...
Property holding a SG store/key/clid from which a ReadHandle is made.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
HLT chain configuration information.
const std::string & lower_chain_name() const
Class for a CylinderSurface in the ATLAS detector.
Class for a DiscSurface in the ATLAS detector.
Definition DiscSurface.h:54
float roiEta() const
Get and set RoI eta.
float roiPhi() const
Get and set RoI phi.
const Trk::Perigee & perigeeParameters() const
Returns the Trk::MeasuredPerigee track parameters.
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .).
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
@ anyDirection
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
double deltaR(double rapidity1, double phi1, double rapidity2, double phi2)
from bare bare rapidity,phi
L2CombinedMuon_v1 L2CombinedMuon
Define the latest version of the muon CB class.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TruthParticle_v1 TruthParticle
Typedef to implementation.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
Muon_v1 Muon
Reference the current persistent version:
L2StandAloneMuon_v2 L2StandAloneMuon
Define the latest version of the muon SA class.
MuonRoI_v1 MuonRoI
Definition MuonRoI.h:15
Helper to keep a Decision object, ElementLink and ActiveState (with respect to some requested ChainGr...
Definition LinkInfo.h:22
ElementLink< T > link
Link to the feature.
Definition LinkInfo.h:55