ATLAS Offline Software
Loading...
Searching...
No Matches
MuonMatchingTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef TRIGMUONMONITORING_MUONMATCHINGTOOL_H
6#define TRIGMUONMONITORING_MUONMATCHINGTOOL_H
7
18#include "GaudiKernel/SystemOfUnits.h"
19#include <string>
20#include <memory>
21#include <tuple>
23
24
30
31 public:
32 MuonMatchingTool(const std::string& type, const std::string &name, const IInterface* parent);
33
34 virtual StatusCode initialize() override;
35
43 const xAOD::MuonRoI* matchL1(const EventContext& ctx, const xAOD::Muon *mu, const std::string& trigger, bool &pass) const;
44
52 const xAOD::MuonRoI* matchL1(const EventContext& ctx, const xAOD::TruthParticle *mu, const std::string& trigger, bool &pass) const;
53
63 const xAOD::MuonRoI* matchL1(const EventContext& ctx, double eta, double phi, double dR, const std::string& trigger, bool &pass) const;
64
73 const xAOD::L2StandAloneMuon* matchL2SA(const EventContext& ctx, const xAOD::Muon *mu, const std::string& trigger, bool &pass) const;
74
83 const xAOD::Muon* matchFastRecoSA(const EventContext& ctx, const xAOD::Muon *mu, const std::string& trigger, bool &pass) const;
84
93 const xAOD::L2StandAloneMuon* matchL2SA(const xAOD::TruthParticle *mu, const std::string& trigger, bool &pass) const;
94
103 const xAOD::Muon* matchFastRecoSA(const xAOD::TruthParticle *mu, const std::string& trigger, bool &pass) const;
104
115
126
132 const xAOD::L2StandAloneMuon* matchL2SAReadHandle(const EventContext& ctx, const xAOD::Muon *mu) const;
133
139 const xAOD::Muon* matchFastRecoSAReadHandle(const EventContext& ctx, const xAOD::Muon *mu) const;
140
149 const xAOD::L2CombinedMuon* matchL2CB(const xAOD::Muon *mu, std::string trigger, bool &pass) const;
150
151 const xAOD::L2CombinedMuon* matchL2CB(const xAOD::TruthParticle *mu, std::string trigger, bool &pass) const;
152
163
169 const xAOD::L2CombinedMuon* matchL2CBReadHandle(const EventContext& ctx, const xAOD::Muon *mu) const;
170
179 const xAOD::Muon* matchEFSA(const xAOD::Muon *mu, std::string trigger, bool &pass) const;
180
189 const xAOD::Muon* matchEFSA(const xAOD::TruthParticle *mu, std::string trigger, bool &pass) const;
190
199
205 const xAOD::Muon* matchEFSAReadHandle(const EventContext& ctx, const xAOD::Muon *mu) const;
206
215 const xAOD::Muon* matchEFCB(const xAOD::Muon *mu, std::string trigger, bool &pass) const;
216
225 const xAOD::Muon* matchEFCB(const xAOD::TruthParticle *mu, std::string trig, bool &pass) const;
226
235
241 const xAOD::Muon* matchEFCBReadHandle(const EventContext& ctx, const xAOD::Muon *mu) const;
242
251 const xAOD::Muon* matchEFSAFS(const xAOD::Muon *mu, std::string trigger, bool &pass) const;
260 const xAOD::Muon* matchEFSAFS(const xAOD::TruthParticle *mu, std::string trigger, bool &pass) const;
261
270
276 const xAOD::Muon* matchEFSAFSReadHandle(const EventContext& ctx, const xAOD::Muon *mu) const;
277
286 const xAOD::Muon* matchEFCBFS(const xAOD::Muon *mu, std::string trigger, bool &pass) const;
287
296 const xAOD::Muon* matchEFCBFS(const xAOD::TruthParticle *mu, std::string trig, bool &pass) const;
297
306
312 const xAOD::Muon* matchEFCBFSReadHandle(const EventContext& ctx, const xAOD::Muon *mu) const;
313
322 const xAOD::Muon* matchEFIso(const xAOD::Muon *mu, std::string trigger, bool &pass) const;
323
332 const xAOD::Muon* matchEFIso(const xAOD::TruthParticle *mu, std::string trigger, bool &pass) const;
333
342
343
351 const xAOD::TrackParticle* SearchEFTrack(const EventContext &ctx, const TrigCompositeUtils::LinkInfo<xAOD::MuonContainer>& muLinkInfo, const SG::ReadHandleKey<xAOD::TrackParticleContainer>& ReadHandleKey) const;
352
353
360 const xAOD::Muon* matchL2SAtoOff(const EventContext& ctx, const xAOD::L2StandAloneMuon* samu) const;
361
368 const xAOD::Muon* matchFastRecoSAtoOff(const EventContext& ctx, const xAOD::Muon* samu) const;
369
376 const xAOD::Muon* matchL2CBtoOff(const EventContext& ctx, const xAOD::L2CombinedMuon* cbmu) const;
377
378
379 bool isMatchedL2SA(const xAOD::L2StandAloneMuon*, const xAOD::Muon*) const;
380 bool isMatchedL2CB(const xAOD::L2CombinedMuon*, const xAOD::Muon*) const;
381 bool isMatchedL2InsideOut(const xAOD::L2CombinedMuon*, const xAOD::Muon*) const;
382
392 const Trk::TrackParameters* extTrackToPivot(const EventContext& ctx, const xAOD::TrackParticle *track) const;
393
400 static double reqdRL1byPt(double mupt);
401
402
403 static std::tuple<bool,double,double> trigPosForMatchSATrack(const xAOD::Muon *mu);
404 static std::tuple<bool,double,double> trigPosForMatchCBTrack(const xAOD::Muon *mu);
405 static std::tuple<bool,double,double> PosForMatchSATrack(const xAOD::Muon *mu);
406 static std::tuple<bool,double,double> PosForMatchCBTrack(const xAOD::Muon *mu);
407
408
409 private:
410
412 int L1ItemStringToInt(const std::string& l1item, int roiSource) const {
413 if( "L1_MU3V"==l1item) return roiSource==0 ? L1Items::L1B_MU3V : L1Items::L1E_MU3V;
414 if( "L1_MU5VF"==l1item) return roiSource==0 ? L1Items::L1B_MU5VF : L1Items::L1E_MU5VF;
415 if( "L1_MU8F"==l1item) return roiSource==0 ? L1Items::L1B_MU8F : L1Items::L1E_MU8F;
416 if( "L1_MU14FCH"==l1item) return roiSource==0 ? L1Items::L1B_MU14FCH : L1Items::L1E_MU14FCH;
417 if( "L1_MU14FCHR"==l1item) return roiSource==0 ? L1Items::L1B_MU14FCHR : L1Items::L1E_MU14FCHR;
418 return L1Items::ERROR;
419 }
420
421 const float m_L2SAreqdR = 0.25;
422 const float m_L2CBreqdR = 0.03;
423 const float m_L2InsideOutreqdR = 0.01;
424 const float m_EFreqdR = 0.03;
425
426 // private methods
438 template<class T, class OFFL> const T* matchReadHandle(const OFFL* offl, float reqdR,
439 SG::ReadHandleKey<DataVector<T> > ReadHandleKey, const EventContext& ctx,
440 std::tuple<bool,double,double> (*trigPosForMatchFunc)(const T*) = &MuonMatchingTool::trigPosForMatch<T>) const;
441
442
453 template<class T, class OFFL>
454 const TrigCompositeUtils::LinkInfo<DataVector<T> > matchLinkInfo(const OFFL *offl, std::string trigger, float reqdR, bool &pass,
455 const std::string& containerSGKey = "",
456 std::tuple<bool,double,double> (*trigPosForMatchFunc)(const T*) = &MuonMatchingTool::trigPosForMatch<T>) const;
457
470 template<class T, class OFFL> const T* match(const OFFL *offl, std::string trigger, float reqdR, bool &pass,
471 const std::string& containerSGKey = "",
472 std::tuple<bool,double,double> (*trigPosForMatchFunc)(const T*) = &MuonMatchingTool::trigPosForMatch<T>) const;
473
485 template<class T> const xAOD::Muon* matchOff(const EventContext& ctx, const T* trig, float reqdR,
486 std::tuple<bool,double,double> (*offlinePosForMatchFunc)(const xAOD::Muon*),
487 std::tuple<bool,double,double> (*trigPosForMatchFunc)(const T*) = &MuonMatchingTool::trigPosForMatch<T>) const;
488
489
490 const Amg::Vector3D offlineMuonAtPivot(const EventContext& ctx, const xAOD::Muon *mu) const;
491 static double FermiFunction(double x, double x0, double w) ;
492 const Trk::TrackParameters* extTrackToTGC(const EventContext& ctx, const xAOD::TrackParticle *track) const;
493 const Trk::TrackParameters* extTrackToRPC(const EventContext& ctx, const xAOD::TrackParticle *track) const;
494
495 // static methods
496 // Template methods that perform different matching schemes for T=xAOD::L2StandAloneMuon, xAOD::L2CombinedMuon and xAOD::Muon (EF).
497 template<class T> static inline std::tuple<bool,double,double> trigPosForMatch(const T *trig);
498
499 SG::ReadHandleKey<xAOD::MuonRoIContainer> m_MuonRoIContainerKey {this, "MuonRoIContainerName", "LVL1MuonRoIs", "Level 1 muon container"};
500 SG::ReadHandleKey<xAOD::MuonContainer> m_MuonContainerKey {this, "MuonContainerName", "Muons", "Offline muon container"};
501 SG::ReadHandleKey<xAOD::L2StandAloneMuonContainer> m_L2MuonSAContainerKey {this, "L2StandAloneMuonContainerName", "HLT_MuonL2SAInfo", "L2MuonSA container"};
502 SG::ReadHandleKey<xAOD::MuonContainer> m_EFFastRecoContainerKey {this, "EFFastRecoSAContainerName", "HLT_FastMuonsInfo", "EFFastRecoSA container (Phase2)"};
503 SG::ReadHandleKey<xAOD::L2CombinedMuonContainer> m_L2muCombContainerKey {this, "L2CombinedMuonContainerName", "HLT_MuonL2CBInfo", "L2muComb container"};
504 SG::ReadHandleKey<xAOD::MuonContainer> m_EFSAMuonContainerKey {this, "EFSAMuonContainerName", "HLT_Muons_RoI", "EFSAMuon container"};
505 SG::ReadHandleKey<xAOD::MuonContainer> m_EFCBMuonContainerKey {this, "EFCBMuonContainerName", "HLT_MuonsCB_RoI", "EFCBMuon container"};
506 SG::ReadHandleKey<xAOD::MuonContainer> m_EFSAFSMuonContainerKey {this, "EFSAFSMuonContainerName", "HLT_Muons_FS", "EFSAFSMuon container"};
507 SG::ReadHandleKey<xAOD::MuonContainer> m_EFCBFSMuonContainerKey {this, "EFCBFSMuonContainerName", "HLT_MuonsCB_FS", "EFCBFSMuon container"};
508 SG::ReadHandleKey<xAOD::TrackParticleContainer> m_MStrackContainerKey {this, "ExtrapolatedMStrackConntainner", "HLT_MSExtrapolatedMuons_RoITrackParticles", "ExtrapolatedMuons track container"};
509 SG::ReadHandleKey<xAOD::TrackParticleContainer> m_CBtrackContainerKey {this, "CBtrackContainerName", "HLT_CBCombinedMuon_RoITrackParticles", "CombinedMuon track container"};
510
511 // properties
512 Gaudi::Property<bool> m_use_extrapolator {this, "UseExtrapolator", false, "Flag to enable the extrapolator for matching offline and trigger muons"};
513
514 // tools
515 ToolHandle<LVL1::ITrigThresholdDecisionTool> m_thresholdTool{
516 this, "TrigThresholdDecisionTool", "LVL1::TrigThresholdDecisionTool/LVL1__TrigThresholdDecisionTool",
517 "Tool to get pass/fail of each trigger threshold"};
518 PublicToolHandle<Trig::TrigDecisionTool> m_trigDec {this, "TrigDecisionTool", "Trig::TrigDecisionTool/TrigDecisionTool", "TrigDecisionTool"};
519 PublicToolHandle<Trk::IExtrapolator> m_extrapolator {"Trk::Extrapolator/AtlasExtrapolator"};
520
521 //The extrapolator is currently not available. Once it gets available, initialize it with the following, which attempts to retrieve:
522 //{this, "Extrapolator", "Trk::Extrapolator/AtlasExtrapolator", "Track extrapolator"};
523};
524
525#include "MuonMatchingTool.icc"
526
527#endif //TRIGMUONMONITORING_MUONMATCHINGTOOL_H
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define x
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Derived DataVector<T>.
Definition DataVector.h:795
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
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 ...
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...
static double FermiFunction(double x, double x0, double w)
const float m_L2SAreqdR
static std::tuple< bool, double, double > trigPosForMatch(const T *trig)
int L1ItemStringToInt(const std::string &l1item, int roiSource) const
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)
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...
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.
SG::ReadHandleKey< xAOD::MuonRoIContainer > m_MuonRoIContainerKey
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
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...
static std::tuple< bool, double, double > PosForMatchSATrack(const xAOD::Muon *mu)
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.
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_MStrackContainerKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_CBtrackContainerKey
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...
const T * matchReadHandle(const OFFL *offl, float reqdR, 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...
SG::ReadHandleKey< xAOD::MuonContainer > m_EFFastRecoContainerKey
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_EFCBMuonContainerKey
const xAOD::Muon * matchOff(const EventContext &ctx, const T *trig, float reqdR, std::tuple< bool, double, double >(*offlinePosForMatchFunc)(const xAOD::Muon *), std::tuple< bool, double, double >(*trigPosForMatchFunc)(const T *)=&MuonMatchingTool::trigPosForMatch< T >) const
Function that searches for an offline muon candidate matched to online muon of type T.
SG::ReadHandleKey< xAOD::MuonContainer > m_EFCBFSMuonContainerKey
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 ...
static std::tuple< bool, double, double > PosForMatchCBTrack(const xAOD::Muon *mu)
const Trk::TrackParameters * extTrackToTGC(const EventContext &ctx, const xAOD::TrackParticle *track) const
SG::ReadHandleKey< xAOD::MuonContainer > m_EFSAFSMuonContainerKey
const 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 Trk::TrackParameters * extTrackToRPC(const EventContext &ctx, const xAOD::TrackParticle *track) const
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...
SG::ReadHandleKey< xAOD::L2StandAloneMuonContainer > m_L2MuonSAContainerKey
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...
SG::ReadHandleKey< xAOD::L2CombinedMuonContainer > m_L2muCombContainerKey
virtual StatusCode initialize() override
SG::ReadHandleKey< xAOD::MuonContainer > m_MuonContainerKey
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 Amg::Vector3D offlineMuonAtPivot(const EventContext &ctx, const xAOD::Muon *mu) const
SG::ReadHandleKey< xAOD::MuonContainer > m_EFSAMuonContainerKey
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.
Eigen::Matrix< double, 3, 1 > Vector3D
ParametersBase< TrackParametersDim, Charged > TrackParameters
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.
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