ATLAS Offline Software
Loading...
Searching...
No Matches
TruthClassificationTool Class Reference

a tool to classify particles based on their type and origin More...

#include <TruthClassificationTool.h>

Inheritance diagram for TruthClassificationTool:
Collaboration diagram for TruthClassificationTool:

Public Member Functions

 TruthClassificationTool (const std::string &type)
virtual StatusCode classify (const xAOD::IParticle &particle, unsigned int &classification) const override
 classify and return unsigned int
virtual StatusCode classify (const xAOD::IParticle &particle, Truth::Type &classification) const override
 classify and return Truth::Type
virtual StatusCode initialize ()
 Dummy implementation of the initialisation function.
virtual void print () const
 Print the state of the tool.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const
Additional helper functions, not directly mimicking Athena
template<class T>
const T * getProperty (const std::string &name) const
 Get one of the tool's properties.
const std::string & msg_level_name () const __attribute__((deprecated))
 A deprecated function for getting the message level's name.
const std::string & getName (const void *ptr) const
 Get the name of an object that is / should be in the event store.
SG::sgkey_t getKey (const void *ptr) const
 Get the (hashed) key of an object that is in the event store.

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvc > StoreGateSvc_t

Private Member Functions

StatusCode classifyElectron (const xAOD::IParticle &electron, Truth::Type &classification) const
 electron classification helper
StatusCode classifyMuon (const xAOD::IParticle &muon, Truth::Type &classification) const
 muon classification helper
bool isPromptElectron (const xAOD::IParticle &electron, bool isTruthParticle, const xAOD::TruthParticle *truthParticle) const
 a helper to check if an electron is prompt
bool isChargeFlipElectron (const xAOD::IParticle &electron, bool isTruthParticle, const xAOD::TruthParticle *truthParticle) const
 a helper to check if an electron has an incorrectly reconstructed charge
bool isChargeFlipMuon (const xAOD::IParticle &muon, bool isTruthParticle, const xAOD::TruthParticle *truthParticle) const
 a helper to check if a muon has an incorrectly reconstructed charge
bool hasBHadronOrigin (int origin) const
 a helper to check if the origin is a b-hadron
bool hasCHadronOrigin (int origin) const
 a helper to check if the origin is a c-hadron
bool hasLightHadronOrigin (int origin) const
 a helper to check if the origin is a light hadron
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

bool m_separateChargeFlipElectrons = false
 separately store charge-flip electrons/muons
bool m_separateChargeFlipMuons = false
bool m_useTruthParticleDecorations {false}
 use truth particle decorations
const SG::AuxElement::ConstAccessor< int > m_truthType {"truthType"}
const SG::AuxElement::ConstAccessor< int > m_truthOrigin {"truthOrigin"}
const SG::AuxElement::ConstAccessor< unsigned int > m_truthClassification {"truthClassification"}
const SG::AuxElement::ConstAccessor< int > m_truthPdgId {"truthPdgId"}
const SG::AuxElement::ConstAccessor< unsigned int > m_classifierParticleType {"classifierParticleType"}
const SG::AuxElement::ConstAccessor< unsigned int > m_classifierParticleOrigin {"classifierParticleOrigin"}
const SG::AuxElement::ConstAccessor< int > m_firstMotherTruthType {"firstEgMotherTruthType"}
const SG::AuxElement::ConstAccessor< int > m_firstMotherTruthOrigin {"firstEgMotherTruthOrigin"}
const SG::AuxElement::ConstAccessor< unsigned int > m_firstMotherTruthClassification {"firstEgMotherTruthClassification"}
const SG::AuxElement::ConstAccessor< int > m_firstMotherPdgId {"firstEgMotherPdgId"}
const SG::AuxElement::ConstAccessor< int > m_lastMotherTruthType {"lastEgMotherTruthType"}
const SG::AuxElement::ConstAccessor< int > m_lastMotherTruthOrigin {"lastEgMotherTruthOrigin"}
const SG::AuxElement::ConstAccessor< unsigned int > m_lastMotherTruthClassification {"lastEgMotherTruthClassification"}
const SG::AuxElement::ConstAccessor< int > m_lastMotherPdgId {"lastEgMotherPdgId"}
const SG::AuxElement::ConstAccessor< int > m_fallbackTruthType {"TruthClassifierFallback_truthType"}
const SG::AuxElement::ConstAccessor< int > m_fallbackTruthOrigin {"TruthClassifierFallback_truthOrigin"}
const SG::AuxElement::ConstAccessor< int > m_fallbackTruthClassification {"TruthClassifierFallback_truthClassification"}
const SG::AuxElement::ConstAccessor< float > m_fallbackDR {"TruthClassifierFallback_dR"}
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default).
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default).
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

a tool to classify particles based on their type and origin

Definition at line 18 of file TruthClassificationTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ TruthClassificationTool()

TruthClassificationTool::TruthClassificationTool ( const std::string & type)
explicit

Definition at line 25 of file TruthClassificationTool.cxx.

26 : asg::AsgTool(type)
27{
28 declareProperty ("separateChargeFlipElectrons", m_separateChargeFlipElectrons, "separate prompt charge-flipped electrons");
29 declareProperty ("separateChargeFlipMuons", m_separateChargeFlipMuons, "separate prompt charge-flipped muons");
30 declareProperty ("useTruthParticleDecorations", m_useTruthParticleDecorations, "use truth particle decorations");
31}
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
bool m_separateChargeFlipElectrons
separately store charge-flip electrons/muons
bool m_useTruthParticleDecorations
use truth particle decorations

Member Function Documentation

◆ classify() [1/2]

StatusCode TruthClassificationTool::classify ( const xAOD::IParticle & particle,
Truth::Type & classification ) const
overridevirtual

classify and return Truth::Type

Implements ITruthClassificationTool.

Definition at line 44 of file TruthClassificationTool.cxx.

46{
47 const xAOD::TruthParticle *truthParticle = dynamic_cast<const xAOD::TruthParticle *> (&particle);
48 if (dynamic_cast<const xAOD::Electron *> (&particle) || (truthParticle != nullptr && MC::isElectron(truthParticle)))
49 {
50 ANA_CHECK(classifyElectron(particle, classification));
51 }
52 else if (dynamic_cast<const xAOD::Muon *> (&particle) || (truthParticle != nullptr && MC::isMuon(truthParticle)))
53 {
54 ANA_CHECK(classifyMuon(particle, classification));
55 }
56 else
57 {
58 ANA_MSG_ERROR("Only electrons and muons are supported.");
59 return StatusCode::FAILURE;
60 }
61
62 return StatusCode::SUCCESS;
63}
#define ANA_MSG_ERROR(xmsg,...)
Macro printing error messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
StatusCode classifyElectron(const xAOD::IParticle &electron, Truth::Type &classification) const
electron classification helper
StatusCode classifyMuon(const xAOD::IParticle &muon, Truth::Type &classification) const
muon classification helper
bool isElectron(const T &p)
bool isMuon(const T &p)
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
TruthParticle_v1 TruthParticle
Typedef to implementation.
Muon_v1 Muon
Reference the current persistent version:
Electron_v1 Electron
Definition of the current "egamma version".

◆ classify() [2/2]

StatusCode TruthClassificationTool::classify ( const xAOD::IParticle & particle,
unsigned int & classification ) const
overridevirtual

classify and return unsigned int

Implements ITruthClassificationTool.

Definition at line 34 of file TruthClassificationTool.cxx.

36{
37 Truth::Type type = Truth::Type::Unknown;
38 ANA_CHECK(classify(particle, type));
39 classification = static_cast<int>(type);
40 return StatusCode::SUCCESS;
41}
virtual StatusCode classify(const xAOD::IParticle &particle, unsigned int &classification) const override
classify and return unsigned int
Type
truth classification type enum

