18 bool isInSet(
int origin,
const std::set<int> &s)
20 return s.find(origin) !=
s.end();
36 unsigned int &classification)
const
40 classification =
static_cast<int>(
type);
41 return StatusCode::SUCCESS;
57 else if (
dynamic_cast<const xAOD::Muon *
> (&particle) || (truthParticle !=
nullptr &&
MC::isMuon(truthParticle)))
64 return StatusCode::FAILURE;
67 return StatusCode::SUCCESS;
78 bool isTruthParticle{};
79 if (truthParticle ==
nullptr)
86 isTruthParticle =
true;
89 if (!
m_truthPdgId.isAvailable(electron) && !isTruthParticle)
91 ANA_MSG_ERROR(
"Electron does not have the 'truthPdgId' decoration.");
92 return StatusCode::FAILURE;
99 ANA_MSG_ERROR(
"Electron does not have one or more 'firstEgMother' decorations.");
100 return StatusCode::FAILURE;
105 int pdgId = isTruthParticle && truthParticle !=
nullptr ? truthParticle->
pdgId() :
m_truthPdgId(electron);
120 int fallbackType{-1};
135 classification = Truth::Type::PromptPhotonConversion;
136 return StatusCode::SUCCESS;
143 classification = Truth::Type::PromptPhotonConversion;
144 return StatusCode::SUCCESS;
151 classification = Truth::Type::PromptPhotonConversion;
152 return StatusCode::SUCCESS;
160 classification = Truth::Type::PromptPhotonConversion;
161 return StatusCode::SUCCESS;
167 classification = Truth::Type::PromptPhotonConversion;
168 return StatusCode::SUCCESS;
174 classification = Truth::Type::PromptPhotonConversion;
175 return StatusCode::SUCCESS;
183 classification = Truth::Type::PromptPhotonConversion;
184 return StatusCode::SUCCESS;
189 classification = Truth::Type::PromptPhotonConversion;
190 return StatusCode::SUCCESS;
202 ANA_MSG_WARNING(
"Electron identified as from a PromptPhotonConversion, "
203 "but this type of electron needs further study!");
204 classification = Truth::Type::PromptPhotonConversion;
205 return StatusCode::SUCCESS;
212 && std::abs(firstMotherPdgId) == 11 && std::abs(pdgId) == 11)
217 classification = Truth::Type::PromptPhotonConversion;
218 return StatusCode::SUCCESS;
230 classification = Truth::Type::ElectronFromMuon;
231 return StatusCode::SUCCESS;
236 classification = Truth::Type::ElectronFromMuon;
237 return StatusCode::SUCCESS;
241 classification = Truth::Type::ElectronFromMuon;
242 return StatusCode::SUCCESS;
254 classification = Truth::Type::TauDecay;
255 return StatusCode::SUCCESS;
262 classification = Truth::Type::TauDecay;
263 return StatusCode::SUCCESS;
273 classification = Truth::Type::LightFlavorDecay;
274 return StatusCode::SUCCESS;
282 classification = Truth::Type::LightFlavorDecay;
283 return StatusCode::SUCCESS;
290 classification = Truth::Type::LightFlavorDecay;
291 return StatusCode::SUCCESS;
294 classification = Truth::Type::LightFlavorDecay;
295 return StatusCode::SUCCESS;
302 classification = Truth::Type::LightFlavorDecay;
303 return StatusCode::SUCCESS;
313 classification = Truth::Type::BHadronDecay;
314 return StatusCode::SUCCESS;
323 classification = Truth::Type::CHadronDecay;
324 return StatusCode::SUCCESS;
336 classification = Truth::Type::ChargeFlipIsoElectron;
337 return StatusCode::SUCCESS;
340 classification = Truth::Type::IsoElectron;
341 return StatusCode::SUCCESS;
355 bool stable = (truthParticle !=
nullptr && statusAcc.
isAvailable(*truthParticle)) ?
MC::isStable(truthParticle) :
false;
364 classification = Truth::Type::KnownUnknown;
365 return StatusCode::SUCCESS;
371 classification = Truth::Type::KnownUnknown;
372 return StatusCode::SUCCESS;
377 classification = Truth::Type::KnownUnknown;
378 return StatusCode::SUCCESS;
385 && firstMotherType == 0 && firstMotherOrigin == 0 && firstMotherPdgId == 0)
387 if (lastMotherType == -1 || (lastMotherType == 0 && lastMotherOrigin == 0 && lastMotherPdgId == 0))
389 classification = Truth::Type::KnownUnknown;
390 return StatusCode::SUCCESS;
397 if (truthParticle !=
nullptr)
400 ATH_MSG_DEBUG(
"Unknown particle decay chain (approximate):");
401 std::string out =
"\t";
402 while (parent !=
nullptr)
404 out.append(std::to_string(parent->pdgId()));
405 parent = parent->parent(0);
406 if (parent) out.append(
" -> ");
411 classification = Truth::Type::Unknown;
412 return StatusCode::SUCCESS;
424 bool isTruthParticle{};
425 if (truthParticle ==
nullptr)
432 isTruthParticle =
true;
444 int fallbackType{-1};
456 classification = Truth::Type::TauDecay;
457 return StatusCode::SUCCESS;
470 classification = Truth::Type::PromptPhotonConversion;
471 return StatusCode::SUCCESS;
481 classification = Truth::Type::LightFlavorDecay;
482 return StatusCode::SUCCESS;
487 classification = Truth::Type::LightFlavorDecay;
488 return StatusCode::SUCCESS;
498 classification = Truth::Type::BHadronDecay;
499 return StatusCode::SUCCESS;
508 classification = Truth::Type::CHadronDecay;
509 return StatusCode::SUCCESS;
518 static const std::set<int> promptOrigin({
538 classification = Truth::Type::ChargeFlipMuon;
539 return StatusCode::SUCCESS;
541 classification = Truth::Type::PromptMuon;
542 return StatusCode::SUCCESS;
552 classification = Truth::Type::KnownUnknown;
553 return StatusCode::SUCCESS;
557 bool stable = (truthParticle !=
nullptr && statusAcc.
isAvailable(*truthParticle)) ?
MC::isStable(truthParticle) :
false;
562 classification = Truth::Type::KnownUnknown;
563 return StatusCode::SUCCESS;
565 if (
type == -99999 && origin == -99999)
567 classification = Truth::Type::KnownUnknown;
568 return StatusCode::SUCCESS;
578 classification = Truth::Type::NonMuonlike;
579 return StatusCode::SUCCESS;
591 if( truthParticle !=
nullptr && truthParticle->
nParents() == 1 && truthParticle->
parent(0) !=
nullptr){
593 int parent_pdgid = parent->pdgId();
595 classification = Truth::Type::TauDecayLike;
596 ATH_MSG_WARNING(
"Muon type taudecaylike: type = " <<
type <<
", origin = " << origin <<
", parent = " << parent_pdgid) ;
597 return StatusCode::SUCCESS;
599 if(parent->isBottomHadron() || parent->hasBottom()){
600 classification = Truth::Type::BHadronDecayLike;
601 ATH_MSG_WARNING(
"Muon type bhadrondecaylike: type = " <<
type <<
", origin = " << origin <<
", parent = " << parent_pdgid) ;
602 return StatusCode::SUCCESS;
604 if(parent->isCharmHadron() || parent->hasCharm()){
605 if( (parent_pdgid / 1000) % 10 != 0 || (parent_pdgid / 100) % 10 != 4 || (parent_pdgid / 10) % 10 != 4){
606 classification = Truth::Type::CHadronDecayLike;
607 ATH_MSG_WARNING(
"Muon type chadrondecaylike: type = " <<
type <<
", origin = " << origin <<
", parent = " << parent_pdgid) ;
608 return StatusCode::SUCCESS;
617 classification = Truth::Type::Unknown;
620 return StatusCode::SUCCESS;
630 const bool isTruthParticle = truthParticle !=
nullptr;
631 if (!isTruthParticle)
653 classification = Truth::Type::InternalConversion;
665 classification = Truth::Type::MaterialConversion;
674 bool isTruthParticle,
711 && std::abs(pdgId) == 11)
722 bool isTruthParticle,
729 int pdgId = isTruthParticle && truthParticle ? truthParticle->
pdgId() :
m_truthPdgId(electron);
747 && std::abs(pdgId) == 11)
755 && std::abs(pdgId) == 11)
762 if (truthParticle && truthParticle->
charge() != 0)
764 return (firstMotherPdgId * truthParticle->
charge()) > 0;
770 if (xAODElectron.
charge() != 0)
772 return (firstMotherPdgId * xAODElectron.
charge()) > 0;
776 return (firstMotherPdgId * (-pdgId)) > 0;
781 bool isTruthParticle,
792 return (truthParticle->
charge() * xAODMuon.
charge()) < 0;
795 ANA_MSG_DEBUG(
"Cannot find associated truth-particle... assuming muon has correct charge");
802 static const std::set<int> b_hadrons({
807 return b_hadrons.contains(origin);
812 static const std::set<int> c_hadrons({
818 return c_hadrons.contains(origin);
823 static const std::set<int> light_source({
832 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.
@ BottomMeson
Decay of an open-bottom meson.
@ ElMagProc
Electromagnetic or nuclear material process: bremsstrahlung/pair production in the detector,...
@ LightBaryon
Decay of a light (u, d only) baryon.
@ SUSY
Decay of a SUSY particle.
@ UndrPhot
"Underlying" photon: radiated from a quark or gluon in the parton shower/underlying event
@ ZBoson
Z boson (or Z/gamma*) decay (including Sherpa Z records and Z+gamma).
@ BBbarMeson
Decay of a hidden-bottom meson.
@ PromptPhot
Prompt (direct) photon of the hard process, e.g. Pythia8 gamma+jet.
@ StrangeMeson
Decay of a meson containing s quark (e.g. kaon).
@ DiBoson
Two-boson (WW, WZ, ZZ) production recorded without explicit bosons: four leptons/neutrinos in the har...
@ Higgs
Higgs boson decay (SM Higgs, PDG 25).
@ CharmedBaryon
Decay of a charmed baryon.
@ StrangeBaryon
Decay of a strange baryon.
@ LightMeson
Decay of a light (u, d only) meson.
@ HiggsMSSM
Decay of an extra (MSSM/2HDM) Higgs boson: H (35), A (36) or H+ (37).
@ BottomBaryon
Decay of a bottom baryon.
@ PhotonConv
Photon conversion (gamma -> e+ e-, or gamma -> mu+ mu- for muons).
@ TauLep
Decay (or radiation) of a tau lepton that is not itself prompt.
@ KaonDecay
Muon from K -> mu nu in flight.
@ FSRPhot
Final-state radiation photon, e.g. from the leptons of W/Z/H decays or from Photos.
@ WBoson
W boson decay (including Sherpa W records and W+gamma).
@ Mu
Decay (or radiation) of a muon.
@ NonDefined
Origin could not be determined (no production vertex, no ancestor, or particle not classified).
@ PiZero
Photon from a pi0 decay.
@ CharmedMeson
Decay of an open-charm meson.
@ CCbarMeson
Decay of a hidden-charm meson other than J/psi.
@ top
Decay of a top quark (including through W).
@ DalitzDec
Dalitz decay of a pi0 (pi0 -> gamma e+ e-, or pi0 -> e+ e- e+ e-).
@ HeavyBoson
Decay of a heavy gauge boson Z', Z'', W'+ (PDG 32, 33, 34), or a KK graviton (5100039) in the photon ...
@ SingleMuon
Single-muon particle gun.
@ PionDecay
Muon from pi -> mu nu in flight.
@ MultiBoson
Three or more bosons (VVV, 4-top with leptonic W decays): six or eight leptons/neutrinos in the hard-...
@ Unknown
Not classified: not a lepton, photon, neutrino or hadron (e.g. a quark, a gluon, a boson),...
@ IsoPhoton
Isolated (prompt) photon: from W/Z/H/BSM decay, a hard-process prompt photon, or a single-photon gun.
@ UnknownMuon
Muon with undefined origin.
@ NonIsoPhoton
Non-isolated photon: initial/final-state radiation, or from tau, muon or right-handed neutrino/W_R de...
@ BkgPhoton
Background photon: bremsstrahlung, pi0 decay, hadron decay, nuclear reaction, underlying-event photon...
@ NonIsoMuon
Non-isolated muon from J/psi, B/D hadron, tau or quark weak decay.
@ BkgMuon
Background muon: pion/kaon decay in flight and other remaining cases.
@ IsoElectron
Isolated (prompt) electron, e.g. from W/Z/H/top/BSM decay, or a single-electron particle gun.
@ IsoMuon
Isolated (prompt) muon.
@ NonIsoElectron
Non-isolated electron from J/psi, B/D hadron, tau, muon or quark weak decay.
@ GenParticle
Generator-level intermediate particle (decayed, or otherwise not a final-state candidate) that is not...
@ UnknownPhoton
Photon with undefined origin.
@ UnknownElectron
Electron with undefined origin (no production vertex, or origin could not be traced).
@ Hadron
Any hadron (neither the beam nor a nuclear fragment); the origin is not studied further.
@ BkgElectron
Background electron: photon conversion, Dalitz decay, material interaction, light-hadron decay,...
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".