ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
AnalysisCommon
AssociationUtils
Root
EleMuSharedTrkOverlapTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// System includes
6
#include <typeinfo>
7
8
// Framework includes
9
#include "
AthContainers/ConstDataVector.h
"
10
11
// EDM includes
12
#include "
xAODEgamma/ElectronxAODHelpers.h
"
13
14
// Local includes
15
#include "
AssociationUtils/EleMuSharedTrkOverlapTool.h
"
16
17
namespace
ORUtils
18
{
19
20
//---------------------------------------------------------------------------
21
// Constructor
22
//---------------------------------------------------------------------------
23
EleMuSharedTrkOverlapTool::EleMuSharedTrkOverlapTool
(
const
std::string& name)
24
:
BaseOverlapTool
(name)
25
{
26
declareProperty
(
"RemoveCaloMuons"
,
m_removeCaloMuons
=
true
,
27
"Turn on removal of overlapping calo muons"
);
28
declareProperty
(
"UseDRMatching"
,
m_useDRMatching
=
false
,
29
"Remove electrons in DR cone of muons"
);
30
declareProperty
(
"DR"
,
m_maxDR
= 0.01,
31
"Delta-R cone for flagging overlaps"
);
32
declareProperty
(
"UseRapidity"
,
m_useRapidity
=
true
,
33
"Calculate delta-R using rapidity"
);
34
}
35
36
//---------------------------------------------------------------------------
37
// Initialize the tool
38
//---------------------------------------------------------------------------
39
StatusCode
EleMuSharedTrkOverlapTool::initializeDerived
()
40
{
41
42
if
(
m_removeCaloMuons
) {
43
ATH_MSG_DEBUG
(
"Configuring removal of overlapping calo muons"
);
44
}
45
46
if
(
m_useDRMatching
){
47
ATH_MSG_DEBUG
(
"Configuring removal of electrons in delta R cone of "
<<
m_maxDR
);
48
m_dRMatcher
= std::make_unique<DeltaRMatcher>(
m_maxDR
,
m_useRapidity
);
49
ATH_CHECK
(
m_dRMatcher
->setObjectTypes (
xAODType::ObjectType::Electron
,
xAODType::ObjectType::Muon
));
50
addSubtool(*
m_dRMatcher
);
51
}
52
53
return
StatusCode::SUCCESS;
54
}
55
56
//---------------------------------------------------------------------------
57
// Identify overlaps
58
//---------------------------------------------------------------------------
59
StatusCode
EleMuSharedTrkOverlapTool::
60
findOverlaps
(
columnar::Particle1Range
cont1,
61
columnar::Particle2Range
cont2,
62
columnar::EventContextId
/*eventContext*/
)
const
63
{
64
// Check the container types
65
ATH_CHECK
(
checkForXAODContainer<xAOD::ElectronContainer>
(cont1,
"First container arg is not of type ElectronContainer!"
) );
66
ATH_CHECK
(
checkForXAODContainer<xAOD::MuonContainer>
(cont2,
"Second container arg is not of type MuonContainer!"
) );
67
68
ATH_CHECK
(
internalFindOverlaps
(cont1, cont2) );
69
return
StatusCode::SUCCESS;
70
}
71
72
//---------------------------------------------------------------------------
73
// Identify overlaps between electrons and muons
74
//---------------------------------------------------------------------------
75
StatusCode
EleMuSharedTrkOverlapTool::
76
internalFindOverlaps
(
columnar::Particle1Range
electrons,
77
columnar::Particle2Range
muons)
const
78
{
79
ATH_MSG_DEBUG
(
"Removing overlapping electrons and muons"
);
80
auto
& acc = *
m_accessors
;
81
82
// Initialize output decorations if necessary
83
initializeDecorations
(electrons);
84
initializeDecorations
(muons);
85
86
// If removing calo-muons that overlap with electrons,
87
// then we need to do it in a separate loop first.
88
if
(
m_removeCaloMuons
) {
89
90
// Loop over electrons
91
for
(
const
auto
electron : electrons){
92
if
(!
isSurvivingObject
(electron))
continue
;
93
94
// Get the original ID track
95
auto
elTrk =
getOriginalTrackParticle
(electron);
96
97
// Loop over input calo muons
98
for
(
const
auto
muon : muons) {
99
if
(!
isSurvivingObject
(muon))
continue
;
100
if
(muon(acc.m_muonTypeAcc) != xAOD::Muon::MuonType::CaloTagged)
continue
;
101
102
// Get the muon ID track
103
auto
muTrk = muon(acc.m_muonTrkAcc);
104
// Flag the calo muon as overlapping if they share the track
105
bool
removeMu =
false
;
106
if
(elTrk.has_value() && muTrk.has_value()) removeMu = (elTrk == muTrk);
107
if
(removeMu) {
108
ATH_CHECK
(
handleOverlap
(muon, electron) );
109
}
110
}
111
}
112
}
113
114
// Loop over muons
115
for
(
const
auto
muon : muons){
116
if
(!
isSurvivingObject
(muon))
continue
;
117
118
// Get the muon ID track
119
auto
muTrk = muon(acc.m_muonTrkAcc);
120
121
// Loop over electrons
122
for
(
const
auto
electron : electrons) {
123
if
(!
isSurvivingObject
(electron))
continue
;
124
125
// Get the original ID track
126
auto
elTrk =
getOriginalTrackParticle
(electron);
127
128
// Flag the electron as overlapping if they share the track
129
// or if they are DR matched
130
bool
removeEle =
false
;
131
if
(elTrk.has_value() && muTrk.has_value()) removeEle = (elTrk == muTrk);
132
if
( (
m_useDRMatching
)
133
&& (
m_dRMatcher
->objectsMatch(electron, muon)) ){
134
removeEle =
true
;
135
}
136
if
(removeEle){
137
ATH_CHECK
(
handleOverlap
(electron, muon) );
138
}
139
}
140
}
141
return
StatusCode::SUCCESS;
142
}
143
144
[[nodiscard]]
columnar::ObjectLink<EleMuSharedTrkOverlapTool::MyTrackDef>
EleMuSharedTrkOverlapTool::
145
getOriginalTrackParticle
(
columnar::Particle1Id
electron)
const
146
{
147
auto
& acc = *
m_accessors
;
148
auto
elGsfTrk = electron(acc.m_eleTrackAcc);
149
if
(elGsfTrk.size() == 0 || !elGsfTrk[0].has_value())
150
throw
std::runtime_error(
"Electron has no associated track"
);
151
return
elGsfTrk[0].value()(acc.m_gsfOriginalTrackAcc);
152
}
153
154
}
// namespace ORUtils
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
EleMuSharedTrkOverlapTool.h
ElectronxAODHelpers.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
ORUtils::BaseOverlapTool::initializeDecorations
void initializeDecorations(columnar::Particle1Range container) const
Definition
BaseOverlapTool.h:142
ORUtils::BaseOverlapTool::BaseOverlapTool
BaseOverlapTool(const std::string &name)
Create proper constructor for Athena.
Definition
BaseOverlapTool.cxx:14
ORUtils::BaseOverlapTool::handleOverlap
StatusCode handleOverlap(const columnar::ObjectId< CI1, CM > &testParticle, const columnar::ObjectId< CI2, CM > &refParticle) const
Common helper method to handle an overlap result.
Definition
BaseOverlapTool.h:178
ORUtils::BaseOverlapTool::isSurvivingObject
bool isSurvivingObject(columnar::Particle1Id obj) const
Definition
BaseOverlapTool.h:150
ORUtils::BaseOverlapTool::checkForXAODContainer
StatusCode checkForXAODContainer(columnar::ObjectRange< CI, CM > cont, std::string_view message) const
check whether the container is of the right type
Definition
BaseOverlapTool.h:83
ORUtils::EleMuSharedTrkOverlapTool::m_accessors
std::unique_ptr< Accessors > m_accessors
Definition
EleMuSharedTrkOverlapTool.h:110
ORUtils::EleMuSharedTrkOverlapTool::internalFindOverlaps
StatusCode internalFindOverlaps(columnar::Particle1Range electrons, columnar::Particle2Range muons) const
Alternate method taking actual container types.
Definition
EleMuSharedTrkOverlapTool.cxx:76
ORUtils::EleMuSharedTrkOverlapTool::m_useDRMatching
bool m_useDRMatching
Flag to remove electrons in a dR cone of muons (default: false).
Definition
EleMuSharedTrkOverlapTool.h:85
ORUtils::EleMuSharedTrkOverlapTool::EleMuSharedTrkOverlapTool
EleMuSharedTrkOverlapTool(const std::string &name)
Create proper constructor for Athena.
Definition
EleMuSharedTrkOverlapTool.cxx:23
ORUtils::EleMuSharedTrkOverlapTool::m_dRMatcher
std::unique_ptr< DeltaRMatcher > m_dRMatcher
Delta-R matcher.
Definition
EleMuSharedTrkOverlapTool.h:115
ORUtils::EleMuSharedTrkOverlapTool::findOverlaps
virtual StatusCode findOverlaps(columnar::Particle1Range cont1, columnar::Particle2Range cont2, columnar::EventContextId eventContext) const override
Identify overlaps via shared ID track.
Definition
EleMuSharedTrkOverlapTool.cxx:60
ORUtils::EleMuSharedTrkOverlapTool::m_useRapidity
bool m_useRapidity
Calculate delta-R using rapidity.
Definition
EleMuSharedTrkOverlapTool.h:89
ORUtils::EleMuSharedTrkOverlapTool::initializeDerived
virtual StatusCode initializeDerived() override
Initialize the tool.
Definition
EleMuSharedTrkOverlapTool.cxx:39
ORUtils::EleMuSharedTrkOverlapTool::m_maxDR
float m_maxDR
Maximum dR between electrons and muons if m_useDRMatching is used.
Definition
EleMuSharedTrkOverlapTool.h:87
ORUtils::EleMuSharedTrkOverlapTool::getOriginalTrackParticle
columnar::ObjectLink< MyTrackDef > getOriginalTrackParticle(columnar::Particle1Id electron) const
Definition
EleMuSharedTrkOverlapTool.cxx:145
ORUtils::EleMuSharedTrkOverlapTool::m_removeCaloMuons
bool m_removeCaloMuons
Flag to remove calo-muons overlapping with electrons.
Definition
EleMuSharedTrkOverlapTool.h:82
columnar::ObjectLink
Definition
ContainerId.h:207
ORUtils
Definition
AltMuJetOverlapTool.h:30
columnar::Particle1Id
ObjectId< Particle1Def > Particle1Id
Definition
ParticleDef.h:45
columnar::EventContextId
ObjectId< EventContextDef > EventContextId
Definition
ContainerId.h:212
columnar::Particle2Range
ObjectRange< Particle2Def > Particle2Range
Definition
ParticleDef.h:50
columnar::Particle1Range
ObjectRange< Particle1Def > Particle1Range
Definition
ParticleDef.h:44
xAODType::Muon
@ Muon
The object is a muon.
Definition
ObjectType.h:48
xAODType::Electron
@ Electron
The object is an electron.
Definition
ObjectType.h:46
Generated on
for ATLAS Offline Software by
1.17.0