◆ classifyElectron()

StatusCode TruthClassificationTool::classifyElectron ( const xAOD::IParticle & electron,
Truth::Type & classification ) const
private

electron classification helper

Definition at line 66 of file TruthClassificationTool.cxx.

68{
69
70
71 // Check if xAOD::TruthParticle or if not if it has the TruthParticleLink
72 const xAOD::TruthParticle *truthParticle = dynamic_cast<const xAOD::TruthParticle *> (&electron);
73 bool isTruthParticle{};
74 if (truthParticle == nullptr)
75 {
76 // need to find the truth particle
77 truthParticle = xAOD::TruthHelpers::getTruthParticle(electron);
78 }
79 else
80 {
81 isTruthParticle = true;
82 }
83
84 if (!m_truthPdgId.isAvailable(electron) && !isTruthParticle)
85 {
86 ANA_MSG_ERROR("Electron does not have the 'truthPdgId' decoration.");
87 return StatusCode::FAILURE;
88 }
89
90 if (!m_firstMotherTruthType.isAvailable(electron)
91 || !m_firstMotherTruthOrigin.isAvailable(electron)
92 || !m_firstMotherPdgId.isAvailable(electron))
93 {
94 ANA_MSG_ERROR("Electron does not have one or more 'firstEgMother' decorations.");
95 return StatusCode::FAILURE;
96 }
97
98 int type = isTruthParticle ? m_classifierParticleType(electron) : m_truthType(electron);
99 int origin = isTruthParticle ? m_classifierParticleOrigin(electron) : m_truthOrigin(electron);
100 int pdgId = isTruthParticle ? truthParticle->pdgId() : m_truthPdgId(electron);
101 if (m_useTruthParticleDecorations && !isTruthParticle)
102 {
103 type = m_classifierParticleType(*truthParticle);
104 origin = m_classifierParticleOrigin(*truthParticle);
105 }
106
107 int firstMotherType = m_firstMotherTruthType(electron);
108 int firstMotherOrigin = m_firstMotherTruthOrigin(electron);
109 int firstMotherPdgId = m_firstMotherPdgId(electron);
110 // not in the smart slimming list, thus only in few derivations
111 int lastMotherType = m_lastMotherTruthType.isAvailable(electron) ? m_lastMotherTruthType(electron) : -1;
112 int lastMotherOrigin = m_lastMotherTruthOrigin.isAvailable(electron) ? m_lastMotherTruthOrigin(electron) : -1;
113 int lastMotherPdgId = m_lastMotherPdgId.isAvailable(electron) ? m_lastMotherPdgId(electron) : -1;
114 // fallback recorations
115 int fallbackType{-1};
116 if (m_fallbackTruthType.isAvailable(electron) && m_fallbackDR.isAvailable(electron))
117 {
118 fallbackType = m_fallbackDR(electron) < 0.05 ? m_fallbackTruthType(electron) : -1;
119 }
120
121 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
122 // Prompt Photon Conversions
123 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
124
125 // gamma -> e+ e-
128 && firstMotherType == MCTruthPartClassifier::IsoPhoton && firstMotherOrigin == MCTruthPartClassifier::PromptPhot)
129 {
130 classification = Truth::Type::PromptPhotonConversion;
131 return StatusCode::SUCCESS;
132 }
133
134 // H -> gamma gamma, gamma -> e+ e-
136 && firstMotherType == MCTruthPartClassifier::IsoPhoton && firstMotherOrigin == MCTruthPartClassifier::Higgs)
137 {
138 classification = Truth::Type::PromptPhotonConversion;
139 return StatusCode::SUCCESS;
140 }
141
142 // bkg electrons from bkg photons
144 && firstMotherType == MCTruthPartClassifier::UnknownPhoton && firstMotherOrigin == MCTruthPartClassifier::NonDefined)
145 {
146 classification = Truth::Type::PromptPhotonConversion;
147 return StatusCode::SUCCESS;
148 }
149
150 // bkg photon from UndrPhot; (Here there is a generator level photon (not gen electron ) that later converts)
153 && firstMotherType == MCTruthPartClassifier::BkgPhoton && firstMotherOrigin == MCTruthPartClassifier::UndrPhot)
154 {
155 classification = Truth::Type::PromptPhotonConversion;
156 return StatusCode::SUCCESS;
157 }
158
159 // type = 16 and origin = 38 (again, this is a photon)
161 {
162 classification = Truth::Type::PromptPhotonConversion;
163 return StatusCode::SUCCESS;
164 }
165
166 // Is an isolated photon
167 if (type == MCTruthPartClassifier::IsoPhoton && pdgId == 22)
168 {
169 classification = Truth::Type::PromptPhotonConversion;
170 return StatusCode::SUCCESS;
171 }
172
173 // electrons from ElMagProc
174 // when FSR, a better classification can be made with the fall back vars
176 && firstMotherType == MCTruthPartClassifier::UnknownPhoton && firstMotherOrigin == MCTruthPartClassifier::NonDefined)
177 {
178 classification = Truth::Type::PromptPhotonConversion;
179 return StatusCode::SUCCESS;
180 }
182 && firstMotherType == MCTruthPartClassifier::NonIsoPhoton && firstMotherOrigin == MCTruthPartClassifier::FSRPhot)
183 {
184 classification = Truth::Type::PromptPhotonConversion;
185 return StatusCode::SUCCESS;
186 }
187
188 // TODO: Message from Otilia: """
189 // but it's not clear if these electrons are really
190 // "fakes" or they should go in the real category (we don't know from where
191 // this photon is coming...). I would say more truth studies should be done.
192 // """
193 // Hence the warning message...
195 && firstMotherType == MCTruthPartClassifier::Unknown && firstMotherOrigin == MCTruthPartClassifier::ZBoson)
196 {
197 ANA_MSG_WARNING("Electron identified as from a PromptPhotonConversion, "
198 "but this type of electron needs further study!");
199 classification = Truth::Type::PromptPhotonConversion;
200 return StatusCode::SUCCESS;
201 }
202
203 // when always a photon (last mum is a photon, even if the truth PDG is 11 and first mum PDG is 11 ):
204 // very likely these are internal conversions; last_mum_pdgId == 22 important as the cases with last_mum_pdgId == 11 were found to be quite often close to a true electron
207 && std::abs(firstMotherPdgId) == 11 && std::abs(pdgId) == 11)
208 { // electron
209 if(lastMotherType == -1 || (lastMotherType == MCTruthPartClassifier::GenParticle && (lastMotherPdgId == 22 || std::abs(lastMotherPdgId) == 11)))
210 {
211 // lastMotherType == -1 ==> when the last mother info is not stored in the derivations
212 classification = Truth::Type::PromptPhotonConversion;
213 return StatusCode::SUCCESS;
214 }
215 }
216
217
218 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
219 // Is muon reco as electron or ele radiated by muons
220 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
221
223 && (origin == MCTruthPartClassifier::Mu || firstMotherOrigin == MCTruthPartClassifier::Mu))
224 {
225 classification = Truth::Type::ElectronFromMuon;
226 return StatusCode::SUCCESS;
227 }
228
229 if (type == MCTruthPartClassifier::BkgElectron && firstMotherOrigin == MCTruthPartClassifier::Mu)
230 {
231 classification = Truth::Type::ElectronFromMuon;
232 return StatusCode::SUCCESS;
233 }
234
236 classification = Truth::Type::ElectronFromMuon;
237 return StatusCode::SUCCESS;
238 }
239
240
241 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
242 // Tau decays
243 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
244
245 // Non-isolated electron/photon from tau decay
248 {
249 classification = Truth::Type::TauDecay;
250 return StatusCode::SUCCESS;
251 }
252
253 // tau -> tau gamma, gamma -> e+ e-, etc
254 if ((firstMotherType == MCTruthPartClassifier::NonIsoElectron || firstMotherType == MCTruthPartClassifier::NonIsoPhoton)
255 && firstMotherOrigin == MCTruthPartClassifier::TauLep)
256 {
257 classification = Truth::Type::TauDecay;
258 return StatusCode::SUCCESS;
259 }
260
261
262 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
263 // Light hadron sources
264 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
265
267 {
268 classification = Truth::Type::LightFlavorDecay;
269 return StatusCode::SUCCESS;
270 }
271
272 if (firstMotherType == MCTruthPartClassifier::BkgElectron)
273 {
275 && (hasLightHadronOrigin(origin) || hasLightHadronOrigin(firstMotherOrigin)))
276 {
277 classification = Truth::Type::LightFlavorDecay;
278 return StatusCode::SUCCESS;
279 }
280 }
281
283 {
284 if (origin == MCTruthPartClassifier::DalitzDec || firstMotherOrigin == MCTruthPartClassifier::DalitzDec) {
285 classification = Truth::Type::LightFlavorDecay;
286 return StatusCode::SUCCESS;
287 }
288 if (hasLightHadronOrigin(origin) || hasLightHadronOrigin(firstMotherOrigin)) {
289 classification = Truth::Type::LightFlavorDecay;
290 return StatusCode::SUCCESS;
291 }
292 }
293
295 && (hasLightHadronOrigin(origin) || hasLightHadronOrigin(firstMotherOrigin)))
296 {
297 classification = Truth::Type::LightFlavorDecay;
298 return StatusCode::SUCCESS;
299 }
300
301
302 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
303 // From B hadron
304 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
305
306 if (hasBHadronOrigin(origin) || hasBHadronOrigin(firstMotherOrigin))
307 {
308 classification = Truth::Type::BHadronDecay;
309 return StatusCode::SUCCESS;
310 }
311
312 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
313 // From C hadron
314 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
315
316 if (type != MCTruthPartClassifier::IsoElectron && (hasCHadronOrigin(origin) || hasCHadronOrigin(firstMotherOrigin)))
317 {
318 classification = Truth::Type::CHadronDecay;
319 return StatusCode::SUCCESS;
320 }
321
322
323 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
324 // Prompt / Isolated electrons
325 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
326
327 if (isPromptElectron(electron, isTruthParticle, truthParticle))
328 {
329 if (m_separateChargeFlipElectrons && isChargeFlipElectron(electron, isTruthParticle, truthParticle))
330 {
331 classification = Truth::Type::ChargeFlipIsoElectron;
332 return StatusCode::SUCCESS;
333 }
334
335 classification = Truth::Type::IsoElectron;
336 return StatusCode::SUCCESS;
337 }
338
339
340 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
341 // Unknown & known Unknown
342 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
343
344 // TODO: See if we want this or not. Now we check if this is something we are
345 // able to classify or not. Note that this might be a bit dangerous because
346 // the reasons for not having origin and status codes might be complex. The
347 // main idea is to weed out things we don't have a hope of classifying due to
348 // missing or unknown information.
349 static const SG::ConstAccessor<int> statusAcc("status");
350 bool stable = (truthParticle != nullptr && statusAcc.isAvailable(*truthParticle)) ? MC::isStable(truthParticle) : false;
351
352
353 if (origin == MCTruthPartClassifier::NonDefined && firstMotherOrigin == MCTruthPartClassifier::NonDefined)
354 {
355 if (!stable)
356 {
358 {
359 classification = Truth::Type::KnownUnknown;
360 return StatusCode::SUCCESS;
361 }
362 } else {
363 if ((type == MCTruthPartClassifier::Unknown && firstMotherType == MCTruthPartClassifier::Unknown)
365 {
366 classification = Truth::Type::KnownUnknown;
367 return StatusCode::SUCCESS;
368 }
369
371 {
372 classification = Truth::Type::KnownUnknown;
373 return StatusCode::SUCCESS;
374 }
375 }
376 }
377
378 // non-iso photons with no info available to classify
379 if (type == MCTruthPartClassifier::NonIsoPhoton && origin == MCTruthPartClassifier::FSRPhot && pdgId == 22
380 && firstMotherType == 0 && firstMotherOrigin == 0 && firstMotherPdgId == 0)
381 {
382 if (lastMotherType == -1 || (lastMotherType == 0 && lastMotherOrigin == 0 && lastMotherPdgId == 0))
383 { // last_firstMotherType == -1 ==> when the last_mum info is not stored in the derivations
384 classification = Truth::Type::KnownUnknown;
385 return StatusCode::SUCCESS;
386 }
387 }
388
389 ANA_MSG_WARNING("Electron type unknown: type = " << type << ", origin = " << origin);
390
391 // debug printout
392 if (truthParticle != nullptr)
393 {
394 const xAOD::TruthParticle *parent = truthParticle;
395 ATH_MSG_DEBUG("Unknown particle decay chain (approximate):");
396 std::string out = "\t";
397 while (parent != nullptr)
398 {
399 out.append(std::to_string(parent->pdgId()));
400 parent = parent->parent(0); //AV: Note the ambiguity: only the first particle is considered.
401 if (parent) out.append(" -> ");
402 }
403 ATH_MSG_DEBUG(out);
404 }
405
406 classification = Truth::Type::Unknown;
407 return StatusCode::SUCCESS;
408}
#define ATH_MSG_DEBUG(x,...)
#define ANA_MSG_WARNING(xmsg,...)
Macro printing warning messages.
const SG::AuxElement::ConstAccessor< int > m_lastMotherTruthOrigin
const SG::AuxElement::ConstAccessor< int > m_lastMotherTruthType
const SG::AuxElement::ConstAccessor< int > m_truthPdgId
bool hasCHadronOrigin(int origin) const
a helper to check if the origin is a c-hadron
const SG::AuxElement::ConstAccessor< int > m_truthOrigin
const SG::AuxElement::ConstAccessor< float > m_fallbackDR
bool isChargeFlipElectron(const xAOD::IParticle &electron, bool isTruthParticle, const xAOD::TruthParticle *truthParticle) const
a helper to check if an electron has an incorrectly reconstructed charge
bool hasBHadronOrigin(int origin) const
a helper to check if the origin is a b-hadron
bool isPromptElectron(const xAOD::IParticle &electron, bool isTruthParticle, const xAOD::TruthParticle *truthParticle) const
a helper to check if an electron is prompt
const SG::AuxElement::ConstAccessor< int > m_firstMotherPdgId
const SG::AuxElement::ConstAccessor< int > m_firstMotherTruthOrigin
const SG::AuxElement::ConstAccessor< unsigned int > m_classifierParticleOrigin
const SG::AuxElement::ConstAccessor< int > m_firstMotherTruthType
bool hasLightHadronOrigin(int origin) const
a helper to check if the origin is a light hadron
const SG::AuxElement::ConstAccessor< int > m_truthType
const SG::AuxElement::ConstAccessor< int > m_fallbackTruthType
const SG::AuxElement::ConstAccessor< int > m_lastMotherPdgId
const SG::AuxElement::ConstAccessor< unsigned int > m_classifierParticleType
XAOD_AUXDATA_DEPRECATED bool isAvailable(const std::string &name, const std::string &clsname="") const
Check if a user property is available for reading or not.
int pdgId() const
PDG ID code.
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle &p)
Return the truthParticle associated to the given IParticle (if any).

