 |
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();
90 const int apid = std::abs(
p->pdg_id());
91 if (apid == NU_E || apid == NU_MU || apid == NU_TAU)
return true;
92 if (apid == 1000022 || apid == 1000024 || apid == 5100022)
return true;
93 if (apid == GRAVITON || apid == 1000039 || apid == 5000039)
return true;
94 if (apid == 9000001 || apid == 9000002 || apid == 9000003 || apid == 9000004 || apid == 9000005 || apid == 9000006)
return true;
101 auto partOriVert = thePart->production_vertex();
102 if (!partOriVert)
return nullptr;
104 long partPDG = thePart->pdg_id();
107 auto MothOriVert = partOriVert;
108 MothOriVert =
nullptr;
113 if (itr != 0) partOriVert = MothOriVert;
114 auto incoming = partOriVert->particles_in();
115 for (
auto p: incoming) {
117 if (!theMoth)
continue;
118 MotherPDG = theMoth->pdg_id();
119 MothOriVert = theMoth->production_vertex();
120 if (MotherPDG == partPDG)
break;
127 MothOriVert != partOriVert);
135 if (!
p)
return ptrPart;
136 if constexpr (std::is_pointer_v<C> || HepMC::is_smart_ptr_v<C>){
137 for (T truthParticle : *TruthContainer) {
139 ptrPart = truthParticle;
145 for (T truthParticle : TruthContainer) {
147 ptrPart = truthParticle;
157 auto prodVtx = thePart->production_vertex();
158 if (!prodVtx)
return;
159 for (
auto theMother: prodVtx->particles_in()) {
160 if (!theMother)
continue;
161 allancestors.insert(theMother);
169 auto endVtx = thePart->end_vertex();
171 for (
auto theDaughter: endVtx->particles_out()) {
172 if (!theDaughter)
continue;
174 allstabledescendants.insert(theDaughter);
185 if (pVert ==
nullptr)
return false;
192 auto incoming = pVert->particles_in();
193 numOfPartIn = incoming.size();
194 pdg = numOfPartIn && incoming.front() !=
nullptr ? incoming.front()->pdg_id() : 0;
195 pV = numOfPartIn && incoming.front() !=
nullptr ? incoming.front()->production_vertex() :
nullptr;
197 }
while (numOfPartIn == 1 && (std::abs(pdg) < 81 || std::abs(pdg) > 100) && pV !=
nullptr);
199 if (numOfPartIn == 2) {
200 auto incoming = pVert->particles_in();
201 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;
212 auto vtx =
p->production_vertex();
213 if (!vtx)
return false;
214 bool fromHad =
false;
215 auto incoming = vtx->particles_in();
216 for (
auto parent: incoming) {
236 decltype(thePart->end_vertex()) EndVert = thePart->end_vertex();
237 decltype(thePart->end_vertex()) pVert(
nullptr);
238 if (EndVert !=
nullptr) {
240 bool samePart =
false;
242 auto outgoing = EndVert->particles_out();
243 auto incoming = EndVert->particles_in();
244 for (
const auto& itrDaug: outgoing) {
245 if (!itrDaug)
continue;
248 (outgoing.size() == 1 && incoming.size() == 1 &&
250 itrDaug->pdg_id() == thePart->pdg_id()) {
252 pVert = itrDaug->end_vertex();
255 if (samePart) EndVert = pVert;
256 }
while (pVert !=
nullptr && pVert != EndVert);
264 if (!theVert)
return {};
265 decltype(theVert->particles_out()) finalStatePart;
266 auto outgoing = theVert->particles_out();
267 for (
const auto& thePart: outgoing) {
268 if (!thePart)
continue;
269 finalStatePart.push_back(thePart);
272 if (pVert == theVert)
break;
273 if (pVert !=
nullptr) {
274 auto vecPart = findFinalStateParticles<V>(pVert);
275 finalStatePart.insert(finalStatePart.end(),vecPart.begin(),vecPart.end());
278 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.
Class describing a truth particle in the MC record.
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....
typename remove_smart_pointer< T >::type remove_smart_pointer_t
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.