ATLAS Offline Software
Loading...
Searching...
No Matches
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
7
9
10#include <algorithm>
11
12namespace CP
13{
14
18
20 // Initialisation
23 {
24
25 if (!m_isDAOD)
26 {
28 {
29 asg::AsgToolConfig config("AsgElectronLikelihoodTool/ElectronLHSelectorVeryLooseNoPix");
30 ATH_CHECK(config.setProperty("WorkingPoint", "VeryLooseLHElectron_LLP"));
32 }
33
34 ATH_MSG_DEBUG("Retrieving electron selection tool");
36
38 {
39 asg::AsgToolConfig config("AsgElectronLikelihoodTool/ElectronLHSelectorLooseNoPix");
40 ATH_CHECK(config.setProperty("WorkingPoint", "LooseLHElectron_LLP"));
42 }
43
44 ATH_MSG_DEBUG("Retrieving electron selection tool");
46
48 {
49 asg::AsgToolConfig config("AsgElectronLikelihoodTool/ElectronLHSelectorMediumNoPix");
50 ATH_CHECK(config.setProperty("WorkingPoint", "MediumLHElectron_LLP"));
52 }
53
54 ATH_MSG_DEBUG("Retrieving electron selection tool");
56
58 {
59 asg::AsgToolConfig config("AsgElectronLikelihoodTool/ElectronLHSelectorTightNoPix");
60 ATH_CHECK(config.setProperty("WorkingPoint", "TightLHElectron_LLP"));
62 }
63
64 ATH_MSG_DEBUG("Retrieving electron selection tool");
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"){
86 }
87 else if (IDWorkingPoint == "DFCommonElectronsLHMediumNoPix"){
89 }
90 else if (IDWorkingPoint == "DFCommonElectronsLHLooseNoPix"){
92 }
93 else if (IDWorkingPoint == "DFCommonElectronsLHVeryLooseNoPix"){
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
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
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 }
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
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
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 {
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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
ToolHandle< IAsgElectronLikelihoodTool > m_electronLLHToolLooseNoPix
Gaudi::Property< std::string > m_IDWorkingPoint
Switches method for retrieving electron ID.
ToolHandle< IAsgElectronLikelihoodTool > m_electronLLHToolTightNoPix
ElectronLRTOverlapRemovalTool(const std::string &name)
Standard algorithm methods:
Gaudi::Property< bool > m_isDAOD
Delta R threshold for matching in overlap removal.
ToolHandle< IAsgElectronLikelihoodTool > m_electronLLHToolVeryLooseNoPix
Switches method for retrieving electron ID.
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.
ToolHandle< IAsgElectronLikelihoodTool > m_electronLLHToolMediumNoPix
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
bool electronPassesID(const xAOD::Electron *electron, const std::string &IDWorkingPoint) const
SG::ConstAccessor< T, ALLOC > ConstAccessor
Definition AuxElement.h:569
an object that can create a AsgTool
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
Description of a calorimeter cluster.
flt_t eta0() const
Returns raw of cluster seed.
flt_t phi0() const
Returns raw of cluster seed.
Select isolated Photons, Electrons and Muons.
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
setBGCode setTAP setLVL2ErrorBits bool
Electron_v1 Electron
Definition of the current "egamma version".
Helper for azimuthal angle calculations.