◆ classifyMuon()

StatusCode TruthClassificationTool::classifyMuon ( const xAOD::IParticle & muon,
Truth::Type & classification ) const
private

muon classification helper

Definition at line 411 of file TruthClassificationTool.cxx.

413{
414
415
416 // Check if xAOD::TruthParticle or if not if it has the TruthParticleLink
417 const xAOD::TruthParticle *truthParticle
418 = dynamic_cast<const xAOD::TruthParticle *> (&muon);
419 bool isTruthParticle{};
420 if (truthParticle == nullptr)
421 {
422 // need to find the truth particle
423 truthParticle = xAOD::TruthHelpers::getTruthParticle(muon);
424 }
425 else
426 {
427 isTruthParticle = true;
428 }
429
430 int type = isTruthParticle ? m_classifierParticleType(muon) : m_truthType(muon);
431 int origin = isTruthParticle ? m_classifierParticleOrigin(muon) : m_truthOrigin(muon);
432 if (m_useTruthParticleDecorations && !isTruthParticle && truthParticle != nullptr)
433 {
434 type = m_classifierParticleType(*truthParticle);
435 origin = m_classifierParticleOrigin(*truthParticle);
436 }
437
438 // fallback recorations
439 int fallbackType{-1};
440 if (m_fallbackTruthType.isAvailable(muon) && m_fallbackDR.isAvailable(muon))
441 {
442 fallbackType = m_fallbackDR(muon) < 0.05 ? m_fallbackTruthType(muon) : -1;
443 }
444
445 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
446 // muons from taus
447 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
448
450 {
451 classification = Truth::Type::TauDecay;
452 return StatusCode::SUCCESS;
453 }
454
455
456 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
457 // Light hadron sources
458 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
459
461 {
462 classification = Truth::Type::LightFlavorDecay;
463 return StatusCode::SUCCESS;
464 }
465
466 if (type == MCTruthPartClassifier::Hadron || fallbackType == MCTruthPartClassifier::Hadron )
467 {
468 classification = Truth::Type::LightFlavorDecay;
469 return StatusCode::SUCCESS;
470 }
471
472
473 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
474 // From B hadron
475 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
476
477 if (hasBHadronOrigin(origin))
478 {
479 classification = Truth::Type::BHadronDecay;
480 return StatusCode::SUCCESS;
481 }
482
483 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
484 // From C hadron
485 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
486
488 {
489 classification = Truth::Type::CHadronDecay;
490 return StatusCode::SUCCESS;
491 }
492 // TODO:: There is a comment in the example code about J/psi but there is a
493 // separate origin code for that: `MCTruthPartClassifier::JPsi == 28.` --> this might not be in all samples/generators?
494
495
496 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
497 // prompt muons
498 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
499 // Check if the type of muon is IsoMuon(6) and whether the origin
500 // of the muon is from a prompt source
501 static const std::set<int> promptOrigin({
502 MCTruthPartClassifier::SingleMuon, // Single muon (origin = 2) from muon twiki
510 MCTruthPartClassifier::CCbarMeson, // PromptQuarkoniumDecay
514 });
515 if (type == MCTruthPartClassifier::IsoMuon && isInSet(origin, promptOrigin))
516 {
517 //separate charge-flip muons
518 if (m_separateChargeFlipMuons && isChargeFlipMuon(muon, isTruthParticle, truthParticle))
519 {
520 classification = Truth::Type::ChargeFlipMuon;
521 return StatusCode::SUCCESS;
522 }
523 classification = Truth::Type::PromptMuon;
524 return StatusCode::SUCCESS;
525 }
526
527
528 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
529 // Known Unknown
530 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
531
533 {
534 classification = Truth::Type::KnownUnknown;
535 return StatusCode::SUCCESS;
536 }
537
538 static const SG::ConstAccessor<int> statusAcc("status");
539 bool stable = (truthParticle != nullptr && statusAcc.isAvailable(*truthParticle)) ? MC::isStable(truthParticle) : false;
540
541 if (!stable) {
543 { // Data
544 classification = Truth::Type::KnownUnknown;
545 return StatusCode::SUCCESS;
546 }
547 if (type == -99999 && origin == -99999)
548 { // MC - no status = 1 truth particle associated with the primary track
549 classification = Truth::Type::KnownUnknown;
550 return StatusCode::SUCCESS;
551 }
552 }
553
554 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
555 // NonMuonlike
556 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
557 // Check if the type of muon is related to electrons, ie IsoElectron (2) or NonIsoElectron (3) or BkgElectron (4)
559 {
560 classification = Truth::Type::NonMuonlike;
561 return StatusCode::SUCCESS;
562 }
563
564 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
565 // TauLike, BHadLike, CHadLike
566 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
567 // Check if the matched parent of truth muon fall into these 3 xxxLike
568 // Only truth muon with one matched parent is considered
569 // If parent is tau, the muons is TauLike
570 // If parent is bhadron/b quark, the muons is BHadLike
571 // If parent is chadron/c quark, the muons is CHadLike
573 if( truthParticle != nullptr && truthParticle->nParents() == 1 && truthParticle->parent(0) != nullptr){
574 const xAOD::TruthParticle *parent = truthParticle->parent(0);
575 int parent_pdgid = parent->pdgId();
576 if(parent->isTau()){
577 classification = Truth::Type::TauDecayLike;
578 ATH_MSG_WARNING("Muon type taudecaylike: type = " << type << ", origin = " << origin << ", parent = " << parent_pdgid) ;
579 return StatusCode::SUCCESS;
580 }
581 if(parent->isBottomHadron() || parent->hasBottom()){
582 classification = Truth::Type::BHadronDecayLike;
583 ATH_MSG_WARNING("Muon type bhadrondecaylike: type = " << type << ", origin = " << origin << ", parent = " << parent_pdgid) ;
584 return StatusCode::SUCCESS;
585 }
586 if(parent->isCharmHadron() || parent->hasCharm()){
587 if( (parent_pdgid / 1000) % 10 != 0 || (parent_pdgid / 100) % 10 != 4 || (parent_pdgid / 10) % 10 != 4){ // to exclude ccbarmeson
588 classification = Truth::Type::CHadronDecayLike;
589 ATH_MSG_WARNING("Muon type chadrondecaylike: type = " << type << ", origin = " << origin << ", parent = " << parent_pdgid) ;
590 return StatusCode::SUCCESS;
591 }
592 }
593 }
594 }
595
596 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
597 // Unknown
598 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
599 classification = Truth::Type::Unknown;
600 ATH_MSG_WARNING("Muon type unknown: type = " << type << ", origin = " << origin) ;
601
602 return StatusCode::SUCCESS;
604}
#define ATH_MSG_WARNING(x,...)
if(pathvar)
bool isChargeFlipMuon(const xAOD::IParticle &muon, bool isTruthParticle, const xAOD::TruthParticle *truthParticle) const
a helper to check if a muon has an incorrectly reconstructed charge
const TruthParticle_v1 * parent(size_t i) const
Retrieve the i-th mother (TruthParticle) of this TruthParticle.
size_t nParents() const
Number of parents of this particle.

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ getKey()

