ATLAS Offline Software
Loading...
Searching...
No Matches
MC::HepMC::Print Namespace Reference

Functions

void line (std::ostream &os, const GenVertex &v)
void line (std::ostream &os, const GenVertex *v)
void line (std::ostream &os, const GenEvent &e)
void line (std::ostream &os, const GenEvent *e)
void content (std::ostream &os, const GenEvent &e)
void content (std::ostream &os, const GenEvent *e)

Function Documentation

◆ content() [1/2]

void MC::HepMC::Print::content ( std::ostream & os,
const GenEvent & e )
inline

Definition at line 698 of file HepMCHelpers.h.

719{
720inline
721auto particles_in (const HepMC::GenVertex* p) {
722 return std::ranges::subrange (p->particles_in_const_begin(),
723 p->particles_in_const_end());
724}
725}
726#endif
727
728namespace MC
729{
730 template <class VTX>
731 auto particles_in (const VTX* p) { return p->particles_in(); }
732 template <class VTX>
733 auto particles_in (const std::shared_ptr<VTX>& p) { return p->particles_in(); }
734
735 namespace Pythia8
736 {
738 template <class T> inline bool isConditionA(const T& p) { return p->status() == 62 || p->status() == 52 || p->status() == 21 || p->status() == 22;}
739
740 template <class T> inline bool isConditionB(const T& p) { return p->status() == 23;}
741
742 template <class T> inline bool isConditionC(const T& p) { return p->status() > 30 && p->status() < 40;}
743 }
744
745#include "AtlasPID.h"
746
748 template <class T> inline bool isInteracting(const T& p) { return isStrongInteracting<T>(p) || isEMInteracting<T>(p) || isGeantino<T>(p); }
749
751 template <class T> inline bool isChargedNonShowering(const T& p) { return (isMuon<T>(p) || isSUSY<T>(p)); }
752
754 template <class T> inline bool isBeam(const T& p) { return HepMC::status(p)%HepMC::SIM_STATUS_THRESHOLD == 4;}
755
757 template <class T> inline bool isDecayed(const T& p) { return HepMC::status(p)%HepMC::SIM_STATUS_THRESHOLD == 2;}
758
760 template <class T> inline bool isStable(const T& p) { return HepMC::status(p)%HepMC::SIM_STATUS_THRESHOLD == 1;}
761
763 template <class T> inline bool isFinalState(const T& p) { return HepMC::status(p)%HepMC::SIM_STATUS_THRESHOLD == 1 && !p->end_vertex();}
764
766 template <class T> inline bool isPhysical(const T& p) { return isStable<T>(p) || isDecayed<T>(p); }
767
769 template <class T> inline bool isGenStable(const T& p) { return isStable<T>(p) && !HepMC::is_simulation_particle<T>(p);}
770
772 template <class T> inline bool isSimStable(const T& p) { return isStable<T>(p) && !p->end_vertex() && HepMC::is_simulation_particle<T>(p);}
773
775 template <class T> inline bool isSimInteracting(const T& p) { return isGenStable<T>(p) && isInteracting<T>(p);}
776
780 template <class T> inline bool isStableOrSimDecayed(const T& p) {
781 const auto vertex = p->end_vertex();
782 return ( isStable<T>(p) || (isDecayed<T>(p) && (!vertex || HepMC::is_simulation_vertex(vertex))));
783 }
784
786 template <class T> inline bool isZeroEnergyPhoton(const T& p) { return isPhoton<T>(p) && p->e() == 0;}
787
789 template <class T> inline bool isSpecialNonInteracting(const T& p) {
790 const int apid = std::abs(p->pdg_id());
791 if (apid == NU_E || apid == NU_MU || apid == NU_TAU) return true; //< neutrinos
792 if (apid == 1000022 || apid == 1000024 || apid == 5100022) return true; // SUSY & KK photon and Z partners
793 if (apid == GRAVITON || apid == 1000039 || apid == 5000039) return true; //< gravitons: standard, SUSY and KK
794 if (apid == 9000001 || apid == 9000002 || apid == 9000003 || apid == 9000004 || apid == 9000005 || apid == 9000006) return true; //< exotic particles from monotop model
795 return false;
796 }
797
799
800 template <class T> T findMother(T thePart) {
801 auto partOriVert = thePart->production_vertex();
802 if (!partOriVert) return nullptr;
803
804 long partPDG = thePart->pdg_id();
805 long MotherPDG(0);
806
807 auto MothOriVert = partOriVert;
808 MothOriVert = nullptr;
809 T theMoth(nullptr);
810
811 size_t itr = 0;
812 do {
813 if (itr != 0) partOriVert = MothOriVert;
814 for ( const auto& p : particles_in(partOriVert) ) {
815 theMoth = p;
816 if (!theMoth) continue;
817 MotherPDG = theMoth->pdg_id();
818 MothOriVert = theMoth->production_vertex();
819 if (MotherPDG == partPDG) break;
820 }
821 itr++;
822 if (itr > 100) {
823 break;
824 }
825 } while (MothOriVert != nullptr && MotherPDG == partPDG && !HepMC::is_simulation_particle(thePart) &&
826 MothOriVert != partOriVert);
827 return theMoth;
828 }
829
831
832 template <class C, class T> T findMatching(C TruthContainer, T p) {
833 T ptrPart = nullptr;
834 if (!p) return ptrPart;
835 if constexpr (std::is_pointer_v<C> || HepMC::is_smart_ptr_v<C>){ //C is ptr
836 for (T truthParticle : *TruthContainer) {
837 if (HepMC::is_sim_descendant(p,truthParticle)) {
838 ptrPart = truthParticle;
839 break;
840 }
841 }
842 }
843 else {
844 for (T truthParticle : TruthContainer) {
845 if (HepMC::is_sim_descendant(p,truthParticle)) {
846 ptrPart = truthParticle;
847 break;
848 }
849 }
850 }
851 return ptrPart;
852 }
854
855 template <class T> void findParticleAncestors(T thePart, std::set<T>& allancestors) {
856 auto prodVtx = thePart->production_vertex();
857 if (!prodVtx) return;
858 for (const auto& theMother: prodVtx->particles_in()) {
859 if (!theMother) continue;
860 allancestors.insert(theMother);
861 findParticleAncestors(theMother, allancestors);
862 }
863 }
864
866
867 template <class T> void findParticleStableDescendants(T thePart, std::set<T>& allstabledescendants) {
868 auto endVtx = thePart->end_vertex();
869 if (!endVtx) return;
870 for (const auto& theDaughter: endVtx->particles_out()) {
871 if (!theDaughter) continue;
872 if (isStable(theDaughter) && !HepMC::is_simulation_particle(theDaughter)) {
873 allstabledescendants.insert(theDaughter);
874 }
875 findParticleStableDescendants(theDaughter, allstabledescendants);
876 }
877 }
878
882
883 template <class T> bool isHardScatteringVertex(T pVert) {
884 if (pVert == nullptr) return false;
885 T pV = pVert;
886 int numOfPartIn(0);
887 int pdg(0);
888
889 do {
890 pVert = pV;
891 auto incoming = pVert->particles_in();
892 numOfPartIn = incoming.size();
893 pdg = numOfPartIn && incoming.front() != nullptr ? incoming.front()->pdg_id() : 0;
894 pV = numOfPartIn && incoming.front() != nullptr ? incoming.front()->production_vertex() : nullptr;
895
896 } while (numOfPartIn == 1 && (std::abs(pdg) < 81 || std::abs(pdg) > 100) && pV != nullptr);
897
898 if (numOfPartIn == 2) {
899 auto incoming = pVert->particles_in();
900 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;
901 }
902 return false;
903}
904
908
909 template <class T, class U>
910 bool isFromHadron(T p, U hadron, bool &fromTau, bool &fromBSM) {
911 if (isHadron(p)&&!isBeam(p)) return true; // trivial case
912 auto vtx = p->production_vertex();
913 if (!vtx) return false;
914 bool fromHad = false;
915 for ( const auto& parent : particles_in(vtx) ) {
916 if (!parent) continue;
917 // should this really go into parton-level territory?
918 // probably depends where BSM particles are being decayed
919 fromBSM |= isBSM(parent);
920 if (!isPhysical(parent)) return false;
921 fromTau |= isTau(parent);
922 if (isHadron(parent)&&!isBeam(parent)) {
923 if (!hadron) hadron = parent; // assumes linear hadron parentage
924 return true;
925 }
926 fromHad |= isFromHadron(parent, hadron, fromTau, fromBSM);
927 }
928 return fromHad;
929 }
930
933
934 template <class T> auto findSimulatedEndVertex(T thePart) -> decltype(thePart->end_vertex()) {
935 decltype(thePart->end_vertex()) EndVert = thePart->end_vertex();
936 decltype(thePart->end_vertex()) pVert(nullptr);
937 if (EndVert != nullptr) {
938 do {
939 bool samePart = false;
940 pVert = nullptr;
941 auto outgoing = EndVert->particles_out();
942 auto incoming = EndVert->particles_in();
943 for (const auto& itrDaug: outgoing) {
944 if (!itrDaug) continue;
945 if ((( HepMC::is_same_generator_particle(itrDaug,thePart)) ||
946 // brem on generator level for tau
947 (outgoing.size() == 1 && incoming.size() == 1 &&
949 itrDaug->pdg_id() == thePart->pdg_id()) {
950 samePart = true;
951 pVert = itrDaug->end_vertex();
952 }
953 }
954 if (samePart) EndVert = pVert;
955 } while (pVert != nullptr && pVert != EndVert); // pVert!=EndVert to prevent Sherpa loop
956 }
957 return EndVert;
958 }
959
961
962 template <class V> auto findFinalStateParticles(V theVert) -> decltype(theVert->particles_out()) {
963 if (!theVert) return {};
964 decltype(theVert->particles_out()) finalStatePart;
965 auto outgoing = theVert->particles_out();
966 for (const auto& thePart: outgoing) {
967 if (!thePart) continue;
968 finalStatePart.push_back(thePart);
969 if (isStable(thePart)) continue;
970 V pVert = findSimulatedEndVertex(thePart);
971 if (pVert == theVert) break; // to prevent Sherpa loop
972 if (pVert != nullptr) {
973 auto vecPart = findFinalStateParticles<V>(pVert);
974 finalStatePart.insert(finalStatePart.end(),vecPart.begin(),vecPart.end());
975 }
976 }
977 return finalStatePart;
978 }
979#if !defined(XAOD_ANALYSIS)
980#include "AtlasHepMC/GenEvent.h"
981#ifdef HEPMC3
982inline void GeVToMeV(HepMC::GenEvent* evt) { for (auto& p: evt->particles()) { p->set_momentum(p->momentum()*1000); p->set_generated_mass(1000* p->generated_mass());}}
983inline 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());} }
984#else
985inline void GeVToMeV(HepMC::GenEvent* evt) {
986 for (HepMC::GenEvent::particle_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p) {
987 const HepMC::FourVector fv((*p)->momentum().px() * 1000,
988 (*p)->momentum().py() * 1000,
989 (*p)->momentum().pz() * 1000,
990 (*p)->momentum().e() * 1000);
991 (*p)->set_momentum(fv);
992 (*p)->set_generated_mass(1000 * (*p)->generated_mass());
993 }
994}
995inline void MeVToGeV(HepMC::GenEvent* evt) {
996 for (HepMC::GenEvent::particle_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p) {
997 const HepMC::FourVector fv((*p)->momentum().px() / 1000,
998 (*p)->momentum().py() / 1000,
999 (*p)->momentum().pz() / 1000,
1000 (*p)->momentum().e() / 1000);
1001 (*p)->set_momentum(fv);
1002 (*p)->set_generated_mass((*p)->generated_mass() / 1000);
1003 }
1004}
1005#endif
1006#endif
1007}
1008#endif
struct color C
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...
int status(const T &p)
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,...
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....
bool isMuon(const T &p)
bool isSUSY(const T &p)
auto findFinalStateParticles(V theVert) -> decltype(theVert->particles_out())
Function to find the stable particle descendants of the given vertex..
static const int NU_MU
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.
auto particles_in(const HepMC::GenVertex *p)
void findParticleStableDescendants(T thePart, std::set< T > &allstabledescendants)
Function to get the particle stable MC daughters.
static const int NU_E
bool isBeam(const T &p)
Identify if the particle is beam particle.
static const int NU_TAU
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 isTau(const T &p)
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.
unsigned long long T

