ATLAS Offline Software
Loading...
Searching...
No Matches
Herwig7HepMC.cxx
Go to the documentation of this file.
1// -*- C++ -*-
2/*
3 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4*/
5
6
11
12
13#include "ThePEG/EventRecord/Event.h"
14#include "ThePEG/EventRecord/SubProcess.h"
15#include "ThePEG/Handlers/XComb.h"
16#include "ThePEG/Handlers/EventHandler.h"
17#include "ThePEG/PDF/PDF.h"
18
19#include "Herwig/API/HerwigAPI.h"
20
24#define HEPMC_HAS_CROSS_SECTION
25#define HEPMC_HAS_PDF_INFO
26
27#include "ThePEG/Vectors/HepMCConverter.h"
28#ifdef HWVER_IS_72
29#ifdef HEPMC3
30#include "HepMC3/GenEvent.h"
31#include "HepMC3/GenParticle.h"
32#include "HepMC3/GenVertex.h"
33namespace ThePEG {
34 template<>
35 struct HepMCTraits<HepMC3::GenEvent>
36 : public HepMCTraitsBase<HepMC3::GenEvent,
37 HepMC3::GenParticle,
38 HepMC3::GenParticlePtr,
39 HepMC3::GenVertex,
40 HepMC3::GenVertexPtr,
41 std::pair<double,double>,
42 HepMC3::GenPdfInfo>
43 {
44 static bool hasUnits() {
45 return true;
46 }
47
48
52 static void setScaleAndAlphas(HepMC3::GenEvent & e, Energy2 scale,
53 double aS, double aEM, Energy unit) {
54 e.add_attribute("event_scale",std::make_shared<HepMC3::DoubleAttribute>(sqrt(scale)/unit));
55 e.add_attribute("alphaQCD",std::make_shared<HepMC3::DoubleAttribute>(aS));
56 e.add_attribute("alphaQED",std::make_shared<HepMC3::DoubleAttribute>(aEM));
57 }
58
60 static void setSignalProcessVertex(HepMC3::GenEvent & e, HepMC3::GenVertexPtr v) {
61 e.add_attribute("signal_process_vertex",std::make_shared<HepMC3::IntAttribute>(v->id()));
62 }
63
66 static void setPolarization(HepMC3::GenParticle & genp, double the, double phi) {
67 genp.add_attribute("theta",std::make_shared<HepMC3::DoubleAttribute>(the));
68 genp.add_attribute("phi",std::make_shared<HepMC3::DoubleAttribute>(phi));
69 }
70
73 static void setColourLine(HepMC3::GenParticle & p, int indx, int coline) {
74 p.add_attribute("flow"+std::to_string(indx),std::make_shared<HepMC3::IntAttribute>(coline));
75 }
77 static void setBeamParticles(HepMC3::GenEvent & e, HepMC3::GenParticlePtr p1, HepMC3::GenParticlePtr p2) {
78 p1->set_status(4);
79 p2->set_status(4);
80 e.set_beam_particles(std::move(p1),std::move(p2));
81 }
82
83 static HepMC3::GenParticlePtr newParticle(const Lorentz5Momentum & p,
84 long id, int status, Energy unit) {
85 // Note that according to the documentation the momentum is stored in a
86 // HepLorentzVector in GeV (event though the CLHEP standard is MeV).
87 LorentzVector<double> p_scalar = p/unit;
88 HepMC3::GenParticlePtr genp = std::make_shared<HepMC3::GenParticle>(HepMC::FourVector(p_scalar.x(),p_scalar.y(),p_scalar.z(),p_scalar.e()), id, status);
89 genp->set_generated_mass(p.mass()/unit);
90 return genp;
91 }
94 static void setPosition( HepMC3::GenVertex & v, const LorentzPoint & p, Length unit) {
95 LorentzVector<double> p_scaled = p/unit;
96 v.set_position(HepMC::FourVector(p_scaled.x(),p_scaled.y(),p_scaled.z(),p_scaled.t()));
97 }
98
100 static HepMC3::GenVertexPtr newVertex() {
101 return std::make_shared<HepMC3::GenVertex>();
102 }
103 };
104}
105#else
106namespace ThePEG {
107 template<>
108 struct HepMCTraits<HepMC::GenEvent>
109 : public HepMCTraitsBase<HepMC::GenEvent,
110 HepMC::GenParticle,
111 HepMC::GenParticle *,
112 HepMC::GenVertex,
113 HepMC::GenVertex *,
114 HepMC::Polarization,
115 HepMC::PdfInfo>
116 {
117 static bool hasUnits() {
118 return true;
119 }
120 };
121}
122#endif
123#else
124namespace ThePEG {
125 template<>
126 struct HepMCTraits<HepMC::GenEvent>
127 : public HepMCTraitsBase<HepMC::GenEvent,
128 HepMC::GenParticle,
129 HepMC::GenVertex,
130 HepMC::Polarization,
131 HepMC::PdfInfo>
132 {
133 static bool hasUnits() {
134 return true;
135 }
136 };
137}
138#endif
139
140void convert_to_HepMC(const ThePEG::Event & event, HepMC::GenEvent & evt, bool nocopies,ThePEG::Energy eunit, ThePEG::Length lunit){
141 ThePEG::HepMCConverter<HepMC::GenEvent>::convert(event, evt, nocopies, eunit, lunit);
142}
Scalar phi() const
phi method
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
std::vector< double > Energy
void convert_to_HepMC(const ThePEG::Event &event, HepMC::GenEvent &evt, bool nocopies, ThePEG::Energy eunit, ThePEG::Length lunit)