SG::sgkey_t asg::AsgTool::getKey ( const void * ptr) const
inherited

Get the (hashed) key of an object that is in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::Event both provide ways for getting the SG::sgkey_t key for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getName
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The hashed key of the object in the store. If not found, an invalid (zero) key.

Definition at line 119 of file AsgTool.cxx.

119 {
120
121#ifdef XAOD_STANDALONE
122 // In case we use @c xAOD::Event, we have a direct function call
123 // for this.
124 return evtStore()->event()->getKey( ptr );
125#else
126 const SG::DataProxy* proxy = evtStore()->proxy( ptr );
127 return ( proxy == nullptr ? 0 : proxy->sgkey() );
128#endif // XAOD_STANDALONE
129 }
ServiceHandle< StoreGateSvc > & evtStore()

◆ getName()

const std::string & asg::AsgTool::getName ( const void * ptr) const
inherited

Get the name of an object that is / should be in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::Event both provide ways for getting the std::string name for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getKey
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The string name of the object in the store. If not found, an empty string.

Definition at line 106 of file AsgTool.cxx.

106 {
107
108#ifdef XAOD_STANDALONE
109 // In case we use @c xAOD::Event, we have a direct function call
110 // for this.
111 return evtStore()->event()->getName( ptr );
112#else
113 const SG::DataProxy* proxy = evtStore()->proxy( ptr );
114 static const std::string dummy = "";
115 return ( proxy == nullptr ? dummy : proxy->name() );
116#endif // XAOD_STANDALONE
117 }