◆ content() [2/2]

void MC::HepMC::Print::content ( std::ostream & os,
const GenEvent * e )
inline

Definition at line 699 of file HepMCHelpers.h.

720{
721inline
722auto particles_in (const HepMC::GenVertex* p) {
723 return std::ranges::subrange (p->particles_in_const_begin(),
724 p->particles_in_const_end());
725}
726}
727#endif
728
729namespace MC
730{
731 template <class VTX>
732 auto particles_in (const VTX* p) { return p->particles_in(); }
733 template <class VTX>
734 auto particles_in (const std::shared_ptr<VTX>& p) { return p->particles_in(); }
735
736 namespace Pythia8
737 {
739 template <class T> inline bool isConditionA(const T& p) { return p->status() == 62 || p->status() == 52 || p->status() == 21 || p->status() == 22;}
740
741 template <class T> inline bool isConditionB(const T& p) { return p->status() == 23;}
742
743 template <class T> inline bool isConditionC(const T& p) { return p->status() > 30 && p->status() < 40;}
744 }
745
746#include "AtlasPID.h"
747
749 template <class T> inline bool isInteracting(const T& p) { return isStrongInteracting<T>(p) || isEMInteracting<T>(p) || isGeantino<T>(p); }
750
752 template <class T> inline bool isChargedNonShowering(const T& p) { return (isMuon<T>(p) || isSUSY<T>(p)); }
753
755 template <class T> inline bool isBeam(const T& p) { return HepMC::status(p)%HepMC::SIM_STATUS_THRESHOLD == 4;}
756
758 template <class T> inline bool isDecayed(const T& p) { return HepMC::status(p)%HepMC::SIM_STATUS_THRESHOLD == 2;}
759
761 template <class T> inline bool isStable(const T& p) { return HepMC::status(p)%HepMC::SIM_STATUS_THRESHOLD == 1;}
762
764 template <class T> inline bool isFinalState(const T& p) { return HepMC::status(p)%HepMC::SIM_STATUS_THRESHOLD == 1 && !p->end_vertex();}
765
767 template <class T> inline bool isPhysical(const T& p) { return isStable<T>(p) || isDecayed<T>(p); }
768
770 template <class T> inline bool isGenStable(const T& p) { return isStable<T>(p) && !HepMC::is_simulation_particle<T>(p);}
771
773 template <class T> inline bool isSimStable(const T& p) { return isStable<T>(p) && !p->end_vertex() && HepMC::is_simulation_particle<T>(p);}
774
776 template <class T> inline bool isSimInteracting(const T& p) { return isGenStable<T>(p) && isInteracting<T>(p);}
777
781 template <class T> inline bool isStableOrSimDecayed(const T& p) {
782 const auto vertex = p->end_vertex();
783 return ( isStable<T>(p) || (isDecayed<T>(p) && (!vertex || HepMC::is_simulation_vertex(vertex))));
784 }
785
787 template <class T> inline bool isZeroEnergyPhoton(const T& p) { return isPhoton<T>(p) && p->e() == 0;}
788
790 template <class T> inline bool isSpecialNonInteracting(const T& p) {
791 const int apid = std::abs(p->pdg_id());
792 if (apid == NU_E || apid == NU_MU || apid == NU_TAU) return true; //< neutrinos
793 if (apid == 1000022 || apid == 1000024 || apid == 5100022) return true; // SUSY & KK photon and Z partners
794 if (apid == GRAVITON || apid == 1000039 || apid == 5000039) return true; //< gravitons: standard, SUSY and KK
795 if (apid == 9000001 || apid == 9000002 || apid == 9000003 || apid == 9000004 || apid == 9000005 || apid == 9000006) return true; //< exotic particles from monotop model
796 return false;
797 }
798
800
801 template <class T> T findMother(T thePart) {
802 auto partOriVert = thePart->production_vertex();
803 if (!partOriVert) return nullptr;
804
805 long partPDG = thePart->pdg_id();
806 long MotherPDG(0);
807
808 auto MothOriVert = partOriVert;
809 MothOriVert = nullptr;
810 T theMoth(nullptr);
811
812 size_t itr = 0;
813 do {
814 if (itr != 0) partOriVert = MothOriVert;
815 for ( const auto& p : particles_in(partOriVert) ) {
816 theMoth = p;
817 if (!theMoth) continue;
818 MotherPDG = theMoth->pdg_id();
819 MothOriVert = theMoth->production_vertex();
820 if (MotherPDG == partPDG) break;
821 }
822 itr++;
823 if (itr > 100) {
824 break;
825 }
826 } while (MothOriVert != nullptr && MotherPDG == partPDG && !HepMC::is_simulation_particle(thePart) &&
827 MothOriVert != partOriVert);
828 return theMoth;
829 }
830
832
833 template <class C, class T> T findMatching(C TruthContainer, T p) {
834 T ptrPart = nullptr;
835 if (!p) return ptrPart;
836 if constexpr (std::is_pointer_v<C> || HepMC::is_smart_ptr_v<C>){ //C is ptr
837 for (T truthParticle : *TruthContainer) {
838 if (HepMC::is_sim_descendant(p,truthParticle)) {
839 ptrPart = truthParticle;
840 break;
841 }
842 }
843 }
844 else {
845 for (T truthParticle : TruthContainer) {
846 if (HepMC::is_sim_descendant(p,truthParticle)) {
847 ptrPart = truthParticle;
848 break;
849 }
850 }
851 }
852 return ptrPart;
853 }
855
856 template <class T> void findParticleAncestors(T thePart, std::set<T>& allancestors) {
857 auto prodVtx = thePart->production_vertex();
858 if (!prodVtx) return;
859 for (const auto& theMother: prodVtx->particles_in()) {
860 if (!theMother) continue;
861 allancestors.insert(theMother);
862 findParticleAncestors(theMother, allancestors);
863 }
864 }
865
867
868 template <class T> void findParticleStableDescendants(T thePart, std::set<T>& allstabledescendants) {
869 auto endVtx = thePart->end_vertex();
870 if (!endVtx) return;
871 for (const auto& theDaughter: endVtx->particles_out()) {
872 if (!theDaughter) continue;
873 if (isStable(theDaughter) && !HepMC::is_simulation_particle(theDaughter)) {
874 allstabledescendants.insert(theDaughter);
875 }
876 findParticleStableDescendants(theDaughter, allstabledescendants);
877 }
878 }
879
883
884 template <class T> bool isHardScatteringVertex(T pVert) {
885 if (pVert == nullptr) return false;
886 T pV = pVert;
887 int numOfPartIn(0);
888 int pdg(0);
889
890 do {
891 pVert = pV;
892 auto incoming = pVert->particles_in();
893 numOfPartIn = incoming.size();
894 pdg = numOfPartIn && incoming.front() != nullptr ? incoming.front()->pdg_id() : 0;
895 pV = numOfPartIn && incoming.front() != nullptr ? incoming.front()->production_vertex() : nullptr;
896
897 } while (numOfPartIn == 1 && (std::abs(pdg) < 81 || std::abs(pdg) > 100) && pV != nullptr);
898
899 if (numOfPartIn == 2) {
900 auto incoming = pVert->particles_in();
901 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;
902 }
903 return false;
904}
905
909
910 template <class T, class U>
911 bool isFromHadron(T p, U hadron, bool &fromTau, bool &fromBSM) {
912 if (isHadron(p)&&!isBeam(p)) return true; // trivial case
913 auto vtx = p->production_vertex();
914 if (!vtx) return false;
915 bool fromHad = false;
916 for ( const auto& parent : particles_in(vtx) ) {
917 if (!parent) continue;
918 // should this really go into parton-level territory?
919 // probably depends where BSM particles are being decayed
920 fromBSM |= isBSM(parent);
921 if (!isPhysical(parent)) return false;
922 fromTau |= isTau(parent);
923 if (isHadron(parent)&&!isBeam(parent)) {
924 if (!hadron) hadron = parent; // assumes linear hadron parentage
925 return true;
926 }
927 fromHad |= isFromHadron(parent, hadron, fromTau, fromBSM);
928 }
929 return fromHad;
930 }
931
934
935 template <class T> auto findSimulatedEndVertex(T thePart) -> decltype(thePart->end_vertex()) {
936 decltype(thePart->end_vertex()) EndVert = thePart->end_vertex();
937 decltype(thePart->end_vertex()) pVert(nullptr);
938 if (EndVert != nullptr) {
939 do {
940 bool samePart = false;
941 pVert = nullptr;
942 auto outgoing = EndVert->particles_out();
943 auto incoming = EndVert->particles_in();
944 for (const auto& itrDaug: outgoing) {
945 if (!itrDaug) continue;
946 if ((( HepMC::is_same_generator_particle(itrDaug,thePart)) ||
947 // brem on generator level for tau
948 (outgoing.size() == 1 && incoming.size() == 1 &&
950 itrDaug->pdg_id() == thePart->pdg_id()) {
951 samePart = true;
952 pVert = itrDaug->end_vertex();
953 }
954 }
955 if (samePart) EndVert = pVert;
956 } while (pVert != nullptr && pVert != EndVert); // pVert!=EndVert to prevent Sherpa loop
957 }
958 return EndVert;
959 }
960
962
963 template <class V> auto findFinalStateParticles(V theVert) -> decltype(theVert->particles_out()) {
964 if (!theVert) return {};
965 decltype(theVert->particles_out()) finalStatePart;
966 auto outgoing = theVert->particles_out();
967 for (const auto& thePart: outgoing) {
968 if (!thePart) continue;
969 finalStatePart.push_back(thePart);
970 if (isStable(thePart)) continue;
971 V pVert = findSimulatedEndVertex(thePart);
972 if (pVert == theVert) break; // to prevent Sherpa loop
973 if (pVert != nullptr) {
974 auto vecPart = findFinalStateParticles<V>(pVert);
975 finalStatePart.insert(finalStatePart.end(),vecPart.begin(),vecPart.end());
976 }
977 }
978 return finalStatePart;
979 }
980#if !defined(XAOD_ANALYSIS)
981#include "AtlasHepMC/GenEvent.h"
982#ifdef HEPMC3
983inline void GeVToMeV(HepMC::GenEvent* evt) { for (auto& p: evt->particles()) { p->set_momentum(p->momentum()*1000); p->set_generated_mass(1000* p->generated_mass());}}
984inline 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());} }
985#else
986inline void GeVToMeV(HepMC::GenEvent* evt) {
987 for (HepMC::GenEvent::particle_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p) {
988 const HepMC::FourVector fv((*p)->momentum().px() * 1000,
989 (*p)->momentum().py() * 1000,
990 (*p)->momentum().pz() * 1000,
991 (*p)->momentum().e() * 1000);
992 (*p)->set_momentum(fv);
993 (*p)->set_generated_mass(1000 * (*p)->generated_mass());
994 }
995}
996inline void MeVToGeV(HepMC::GenEvent* evt) {
997 for (HepMC::GenEvent::particle_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p) {
998 const HepMC::FourVector fv((*p)->momentum().px() / 1000,
999 (*p)->momentum().py() / 1000,
1000 (*p)->momentum().pz() / 1000,
1001 (*p)->momentum().e() / 1000);
1002 (*p)->set_momentum(fv);
1003 (*p)->set_generated_mass((*p)->generated_mass() / 1000);
1004 }
1005}
1006#endif
1007#endif
1008}
1009#endif

