File indexing completed on 2025-04-13 22:49:55
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include "GeneratorInterface/Herwig7Interface/interface/HepMC3Traits.h"
0013 #include "HepMC3/GenEvent.h"
0014 #include "HepMC3/GenVertex.h"
0015 #include "HepMC3/GenParticle.h"
0016 #include "HepMC3/Version.h"
0017 #include "HepMC3/WriterAscii.h"
0018 #include "HepMC3/WriterHEPEVT.h"
0019 #include "HepMC3/WriterAsciiHepMC2.h"
0020 #ifdef HAVE_HEPMC3_WRITERROOT_H
0021 #include "HepMC3/WriterRoot.h"
0022 #endif
0023 #ifdef HAVE_HEPMC3_WRITERROOTTREE_H
0024 #include "HepMC3/WriterRootTree.h"
0025 #endif
0026 #include <string>
0027 namespace HepMC3 {
0028 using Polarization = std::pair<double, double>;
0029 }
0030 namespace ThePEG {
0031
0032
0033
0034
0035 template <>
0036 struct HepMCTraits<HepMC3::GenEvent> : public HepMCTraitsBase<HepMC3::GenEvent,
0037 HepMC3::GenParticle,
0038 HepMC3::GenParticlePtr,
0039 HepMC3::GenVertex,
0040 HepMC3::GenVertexPtr,
0041 HepMC3::Polarization,
0042 HepMC3::GenPdfInfo> {
0043
0044 static EventT *newEvent(long evno, double weight, const map<string, double> &optionalWeights) {
0045 EventT *e = new EventT(HepMC3::Units::GEV, HepMC3::Units::MM);
0046 e->set_event_number(evno);
0047 e->set_event_number(evno);
0048
0049 std::vector<double> wvalues;
0050
0051
0052 wvalues.push_back(weight);
0053 for (map<string, double>::const_iterator w = optionalWeights.begin(); w != optionalWeights.end(); ++w) {
0054
0055 wvalues.push_back(w->second);
0056 }
0057
0058 e->weights() = wvalues;
0059 return e;
0060 }
0061
0062
0063 static VertexPtrT newVertex() { return std::make_shared<VertexT>(VertexT()); }
0064
0065
0066
0067
0068 static void setScaleAndAlphas(EventT &e, Energy2 scale, double aS, double aEM, Energy unit) {
0069 e.add_attribute("event_scale", std::make_shared<HepMC3::DoubleAttribute>(sqrt(scale) / unit));
0070 e.add_attribute("mpi",
0071 std::make_shared<HepMC3::IntAttribute>(-1));
0072 e.add_attribute("signal_process_id",
0073 std::make_shared<HepMC3::IntAttribute>(0));
0074 e.add_attribute("alphaQCD", std::make_shared<HepMC3::DoubleAttribute>(aS));
0075 e.add_attribute("alphaQED", std::make_shared<HepMC3::DoubleAttribute>(aEM));
0076 }
0077
0078
0079
0080 static void setColourLine(ParticleT &p, int indx, int coline) {
0081 p.add_attribute("flow" + std::to_string(indx), std::make_shared<HepMC3::IntAttribute>(coline));
0082 }
0083
0084
0085 static void addIncoming(VertexT &v, ParticlePtrT p) { v.add_particle_in(p); }
0086
0087
0088 static void addOutgoing(VertexT &v, ParticlePtrT p) { v.add_particle_out(p); }
0089
0090
0091 static void setSignalProcessVertex(EventT &e, VertexPtrT v) {
0092 e.add_vertex(v);
0093 e.add_attribute("signal_process_vertex", std::make_shared<HepMC3::IntAttribute>(v->id()));
0094 }
0095
0096
0097 static void addVertex(EventT &e, VertexPtrT v) { e.add_vertex(v); }
0098
0099
0100 static void setBeamParticles(EventT &e, ParticlePtrT p1, ParticlePtrT p2) {
0101
0102 p1->set_status(4);
0103 p2->set_status(4);
0104 e.set_beam_particles(p1, p2);
0105 }
0106
0107
0108
0109
0110
0111 static ParticlePtrT newParticle(const Lorentz5Momentum &p, long id, int status, Energy unit) {
0112
0113
0114 HepMC3::FourVector p_scalar(p.x() / unit, p.y() / unit, p.z() / unit, p.e() / unit);
0115 ParticlePtrT genp = std::make_shared<ParticleT>(ParticleT(p_scalar, id, status));
0116 genp->set_generated_mass(p.mass() / unit);
0117 return genp;
0118 }
0119
0120
0121
0122 static void setPolarization(ParticleT &genp, double the, double phi) {
0123 genp.add_attribute("theta", std::make_shared<HepMC3::DoubleAttribute>(the));
0124 genp.add_attribute("phi", std::make_shared<HepMC3::DoubleAttribute>(phi));
0125 }
0126
0127
0128
0129 static void setPosition(VertexT &v, const LorentzPoint &p, Length unit) {
0130 HepMC3::FourVector v_scaled(p.x() / unit, p.y() / unit, p.z() / unit, p.e() / unit);
0131 v.set_position(v_scaled);
0132 }
0133 };
0134 }