◆ getProperty()

template<class T>
const T * asg::AsgTool::getProperty ( const std::string & name) const
inherited

Get one of the tool's properties.

◆ hasBHadronOrigin()

bool TruthClassificationTool::hasBHadronOrigin ( int origin) const
private

a helper to check if the origin is a b-hadron

Definition at line 733 of file TruthClassificationTool.cxx.

734{
735 static const std::set<int> b_hadrons({
739 });
740 return b_hadrons.contains(origin);
741}

◆ hasCHadronOrigin()

bool TruthClassificationTool::hasCHadronOrigin ( int origin) const
private

a helper to check if the origin is a c-hadron

Definition at line 744 of file TruthClassificationTool.cxx.

744 {
745 static const std::set<int> c_hadrons({
749 });
750 return c_hadrons.contains(origin);
751}

◆ hasLightHadronOrigin()

bool TruthClassificationTool::hasLightHadronOrigin ( int origin) const
private

◆ initialize()

virtual StatusCode asg::AsgTool::initialize ( void )
inlinevirtualinherited

Dummy implementation of the initialisation function.

It's here to allow the dual-use tools to skip defining an initialisation function. Since many are doing so...

Reimplemented in asg::DataHandleTestTool, asg::EventStoreTestTool, asg::UnitTestTool1, asg::UnitTestTool1A, asg::UnitTestTool2, asg::UnitTestTool3, AsgDeadHVCellRemovalTool, AsgElectronChargeIDSelectorTool, AsgElectronEfficiencyCorrectionTool, AsgElectronIsEMSelector, AsgElectronLikelihoodTool, AsgElectronSelectorTool, AsgForwardElectronCalibrationTool, AsgForwardElectronIsEMSelector, AsgForwardElectronLikelihoodTool, AsgForwardElectronSelectorTool, AsgHelloTool, AsgPhotonEfficiencyCorrectionTool, AsgPhotonIsEMSelector, AthAsgExUnittestTool, AthONNX::JSSMLTool, AthOnnx::OnnxRuntimeInferenceTool, AthOnnx::OnnxRuntimeSessionToolCPU, AthOnnx::OnnxRuntimeSessionToolCUDA, BaseFakeBkgTool, BDTVertexWeightCalculator, BJetCorrectionTool, BJT::qgTagger, BJT::ScaleFactors, BookkeeperDumperTool, BookkeeperTool, BoostedJetTaggerTool, BTaggingEfficiencyJsonTool, BTaggingEfficiencyTool, BTaggingEigenVectorRecompositionTool, BTaggingSelectionJsonTool, BTaggingSelectionTool, BTaggingTruthTaggingTool, CaloClusterConstituentsOrigin, CenterOfMassShapesTool, ChargedHadronSubtractionTool, ClusterAtEMScaleTool, ClusterAtMLScaleTool, ClusterMatching::CaloClusterMatchingTool, columnar::ColumnarLinkTool, columnar::ConfigurableColumnExampleTool, columnar::LinkColumnExampleTool, columnar::ModularExampleTool, columnar::MomentumAccessorExampleTool, columnar::OptionalColumnExampleTool, columnar::SimpleSelectorExampleTool, columnar::StringExampleTool, columnar::VariantExampleTool, columnar::VectorExampleTool, ConstitTimeCutTool, ConstituentSubtractorTool, CopyTruthJetParticles, CopyTruthParticles, CorrectPFOTool, CP::ApplyE2YFakeRate, CP::ApplyFakeFactor, CP::AsgFlagSelectionTool, CP::AsgMaskSelectionTool, CP::AsgMassSelectionTool, CP::AsgNumDecorationSelectionTool< T >, CP::AsgNumDecorationSelectionTool< int >, CP::AsgNumDecorationSelectionTool< uint8_t >, CP::AsgPtEtaSelectionTool, CP::AsymptMatrixTool, CP::BaseFakeBkgTool, CP::BaseLinearFakeBkgTool, CP::CalcPartonHistory, CP::EgammaCalibrationAndSmearingTool, CP::EgammaIsGoodOQSelectionTool, CP::ElectronChargeEfficiencyCorrectionTool, CP::ElectronLRTOverlapRemovalTool, CP::FFJetSmearingTool, CP::FJvtEfficiencyTool, CP::FJvtSelectionTool, CP::IsolationCloseByCorrectionTool, CP::IsolationCorrectionTool, CP::IsolationHelper, CP::IsolationLowPtPLVTool, CP::IsolationSelectionTool, CP::JetQGTagger, CP::JetQGTaggerBDT, CP::JetTileCorrectionTool, CP::JvtEfficiencyTool, CP::JvtEfficiencyToolBase, CP::JvtSelectionTool, CP::JvtSelectionToolBase, CP::LhoodMM_tools, CP::MuonCalibIntHighpTSmearTool, CP::MuonCalibIntSagittaTool, CP::MuonCalibIntScaleSmearTool, CP::MuonCalibTool, CP::MuonEfficiencyScaleFactors, CP::MuonLRTOverlapRemovalTool, CP::MuonSelectionTool, CP::MuonTriggerScaleFactors, CP::MVATrackVertexAssociationTool, CP::NNJvtEfficiencyTool, CP::NNJvtSelectionTool, CP::PhotonPointingTool, CP::PhotonVertexSelectionTool, CP::PileupReweightingTool, CP::TrackVertexAssociationTool, D3PD::D3PDMCTruthClassifier, Diagram, DiTauMassTools::MissingMassTool, dRMatchingTool, ECUtils::EventCleaningTool, EfficiencyResponseHistos, EGammaAmbiguityTool, egammaMVACalibTool, egammaTransformerCalibTool, EL::UnitTestTool, ElectronPhotonVariableCorrectionBase, ElectronPhotonVariableCorrectionTool, ElectronPhotonVariableNFCorrectionTool, EnergyCorrelatorGeneralizedRatiosTool, EnergyCorrelatorGeneralizedTool, EnergyCorrelatorRatiosTool, EnergyCorrelatorTool, EnhancedBiasWeighter, EtaJESCalibStep, EventDensityTool, EventShapeCopier, ExtendTrackToLayerTool, FastJetInterfaceTool, FlavorTagDiscriminants::DL2Tool, FlavorTagDiscriminants::TrackClassifier, FlavorTagDiscriminants::VRJetOverlapDecoratorTool, FlavorTagInference::GNNTool, FlavorTagInference::MultifoldGNNTool, FSR::FsrPhotonTool, FtagLargeRJetTruthLabelTool, Generic4VecCorrectionStep, GoodRunsListSelectionTool, GSCCalibStep, HI::HIEventSelectionTool, HI::HIEventSelectionToolRun3, HI::HIPileupTool, HI::HIVertexSelectionTool, HIClusterSubtraction, HIEfficiencyResponseHistos, HIEventShapeFillerTool, HIEventShapeJetIteration, HIEventShapeMapTool, HIEventShapeSummaryTool, HiggsTruthCategoryTool, HIJetClusterIndexAssociationTool, HIJetClusterSubtractorTool, HIJetConstituentModifierTool, HIJetConstituentSubtractionTool, HIJetDRAssociationTool, HIJetMaxOverMeanTool, HIJetSignificanceTool, HIJetUEMonitoring, HistoDefinitionTool, HistoGroupBase, HistosForJetSelection, HIUEModulatorTool, IDTPM::DeltaRMatchingToolBase< T, R >, IDTPM::DeltaRMatchingToolBase< xAOD::TrackParticle >, IDTPM::DeltaRMatchingToolBase< xAOD::TrackParticle, xAOD::TruthParticle >, IDTPM::DeltaRMatchingToolBase< xAOD::TruthParticle, xAOD::TrackParticle >, IDTPM::EFTrackMatchingTool, IDTPM::JsonPlotsDefReadTool, IDTPM::OfflineTrackQualitySelectionTool, IDTPM::RoiSelectionTool, IDTPM::StableDeltaRMatchingTool< T, R >, IDTPM::StableDeltaRMatchingTool< xAOD::TrackParticle, xAOD::TrackParticle >, IDTPM::StableDeltaRMatchingTool< xAOD::TrackParticle, xAOD::TruthParticle >, IDTPM::StableDeltaRMatchingTool< xAOD::TruthParticle, xAOD::TrackParticle >, IDTPM::TrackAnalysisInfoWriteTool, IDTPM::TrackObjectSelectionTool, IDTPM::TrackQualitySelectionTool, IDTPM::TrackRoiSelectionTool, IDTPM::TrackTruthMatchingTool, IDTPM::TruthQualitySelectionTool, IDTPM::TruthTrackMatchingTool, IDTPM::VertexQualitySelectionTool, IDTPM::VertexRoiSelectionTool, IHIEventShapeMapTool, InDet::InclusiveTrackFilterTool, InDet::InDetHardScatterSelectionTool, InDet::InDetSecVtxTrackSelectionTool, InDet::InDetTrackBiasingTool, InDet::InDetTrackSelectionTool, InDet::InDetTrackSmearingTool, InDet::InDetTrackSystematicsTool, InDet::InDetTrackTruthFilterTool, InDet::InDetTrackTruthOriginTool, InDet::InDetUsedInFitTrackDecoratorTool, InDet::JetTrackFilterTool, InDetGNNHardScatterSelection::GNNTool, InDetSecVtxTruthMatchTool, InDetVertexTruthMatchTool, InSituCalibStep, InSituJMSCalibStep, JetAttributeHisto, JetAttributeRatioSelector, JetAttributeSelector, JetBadChanCorrTool, JetBalancePFlowJvtTool, JetBottomUpSoftDrop, JetCalibrationTool, JetCalibTool, JetCaloCellQualityTool, JetCaloEnergies, JetCaloQualityTool, JetCaloQualityToolFE, JetCleaningTool, JetClusterer, JetClustererByVertex, JetClusterMomentsTool, JetConstitFourMomTool, JetConstituentFrac, JetConstituentModSequence, JetConstituentsRetriever, JetContainerHistoFiller, JetCopier, JetDNNCalibStep, JetDRTrackAssocTool, JetECPSFractionTool, JetEMScaleMomTool, JetEventSelector, JetFinder, JetForwardJvtTool, JetForwardJvtToolBDT, JetForwardPFlowJvtTool, JetFromPseudojet, JetGrooming::JetGroomer, JetGrooming::JetTrimming, JetGrooming::RecSoftDrop, JetGrooming::SoftDrop, JetGroomMRatio, JetHelper::HistoInput1D, JetHelper::HistoInput2D, JetHelper::HistoInput3D, JetHelper::VarTool, JetHistoBase, JetInputElRemovalTool, JetIRCSafeLabelTool, JetIsolationTool, JetLArHVTool, JetModifiedMassDrop, JetNumConstitTool, JetOriginCorrectionTool, JetParticleAssociation, JetPileupLabelingTool, JetPileupTag::JetVertexNNTagger, JetPruner, JetPseudojetCopier, JetPseudojetRetriever, JetPtAssociationTool, JetQGTaggerVariableTool, JetQuarkChargeLabelingTool, JetReclusterer, JetReclusteringTool, JetRecTool, JetRecursiveSoftDrop, JetResponseTool, JetSelectorAttribute, JetSelectorAttributeRunII, JetSoftDrop, JetSplitter, JetSubStructureMomentToolsBase, JetToolRunner, JetTrackMomentsTool, JetTrackSumMomentsTool, JetTrimmer, JetTruthLabelingTool, JetTruthParticleSelectorTool, JetUncertaintiesTool, JetUsedInFitTrackDecoratorTool, JetVertexFractionTool, JetVertexTaggerTool, JetVoronoiDiagramHelpers::Diagram, JetVoronoiMomentsTool, JetWidthTool, JMSCalibStep, JSSTaggerBase, JSSTaggerUtils, JSSWTopTaggerANN, JSSWTopTaggerDNN, KTSplittingScaleTool, LeadingJetsRelations, LundNetTagger, LVL1::L1CaloCells2TriggerTowers, LVL1::L1CaloFcal23Cells2RxMappingTool, LVL1::L1CaloLArTowerEnergy, LVL1::L1CaloMonitoringCaloTool, LVL1::L1CaloOfflineTriggerTowerTools, LVL1::L1CaloTTIdTools, LVL1::L1CaloxAODOfflineTriggerTowerTools, LVL1::TrigT1CaloMonErrorTool, LVL1::TrigT1CaloMonErrorToolV1, LVL1BS::PpmByteStreamReadV1V2Tool, LVL1BS::TrigT1CaloDataAccessV2, MBTSTimeFilterTool, MCTruthClassifier, met::ColumnarMETMaker, met::METAssociationTool, met::METAssociator, met::METBuilderTool, met::METCaloRegionsTool, met::METEgammaAssociator, met::METElectronAssociator, met::METJetAssocTool, met::METJetTool, met::METMaker, met::METMuonAssociator, met::METNet, met::METNetSig, met::METPhotonAssociator, met::METRecoTool, met::METRefinerTool, met::METRegionsTool, met::METSignificance, met::METSoftAssociator, met::METSoftTermsTool, met::METSystematicsTool, met::METTauAssociator, met::METTrackFilterTool, met::METTruthAssociator, met::METTruthTool, MissingCellListTool, MvaTESEvaluator, MvaTESVariableDecorator, NSubjettinessRatiosTool, NSubjettinessTool, ORUtils::BaseOverlapTool, ORUtils::FEAssociationTool, ORUtils::OverlapRemovalTool, PanTau::PanTauProcessor, PanTau::Tool_DecayModeDeterminator, PanTau::Tool_DetailsArranger, PanTau::Tool_FeatureExtractor, PanTau::Tool_InformationStore, PanTau::Tool_InputConverter, PanTau::Tool_ModeDiscriminator, PanTau::Tool_TauConstituentGetter, PanTau::Tool_TauConstituentSelector, ParticleJetDeltaRLabelTool, ParticleJetGhostLabelTool, ParticleScaleFactorTool, PDFWeight, PhotonIDBDT::AsgPhotonBDTSelector, PhotonIDBDT::PhotonBDTCalculator, PhotonIDBDT::PhotonSingleBDTCalculator, Pileup1DResidualCalibStep, PileupCalibStep, PMGTools::PMGCrossSectionTool, PMGTools::PMGDecayProductsSelectionTool, PMGTools::PMGHFProductionFractionTool, PMGTools::PMGSherpa22VJetsWeightTool, PMGTools::PMGSherpaVjetsSysTool, PMGTools::PMGTruthWeightTool, PuppiWeightTool, QwTool, Ringer::AsgRingerSelectorTool, SimpleMuonTriggerScaleFactors, SmearingCalibStep, SmoothedTopTagger, SmoothedWZTagger, SoftKillerWeightTool, ST::SUSYObjDef_xAOD, TauAnalysisTools::BuildTruthTaus, TauAnalysisTools::CommonDiTauEfficiencyTool, TauAnalysisTools::CommonDiTauSmearingTool, TauAnalysisTools::CommonEfficiencyTool, TauAnalysisTools::CommonSmearingTool, TauAnalysisTools::DiTauEfficiencyCorrectionsTool, TauAnalysisTools::DiTauSelectionTool, TauAnalysisTools::DiTauSmearingTool, TauAnalysisTools::DiTauTruthMatchingTool, TauAnalysisTools::TauEfficiencyCorrectionsTool, TauAnalysisTools::TauSelectionTool, TauAnalysisTools::TauSmearingTool, TauAnalysisTools::TauTruthMatchingTool, TauAnalysisTools::TauTruthTrackMatchingTool, TauAODMuonRemovalTool, TauCalibrateLC, TauCombinedTES, TauDecayModeNNClassifier, TauElectronVetoVariables, TauEleOverlapChecker, TauGNNEvaluator, TauJetRNNEvaluator, TauPi0CreateROI, TauPi0ScoreCalculator, TauRecToolBase, tauRecTools::TauTrackRNNClassifier, tauRecTools::TrackRNN, TauShotFinder, TauTrackFinder, TauVertexedClusterDecorator, TauVertexFinder, TauVertexVariables, TauWPDecorator, TrackTruthSelectionTool, TrackVertexAssociationTool, Trig::DRScoringTool, Trig::EgammaDRScoringTool, Trig::IParticleRetrievalTool, Trig::JetManagerTool, Trig::MatchFromCompositeTool, Trig::MatchingTool, Trig::R3IParticleRetrievalTool, Trig::R3MatchingTool, Trig::StaticBunchCrossingTool, Trig::TrigConfBunchCrossingTool, Trig::TrigDecisionTool, Trig::TrigDecisionToolLite, Trig::TrigEgammaEmulationBaseHypoTool, Trig::TrigEgammaEmulationChain, Trig::TrigEgammaEmulationFastCaloHypoTool, Trig::TrigEgammaEmulationPrecisionElectronHypoTool, Trig::TrigEgammaEmulationPrecisionPhotonHypoTool, Trig::TrigEgammaEmulationToolMT, Trig::TrigMuonMatching, Trig::TypedScoringTool, Trig::xAODBunchCrossingTool, TrigConf::xAODConfigTool, TrigEgammaMatchingToolMT, TrigFastCalibWithRings, TrigGlobalEfficiencyCorrectionTool, Validator, VoronoiWeightTool, WeightsAgregator, WeightToolBase, xAOD::BPhysBlindingTool, xAOD::BPhysTrackVertexMapTool, xAOD::CaloIsolationTool, xAOD::TrackIsolationTool, xAODMaker::TriggerMenuMetaDataTool, xAODMaker::TruthMetaDataTool, xAODtoHepMCTool, ZDC::LISAnalysisTool, ZDC::RPDAnalysisTool, ZDC::RpdSubtractCentroidTool, ZDC::ZdcAnalysisTool, ZDC::ZdcLEDAnalysisTool, ZDC::ZdcRecTool, ZDC::ZdcTrigValidTool, ZdcByteStreamReadV1V2Tool, ZdcDataAccessV2, ZdcRecChannelToolLucrod, ZdcRecChannelToolV2, and ZMassConstraint::ConstraintFit.