◆ line() [1/4]

void MC::HepMC::Print::line ( std::ostream & os,
const GenEvent & e )
inline

Definition at line 696 of file HepMCHelpers.h.

717{
718inline
719auto particles_in (const HepMC::GenVertex* p) {
720 return std::ranges::subrange (p->particles_in_const_begin(),
721 p->particles_in_const_end());
722}
723}
724#endif
725
726namespace MC
727{
728 template <class VTX>
729 auto particles_in (const VTX* p) { return p->particles_in(); }
730 template <class VTX>
731 auto particles_in (const std::shared_ptr<VTX>& p) { return p->particles_in(); }
732
733 namespace Pythia8
734 {
736 template <class T> inline bool isConditionA(const T& p) { return p->status() == 62 || p->status() == 52 || p->status() == 21 || p->status() == 22;}
737
738 template <class T> inline bool isConditionB(const T& p) { return p->status() == 23;}
739
740 template <class T> inline bool isConditionC(const T& p) { return p->status() > 30 && p->status() < 40;}
741 }
742
743#include "AtlasPID.h"
744
746 template <class T> inline bool isInteracting(const T& p) { return isStrongInteracting<T>(p) || isEMInteracting<T>(p) || isGeantino<T>(p); }
747
749 template <class T> inline bool isChargedNonShowering(const T& p) { return (isMuon<T>(p) || isSUSY<T>(p)); }
750
752 template <class T> inline bool isBeam(const T& p) { return HepMC::status(p)%HepMC::SIM_STATUS_THRESHOLD == 4;}
753
755 template <class T> inline bool isDecayed(const T& p) { return HepMC::status(p)%HepMC::SIM_STATUS_THRESHOLD == 2;}
756
758 template <class T> inline bool isStable(const T& p) { return HepMC::status(p)%HepMC::SIM_STATUS_THRESHOLD == 1;}
759
761 template <class T> inline bool isFinalState(const T& p) { return HepMC::status(p)%HepMC::SIM_STATUS_THRESHOLD == 1 && !p->end_vertex();}
762
764 template <class T> inline bool isPhysical(const T& p) { return isStable<T>(p) || isDecayed<T>(p); }
765
767 template <class T> inline bool isGenStable(const T& p) { return isStable<T>(p) && !HepMC::is_simulation_particle<T>(p);}
768
770 template <class T> inline bool isSimStable(const T& p) { return isStable<T>(p) && !p->end_vertex() && HepMC::is_simulation_particle<T>(p);}
771
773 template <class T> inline bool isSimInteracting(const T& p) { return isGenStable<T>(p) && isInteracting<T>(p);}
774
778 template <class T> inline bool isStableOrSimDecayed(const T& p) {
779 const auto vertex = p->end_vertex();
780 return ( isStable<T>(p) || (isDecayed<T>(p) && (!vertex || HepMC::is_simulation_vertex(vertex))));
781 }
782
784 template <class T> inline bool isZeroEnergyPhoton(const T& p) { return isPhoton<T>(p) && p->e() == 0;}
785
787 template <class T> inline bool isSpecialNonInteracting(const T& p) {
788 const int apid = std::abs(p->pdg_id());
789 if (apid == NU_E || apid == NU_MU || apid == NU_TAU) return true; //< neutrinos
790 if (apid == 1000022 || apid == 1000024 || apid == 5100022) return true; // SUSY & KK photon and Z partners
791 if (apid == GRAVITON || apid == 1000039 || apid == 5000039) return true; //< gravitons: standard, SUSY and KK
792 if (apid == 9000001 || apid == 9000002 || apid == 9000003 || apid == 9000004 || apid == 9000005 || apid == 9000006) return true; //< exotic particles from monotop model
793 return false;
794 }
795
797
798 template <class T> T findMother(T thePart) {
799 auto partOriVert = thePart->production_vertex();
800 if (!partOriVert) return nullptr;
801
802 long partPDG = thePart->pdg_id();
803 long MotherPDG(0);
804
805 auto MothOriVert = partOriVert;
806 MothOriVert = nullptr;
807 T theMoth(nullptr);
808
809 size_t itr = 0;
810 do {
811 if (itr != 0) partOriVert = MothOriVert;
812 for ( const auto& p : particles_in(partOriVert) ) {
813 theMoth = p;
814 if (!theMoth) continue;
815 MotherPDG = theMoth->pdg_id();
816 MothOriVert = theMoth->production_vertex();
817 if (MotherPDG == partPDG) break;
818 }
819 itr++;
820 if (itr > 100) {
821 break;
822 }
823 } while (MothOriVert != nullptr && MotherPDG == partPDG && !HepMC::is_simulation_particle(thePart) &&
824 MothOriVert != partOriVert);
825 return theMoth;
826 }
827
829
830 template <class C, class T> T findMatching(C TruthContainer, T p) {
831 T ptrPart = nullptr;
832 if (!p) return ptrPart;
833 if constexpr (std::is_pointer_v<C> || HepMC::is_smart_ptr_v<C>){ //C is ptr
834 for (T truthParticle : *TruthContainer) {
835 if (HepMC::is_sim_descendant(p,truthParticle)) {
836 ptrPart = truthParticle;
837 break;
838 }
839 }
840 }
841 else {
842 for (T truthParticle : TruthContainer) {
843 if (HepMC::is_sim_descendant(p,truthParticle)) {
844 ptrPart = truthParticle;
845 break;
846 }
847 }
848 }
849 return ptrPart;
850 }
852
853 template <class T> void findParticleAncestors(T thePart, std::set<T>& allancestors) {
854 auto prodVtx = thePart->production_vertex();
855 if (!prodVtx) return;
856 for (const auto& theMother: prodVtx->particles_in()) {
857 if (!theMother) continue;
858 allancestors.insert(theMother);
859 findParticleAncestors(theMother, allancestors);
860 }
861 }
862
864
865 template <class T> void findParticleStableDescendants(T thePart, std::set<T>& allstabledescendants) {
866 auto endVtx = thePart->end_vertex();
867 if (!endVtx) return;
868 for (const auto& theDaughter: endVtx->particles_out()) {
869 if (!theDaughter) continue;
870 if (isStable(theDaughter) && !HepMC::is_simulation_particle(theDaughter)) {
871 allstabledescendants.insert(theDaughter);
872 }
873 findParticleStableDescendants(theDaughter, allstabledescendants);
874 }
875 }
876
880
881 template <class T> bool isHardScatteringVertex(T pVert) {
882 if (pVert == nullptr) return false;
883 T pV = pVert;
884 int numOfPartIn(0);
885 int pdg(0);
886
887 do {
888 pVert = pV;
889 auto incoming = pVert->particles_in();
890 numOfPartIn = incoming.size();
891 pdg = numOfPartIn && incoming.front() != nullptr ? incoming.front()->pdg_id() : 0;
892 pV = numOfPartIn && incoming.front() != nullptr ? incoming.front()->production_vertex() : nullptr;
893
894 } while (numOfPartIn == 1 && (std::abs(pdg) < 81 || std::abs(pdg) > 100) && pV != nullptr);
895
896 if (numOfPartIn == 2) {
897 auto incoming = pVert->particles_in();
898 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;
899 }
900 return false;
901}
902
906
907 template <class T, class U>
908 bool isFromHadron(T p, U hadron, bool &fromTau, bool &fromBSM) {
909 if (isHadron(p)&&!isBeam(p)) return true; // trivial case
910 auto vtx = p->production_vertex();
911 if (!vtx) return false;
912 bool fromHad = false;
913 for ( const auto& parent : particles_in(vtx) ) {
914 if (!parent) continue;
915 // should this really go into parton-level territory?
916 // probably depends where BSM particles are being decayed
917 fromBSM |= isBSM(parent);
918 if (!isPhysical(parent)) return false;
919 fromTau |= isTau(parent);
920 if (isHadron(parent)&&!isBeam(parent)) {
921 if (!hadron) hadron = parent; // assumes linear hadron parentage
922 return true;
923 }
924 fromHad |= isFromHadron(parent, hadron, fromTau, fromBSM);
925 }
926 return fromHad;
927 }
928
931
932 template <class T> auto findSimulatedEndVertex(T thePart) -> decltype(thePart->end_vertex()) {
933 decltype(thePart->end_vertex()) EndVert = thePart->end_vertex();
934 decltype(thePart->end_vertex()) pVert(nullptr);
935 if (EndVert != nullptr) {
936 do {
937 bool samePart = false;
938 pVert = nullptr;
939 auto outgoing = EndVert->particles_out();
940 auto incoming = EndVert->particles_in();
941 for (const auto& itrDaug: outgoing) {
942 if (!itrDaug) continue;
943 if ((( HepMC::is_same_generator_particle(itrDaug,thePart)) ||
944 // brem on generator level for tau
945 (outgoing.size() == 1 && incoming.size() == 1 &&
947 itrDaug->pdg_id() == thePart->pdg_id()) {
948 samePart = true;
949 pVert = itrDaug->end_vertex();
950 }
951 }
952 if (samePart) EndVert = pVert;
953 } while (pVert != nullptr && pVert != EndVert); // pVert!=EndVert to prevent Sherpa loop
954 }
955 return EndVert;
956 }
957
959
960 template <class V> auto findFinalStateParticles(V theVert) -> decltype(theVert->particles_out()) {
961 if (!theVert) return {};
962 decltype(theVert->particles_out()) finalStatePart;
963 auto outgoing = theVert->particles_out();
964 for (const auto& thePart: outgoing) {
965 if (!thePart) continue;
966 finalStatePart.push_back(thePart);
967 if (isStable(thePart)) continue;
968 V pVert = findSimulatedEndVertex(thePart);
969 if (pVert == theVert) break; // to prevent Sherpa loop
970 if (pVert != nullptr) {
971 auto vecPart = findFinalStateParticles<V>(pVert);
972 finalStatePart.insert(finalStatePart.end(),vecPart.begin(),vecPart.end());
973 }
974 }
975 return finalStatePart;
976 }
977#if !defined(XAOD_ANALYSIS)
978#include "AtlasHepMC/GenEvent.h"
979#ifdef HEPMC3
980inline void GeVToMeV(HepMC::GenEvent* evt) { for (auto& p: evt->particles()) { p->set_momentum(p->momentum()*1000); p->set_generated_mass(1000* p->generated_mass());}}
981inline 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());} }
982#else
983inline void GeVToMeV(HepMC::GenEvent* evt) {
984 for (HepMC::GenEvent::particle_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p) {
985 const HepMC::FourVector fv((*p)->momentum().px() * 1000,
986 (*p)->momentum().py() * 1000,
987 (*p)->momentum().pz() * 1000,
988 (*p)->momentum().e() * 1000);
989 (*p)->set_momentum(fv);
990 (*p)->set_generated_mass(1000 * (*p)->generated_mass());
991 }
992}
993inline void MeVToGeV(HepMC::GenEvent* evt) {
994 for (HepMC::GenEvent::particle_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p) {
995 const HepMC::FourVector fv((*p)->momentum().px() / 1000,
996 (*p)->momentum().py() / 1000,
997 (*p)->momentum().pz() / 1000,
998 (*p)->momentum().e() / 1000);
999 (*p)->set_momentum(fv);
1000 (*p)->set_generated_mass((*p)->generated_mass() / 1000);
1001 }
1002}
1003#endif
1004#endif
1005}
1006#endif

