File indexing completed on 2026-08-06 09:38:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include "ThePEG/Vectors/HepMCTraits.h"
0013 #ifdef HAVE_HEPMC3
0014 #include "HepMC3/GenEvent.h"
0015 #include "HepMC3/GenVertex.h"
0016 #include "HepMC3/GenParticle.h"
0017 #include "HepMC3/Version.h"
0018 #include "HepMC3/WriterAscii.h"
0019 #include "HepMC3/WriterHEPEVT.h"
0020 #include "HepMC3/WriterAsciiHepMC2.h"
0021 #ifdef HAVE_HEPMC3_WRITERROOT_H
0022 #include "HepMC3/WriterRoot.h"
0023 #endif
0024 #ifdef HAVE_HEPMC3_WRITERROOTTREE_H
0025 #include "HepMC3/WriterRootTree.h"
0026 #endif
0027 namespace HepMC3 {
0028 using PdfInfo=GenPdfInfo;
0029 using Polarization=std::pair<double,double>;
0030 }
0031 namespace HepMC=HepMC3;
0032 #else
0033 #include "HepMC/GenEvent.h"
0034 #include "HepMC/GenVertex.h"
0035 #include "HepMC/GenParticle.h"
0036 #include "HepMC/Version.h"
0037 #include "HepMC/IO_BaseClass.h"
0038 #include "HepMC/IO_GenEvent.h"
0039 #include "HepMC/IO_AsciiParticles.h"
0040 namespace HepMC {
0041 #undef GenParticlePtr
0042 #undef GenVertexPtr
0043 typedef GenParticle * GenParticlePtr;
0044 typedef GenVertex * GenVertexPtr;
0045 }
0046 #endif
0047 namespace ThePEG {
0048
0049
0050
0051 #ifndef HAVE_HEPMC3
0052 template<>
0053 struct HepMCTraits<HepMC::GenEvent>
0054 : public HepMCTraitsBase<HepMC::GenEvent,
0055 HepMC::GenParticle,
0056 HepMC::GenParticle *,
0057 HepMC::GenVertex,
0058 HepMC::GenVertex *,
0059 HepMC::Polarization,
0060 HepMC::PdfInfo>
0061 {
0062 #else
0063
0064 template<>
0065 struct HepMCTraits<HepMC::GenEvent>
0066 : public HepMCTraitsBase<HepMC::GenEvent,
0067 HepMC::GenParticle,
0068 HepMC::GenParticlePtr,
0069 HepMC::GenVertex,
0070 HepMC::GenVertexPtr,
0071 HepMC::Polarization,
0072 HepMC::PdfInfo>
0073 {
0074
0075
0076 static EventT * newEvent(long evno, double weight,
0077 const map<string,double>& optionalWeights) {
0078 EventT * e = new EventT(HepMC::Units::GEV, HepMC::Units::MM);
0079 e->set_event_number(evno);
0080 e->set_event_number(evno);
0081
0082 std::vector<double> wvalues;
0083
0084
0085 wvalues.push_back(weight);
0086 for ( map<string,double>::const_iterator w = optionalWeights.begin();
0087 w != optionalWeights.end(); ++w ) {
0088
0089 wvalues.push_back(w->second);
0090 }
0091
0092 e->weights()=wvalues;
0093 return e;
0094 }
0095
0096
0097 static VertexPtrT newVertex() {
0098 return std::make_shared<VertexT>(VertexT());
0099 }
0100
0101
0102
0103
0104 static void setScaleAndAlphas(EventT & e, Energy2 scale,
0105 double aS, double aEM, Energy unit) {
0106 e.add_attribute("event_scale",std::make_shared<HepMC::DoubleAttribute>(sqrt(scale)/unit));
0107 e.add_attribute("mpi",std::make_shared<HepMC::IntAttribute>(-1));
0108 e.add_attribute("signal_process_id",std::make_shared<HepMC::IntAttribute>(0));
0109 e.add_attribute("alphaQCD",std::make_shared<HepMC::DoubleAttribute>(aS));
0110 e.add_attribute("alphaQED",std::make_shared<HepMC::DoubleAttribute>(aEM));
0111 }
0112
0113
0114
0115 static void setColourLine(ParticleT & p, int indx, int coline) {
0116 p.add_attribute("flow"+std::to_string(indx),std::make_shared<HepMC::IntAttribute>(coline));
0117 }
0118
0119
0120 static void addIncoming(VertexT & v, ParticlePtrT p) {
0121 v.add_particle_in(p);
0122 }
0123
0124
0125 static void addOutgoing(VertexT & v, ParticlePtrT p) {
0126 v.add_particle_out(p);
0127 }
0128
0129
0130 static void setSignalProcessVertex(EventT & e, VertexPtrT v) {
0131 e.add_vertex(v);
0132 e.add_attribute("signal_process_vertex",
0133 std::make_shared<HepMC::IntAttribute>(v->id()));
0134 }
0135
0136
0137 static void addVertex(EventT & e, VertexPtrT v) {
0138 e.add_vertex(v);
0139 }
0140
0141
0142 static void setBeamParticles(EventT & e, ParticlePtrT p1, ParticlePtrT p2) {
0143
0144 p1->set_status(4);
0145 p2->set_status(4);
0146 e.set_beam_particles(p1, p2);
0147 }
0148
0149
0150
0151
0152
0153 static ParticlePtrT newParticle(const Lorentz5Momentum & p,
0154 long id, int status, Energy unit) {
0155
0156
0157 HepMC::FourVector p_scalar(p.x()/unit, p.y()/unit, p.z()/unit, p.e()/unit);
0158 ParticlePtrT genp = std::make_shared<ParticleT>(ParticleT(p_scalar, id, status));
0159 genp->set_generated_mass(p.mass()/unit);
0160 return genp;
0161 }
0162
0163
0164
0165 static void setPolarization(ParticleT & genp, double the, double phi) {
0166 genp.add_attribute("theta",std::make_shared<HepMC::DoubleAttribute>(the));
0167 genp.add_attribute("phi",std::make_shared<HepMC::DoubleAttribute>(phi));
0168 }
0169
0170
0171
0172 static void setPosition(VertexT & v, const LorentzPoint & p, Length unit) {
0173 HepMC::FourVector v_scaled(p.x()/unit, p.y()/unit, p.z()/unit, p.e()/unit);
0174 v.set_position(v_scaled);
0175 }
0176
0177 #endif
0178
0179 };
0180 }