ATLAS Offline Software
MuJetGhostDRMatcher.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Infrastructure
7 #include "AthLinks/ElementLink.h"
8 
9 // EDM includes
11 #include "xAODMuon/Muon.h"
12 
13 // Local includes
16 
17 namespace ORUtils
18 {
19 
20  //---------------------------------------------------------------------------
21  // Constructor
22  //---------------------------------------------------------------------------
23  MuJetGhostDRMatcher::MuJetGhostDRMatcher(double dR, bool useRapidity)
24  : asg::AsgMessaging("MuJetGhostDRMatcher"),
25  m_drMatcher (std::make_unique<DeltaRMatcher>(dR, useRapidity))
26  {
27  }
28 
29  //---------------------------------------------------------------------------
30  // Check for a match via ghost association or delta-R
31  //---------------------------------------------------------------------------
33  const xAOD::IParticle& jet) const
34  {
35  // Ghost track list accessor
36  using GhostList_t = std::vector< ElementLink<xAOD::IParticleContainer> >;
37  const static SG::AuxElement::ConstAccessor<GhostList_t> ghostAcc("GhostTrack");
38 
39  // Check the particle types. First particle should be the muon,
40  // and the second particle should be the jet.
41  if(mu.type() != xAOD::Type::Muon) {
42  ATH_MSG_WARNING("First particle arg to objectsMatch is not a muon!");
43  return false;
44  }
45  if(jet.type() != xAOD::Type::Jet) {
46  ATH_MSG_WARNING("Second particle arg to objectsMatch is not a jet!");
47  return false;
48  }
49 
50  // Try the delta-R match first.
51  if(m_drMatcher->objectsMatch(mu, jet)) {
52  ATH_MSG_DEBUG(" Found a dR association");
53  return true;
54  }
55 
56  // Retrieve the muon's ID track, or bail if none available.
57  const auto idTrkFlag = xAOD::Muon::InnerDetectorTrackParticle;
58  auto muTrk = static_cast<const xAOD::Muon&>(mu).trackParticle(idTrkFlag);
59  if(!muTrk) return false;
60 
61  // Search for the muon ID track in the list of ghosts.
62  for(const auto& ghostLink : ghostAcc(jet)) {
63  if(ghostLink.isValid() && (muTrk == *ghostLink)) {
64  ATH_MSG_DEBUG(" Found a ghost association!");
65  return true;
66  }
67  }
68 
69  return false;
70  }
71 
72 } // namespace ORUtils
Muon.h
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
ORUtils::MuJetGhostDRMatcher::objectsMatch
virtual bool objectsMatch(const xAOD::IParticle &mu, const xAOD::IParticle &jet) const override
Check for a match via ghost association or delta-R.
Definition: MuJetGhostDRMatcher.cxx:32
asg
Definition: DataHandleTestTool.h:28
MuJetGhostDRMatcher.h
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:54
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:40
ORUtils
Definition: AltMuJetOverlapTool.h:20
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
IParticleContainer.h
ORUtils::DeltaRMatcher
Encapsulates the delta-R matching strategy.
Definition: DeltaRMatcher.h:27
ORUtils::MuJetGhostDRMatcher::m_drMatcher
std::unique_ptr< IParticleAssociator > m_drMatcher
The delta-R matcher.
Definition: MuJetGhostDRMatcher.h:46
DeltaRMatcher.h
ORUtils::MuJetGhostDRMatcher::MuJetGhostDRMatcher
MuJetGhostDRMatcher(double dR, bool useRapidity=true)
Constructor takes same arguments as the DeltaRMatcher.
Definition: MuJetGhostDRMatcher.cxx:23
Muon
struct TBPatternUnitContext Muon
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition: Event/xAOD/xAODJet/xAODJet/Jet.h:17
AuxElement.h
Base class for elements of a container that can have aux data.