◆ line() [2/4]

void MC::HepMC::Print::line ( std::ostream & os,
const GenEvent * e )
inline

Definition at line 697 of file HepMCHelpers.h.

718{
719inline
720auto particles_in (const HepMC::GenVertex* p) {
721 return std::ranges::subrange (p->particles_in_const_begin(),
722 p->particles_in_const_end());
723}
724}
725#endif
726
727namespace MC
728{
729 template <class VTX>
730 auto particles_in (const VTX* p) { return p->particles_in(); }
731 template <class VTX>
732 auto particles_in (const std::shared_ptr<VTX>& p) { return p->particles_in(); }
733
734 namespace Pythia8
735 {
737 template <class T> inline bool isConditionA(const T& p) { return p->status() == 62 || p->status() == 52 || p->status() == 21 || p->status() == 22;}
738
739 template <class T> inline bool isConditionB(const T& p) { return p->status() == 23;}
740
741 template <class T> inline bool isConditionC(const T& p) { return p->status() > 30 && p->status() < 40;}
742 }
743
744#include "AtlasPID.h"
745
747 template <class T> inline bool isInteracting(const T& p) { return isStrongInteracting<T>(p) || isEMInteracting<T>(p) || isGeantino<T>(p); }
748
750 template <class T> inline bool isChargedNonShowering(const T& p) { return (isMuon<T>(p) || isSUSY<T>(p)); }
751
753 template <class T> inline bool isBeam(const T& p) { return HepMC::status(p)%HepMC::SIM_STATUS_THRESHOLD == 4;}
754
756 template <class T> inline bool isDecayed(const T& p) { return HepMC::status(p)%HepMC::SIM_STATUS_THRESHOLD == 2;}
757
759 template <class T> inline bool isStable(const T& p) { return HepMC::status(p)%HepMC::SIM_STATUS_THRESHOLD == 1;}
760
762 template <class T> inline bool isFinalState(const T& p) { return HepMC::status(p)%HepMC::SIM_STATUS_THRESHOLD == 1 && !p->end_vertex();}
763
765 template <class T> inline bool isPhysical(const T& p) { return isStable<T>(p) || isDecayed<T>(p); }
766
768 template <class T> inline bool isGenStable(const T& p) { return isStable<T>(p) && !HepMC::is_simulation_particle<T>(p);}
769
771 template <class T> inline bool isSimStable(const T& p) { return isStable<T>(p) && !p->end_vertex() && HepMC::is_simulation_particle<T>(p);}
772
774 template <class T> inline bool isSimInteracting(const T& p) { return isGenStable<T>(p) && isInteracting<T>(p);}
775
779 template <class T> inline bool isStableOrSimDecayed(const T& p) {
780 const auto vertex = p->end_vertex();
781 return ( isStable<T>(p) || (isDecayed<T>(p) && (!vertex || HepMC::is_simulation_vertex(vertex))));
782 }
783
785 template <class T> inline bool isZeroEnergyPhoton(const T& p) { return isPhoton<T>(p) && p->e() == 0;}
786
788 template <class T> inline bool isSpecialNonInteracting(const T& p) {
789 const int apid = std::abs(p->pdg_id());
790 if (apid == NU_E || apid == NU_MU || apid == NU_TAU) return true; //< neutrinos
791 if (apid == 1000022 || apid == 1000024 || apid == 5100022) return true; // SUSY & KK photon and Z partners
792 if (apid == GRAVITON || apid == 1000039 || apid == 5000039) return true; //< gravitons: standard, SUSY and KK
793 if (apid == 9000001 || apid == 9000002 || apid == 9000003 || apid == 9000004 || apid == 9000005 || apid == 9000006) return true; //< exotic particles from monotop model
794 return false;
795 }
796
798
799 template <class T> T findMother(T thePart) {
800 auto partOriVert = thePart->production_vertex();
801 if (!partOriVert) return nullptr;
802
803 long partPDG = thePart->pdg_id();
804 long MotherPDG(0);
805
806 auto MothOriVert = partOriVert;
807 MothOriVert = nullptr;
808 T theMoth(nullptr);
809
810 size_t itr = 0;
811 do {
812 if (itr != 0) partOriVert = MothOriVert;
813 for ( const auto& p : particles_in(partOriVert) ) {
814 theMoth = p;
815 if (!theMoth) continue;
816 MotherPDG = theMoth->pdg_id();
817 MothOriVert = theMoth->production_vertex();
818 if (MotherPDG == partPDG) break;
819 }
820 itr++;
821 if (itr > 100) {
822 break;
823 }
824 } while (MothOriVert != nullptr && MotherPDG == partPDG && !HepMC::is_simulation_particle(thePart) &&
825 MothOriVert != partOriVert);
826 return theMoth;
827 }
828
830
831 template <class C, class T> T findMatching(C TruthContainer, T p) {
832 T ptrPart = nullptr;
833 if (!p) return ptrPart;
834 if constexpr (std::is_pointer_v<C> || HepMC::is_smart_ptr_v<C>){ //C is ptr
835 for (T truthParticle : *TruthContainer) {
836 if (HepMC::is_sim_descendant(p,truthParticle)) {
837 ptrPart = truthParticle;
838 break;
839 }
840 }
841 }
842 else {
843 for (T truthParticle : TruthContainer) {
844 if (HepMC::is_sim_descendant(p,truthParticle)) {
845 ptrPart = truthParticle;
846 break;
847 }
848 }
849 }
850 return ptrPart;
851 }
853
854 template <class T> void findParticleAncestors(T thePart, std::set<T>& allancestors) {
855 auto prodVtx = thePart->production_vertex();
856 if (!prodVtx) return;
857 for (const auto& theMother: prodVtx->particles_in()) {
858 if (!theMother) continue;
859 allancestors.insert(theMother);
860 findParticleAncestors(theMother, allancestors);
861 }
862 }
863
865
866 template <class T> void findParticleStableDescendants(T thePart, std::set<T>& allstabledescendants) {
867 auto endVtx = thePart->end_vertex();
868 if (!endVtx) return;
869 for (const auto& theDaughter: endVtx->particles_out()) {
870 if (!theDaughter) continue;
871 if (isStable(theDaughter) && !HepMC::is_simulation_particle(theDaughter)) {
872 allstabledescendants.insert(theDaughter);
873 }
874 findParticleStableDescendants(theDaughter, allstabledescendants);
875 }
876 }
877
881
882 template <class T> bool isHardScatteringVertex(T pVert) {
883 if (pVert == nullptr) return false;
884 T pV = pVert;
885 int numOfPartIn(0);
886 int pdg(0);
887
888 do {
889 pVert = pV;
890 auto incoming = pVert->particles_in();
891 numOfPartIn = incoming.size();
892 pdg = numOfPartIn && incoming.front() != nullptr ? incoming.front()->pdg_id() : 0;
893 pV = numOfPartIn && incoming.front() != nullptr ? incoming.front()->production_vertex() : nullptr;
894
895 } while (numOfPartIn == 1 && (std::abs(pdg) < 81 || std::abs(pdg) > 100) && pV != nullptr);
896
897 if (numOfPartIn == 2) {
898 auto incoming = pVert->particles_in();
899 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;
900 }
901 return false;
902}
903
907
908 template <class T, class U>
909 bool isFromHadron(T p, U hadron, bool &fromTau, bool &fromBSM) {
910 if (isHadron(p)&&!isBeam(p)) return true; // trivial case
911 auto vtx = p->production_vertex();
912 if (!vtx) return false;
913 bool fromHad = false;
914 for ( const auto& parent : particles_in(vtx) ) {
915 if (!parent) continue;
916 // should this really go into parton-level territory?
917 // probably depends where BSM particles are being decayed
918 fromBSM |= isBSM(parent);
919 if (!isPhysical(parent)) return false;
920 fromTau |= isTau(parent);
921 if (isHadron(parent)&&!isBeam(parent)) {
922 if (!hadron) hadron = parent; // assumes linear hadron parentage
923 return true;
924 }
925 fromHad |= isFromHadron(parent, hadron, fromTau, fromBSM);
926 }
927 return fromHad;
928 }
929
932
933 template <class T> auto findSimulatedEndVertex(T thePart) -> decltype(thePart->end_vertex()) {
934 decltype(thePart->end_vertex()) EndVert = thePart->end_vertex();
935 decltype(thePart->end_vertex()) pVert(nullptr);
936 if (EndVert != nullptr) {
937 do {
938 bool samePart = false;
939 pVert = nullptr;
940 auto outgoing = EndVert->particles_out();
941 auto incoming = EndVert->particles_in();
942 for (const auto& itrDaug: outgoing) {
943 if (!itrDaug) continue;
944 if ((( HepMC::is_same_generator_particle(itrDaug,thePart)) ||
945 // brem on generator level for tau
946 (outgoing.size() == 1 && incoming.size() == 1 &&
948 itrDaug->pdg_id() == thePart->pdg_id()) {
949 samePart = true;
950 pVert = itrDaug->end_vertex();
951 }
952 }
953 if (samePart) EndVert = pVert;
954 } while (pVert != nullptr && pVert != EndVert); // pVert!=EndVert to prevent Sherpa loop
955 }
956 return EndVert;
957 }
958
960
961 template <class V> auto findFinalStateParticles(V theVert) -> decltype(theVert->particles_out()) {
962 if (!theVert) return {};
963 decltype(theVert->particles_out()) finalStatePart;
964 auto outgoing = theVert->particles_out();
965 for (const auto& thePart: outgoing) {
966 if (!thePart) continue;
967 finalStatePart.push_back(thePart);
968 if (isStable(thePart)) continue;
969 V pVert = findSimulatedEndVertex(thePart);
970 if (pVert == theVert) break; // to prevent Sherpa loop
971 if (pVert != nullptr) {
972 auto vecPart = findFinalStateParticles<V>(pVert);
973 finalStatePart.insert(finalStatePart.end(),vecPart.begin(),vecPart.end());
974 }
975 }
976 return finalStatePart;
977 }
978#if !defined(XAOD_ANALYSIS)
979#include "AtlasHepMC/GenEvent.h"
980#ifdef HEPMC3
981inline void GeVToMeV(HepMC::GenEvent* evt) { for (auto& p: evt->particles()) { p->set_momentum(p->momentum()*1000); p->set_generated_mass(1000* p->generated_mass());}}
982inline 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());} }
983#else
984inline void GeVToMeV(HepMC::GenEvent* evt) {
985 for (HepMC::GenEvent::particle_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p) {
986 const HepMC::FourVector fv((*p)->momentum().px() * 1000,
987 (*p)->momentum().py() * 1000,
988 (*p)->momentum().pz() * 1000,
989 (*p)->momentum().e() * 1000);
990 (*p)->set_momentum(fv);
991 (*p)->set_generated_mass(1000 * (*p)->generated_mass());
992 }
993}
994inline void MeVToGeV(HepMC::GenEvent* evt) {
995 for (HepMC::GenEvent::particle_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p) {
996 const HepMC::FourVector fv((*p)->momentum().px() / 1000,
997 (*p)->momentum().py() / 1000,
998 (*p)->momentum().pz() / 1000,
999 (*p)->momentum().e() / 1000);
1000 (*p)->set_momentum(fv);
1001 (*p)->set_generated_mass((*p)->generated_mass() / 1000);
1002 }
1003}
1004#endif
1005#endif
1006}
1007#endif

◆ line() [3/4]

void MC::HepMC::Print::line ( std::ostream & os,
const GenVertex & v )
inline

Definition at line 68 of file HepMCHelpers.h.

◆ line() [4/4]

void MC::HepMC::Print::line ( std::ostream & os,
const GenVertex * v )
inline

Definition at line 69 of file HepMCHelpers.h.

69{ return isStable<T>(p) || isDecayed<T>(p); }