Definition at line 133 of file AsgTool.h.

133{ return StatusCode::SUCCESS; }

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ isChargeFlipElectron()

bool TruthClassificationTool::isChargeFlipElectron ( const xAOD::IParticle & electron,
bool isTruthParticle,
const xAOD::TruthParticle * truthParticle ) const
private

a helper to check if an electron has an incorrectly reconstructed charge

Definition at line 654 of file TruthClassificationTool.cxx.

657{
658
659
660 int type = isTruthParticle ? m_classifierParticleType(electron) : m_truthType(electron);
661 int origin = isTruthParticle ? m_classifierParticleOrigin(electron) : m_truthOrigin(electron);
662 int pdgId = isTruthParticle && truthParticle ? truthParticle->pdgId() : m_truthPdgId(electron);
663 if (m_useTruthParticleDecorations && !isTruthParticle && truthParticle != nullptr)
664 {
665 type = m_classifierParticleType(*truthParticle);
666 origin = m_classifierParticleOrigin(*truthParticle);
667 }
668
669 int firstMotherType = m_firstMotherTruthType(electron);
670 int firstMotherOrigin = m_firstMotherTruthOrigin(electron);
671 int firstMotherPdgId = m_firstMotherPdgId(electron);
672
673 // not consider FSR photons from electrons (the photon has no charge)
674 if (origin == MCTruthPartClassifier::FSRPhot && type == MCTruthPartClassifier::NonIsoPhoton && std::abs(pdgId) == 11)
675 {
676 return false;
677 }
679 && firstMotherType == MCTruthPartClassifier::NonIsoPhoton && firstMotherOrigin == MCTruthPartClassifier::FSRPhot
680 && std::abs(pdgId) == 11)
681 {
682 return false;
683 }
684
685 // bkg electrons with no additional info to help us classify them FSR -- not in the charge flip category
687 && firstMotherType == MCTruthPartClassifier::BkgElectron && firstMotherOrigin == MCTruthPartClassifier::PhotonConv
688 && std::abs(pdgId) == 11)
689 {
690 return false;
691 }
692
693 if (isTruthParticle)
694 {
695 if (truthParticle && truthParticle->charge() != 0)
696 {
697 return (firstMotherPdgId * truthParticle->charge()) > 0;
698 }
699 }
700 else
701 {
702 const xAOD::Electron &xAODElectron = *static_cast<const xAOD::Electron *> (&electron);
703 if (xAODElectron.charge() != 0)
704 {
705 return (firstMotherPdgId * xAODElectron.charge()) > 0;
706 }
707 }
708
709 return (firstMotherPdgId * (-pdgId)) > 0;
710}
float charge() const
Obtain the charge of the object.
double charge() const
Physical charge.

