ATLAS Offline Software
Loading...
Searching...
No Matches
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
17namespace 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 addSubtool (*m_drMatcher.get());
28 }
29
30
31
34 {
35 if (type1 != xAOD::Type::Muon) {
36 ATH_MSG_ERROR("First particle arg to setObjectTypes is not a muon!");
37 return StatusCode::FAILURE;
38 }
39 if (type2 != xAOD::Type::Jet) {
40 ATH_MSG_ERROR("Second particle arg to setObjectTypes is not a jet!");
41 return StatusCode::FAILURE;
42 }
43 ATH_CHECK (m_drMatcher->setObjectTypes(type1, type2));
44 addSubtool (*m_drMatcher.get());
45 return StatusCode::SUCCESS;
46 }
47
48 //---------------------------------------------------------------------------
49 // Check for a match via ghost association or delta-R
50 //---------------------------------------------------------------------------
53 bool swapArgs) const
54 {
55 if (swapArgs) {
56 ATH_MSG_WARNING("MuJetGhostDRMatcher does not support swapped args");
57 return false;
58 }
59
60 // Check the particle types. First particle should be the muon,
61 // and the second particle should be the jet.
63 {
64 if(mu.getXAODObject().type() != xAOD::Type::Muon) {
65 ATH_MSG_WARNING("First particle arg to objectsMatch is not a muon!");
66 return false;
67 }
68 if(jet.getXAODObject().type() != xAOD::Type::Jet) {
69 ATH_MSG_WARNING("Second particle arg to objectsMatch is not a jet!");
70 return false;
71 }
72 }
73
74 // Try the delta-R match first.
75 if(m_drMatcher->objectsMatch(mu, jet)) {
76 ATH_MSG_DEBUG(" Found a dR association");
77 return true;
78 }
79
80 // Retrieve the muon's ID track, or bail if none available.
81 auto muTrk = mu(m_muonTrkAcc).opt_value();
82 if(!muTrk) return false;
83
84 // Search for the muon ID track in the list of ghosts.
85 for(const auto ghostLink : m_ghostAcc(jet)) {
86 if(ghostLink.has_value() && muTrk == ghostLink) {
87 ATH_MSG_DEBUG(" Found a ghost association!");
88 return true;
89 }
90 }
91
92 return false;
93 }
94
95} // namespace ORUtils
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Base class for elements of a container that can have aux data.
Encapsulates the delta-R matching strategy.
MuJetGhostDRMatcher(double dR, bool useRapidity=true)
Constructor takes same arguments as the DeltaRMatcher.
virtual StatusCode setObjectTypes(xAODType::ObjectType type1, xAODType::ObjectType type2) override
Set the object types to be used in the association.
columnar::Particle2Accessor< std::vector< columnar::LinkCastColumn< MyTrackDef, xAOD::IParticleContainer > > > m_ghostAcc
virtual bool objectsMatch(columnar::Particle1Id mu, columnar::Particle2Id jet, bool swapArgs=false) const override
Check for a match via ghost association or delta-R.
columnar::Particle1Accessor< columnar::ObjectLink< MyTrackDef > > m_muonTrkAcc
std::unique_ptr< IParticleAssociator > m_drMatcher
The delta-R matcher.
AsgMessaging(const std::string &name)
Constructor with a name.
ObjectId< ContainerId::particle1 > Particle1Id
Definition ParticleDef.h:48
ObjectId< ContainerId::particle2 > Particle2Id
Definition ParticleDef.h:54
STL namespace.
ObjectType
Type of objects that have a representation in the xAOD EDM.
Definition ObjectType.h:32
@ Jet
The object is a jet.
Definition ObjectType.h:40
@ Muon
The object is a muon.
Definition ObjectType.h:48
static constexpr bool isXAOD
Whether this is the xAOD mode.
Definition ColumnarDef.h:20