ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
AnalysisCommon
AssociationUtils
Root
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
6
#include "
AthContainers/AuxElement.h
"
7
#include "AthLinks/ElementLink.h"
8
9
// EDM includes
10
#include "
xAODBase/IParticleContainer.h
"
11
#include "
xAODMuon/Muon.h
"
12
13
// Local includes
14
#include "
AssociationUtils/MuJetGhostDRMatcher.h
"
15
#include "
AssociationUtils/DeltaRMatcher.h
"
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
addSubtool (*
m_drMatcher
.get());
28
}
29
30
31
32
StatusCode
MuJetGhostDRMatcher::setObjectTypes
(
xAODType::ObjectType
type1,
33
xAODType::ObjectType
type2)
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
//---------------------------------------------------------------------------
51
bool
MuJetGhostDRMatcher::objectsMatch
(
columnar::Particle1Id
mu,
52
columnar::Particle2Id
jet
,
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.
62
if
constexpr
(
columnar::ColumnarModeDefault::isXAOD
)
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
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
AuxElement.h
Base class for elements of a container that can have aux data.
DeltaRMatcher.h
Muon.h
MuJetGhostDRMatcher.h
ORUtils::DeltaRMatcher
Encapsulates the delta-R matching strategy.
Definition
DeltaRMatcher.h:31
ORUtils::MuJetGhostDRMatcher::MuJetGhostDRMatcher
MuJetGhostDRMatcher(double dR, bool useRapidity=true)
Constructor takes same arguments as the DeltaRMatcher.
Definition
MuJetGhostDRMatcher.cxx:23
ORUtils::MuJetGhostDRMatcher::setObjectTypes
virtual StatusCode setObjectTypes(xAODType::ObjectType type1, xAODType::ObjectType type2) override
Set the object types to be used in the association.
Definition
MuJetGhostDRMatcher.cxx:32
ORUtils::MuJetGhostDRMatcher::m_ghostAcc
columnar::Particle2Accessor< std::vector< columnar::LinkCastColumn< MyTrackDef, xAOD::IParticleContainer > > > m_ghostAcc
Definition
MuJetGhostDRMatcher.h:65
ORUtils::MuJetGhostDRMatcher::objectsMatch
virtual bool objectsMatch(columnar::Particle1Id mu, columnar::Particle2Id jet, bool swapArgs=false) const override
Check for a match via ghost association or delta-R.
Definition
MuJetGhostDRMatcher.cxx:51
ORUtils::MuJetGhostDRMatcher::m_muonTrkAcc
columnar::Particle1Accessor< columnar::ObjectLink< MyTrackDef > > m_muonTrkAcc
Definition
MuJetGhostDRMatcher.h:62
ORUtils::MuJetGhostDRMatcher::m_drMatcher
std::unique_ptr< IParticleAssociator > m_drMatcher
The delta-R matcher.
Definition
MuJetGhostDRMatcher.h:57
asg::AsgMessaging::AsgMessaging
AsgMessaging(const std::string &name)
Constructor with a name.
Definition
AsgMessaging.cxx:17
ORUtils
Definition
AltMuJetOverlapTool.h:30
asg
Definition
DataHandleTestTool.h:28
columnar::Particle1Id
ObjectId< Particle1Def > Particle1Id
Definition
ParticleDef.h:45
columnar::Particle2Id
ObjectId< Particle2Def > Particle2Id
Definition
ParticleDef.h:51
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
std
STL namespace.
xAODType::ObjectType
ObjectType
Type of objects that have a representation in the xAOD EDM.
Definition
ObjectType.h:32
xAODType::Jet
@ Jet
The object is a jet.
Definition
ObjectType.h:40
xAODType::Muon
@ Muon
The object is a muon.
Definition
ObjectType.h:48
columnar::ColumnarModeXAOD::isXAOD
static constexpr bool isXAOD
Whether this is the xAOD mode.
Definition
ColumnarCore/ColumnarCore/ColumnarDef.h:23
IParticleContainer.h
Generated on
for ATLAS Offline Software by
1.17.0