◆ isChargeFlipMuon()

bool TruthClassificationTool::isChargeFlipMuon ( const xAOD::IParticle & muon,
bool isTruthParticle,
const xAOD::TruthParticle * truthParticle ) const
private

a helper to check if a muon has an incorrectly reconstructed charge

Definition at line 713 of file TruthClassificationTool.cxx.

716{
717 if (isTruthParticle)
718 {
719 return false;
720 }
721
722 if (truthParticle != nullptr && xAOD::P4Helpers::isInDeltaR(*truthParticle, muon, 0.025))
723 {
724 const xAOD::Muon &xAODMuon = *static_cast<const xAOD::Muon *> (&muon);
725 return (truthParticle->charge() * xAODMuon.charge()) < 0;
726 }
727
728 ANA_MSG_DEBUG("Cannot find associated truth-particle... assuming muon has correct charge");
729 return false;
730}
#define ANA_MSG_DEBUG(xmsg,...)
Macro printing debug messages.
float charge() const
bool isInDeltaR(const xAOD::IParticle &p1, const xAOD::IParticle &p2, double dR, bool useRapidity=true)
Check if 2 xAOD::IParticle are in a cone.

◆ isPromptElectron()

bool TruthClassificationTool::isPromptElectron ( const xAOD::IParticle & electron,
bool isTruthParticle,
const xAOD::TruthParticle * truthParticle ) const
private

a helper to check if an electron is prompt

Definition at line 606 of file TruthClassificationTool.cxx.

