Default constructor.
331{
332 namespace Pythia8
333 {
335 template <
class T>
inline bool isConditionA(
const T& p) {
return p->status() == 62 ||
p->status() == 52 ||
p->status() == 21 ||
p->status() == 22;}
336
337 template <
class T>
inline bool isConditionB(
const T& p) {
return p->status() == 23;}
338
339 template <
class T>
inline bool isConditionC(
const T& p) {
return p->status() > 30 &&
p->status() < 40;}
340 }
341
343
346
349
352
355
358
361
364
367
370
373
378 const auto vertex =
p->end_vertex();
380 }
381
384
387 const int apid = std::abs(
p->pdg_id());
389 if (apid == 1000022 || apid == 1000024 || apid == 5100022) return true;
390 if (apid ==
GRAVITON || apid == 1000039 || apid == 5000039)
return true;
391 if (apid == 9000001 || apid == 9000002 || apid == 9000003 || apid == 9000004 || apid == 9000005 || apid == 9000006) return true;
392 return false;
393 }
394
396
398 auto partOriVert = thePart->production_vertex();
399 if (!partOriVert) return nullptr;
400
401 long partPDG = thePart->pdg_id();
402 long MotherPDG(0);
403
404 auto MothOriVert = partOriVert;
405 MothOriVert = nullptr;
407
408 size_t itr = 0;
409 do {
410 if (itr != 0) partOriVert = MothOriVert;
411 for ( const auto& p : partOriVert->particles_in() ) {
413 if (!theMoth) continue;
414 MotherPDG = theMoth->pdg_id();
415 MothOriVert = theMoth->production_vertex();
416 if (MotherPDG == partPDG) break;
417 }
418 itr++;
419 if (itr > 100) {
420 break;
421 }
423 MothOriVert != partOriVert);
424 return theMoth;
425 }
426
428
429 template <
class C,
class T>
T findMatching(
C TruthContainer, T p) {
431 if (!p) return ptrPart;
433 for (T truthParticle : *TruthContainer) {
435 ptrPart = truthParticle;
436 break;
437 }
438 }
439 }
440 else {
441 for (T truthParticle : TruthContainer) {
443 ptrPart = truthParticle;
444 break;
445 }
446 }
447 }
448 return ptrPart;
449 }
451
453 auto prodVtx = thePart->production_vertex();
454 if (!prodVtx) return;
455 for (const auto& theMother: prodVtx->particles_in()) {
456 if (!theMother) continue;
457 allancestors.insert(theMother);
459 }
460 }
461
463
465 auto endVtx = thePart->end_vertex();
466 if (!endVtx) return;
467 for (const auto& theDaughter: endVtx->particles_out()) {
468 if (!theDaughter) continue;
470 allstabledescendants.insert(theDaughter);
471 }
473 }
474 }
475
479
481 if (pVert == nullptr) return false;
483 int numOfPartIn(0);
484 int pdg(0);
485
486 do {
487 pVert = pV;
488 auto incoming = pVert->particles_in();
489 numOfPartIn = incoming.size();
490 pdg = numOfPartIn && incoming.front() != nullptr ? incoming.front()->pdg_id() : 0;
491 pV = numOfPartIn && incoming.front() != nullptr ? incoming.front()->production_vertex() : nullptr;
492
493 } while (numOfPartIn == 1 && (std::abs(pdg) < 81 || std::abs(pdg) > 100) && pV != nullptr);
494
495 if (numOfPartIn == 2) {
496 auto incoming = pVert->particles_in();
497 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;
498 }
499 return false;
500}
501
505
506 template <
class T,
class U>
bool isFromHadron(T p, U hadron,
bool &fromTau,
bool &fromBSM) {
508 auto vtx =
p->production_vertex();
509 if (!vtx) return false;
510 bool fromHad = false;
511 for ( const auto& parent : vtx->particles_in() ) {
512 if (!parent) continue;
513
514
515 fromBSM |=
isBSM(parent);
517 fromTau |=
isTau(parent);
520 return true;
521 }
522 fromHad |=
isFromHadron(parent, hadron, fromTau, fromBSM);
523 }
524 return fromHad;
525 }
526
529
531 decltype(thePart->end_vertex()) EndVert = thePart->end_vertex();
532 decltype(thePart->end_vertex()) pVert(nullptr);
533 if (EndVert != nullptr) {
534 do {
535 bool samePart = false;
536 pVert = nullptr;
537 auto outgoing = EndVert->particles_out();
538 auto incoming = EndVert->particles_in();
539 for (const auto& itrDaug: outgoing) {
540 if (!itrDaug) continue;
542
543 (outgoing.size() == 1 && incoming.size() == 1 &&
545 itrDaug->pdg_id() == thePart->pdg_id()) {
546 samePart = true;
547 pVert = itrDaug->end_vertex();
548 }
549 }
550 if (samePart) EndVert = pVert;
551 } while (pVert != nullptr && pVert != EndVert);
552 }
553 return EndVert;
554 }
555
557
559 if (!theVert) return {};
560 decltype(theVert->particles_out()) finalStatePart;
561 auto outgoing = theVert->particles_out();
562 for (const auto& thePart: outgoing) {
563 if (!thePart) continue;
564 finalStatePart.push_back(thePart);
567 if (pVert == theVert) break;
568 if (pVert != nullptr) {
570 finalStatePart.insert(finalStatePart.end(),vecPart.begin(),vecPart.end());
571 }
572 }
573 return finalStatePart;
574 }
575#if !defined(XAOD_ANALYSIS)
577inline void GeVToMeV(
HepMC::GenEvent* evt) {
for (
auto& p:
evt->particles()) {
p->set_momentum(
p->momentum()*1000);
p->set_generated_mass(1000*
p->generated_mass());}}
578inline void MeVToGeV(
HepMC::GenEvent* evt) {
for (
auto& p:
evt->particles()) {
p->set_momentum(
p->momentum()*1.0/1000);
p->set_generated_mass(1.0/1000*
p->generated_mass());} }
579
580#endif
581}
582#endif
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.
bool is_simulation_vertex(const T &v)
Method to establish if the vertex was created during simulation (TODO migrate to be based on status).
constexpr int SIM_STATUS_THRESHOLD
Constant definiting the status threshold for simulated particles, eg. can be used to separate generat...
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...
constexpr bool is_smart_ptr_v
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,...
HepMC3::GenEvent GenEvent
bool isConditionB(const T &p)
bool isConditionA(const T &p)
To be understood.
bool isConditionC(const T &p)
T findMatching(C TruthContainer, T p)
Function to find a particle in container.
static const int GRAVITON
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.
void MeVToGeV(HepMC::GenEvent *evt)
bool isStableOrSimDecayed(const T &p)
Identify if particle is satble or decayed in simulation.
bool isPhoton(const T &p)
bool isSpecialNonInteracting(const T &p)
Identify a special non-interacting particles.
bool isFromHadron(T p, U hadron, bool &fromTau, bool &fromBSM)
Function to classify the particle.
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
bool isGeantino(const T &p)
bool isSimInteracting(const T &p)
Identify if the particle could interact with the detector during the simulation, e....
void GeVToMeV(HepMC::GenEvent *evt)
bool isEMInteracting(const T &p)
void findParticleAncestors(T thePart, std::set< T > &allancestors)
Function to find all ancestors of the particle.
bool isStrongInteracting(const T &p)
bool isInteracting(const T &p)
Identify if the particle with given PDG ID would not interact with the detector, i....
auto findFinalStateParticles(V theVert) -> decltype(theVert->particles_out())
Function to find the stable particle descendants of the given vertex..
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 isDecayed(const T &p)
Identify if the particle decayed.
T findMother(T thePart)
Function to get a mother of particle. MCTruthClassifier legacy.
void findParticleStableDescendants(T thePart, std::set< T > &allstabledescendants)
Function to get the particle stable MC daughters.
bool isBeam(const T &p)
Identify if the particle is beam particle.
bool isFinalState(const T &p)
Identify if the particle is final state particle.
bool isGenStable(const T &p)
Determine if the particle is stable at the generator (not det-sim) level,.
bool isHadron(const T &p)
bool isSimStable(const T &p)
Identify if the particle is considered stable at the post-detector-sim stage.
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.