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 678 of file HepMCHelpers.h.

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

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

◆ line() [1/4]

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

Definition at line 676 of file HepMCHelpers.h.

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

◆ line() [2/4]

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

Definition at line 677 of file HepMCHelpers.h.

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