609{
610
611
612 int type = isTruthParticle ? m_classifierParticleType(electron) : m_truthType(electron);
613 int origin = isTruthParticle ? m_classifierParticleOrigin(electron) : m_truthOrigin(electron);
614 if (m_useTruthParticleDecorations && !isTruthParticle && truthParticle != nullptr)
615 {
616 type = m_classifierParticleType(*truthParticle);
617 origin = m_classifierParticleOrigin(*truthParticle);
618 }
619
620 // Electron is IsoElectron - return true
622 {
623 return true;
624 }
625
626 int pdgId = isTruthParticle ? truthParticle->pdgId() : m_truthPdgId(electron);
627 int firstMotherType = m_firstMotherTruthType(electron);
628 int firstMotherOrigin = m_firstMotherTruthOrigin(electron);
629
630 // Adding these cases from ElectronEfficiencyHelpers
631 if (firstMotherType == MCTruthPartClassifier::IsoElectron && std::abs(m_firstMotherPdgId(electron)) == 11)
632 {
633 return true;
634 }
635
636 // FSR photons from electrons
637 if (origin == MCTruthPartClassifier::FSRPhot && type == MCTruthPartClassifier::NonIsoPhoton && std::abs(pdgId) == 11)
638 {
639 return true;
640 }
641
643 && firstMotherType == MCTruthPartClassifier::NonIsoPhoton && firstMotherOrigin == MCTruthPartClassifier::FSRPhot
644 && std::abs(pdgId) == 11)
645 {
646 return true;
647 }
648
649 // If we reach here then it is not a prompt electron
650 return false;
651}

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msg_level_name()

const std::string & asg::AsgTool::msg_level_name ( ) const
inherited

A deprecated function for getting the message level's name.

Instead of using this, weirdly named function, user code should get the string name of the current minimum message level (in case they really need it...), with:

MSG::name( msg().level() )

This function's name doesn't follow the ATLAS coding rules, and as such will be removed in the not too distant future.

Returns
The string name of the current minimum message level that's printed

Definition at line 101 of file AsgTool.cxx.

101 {
102
103 return MSG::name( msg().level() );
104 }
MsgStream & msg() const
const std::string & name(Level lvl)
Convenience function for translating message levels to strings.
Definition MsgLevel.cxx:19

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ print()

void asg::AsgTool::print ( ) const
virtualinherited

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, and AthCheckedComponent<::AthAlgTool >.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_classifierParticleOrigin

const SG::AuxElement::ConstAccessor<unsigned int> TruthClassificationTool::m_classifierParticleOrigin {"classifierParticleOrigin"}
private

Definition at line 55 of file TruthClassificationTool.h.

55{"classifierParticleOrigin"};

◆ m_classifierParticleType

const SG::AuxElement::ConstAccessor<unsigned int> TruthClassificationTool::m_classifierParticleType {"classifierParticleType"}
private

Definition at line 54 of file TruthClassificationTool.h.

54{"classifierParticleType"};

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 390 of file AthCommonDataStore.h.

◆ m_fallbackDR

const SG::AuxElement::ConstAccessor<float> TruthClassificationTool::m_fallbackDR {"TruthClassifierFallback_dR"}
private

Definition at line 67 of file TruthClassificationTool.h.

67{"TruthClassifierFallback_dR"};

◆ m_fallbackTruthClassification

const SG::AuxElement::ConstAccessor<int> TruthClassificationTool::m_fallbackTruthClassification {"TruthClassifierFallback_truthClassification"}
private

Definition at line 66 of file TruthClassificationTool.h.

66{"TruthClassifierFallback_truthClassification"};

◆ m_fallbackTruthOrigin

const SG::AuxElement::ConstAccessor<int> TruthClassificationTool::m_fallbackTruthOrigin {"TruthClassifierFallback_truthOrigin"}
private

Definition at line 65 of file TruthClassificationTool.h.

65{"TruthClassifierFallback_truthOrigin"};

◆ m_fallbackTruthType

const SG::AuxElement::ConstAccessor<int> TruthClassificationTool::m_fallbackTruthType {"TruthClassifierFallback_truthType"}
private

Definition at line 64 of file TruthClassificationTool.h.

64{"TruthClassifierFallback_truthType"};

◆ m_firstMotherPdgId

const SG::AuxElement::ConstAccessor<int> TruthClassificationTool::m_firstMotherPdgId {"firstEgMotherPdgId"}
private

Definition at line 59 of file TruthClassificationTool.h.

59{"firstEgMotherPdgId"};

◆ m_firstMotherTruthClassification

const SG::AuxElement::ConstAccessor<unsigned int> TruthClassificationTool::m_firstMotherTruthClassification {"firstEgMotherTruthClassification"}
private

Definition at line 58 of file TruthClassificationTool.h.

58{"firstEgMotherTruthClassification"};

◆ m_firstMotherTruthOrigin

const SG::AuxElement::ConstAccessor<int> TruthClassificationTool::m_firstMotherTruthOrigin {"firstEgMotherTruthOrigin"}
private

Definition at line 57 of file TruthClassificationTool.h.

57{"firstEgMotherTruthOrigin"};

◆ m_firstMotherTruthType

const SG::AuxElement::ConstAccessor<int> TruthClassificationTool::m_firstMotherTruthType {"firstEgMotherTruthType"}
private

Definition at line 56 of file TruthClassificationTool.h.

56{"firstEgMotherTruthType"};

◆ m_lastMotherPdgId

const SG::AuxElement::ConstAccessor<int> TruthClassificationTool::m_lastMotherPdgId {"lastEgMotherPdgId"}
private

Definition at line 63 of file TruthClassificationTool.h.

63{"lastEgMotherPdgId"};

◆ m_lastMotherTruthClassification

const SG::AuxElement::ConstAccessor<unsigned int> TruthClassificationTool::m_lastMotherTruthClassification {"lastEgMotherTruthClassification"}
private

Definition at line 62 of file TruthClassificationTool.h.

62{"lastEgMotherTruthClassification"};

◆ m_lastMotherTruthOrigin

const SG::AuxElement::ConstAccessor<int> TruthClassificationTool::m_lastMotherTruthOrigin {"lastEgMotherTruthOrigin"}
private

Definition at line 61 of file TruthClassificationTool.h.

61{"lastEgMotherTruthOrigin"};

◆ m_lastMotherTruthType

const SG::AuxElement::ConstAccessor<int> TruthClassificationTool::m_lastMotherTruthType {"lastEgMotherTruthType"}
private

Definition at line 60 of file TruthClassificationTool.h.

60{"lastEgMotherTruthType"};

◆ m_separateChargeFlipElectrons

bool TruthClassificationTool::m_separateChargeFlipElectrons = false
private

separately store charge-flip electrons/muons

Definition at line 43 of file TruthClassificationTool.h.

◆ m_separateChargeFlipMuons

bool TruthClassificationTool::m_separateChargeFlipMuons = false
private

Definition at line 44 of file TruthClassificationTool.h.

◆ m_truthClassification

const SG::AuxElement::ConstAccessor<unsigned int> TruthClassificationTool::m_truthClassification {"truthClassification"}
private

Definition at line 52 of file TruthClassificationTool.h.

52{"truthClassification"};

◆ m_truthOrigin

const SG::AuxElement::ConstAccessor<int> TruthClassificationTool::m_truthOrigin {"truthOrigin"}
private

Definition at line 51 of file TruthClassificationTool.h.

51{"truthOrigin"};

◆ m_truthPdgId

const SG::AuxElement::ConstAccessor<int> TruthClassificationTool::m_truthPdgId {"truthPdgId"}
private

Definition at line 53 of file TruthClassificationTool.h.

53{"truthPdgId"};

◆ m_truthType

const SG::AuxElement::ConstAccessor<int> TruthClassificationTool::m_truthType {"truthType"}
private

Definition at line 50 of file TruthClassificationTool.h.

50{"truthType"};

◆ m_useTruthParticleDecorations

bool TruthClassificationTool::m_useTruthParticleDecorations {false}
private

use truth particle decorations

Definition at line 47 of file TruthClassificationTool.h.

47{false};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: