4#ifndef TRUTHUTILS_TRUTHCLASSIFIERS_H
5#define TRUTHUTILS_TRUTHCLASSIFIERS_H
140 for (
const auto& it: allJetMothers) {
141 int pdg = abs(it->pdg_id());
147 if (pdg == 35 || pdg == 36 || pdg == 37)
return HiggsMSSM;
148 if (pdg == 32 || pdg == 33 || pdg == 34)
return HeavyBoson;
149 if (pdg == 42)
return LQ;
183 T parent_hadron_ptr =
nullptr;
185 bool uncat = 0, fromHad = 0, fromTau = 0;
189 bool fromBSM =
isBSM;
191 auto prodVtx = thePart->production_vertex();
192 if (isPhysical && prodVtx && !isGeant) {
197 std::bitset<MCTC_bits::totalBits> classifier;
206 unsigned int outputvalue =
static_cast<unsigned int>(classifier.to_ulong());
208 return std::make_tuple(outputvalue,parent_hadron_ptr);
214inline int isPrompt(
const unsigned int classify,
bool allow_prompt_tau_decays =
true) {
215 std::bitset<MCTC_bits::totalBits>
res(classify);
218 if (fromPromptTau)
return int(allow_prompt_tau_decays);
229 int ElecOutNumOfNucFr(0);
230 int ElecOutNumOfElec(0);
232 auto outgoing = EndVert->particles_out();
233 int NumOfElecDaug = outgoing.size();
234 for (
const auto& p: outgoing) {
236 int EndDaugType = p->pdg_id();
239 if (EndDaugType > 1000000000 || EndDaugType == 0 || abs(EndDaugType) == 2212 || abs(EndDaugType) == 2112) ElecOutNumOfNucFr++;
242 if (ElecOutNumOfNucFr != 0 || NumOfHadr != 0) PartOutCome =
NuclInteraction;
243 if (ElecOutNumOfElec == 1 && NumOfElecDaug == 1) PartOutCome =
ElectrMagInter;
254 int MuOutNumOfNucFr(0);
256 int NumOfEleNeutr(0);
257 int NumOfMuonNeutr(0);
259 auto outgoing = EndVert->particles_out();
260 int NumOfMuDaug = outgoing.size();
261 for (
const auto& p: outgoing) {
263 int EndDaugType = p->pdg_id();
265 if (abs(EndDaugType) == 12) NumOfEleNeutr++;
266 if (abs(EndDaugType) == 14) NumOfMuonNeutr++;
268 if (EndDaugType > 1000000000 || EndDaugType == 0 || abs(EndDaugType) == 2212 || abs(EndDaugType) == 2112) MuOutNumOfNucFr++;
271 if (MuOutNumOfNucFr != 0 || NumOfHadr != 0) PartOutCome =
NuclInteraction;
272 if (NumOfMuDaug == 3 && NumOfElec == 1 && NumOfEleNeutr == 1 && NumOfMuonNeutr == 1) PartOutCome =
DecaytoElectron;
282 int NumOfTauDaug = EndVert->nOutgoingParticles();
284 auto PD = DecayProducts(tauFinalStatePart);
285 int NumOfElec =
PD.apd(11);
286 int NumOfMuon =
PD.apd(13);
287 int NumOfElecNeut =
PD.apd(12);
288 int NumOfMuonNeut =
PD.apd(14);
289 int NumOfPhot =
PD.apd(22);
290 int NumOfPi =
PD.apd(211);
291 int NumOfKaon =
PD.apd(321);
292 int NumOfNucFr =
PD.apd(0) +
PD.apd(1000000000, std::numeric_limits<int>::max());
295 if ((NumOfTauDaug == 3 && NumOfElec == 1 && NumOfElecNeut == 1) || (NumOfTauDaug == (3 + NumOfPhot) && NumOfElecNeut == 1)) PartOutCome =
DecaytoElectron;
296 if ((NumOfTauDaug == 3 && NumOfMuon == 1 && NumOfMuonNeut == 1) || (NumOfTauDaug == (3 + NumOfPhot) && NumOfMuonNeut == 1)) PartOutCome =
DecaytoMuon;
298 if (NumOfPi == 1 || NumOfKaon == 1) PartOutCome =
OneProng;
299 if (NumOfPi + NumOfKaon == 3) PartOutCome =
ThreeProng;
300 if (NumOfPi + NumOfKaon == 5) PartOutCome =
FiveProng;
313 int PhtOutNumOfNucFr(0);
314 int PhtOutNumOfEl(0);
315 int PhtOutNumOfPos(0);
316 int PhtOutNumOfHadr(0);
318 auto outgoing = EndVert->particles_out();
319 int NumOfPhtDaug = outgoing.size();
320 for (
const auto& p: outgoing) {
322 int EndDaugType = p->pdg_id();
323 if (EndDaugType > 1000000000 || EndDaugType == 0 || abs(EndDaugType) == 2212 || abs(EndDaugType) == 2112) PhtOutNumOfNucFr++;
324 if (EndDaugType == 11) PhtOutNumOfEl++;
325 if (EndDaugType == -11) PhtOutNumOfPos++;
329 if (PhtOutNumOfEl == 1 && PhtOutNumOfPos == 1 && NumOfPhtDaug == 2) PartOutCome =
Converted;
330 if ((NumOfPhtDaug > 1 && PhtOutNumOfNucFr != 0) || PhtOutNumOfHadr > 0) PartOutCome =
NuclInteraction;
bool isBSM(const T &p)
APID: graviton and all Higgs extensions are BSM.
ATLAS-specific HepMC functions.
std::pair< std::vector< unsigned int >, bool > res
bool is_simulation_particle(const T &p)
Method to establish if a particle was created during the simulation (based on the status value).
ParticleOutCome defOutComeOfElectron(T thePart)
Determine the outcome of a simulated electron from its end vertex (NonInteract, ElectrMagInter,...
ParticleOutCome defOutComeOfPhoton(T thePart)
Determine the outcome of a simulated photon from its end vertex (UnConverted, Converted,...
ParticleOutCome
Outcome of a (simulated) truth particle: what happened to it after being produced,...
@ ThreeProng
Tau decayed hadronically with three charged pions or kaons.
@ DecaytoMuon
Tau decayed to mu nu nu (with optional photons).
@ NonInteract
Particle without an end vertex (survived the detector) – also used for neutrinos.
@ Converted
Photon converted: end vertex has exactly one e+ and one e-.
@ DecaytoElectron
Muon decayed to e nu_e nu_mu, or tau decayed to e nu nu (with optional photons).
@ NuclInteraction
Interaction with nuclei: the end vertex contains hadrons, nucleons or nuclear fragments.
@ FiveProng
Tau decayed hadronically with five charged pions or kaons.
@ UnConverted
Photon without an end vertex: it did not convert.
@ UnknownOutCome
End vertex exists, but its content matches none of the patterns below.
@ ElectrMagInter
Electron that only scattered electromagnetically: its end vertex has one electron and nothing else.
@ OneProng
Tau decayed hadronically with one charged pion or kaon.
ParticleOrigin defJetOrig(const T &allJetMothers)
Determine a jet's origin from its mother particles (Higgs/BSM mothers return immediately; otherwise t...
ParticleType defTypeOfPhoton(ParticleOrigin PhotOrig)
Classify a photon (Unknown/Iso/NonIso/Bkg) from its origin.
MCTC_bits
Bit positions in the classification word returned by defOrigOfParticle().
@ frombsm
A BSM particle is among the ancestors walked, or the particle is itself BSM.
@ isbsm
The particle itself is a BSM particle.
@ HadTau
Descends from a hadron and from a tau: a hadronic tau decay product (hadron && Tau).
@ Tau
A tau is among the ancestors, or the parents of an ancestor, that were walked on the way up (product ...
@ hadron
The particle is a hadron (not a beam particle) or descends from one (non-prompt); unset for prompt pa...
@ totalBits
Number of bits (not a property).
@ stable
The particle is physical: stable or decayed (MC::isPhysical), not an intermediate or documentation en...
@ uncat
Uncategorised: the particle is not physical (neither stable nor decayed), has no production vertex or...
@ isgeant
The particle is produced by the detector simulation (e.g. Geant4), not by the generator.
ParticleOrigin convHadronTypeToOrig(ParticleType pType, int motherPDG)
Convert a hadron ParticleType to a ParticleOrigin (JPsi if a c-cbar meson has a J/psi mother).
ParticleOutCome defOutComeOfTau(T thePart)
Determine the outcome of a simulated tau from its decay products (NonInteract, NuclInteraction,...
ParticleType defTypeOfTau(ParticleOrigin TauOrig)
Classify a tau (Unknown/Iso/NonIso/Bkg) from its origin.
ParticleType defTypeOfMuon(ParticleOrigin MuOrig, bool isPrompt)
Classify a muon (Unknown/Iso/NonIso/Bkg) from its origin; prompt muons are always Iso.
ParticleOrigin defHadronType(int pdg)
Classify a hadron by PDG ID into a ParticleOrigin (NonDefined if none applies).
ParticleOrigin
Origin of a truth particle, as assigned by MCTruthClassifier::particleTruthClassifier (the second mem...
@ BottomMeson
Decay of an open-bottom meson.
@ LightBaryon
Decay of a light (u, d only) baryon.
@ WBosonLRSM
Decay of the W_R boson of the left-right symmetric model (Pythia-specific PDG 9900024).
@ ZBoson
Z boson (or Z/gamma*) decay (including Sherpa Z records and Z+gamma).
@ BBbarMeson
Decay of a hidden-bottom meson.
@ ISRPhot
Initial-state radiation photon (quark/gluon mother whose copy is a Herwig cluster).
@ 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).
@ ZorHeavyBoson
UNUSED: never returned by the classifier; only compared against in defTypeOfElectron/Muon/Tau.
@ LQ
Leptoquark: the ancestor is a leptoquark, or the decay vertex contains one.
@ BottomBaryon
Decay of a bottom baryon.
@ NuREle
Decay of a right-handed electron neutrino (Pythia-specific PDG 9900012), or of a W_R decaying to it.
@ TauLep
Decay (or radiation) of a tau lepton that is not itself prompt.
@ NuRMu
Decay of a right-handed muon neutrino (Pythia-specific PDG 9900014).
@ 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.
@ OtherBSM
Decay of a non-SUSY BSM particle (added later, hence the out-of-order value).
@ NuRTau
Decay of a right-handed tau neutrino (Pythia-specific PDG 9900016).
@ NonDefined
Origin could not be determined (no production vertex, no ancestor, or particle not classified).
@ CharmedMeson
Decay of an open-charm meson.
@ SingleElec
Single-electron particle gun: production vertex with no mother and one outgoing particle.
@ CCbarMeson
Decay of a hidden-charm meson other than J/psi.
@ top
Decay of a top quark (including through W).
@ QuarkWeakDec
Weak decay of a quark: q -> q' l nu with a single other quark in the final state.
@ SingleTau
Single-tau particle gun.
@ 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.
@ QCD
Jet origin: a quark or gluon mother (see defJetOrig); only assigned by the jet classifier,...
@ SinglePhot
Single-photon particle gun.
@ MultiBoson
Three or more bosons (VVV, 4-top with leptonic W decays): six or eight leptons/neutrinos in the hard-...
ParticleType defTypeOfHadron(int pdg)
Classify a hadron by PDG ID into a ParticleType (Unknown if none applies).
int isPrompt(const unsigned int classify, bool allow_prompt_tau_decays=true)
Tell whether a particle is prompt, from the word returned by defOrigOfParticle().
ParticleOutCome defOutComeOfMuon(T thePart)
Determine the outcome of a simulated muon from its end vertex (NonInteract, DecaytoElectron,...
ParticleType defTypeOfElectron(ParticleOrigin EleOrig, bool isPrompt)
Classify an electron (Unknown/Iso/NonIso/Bkg) from its origin; prompt electrons are always Iso.
ParticleType
Type of a truth particle, as assigned by MCTruthClassifier::particleTruthClassifier (the first member...
@ BkgTau
Background tau (remaining cases).
@ BBbarMesonPart
Hidden-bottom meson (e.g. Upsilon, chi_b).
@ Unknown
Not classified: not a lepton, photon, neutrino or hadron (e.g. a quark, a gluon, a boson),...
@ LightMesonPart
Meson made of u and d quarks only, e.g. a pion.
@ CharmedMesonPart
Open-charm meson (D, D_s).
@ IsoPhoton
Isolated (prompt) photon: from W/Z/H/BSM decay, a hard-process prompt photon, or a single-photon gun.
@ StrangeBaryonPart
Baryon containing an s quark (and no c, b).
@ IsoTau
Isolated (prompt) tau.
@ UnknownMuon
Muon with undefined origin.
@ StrangeMesonPart
Meson containing an s quark (and no c, b), e.g. a kaon.
@ CCbarMesonPart
Hidden-charm meson (e.g. J/psi, chi_c).
@ 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.
@ BottomBaryonPart
Baryon containing a b quark.
@ BkgMuon
Background muon: pion/kaon decay in flight and other remaining cases.
@ NonIsoTau
Non-isolated tau from J/psi, B/D hadron or quark weak decay.
@ CharmedBaryonPart
Baryon containing a c quark (and no b).
@ 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.
@ UnknownPhoton
Photon with undefined origin.
@ UnknownElectron
Electron with undefined origin (no production vertex, or origin could not be traced).
@ BottomMesonPart
Open-bottom meson (B, B_s, B_c).
@ BkgElectron
Background electron: photon conversion, Dalitz decay, material interaction, light-hadron decay,...
@ UnknownTau
Tau with undefined origin.
@ LightBaryonPart
Baryon made of u and d quarks only.
std::tuple< unsigned int, T > defOrigOfParticle(T thePart)
Classify a particle into a bit-word (see MCTC_bits).
bool isStrangeBaryon(const T &p)
bool isLightBaryon(const T &p)
bool isLightMeson(const T &p)
bool isStrangeMeson(const T &p)
bool isBottomMeson(const T &p)
bool isCharmBaryon(const T &p)
bool isCCbarMeson(const T &p)
bool isFromHadron(T p, U &hadron, bool &fromTau, bool &fromBSM)
Function to check if the particle is a hadron or descends from one; sets the parent hadron,...
bool isBottomBaryon(const T &p)
bool isCharmMeson(const T &p)
bool isElectron(const T &p)
bool isBBbarMeson(const T &p)
auto findFinalStateParticles(V theVert) -> decltype(theVert->particles_out())
Function to find the descendants of the given vertex: its outgoing particles and, recursively,...
bool isQuark(const T &p)
PDG rule 2: Quarks and leptons are numbered consecutively starting from 1 and 11 respectively; to do ...
bool isHiggs(const T &p)
APID: HIGGS boson is only one particle.
bool isBeam(const T &p)
Identify if the particle is beam particle.
bool isHadron(const T &p)
auto findSimulatedEndVertex(T thePart) -> decltype(thePart->end_vertex())
Function to find the end vertex of a particle.
bool isPhysical(const T &p)
Identify if the particle is physical, i.e. is stable or decayed.
bool isBSM(const T &p)
APID: graviton and all Higgs extensions are BSM.