|
ATLAS Offline Software
|
Go to the documentation of this file.
4 #ifndef TRUTHUTILS_HEPMCHELPERS_H
5 #define TRUTHUTILS_HEPMCHELPERS_H
23 template <
class T>
inline bool isConditionA(
const T&
p) {
return p->status() == 62 ||
p->status() == 52 ||
p->status() == 21 ||
p->status() == 22;}
25 template <
class T>
inline bool isConditionB(
const T&
p) {
return p->status() == 23;}
27 template <
class T>
inline bool isConditionC(
const T&
p) {
return p->status() > 30 &&
p->status() < 40;}
33 template <
class T>
inline bool isInteracting(
const T&
p) {
return isStrongInteracting<T>(
p) || isEMInteracting<T>(
p) || isGeantino<T>(
p); }
51 template <
class T>
inline bool isPhysical(
const T&
p) {
return isStable<T>(
p) || isDecayed<T>(
p); }
54 template <
class T>
inline bool isGenStable(
const T&
p) {
return isStable<T>(
p) && !HepMC::is_simulation_particle<T>(
p);}
57 template <
class T>
inline bool isSimStable(
const T&
p) {
return isStable<T>(
p) && !
p->end_vertex() && HepMC::is_simulation_particle<T>(
p);}
60 template <
class T>
inline bool isSimInteracting(
const T&
p) {
return isGenStable<T>(
p) && isInteracting<T>(
p);}
66 const auto vertex =
p->end_vertex();
84 const int apid = std::abs(
p->pdg_id());
85 if (apid == NU_E || apid == NU_MU || apid == NU_TAU)
return true;
86 if (apid == 1000022 || apid == 1000024 || apid == 5100022)
return true;
87 if (apid == GRAVITON || apid == 1000039 || apid == 5000039)
return true;
88 if (apid == 9000001 || apid == 9000002 || apid == 9000003 || apid == 9000004 || apid == 9000005 || apid == 9000006)
return true;
95 auto partOriVert = thePart->production_vertex();
96 if (!partOriVert)
return nullptr;
98 long partPDG = thePart->pdg_id();
101 auto MothOriVert = partOriVert;
102 MothOriVert =
nullptr;
107 if (itr != 0) partOriVert = MothOriVert;
108 auto incoming = partOriVert->particles_in();
109 for (
auto p: incoming) {
111 if (!theMoth)
continue;
112 MotherPDG = theMoth->pdg_id();
113 MothOriVert = theMoth->production_vertex();
114 if (MotherPDG == partPDG)
break;
121 MothOriVert != partOriVert);
129 if (!
p)
return ptrPart;
130 for (T truthParticle : *TruthContainer) {
132 ptrPart = truthParticle;
141 auto prodVtx = thePart->production_vertex();
142 if (!prodVtx)
return;
143 for (
auto theMother: prodVtx->particles_in()) {
144 if (!theMother)
continue;
145 allancestors.insert(theMother);
153 auto endVtx = thePart->end_vertex();
155 for (
auto theDaughter: endVtx->particles_out()) {
156 if (!theDaughter)
continue;
158 allstabledescendants.insert(theDaughter);
169 if (pVert ==
nullptr)
return false;
176 auto incoming = pVert->particles_in();
177 numOfPartIn = incoming.size();
178 pdg = numOfPartIn && incoming.front() !=
nullptr ? incoming.front()->pdg_id() : 0;
179 pV = numOfPartIn && incoming.front() !=
nullptr ? incoming.front()->production_vertex() :
nullptr;
181 }
while (numOfPartIn == 1 && (std::abs(pdg) < 81 || std::abs(pdg) > 100) && pV !=
nullptr);
183 if (numOfPartIn == 2) {
184 auto incoming = pVert->particles_in();
185 if (incoming.at(0) && incoming.at(1) && (std::abs(incoming.at(0)->pdg_id()) < 7 || incoming.at(0)->pdg_id() == 21) && (std::abs(incoming.at(1)->pdg_id()) < 7 || incoming.at(1)->pdg_id() == 21))
return true;
196 auto vtx =
p->production_vertex();
197 if (!vtx)
return false;
198 bool fromHad =
false;
199 auto incoming = vtx->particles_in();
200 for (
auto parent: incoming) {
220 decltype(thePart->end_vertex()) EndVert = thePart->end_vertex();
221 decltype(thePart->end_vertex()) pVert(
nullptr);
222 if (EndVert !=
nullptr) {
224 bool samePart =
false;
226 auto outgoing = EndVert->particles_out();
227 auto incoming = EndVert->particles_in();
228 for (
const auto& itrDaug: outgoing) {
229 if (!itrDaug)
continue;
232 (outgoing.size() == 1 && incoming.size() == 1 &&
234 itrDaug->pdg_id() == thePart->pdg_id()) {
236 pVert = itrDaug->end_vertex();
239 if (samePart) EndVert = pVert;
240 }
while (pVert !=
nullptr && pVert != EndVert);
248 if (!theVert)
return {};
249 decltype(theVert->particles_out()) finalStatePart;
250 auto outgoing = theVert->particles_out();
251 for (
const auto& thePart: outgoing) {
252 if (!thePart)
continue;
253 finalStatePart.push_back(thePart);
256 if (pVert == theVert)
break;
257 if (pVert !=
nullptr) {
258 auto vecPart = findFinalStateParticles<V>(pVert);
259 finalStatePart.insert(finalStatePart.end(),vecPart.begin(),vecPart.end());
262 return finalStatePart;
bool isFromHadron(T p, T hadron, bool &fromTau, bool &fromBSM)
Function to classify the particle.
void findParticleAncestors(T thePart, std::set< T > &allancestors)
Function to find all ancestors of the particle.
bool isSpecialNonInteracting(const T &p)
Identify a special non-interacting particles.
bool isBSM(const T &p)
APID: graviton and all Higgs extensions are BSM.
bool isConditionC(const T &p)
bool isGenStable(const T &p)
Determine if the particle is stable at the generator (not det-sim) level,.
Author: James Monk (jmonk@cern.ch)
bool isPhysical(const T &p)
Identify if the particle is physical, i.e. is stable or decayed.
bool is_same_generator_particle(const T1 &p1, const T2 &p2)
Method to establish if two particles in the GenEvent actually represent the same generated particle.
auto findFinalStateParticles(V theVert) -> decltype(theVert->particles_out())
Function to find the stable particle descendants of the given vertex..
bool isFinalState(const T &p)
Identify if the particle is final state particle.
bool is_simulation_particle(const T &p)
Method to establish if a particle (or barcode) was created during the simulation (TODO update to be s...
T findMatching(C TruthContainer, T p)
Function to find a particle in container.
void findParticleStableDescendants(T thePart, std::set< T > &allstabledescendants)
Function to get the particle stable MC daughters.
bool is_simulation_vertex(const T &v)
Method to establish if the vertex was created during simulation (TODO migrate to be based on status).
T findMother(T thePart)
Function to get a mother of particle. MCTruthClassifier legacy.
bool isSingleParticle(const T &p)
Identify a particlegun particle.
bool isConditionA(const T &p)
To be understood.
constexpr int SIM_STATUS_THRESHOLD
Constant definiting the status threshold for simulated particles, eg. can be used to separate generat...
bool isChargedNonShowering(const T &p)
Identify if the particle with given PDG ID would produce ID tracks but not shower in the detector if ...
bool isHadron(const T &p)
bool isStableOrSimDecayed(const T &p)
Identify if particle is satble or decayed in simulation.
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
bool isDecayed(const T &p)
Identify if the particle decayed.
bool isBeam(const T &p)
Identify if the particle is beam particle.
bool isSimInteracting(const T &p)
Identify if the particle could interact with the detector during the simulation, e....
bool isConditionB(const T &p)
bool isInteracting(const T &p)
Identify if the particle with given PDG ID would not interact with the detector, i....
bool is_sim_descendant(const T1 &p1, const T2 &p2)
Method to check if the first particle is a descendant of the second in the simulation,...
bool isSimStable(const T &p)
Identify if the particle is considered stable at the post-detector-sim stage.
bool isZeroEnergyPhoton(const T &p)
Identify a photon with zero energy. Probably a workaround for a generator bug.
bool isHardScatteringVertex(T pVert)
Function to classify the vertex as hard scattering vertex.
auto findSimulatedEndVertex(T thePart) -> decltype(thePart->end_vertex())
Function to find the end vertex of a particle.