17 bool isInSet(
int origin,
const std::set<int> &s)
19 return s.find(origin) !=
s.end();
34 unsigned int &classification)
const
38 classification =
static_cast<int>(
type);
39 return StatusCode::SUCCESS;
51 else if (
dynamic_cast<const xAOD::Muon *
> (&particle) || (truthParticle !=
nullptr &&
MC::isMuon(truthParticle)))
58 return StatusCode::FAILURE;
61 return StatusCode::SUCCESS;
72 bool isTruthParticle{};
73 if (truthParticle ==
nullptr)
80 isTruthParticle =
true;
83 if (!
m_truthPdgId.isAvailable(electron) && !isTruthParticle)
85 ANA_MSG_ERROR(
"Electron does not have the 'truthPdgId' decoration.");
86 return StatusCode::FAILURE;
93 ANA_MSG_ERROR(
"Electron does not have one or more 'firstEgMother' decorations.");
94 return StatusCode::FAILURE;
114 int fallbackType{-1};
129 classification = Truth::Type::PromptPhotonConversion;
130 return StatusCode::SUCCESS;
137 classification = Truth::Type::PromptPhotonConversion;
138 return StatusCode::SUCCESS;
145 classification = Truth::Type::PromptPhotonConversion;
146 return StatusCode::SUCCESS;
154 classification = Truth::Type::PromptPhotonConversion;
155 return StatusCode::SUCCESS;
161 classification = Truth::Type::PromptPhotonConversion;
162 return StatusCode::SUCCESS;
168 classification = Truth::Type::PromptPhotonConversion;
169 return StatusCode::SUCCESS;
177 classification = Truth::Type::PromptPhotonConversion;
178 return StatusCode::SUCCESS;
183 classification = Truth::Type::PromptPhotonConversion;
184 return StatusCode::SUCCESS;
196 ANA_MSG_WARNING(
"Electron identified as from a PromptPhotonConversion, "
197 "but this type of electron needs further study!");
198 classification = Truth::Type::PromptPhotonConversion;
199 return StatusCode::SUCCESS;
206 && std::abs(firstMotherPdgId) == 11 && std::abs(pdgId) == 11)
211 classification = Truth::Type::PromptPhotonConversion;
212 return StatusCode::SUCCESS;
224 classification = Truth::Type::ElectronFromMuon;
225 return StatusCode::SUCCESS;
230 classification = Truth::Type::ElectronFromMuon;
231 return StatusCode::SUCCESS;
235 classification = Truth::Type::ElectronFromMuon;
236 return StatusCode::SUCCESS;
248 classification = Truth::Type::TauDecay;
249 return StatusCode::SUCCESS;
256 classification = Truth::Type::TauDecay;
257 return StatusCode::SUCCESS;
267 classification = Truth::Type::LightFlavorDecay;
268 return StatusCode::SUCCESS;
276 classification = Truth::Type::LightFlavorDecay;
277 return StatusCode::SUCCESS;
284 classification = Truth::Type::LightFlavorDecay;
285 return StatusCode::SUCCESS;
288 classification = Truth::Type::LightFlavorDecay;
289 return StatusCode::SUCCESS;
296 classification = Truth::Type::LightFlavorDecay;
297 return StatusCode::SUCCESS;
307 classification = Truth::Type::BHadronDecay;
308 return StatusCode::SUCCESS;
317 classification = Truth::Type::CHadronDecay;
318 return StatusCode::SUCCESS;
330 classification = Truth::Type::ChargeFlipIsoElectron;
331 return StatusCode::SUCCESS;
334 classification = Truth::Type::IsoElectron;
335 return StatusCode::SUCCESS;
349 bool stable = (truthParticle !=
nullptr && statusAcc.
isAvailable(*truthParticle)) ?
MC::isStable(truthParticle) :
false;
358 classification = Truth::Type::KnownUnknown;
359 return StatusCode::SUCCESS;
365 classification = Truth::Type::KnownUnknown;
366 return StatusCode::SUCCESS;
371 classification = Truth::Type::KnownUnknown;
372 return StatusCode::SUCCESS;
379 && firstMotherType == 0 && firstMotherOrigin == 0 && firstMotherPdgId == 0)
381 if (lastMotherType == -1 || (lastMotherType == 0 && lastMotherOrigin == 0 && lastMotherPdgId == 0))
383 classification = Truth::Type::KnownUnknown;
384 return StatusCode::SUCCESS;
391 if (truthParticle !=
nullptr)
394 ATH_MSG_DEBUG(
"Unknown particle decay chain (approximate):");
395 std::string out =
"\t";
396 while (parent !=
nullptr)
398 out.append(std::to_string(parent->pdgId()));
399 parent = parent->parent(0);
400 if (parent) out.append(
" -> ");
405 classification = Truth::Type::Unknown;
406 return StatusCode::SUCCESS;
418 bool isTruthParticle{};
419 if (truthParticle ==
nullptr)
426 isTruthParticle =
true;
438 int fallbackType{-1};
450 classification = Truth::Type::TauDecay;
451 return StatusCode::SUCCESS;
461 classification = Truth::Type::LightFlavorDecay;
462 return StatusCode::SUCCESS;
467 classification = Truth::Type::LightFlavorDecay;
468 return StatusCode::SUCCESS;
478 classification = Truth::Type::BHadronDecay;
479 return StatusCode::SUCCESS;
488 classification = Truth::Type::CHadronDecay;
489 return StatusCode::SUCCESS;
500 static const std::set<int> promptOrigin({
518 classification = Truth::Type::ChargeFlipMuon;
519 return StatusCode::SUCCESS;
521 classification = Truth::Type::PromptMuon;
522 return StatusCode::SUCCESS;
532 classification = Truth::Type::KnownUnknown;
533 return StatusCode::SUCCESS;
537 bool stable = (truthParticle !=
nullptr && statusAcc.
isAvailable(*truthParticle)) ?
MC::isStable(truthParticle) :
false;
542 classification = Truth::Type::KnownUnknown;
543 return StatusCode::SUCCESS;
545 if (
type == -99999 && origin == -99999)
547 classification = Truth::Type::KnownUnknown;
548 return StatusCode::SUCCESS;
558 classification = Truth::Type::NonMuonlike;
559 return StatusCode::SUCCESS;
571 if( truthParticle !=
nullptr && truthParticle->
nParents() == 1 && truthParticle->
parent(0) !=
nullptr){
573 int parent_pdgid = parent->pdgId();
575 classification = Truth::Type::TauDecayLike;
576 ATH_MSG_WARNING(
"Muon type taudecaylike: type = " <<
type <<
", origin = " << origin <<
", parent = " << parent_pdgid) ;
577 return StatusCode::SUCCESS;
579 if(parent->isBottomHadron() || parent->hasBottom()){
580 classification = Truth::Type::BHadronDecayLike;
581 ATH_MSG_WARNING(
"Muon type bhadrondecaylike: type = " <<
type <<
", origin = " << origin <<
", parent = " << parent_pdgid) ;
582 return StatusCode::SUCCESS;
584 if(parent->isCharmHadron() || parent->hasCharm()){
585 if( (parent_pdgid / 1000) % 10 != 0 || (parent_pdgid / 100) % 10 != 4 || (parent_pdgid / 10) % 10 != 4){
586 classification = Truth::Type::CHadronDecayLike;
587 ATH_MSG_WARNING(
"Muon type chadrondecaylike: type = " <<
type <<
", origin = " << origin <<
", parent = " << parent_pdgid) ;
588 return StatusCode::SUCCESS;
597 classification = Truth::Type::Unknown;
600 return StatusCode::SUCCESS;
605 bool isTruthParticle,
642 && std::abs(pdgId) == 11)
653 bool isTruthParticle,
660 int pdgId = isTruthParticle && truthParticle ? truthParticle->
pdgId() :
m_truthPdgId(electron);
678 && std::abs(pdgId) == 11)
686 && std::abs(pdgId) == 11)
693 if (truthParticle->
charge() != 0)
695 return (firstMotherPdgId * truthParticle->
charge()) > 0;
701 if (xAODElectron.
charge() != 0)
703 return (firstMotherPdgId * xAODElectron.
charge()) > 0;
707 return (firstMotherPdgId * (-pdgId)) > 0;
712 bool isTruthParticle,
723 return (truthParticle->
charge() * xAODMuon.
charge()) < 0;
726 ANA_MSG_DEBUG(
"Cannot find associated truth-particle... assuming muon has correct charge");
733 static const std::set<int> b_hadrons({
738 return isInSet(origin, b_hadrons);
743 static const std::set<int> c_hadrons({
748 return isInSet(origin, c_hadrons);
753 static const std::set<int> light_source({
762 return isInSet(origin, light_source);
#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".