18 bool isInSet(
int origin,
const std::set<int> &s)
20 return s.find(origin) !=
s.end();
35 unsigned int &classification)
const
39 classification =
static_cast<int>(
type);
40 return StatusCode::SUCCESS;
52 else if (
dynamic_cast<const xAOD::Muon *
> (&particle) || (truthParticle !=
nullptr &&
MC::isMuon(truthParticle)))
59 return StatusCode::FAILURE;
62 return StatusCode::SUCCESS;
73 bool isTruthParticle{};
74 if (truthParticle ==
nullptr)
81 isTruthParticle =
true;
84 if (!
m_truthPdgId.isAvailable(electron) && !isTruthParticle)
86 ANA_MSG_ERROR(
"Electron does not have the 'truthPdgId' decoration.");
87 return StatusCode::FAILURE;
94 ANA_MSG_ERROR(
"Electron does not have one or more 'firstEgMother' decorations.");
95 return StatusCode::FAILURE;
115 int fallbackType{-1};
130 classification = Truth::Type::PromptPhotonConversion;
131 return StatusCode::SUCCESS;
138 classification = Truth::Type::PromptPhotonConversion;
139 return StatusCode::SUCCESS;
146 classification = Truth::Type::PromptPhotonConversion;
147 return StatusCode::SUCCESS;
155 classification = Truth::Type::PromptPhotonConversion;
156 return StatusCode::SUCCESS;
162 classification = Truth::Type::PromptPhotonConversion;
163 return StatusCode::SUCCESS;
169 classification = Truth::Type::PromptPhotonConversion;
170 return StatusCode::SUCCESS;
178 classification = Truth::Type::PromptPhotonConversion;
179 return StatusCode::SUCCESS;
184 classification = Truth::Type::PromptPhotonConversion;
185 return StatusCode::SUCCESS;
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;
207 && std::abs(firstMotherPdgId) == 11 && std::abs(pdgId) == 11)
212 classification = Truth::Type::PromptPhotonConversion;
213 return StatusCode::SUCCESS;
225 classification = Truth::Type::ElectronFromMuon;
226 return StatusCode::SUCCESS;
231 classification = Truth::Type::ElectronFromMuon;
232 return StatusCode::SUCCESS;
236 classification = Truth::Type::ElectronFromMuon;
237 return StatusCode::SUCCESS;
249 classification = Truth::Type::TauDecay;
250 return StatusCode::SUCCESS;
257 classification = Truth::Type::TauDecay;
258 return StatusCode::SUCCESS;
268 classification = Truth::Type::LightFlavorDecay;
269 return StatusCode::SUCCESS;
277 classification = Truth::Type::LightFlavorDecay;
278 return StatusCode::SUCCESS;
285 classification = Truth::Type::LightFlavorDecay;
286 return StatusCode::SUCCESS;
289 classification = Truth::Type::LightFlavorDecay;
290 return StatusCode::SUCCESS;
297 classification = Truth::Type::LightFlavorDecay;
298 return StatusCode::SUCCESS;
308 classification = Truth::Type::BHadronDecay;
309 return StatusCode::SUCCESS;
318 classification = Truth::Type::CHadronDecay;
319 return StatusCode::SUCCESS;
331 classification = Truth::Type::ChargeFlipIsoElectron;
332 return StatusCode::SUCCESS;
335 classification = Truth::Type::IsoElectron;
336 return StatusCode::SUCCESS;
350 bool stable = (truthParticle !=
nullptr && statusAcc.
isAvailable(*truthParticle)) ?
MC::isStable(truthParticle) :
false;
359 classification = Truth::Type::KnownUnknown;
360 return StatusCode::SUCCESS;
366 classification = Truth::Type::KnownUnknown;
367 return StatusCode::SUCCESS;
372 classification = Truth::Type::KnownUnknown;
373 return StatusCode::SUCCESS;
380 && firstMotherType == 0 && firstMotherOrigin == 0 && firstMotherPdgId == 0)
382 if (lastMotherType == -1 || (lastMotherType == 0 && lastMotherOrigin == 0 && lastMotherPdgId == 0))
384 classification = Truth::Type::KnownUnknown;
385 return StatusCode::SUCCESS;
392 if (truthParticle !=
nullptr)
395 ATH_MSG_DEBUG(
"Unknown particle decay chain (approximate):");
396 std::string out =
"\t";
397 while (parent !=
nullptr)
399 out.append(std::to_string(parent->pdgId()));
400 parent = parent->parent(0);
401 if (parent) out.append(
" -> ");
406 classification = Truth::Type::Unknown;
407 return StatusCode::SUCCESS;
419 bool isTruthParticle{};
420 if (truthParticle ==
nullptr)
427 isTruthParticle =
true;
439 int fallbackType{-1};
451 classification = Truth::Type::TauDecay;
452 return StatusCode::SUCCESS;
462 classification = Truth::Type::LightFlavorDecay;
463 return StatusCode::SUCCESS;
468 classification = Truth::Type::LightFlavorDecay;
469 return StatusCode::SUCCESS;
479 classification = Truth::Type::BHadronDecay;
480 return StatusCode::SUCCESS;
489 classification = Truth::Type::CHadronDecay;
490 return StatusCode::SUCCESS;
501 static const std::set<int> promptOrigin({
520 classification = Truth::Type::ChargeFlipMuon;
521 return StatusCode::SUCCESS;
523 classification = Truth::Type::PromptMuon;
524 return StatusCode::SUCCESS;
534 classification = Truth::Type::KnownUnknown;
535 return StatusCode::SUCCESS;
539 bool stable = (truthParticle !=
nullptr && statusAcc.
isAvailable(*truthParticle)) ?
MC::isStable(truthParticle) :
false;
544 classification = Truth::Type::KnownUnknown;
545 return StatusCode::SUCCESS;
547 if (
type == -99999 && origin == -99999)
549 classification = Truth::Type::KnownUnknown;
550 return StatusCode::SUCCESS;
560 classification = Truth::Type::NonMuonlike;
561 return StatusCode::SUCCESS;
573 if( truthParticle !=
nullptr && truthParticle->
nParents() == 1 && truthParticle->
parent(0) !=
nullptr){
575 int parent_pdgid = parent->pdgId();
577 classification = Truth::Type::TauDecayLike;
578 ATH_MSG_WARNING(
"Muon type taudecaylike: type = " <<
type <<
", origin = " << origin <<
", parent = " << parent_pdgid) ;
579 return StatusCode::SUCCESS;
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;
586 if(parent->isCharmHadron() || parent->hasCharm()){
587 if( (parent_pdgid / 1000) % 10 != 0 || (parent_pdgid / 100) % 10 != 4 || (parent_pdgid / 10) % 10 != 4){
588 classification = Truth::Type::CHadronDecayLike;
589 ATH_MSG_WARNING(
"Muon type chadrondecaylike: type = " <<
type <<
", origin = " << origin <<
", parent = " << parent_pdgid) ;
590 return StatusCode::SUCCESS;
599 classification = Truth::Type::Unknown;
602 return StatusCode::SUCCESS;
607 bool isTruthParticle,
644 && std::abs(pdgId) == 11)
655 bool isTruthParticle,
662 int pdgId = isTruthParticle && truthParticle ? truthParticle->
pdgId() :
m_truthPdgId(electron);
680 && std::abs(pdgId) == 11)
688 && std::abs(pdgId) == 11)
695 if (truthParticle && truthParticle->
charge() != 0)
697 return (firstMotherPdgId * truthParticle->
charge()) > 0;
703 if (xAODElectron.
charge() != 0)
705 return (firstMotherPdgId * xAODElectron.
charge()) > 0;
709 return (firstMotherPdgId * (-pdgId)) > 0;
714 bool isTruthParticle,
725 return (truthParticle->
charge() * xAODMuon.
charge()) < 0;
728 ANA_MSG_DEBUG(
"Cannot find associated truth-particle... assuming muon has correct charge");
735 static const std::set<int> b_hadrons({
740 return b_hadrons.contains(origin);
745 static const std::set<int> c_hadrons({
750 return c_hadrons.contains(origin);
755 static const std::set<int> light_source({
764 return light_source.contains(origin);
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
ATLAS-specific HepMC functions.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Helper class to provide constant type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
float charge() const
Obtain the charge of the object.
Class providing the definition of the 4-vector interface.
int pdgId() const
PDG ID code.
const TruthParticle_v1 * parent(size_t i) const
Retrieve the i-th mother (TruthParticle) of this TruthParticle.
double charge() const
Physical charge.
size_t nParents() const
Number of parents of this particle.
bool isElectron(const T &p)
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
Type
truth classification type enum
bool isInDeltaR(const xAOD::IParticle &p1, const xAOD::IParticle &p2, double dR, bool useRapidity=true)
Check if 2 xAOD::IParticle are in a cone.
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle &p)
Return the truthParticle associated to the given IParticle (if any).
TruthParticle_v1 TruthParticle
Typedef to implementation.
Muon_v1 Muon
Reference the current persistent version:
Electron_v1 Electron
Definition of the current "egamma version".