ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
ElectronPhotonID
LRTElectronAnalysisTools
Root
ElectronLRTOverlapRemovalTool.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
#include "
LRTElectronAnalysisTools/ElectronLRTOverlapRemovalTool.h
"
6
#include "
AsgTools/AsgToolConfig.h
"
7
8
#include "
CxxUtils/phihelper.h
"
9
10
#include <algorithm>
11
12
namespace
CP
13
{
14
15
ElectronLRTOverlapRemovalTool::ElectronLRTOverlapRemovalTool
(
const
std::string &
name
) :
asg
::
AsgTool
(
name
)
16
{
17
}
18
20
// Initialisation
22
StatusCode
ElectronLRTOverlapRemovalTool::initialize
()
23
{
24
25
if
(!
m_isDAOD
)
26
{
27
if
(
m_electronLLHToolVeryLooseNoPix
.empty())
28
{
29
asg::AsgToolConfig
config(
"AsgElectronLikelihoodTool/ElectronLHSelectorVeryLooseNoPix"
);
30
ATH_CHECK
(config.setProperty(
"WorkingPoint"
,
"VeryLooseLHElectron_LLP"
));
31
ATH_CHECK
(config.makePrivateTool(
m_electronLLHToolVeryLooseNoPix
));
32
}
33
34
ATH_MSG_DEBUG
(
"Retrieving electron selection tool"
);
35
ATH_CHECK
(
m_electronLLHToolVeryLooseNoPix
.retrieve());
36
37
if
(
m_electronLLHToolLooseNoPix
.empty())
38
{
39
asg::AsgToolConfig
config(
"AsgElectronLikelihoodTool/ElectronLHSelectorLooseNoPix"
);
40
ATH_CHECK
(config.setProperty(
"WorkingPoint"
,
"LooseLHElectron_LLP"
));
41
ATH_CHECK
(config.makePrivateTool(
m_electronLLHToolLooseNoPix
));
42
}
43
44
ATH_MSG_DEBUG
(
"Retrieving electron selection tool"
);
45
ATH_CHECK
(
m_electronLLHToolLooseNoPix
.retrieve());
46
47
if
(
m_electronLLHToolMediumNoPix
.empty())
48
{
49
asg::AsgToolConfig
config(
"AsgElectronLikelihoodTool/ElectronLHSelectorMediumNoPix"
);
50
ATH_CHECK
(config.setProperty(
"WorkingPoint"
,
"MediumLHElectron_LLP"
));
51
ATH_CHECK
(config.makePrivateTool(
m_electronLLHToolMediumNoPix
));
52
}
53
54
ATH_MSG_DEBUG
(
"Retrieving electron selection tool"
);
55
ATH_CHECK
(
m_electronLLHToolMediumNoPix
.retrieve());
56
57
if
(
m_electronLLHToolTightNoPix
.empty())
58
{
59
asg::AsgToolConfig
config(
"AsgElectronLikelihoodTool/ElectronLHSelectorTightNoPix"
);
60
ATH_CHECK
(config.setProperty(
"WorkingPoint"
,
"TightLHElectron_LLP"
));
61
ATH_CHECK
(config.makePrivateTool(
m_electronLLHToolTightNoPix
));
62
}
63
64
ATH_MSG_DEBUG
(
"Retrieving electron selection tool"
);
65
ATH_CHECK
(
m_electronLLHToolTightNoPix
.retrieve());
66
}
67
68
return
StatusCode::SUCCESS;
69
}
70
71
73
// Check if electron passes ID
75
bool
ElectronLRTOverlapRemovalTool::electronPassesID
(
const
xAOD::Electron
*
electron
,
const
std::string& IDWorkingPoint)
const
76
{
77
78
if
(
m_isDAOD
)
79
{
80
SG::AuxElement::ConstAccessor<char> DFCommonElectronsWP(IDWorkingPoint);
81
return
bool
(DFCommonElectronsWP(*
electron
) );
82
}
else
83
{
84
if
(IDWorkingPoint ==
"DFCommonElectronsLHTightNoPix"
){
85
return
bool
(
m_electronLLHToolTightNoPix
->accept(
electron
));
86
}
87
else
if
(IDWorkingPoint ==
"DFCommonElectronsLHMediumNoPix"
){
88
return
bool
(
m_electronLLHToolMediumNoPix
->accept(
electron
));
89
}
90
else
if
(IDWorkingPoint ==
"DFCommonElectronsLHLooseNoPix"
){
91
return
bool
(
m_electronLLHToolLooseNoPix
->accept(
electron
));
92
}
93
else
if
(IDWorkingPoint ==
"DFCommonElectronsLHVeryLooseNoPix"
){
94
return
bool
(
m_electronLLHToolVeryLooseNoPix
->accept(
electron
));
95
}
96
else
{
97
ATH_MSG_ERROR
(
"IDWorkingPoint provided is not a valid Working Point!"
);
98
return
false
;
99
}
100
}
101
102
}
103
104
106
// Check overlap between the electron collections and save pointer of duplicates
107
// This removes the LRT electron in favor of prompt
109
void
ElectronLRTOverlapRemovalTool::checkOverlap
(
const
xAOD::ElectronContainer
&promptElectronCol,
110
const
xAOD::ElectronContainer
&LRTElectronCol,
111
std::set<const xAOD::Electron *> &ElectronsToRemove)
const
112
{
113
114
// Loop over lrt electrons to remove those that do not pass ID.
115
// Needed in case there are no prompt electrons passing ID
116
if
(
m_strategy
==
CP::IElectronLRTOverlapRemovalTool::promptStrategy
){
117
ATH_MSG_DEBUG
(
"Implementing overlap removal strategy 1"
);
118
for
(
const
xAOD::Electron
*LRTElectron : LRTElectronCol)
119
{
120
if
(!
electronPassesID
(LRTElectron,
"DFCommonElectronsLHVeryLooseNoPix"
)) ElectronsToRemove.insert(LRTElectron);
121
}
122
}
123
else
if
(
m_strategy
==
CP::IElectronLRTOverlapRemovalTool::passThrough
){
124
ATH_MSG_DEBUG
(
"Implementing overlap removal strategy 2"
);
125
ATH_MSG_DEBUG
(
"Electrons with overlapping clusters will be kept"
);
126
}
127
128
129
// loop over prompt electrons
130
for
(
const
xAOD::Electron
*promptElectron : promptElectronCol)
131
{
132
const
ElementLink
promptClusterLink = promptElectron->caloClusterLink(0);
133
const
xAOD::CaloCluster_v1
*prompt_cluster = (*promptClusterLink);
134
135
// Skip electrons that do not pass ID threshold
136
if
(
m_strategy
==
CP::IElectronLRTOverlapRemovalTool::promptStrategy
){
137
if
(!
electronPassesID
(promptElectron,
m_IDWorkingPoint
))
138
{
139
ElectronsToRemove.insert(promptElectron);
140
continue
;
141
}
142
}
143
144
// loop over lrt electrons
145
for
(
const
xAOD::Electron
*LRTElectron : LRTElectronCol)
146
{
147
const
ElementLink
LRTClusterLink = LRTElectron->caloClusterLink(0);
148
const
xAOD::CaloCluster_v1
*lrt_cluster = (*LRTClusterLink);
149
150
// Skip LRT electrons that do not pass ID threshold
151
if
(
m_strategy
==
CP::IElectronLRTOverlapRemovalTool::promptStrategy
){
152
if
(!
electronPassesID
(LRTElectron,
m_IDWorkingPoint
))
continue
;
153
}
154
// check that clusters exist (necessary? copied from MuonSpec overlap, but all electrons have clusters...)
155
// TODO: This should then fall back to delta R if clusters are missing
156
if
(!lrt_cluster and !prompt_cluster)
157
continue
;
158
159
// matching based on hottest cell of cluster
160
// as in ambiguity res for el/ph
161
162
const
double
prompt_elEta0 = prompt_cluster->
eta0
();
163
const
double
prompt_elPhi0 = prompt_cluster->
phi0
();
164
165
const
double
lrt_elEta0 = lrt_cluster->
eta0
();
166
const
double
lrt_elPhi0 = lrt_cluster->
phi0
();
167
ATH_MSG_DEBUG
(
"Prompt eta, phi: "
<<prompt_elEta0<<
", "
<<prompt_elPhi0);
168
ATH_MSG_DEBUG
(
"LRT eta, phi: "
<<lrt_elEta0<<
", "
<<lrt_elPhi0);
169
170
if
(prompt_elEta0 == lrt_elEta0 && prompt_elPhi0 == lrt_elPhi0)
171
{
172
if
(
m_strategy
==
CP::IElectronLRTOverlapRemovalTool::promptStrategy
){
173
ATH_MSG_DEBUG
(
"Found a Calo cluster shared by LRT electron and prompt electron !"
);
174
ATH_MSG_DEBUG
(
"Removing LRT Electron"
);
175
// Save pointer to LRT electrons failing overlap
176
// This removes the LRT electron in favor of prompt
177
ElectronsToRemove.insert(LRTElectron);
178
}
179
else
if
(
m_strategy
==
CP::IElectronLRTOverlapRemovalTool::defaultStrategy
){
//use tighter electron, if both equally tight use std collection
180
181
ATH_MSG_DEBUG
(
"Removing Electron with looser WP"
);
182
if
(
electronPassesID
(promptElectron,
"DFCommonElectronsLHTightNoPix"
)){
183
ElectronsToRemove.insert(LRTElectron);
184
}
185
else
if
(
electronPassesID
(promptElectron,
"DFCommonElectronsLHMediumNoPix"
) ) {
186
if
(
electronPassesID
(LRTElectron,
"DFCommonElectronsLHTightNoPix"
) ){
187
ElectronsToRemove.insert(promptElectron);
188
}
189
else
ElectronsToRemove.insert(LRTElectron);
190
}
191
else
if
(
electronPassesID
(promptElectron,
"DFCommonElectronsLHLooseNoPix"
) ) {
192
if
(
electronPassesID
(LRTElectron,
"DFCommonElectronsLHMediumNoPix"
) ){
193
ElectronsToRemove.insert(promptElectron);
194
}
195
else
ElectronsToRemove.insert(LRTElectron);
196
}
197
else
if
(
electronPassesID
(promptElectron,
"DFCommonElectronsLHVeryLooseNoPix"
) ) {
198
if
(
electronPassesID
(LRTElectron,
"DFCommonElectronsLHLooseNoPix"
) ){
199
ElectronsToRemove.insert(promptElectron);
200
}
201
else
ElectronsToRemove.insert(LRTElectron);
202
}
203
else
{
204
if
(
electronPassesID
(LRTElectron,
"DFCommonElectronsLHVeryLooseNoPix"
) ) {
205
ElectronsToRemove.insert(promptElectron);
206
}
207
else
ElectronsToRemove.insert(LRTElectron);
208
}
209
}
210
}
211
}
// end lrt loop
212
}
// end prompt loop
213
}
214
215
}
// end namespace CP
AsgToolConfig.h
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_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
ElectronLRTOverlapRemovalTool.h
CP::ElectronLRTOverlapRemovalTool::m_electronLLHToolLooseNoPix
ToolHandle< IAsgElectronLikelihoodTool > m_electronLLHToolLooseNoPix
Definition
ElectronLRTOverlapRemovalTool.h:59
CP::ElectronLRTOverlapRemovalTool::m_IDWorkingPoint
Gaudi::Property< std::string > m_IDWorkingPoint
Switches method for retrieving electron ID.
Definition
ElectronLRTOverlapRemovalTool.h:56
CP::ElectronLRTOverlapRemovalTool::m_electronLLHToolTightNoPix
ToolHandle< IAsgElectronLikelihoodTool > m_electronLLHToolTightNoPix
Definition
ElectronLRTOverlapRemovalTool.h:61
CP::ElectronLRTOverlapRemovalTool::ElectronLRTOverlapRemovalTool
ElectronLRTOverlapRemovalTool(const std::string &name)
Standard algorithm methods:
Definition
ElectronLRTOverlapRemovalTool.cxx:15
CP::ElectronLRTOverlapRemovalTool::m_isDAOD
Gaudi::Property< bool > m_isDAOD
Delta R threshold for matching in overlap removal.
Definition
ElectronLRTOverlapRemovalTool.h:55
CP::ElectronLRTOverlapRemovalTool::m_electronLLHToolVeryLooseNoPix
ToolHandle< IAsgElectronLikelihoodTool > m_electronLLHToolVeryLooseNoPix
Switches method for retrieving electron ID.
Definition
ElectronLRTOverlapRemovalTool.h:58
CP::ElectronLRTOverlapRemovalTool::checkOverlap
virtual void checkOverlap(const xAOD::ElectronContainer &promptCollection, const xAOD::ElectronContainer &lrtCollection, std::set< const xAOD::Electron * > &ElectronsToRemove) const
Check the overlap between the prompt and LRT electron collections.
Definition
ElectronLRTOverlapRemovalTool.cxx:109
CP::ElectronLRTOverlapRemovalTool::m_electronLLHToolMediumNoPix
ToolHandle< IAsgElectronLikelihoodTool > m_electronLLHToolMediumNoPix
Definition
ElectronLRTOverlapRemovalTool.h:60
CP::ElectronLRTOverlapRemovalTool::initialize
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
Definition
ElectronLRTOverlapRemovalTool.cxx:22
CP::ElectronLRTOverlapRemovalTool::m_strategy
Gaudi::Property< int > m_strategy
Definition
ElectronLRTOverlapRemovalTool.h:53
CP::ElectronLRTOverlapRemovalTool::electronPassesID
bool electronPassesID(const xAOD::Electron *electron, const std::string &IDWorkingPoint) const
Definition
ElectronLRTOverlapRemovalTool.cxx:75
CP::IElectronLRTOverlapRemovalTool::promptStrategy
@ promptStrategy
Definition
IElectronLRTOverlapRemovalTool.h:50
CP::IElectronLRTOverlapRemovalTool::defaultStrategy
@ defaultStrategy
Definition
IElectronLRTOverlapRemovalTool.h:49
CP::IElectronLRTOverlapRemovalTool::passThrough
@ passThrough
Definition
IElectronLRTOverlapRemovalTool.h:51
ElementLink
ElementLink implementation for ROOT usage.
Definition
A/AthLinks/ElementLink.h:40
asg::AsgToolConfig
an object that can create a AsgTool
Definition
AsgToolConfig.h:22
asg::AsgTool::AsgTool
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition
AsgTool.cxx:58
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition
CaloCluster_v1.h:62
xAOD::CaloCluster_v1::eta0
flt_t eta0() const
Returns raw of cluster seed.
xAOD::CaloCluster_v1::phi0
flt_t phi0() const
Returns raw of cluster seed.
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
asg
Definition
DataHandleTestTool.h:28
xAOD::name
name
Definition
TriggerMenuJson_v1.cxx:29
xAOD::ElectronContainer
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
Definition
Event/xAOD/xAODEgamma/xAODEgamma/ElectronContainer.h:17
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition
TrigDecision_v1.cxx:60
xAOD::electron
@ electron
Definition
TrackingPrimitives.h:195
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition
Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
phihelper.h
Helper for azimuthal angle calculations.
Generated on
for ATLAS Offline Software by
1.17.0