ATLAS Offline Software
Loading...
Searching...
No Matches
Herwig7HepMC.cxx
Go to the documentation of this file.
1// -*- C++ -*-
2/*
3 Copyright (C) 2002-2026 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"
21
25#define HEPMC_HAS_CROSS_SECTION
26#define HEPMC_HAS_PDF_INFO
27#define HAVE_HEPMC3 1
28
29#include "ThePEG/Vectors/HepMCConverter.h"
30#ifdef HWVER_IS_72
31#include "HepMC3/GenEvent.h"
32#include "HepMC3/GenParticle.h"
33#include "HepMC3/GenVertex.h"
34namespace ThePEG {
35 template<>
36 struct HepMCTraits<HepMC3::GenEvent>
37 : public HepMCTraitsBase<HepMC3::GenEvent,
38 HepMC3::GenParticle,
39 HepMC3::GenParticlePtr,
40 HepMC3::GenVertex,
41 HepMC3::GenVertexPtr,
42 std::pair<double,double>,
43 HepMC3::GenPdfInfo>
44 {
45 static bool hasUnits() {
46 return true;
47 }
48
49
53 static void setScaleAndAlphas(HepMC3::GenEvent & e, Energy2 scale,
54 double aS, double aEM, Energy unit) {
55 e.add_attribute(HepMCStr::event_scale,std::make_shared<HepMC3::DoubleAttribute>(sqrt(scale)/unit));
56 e.add_attribute(HepMCStr::alphaQCD,std::make_shared<HepMC3::DoubleAttribute>(aS));
57 e.add_attribute(HepMCStr::alphaQED,std::make_shared<HepMC3::DoubleAttribute>(aEM));
58 }
59
61 static void setSignalProcessVertex(HepMC3::GenEvent & e, HepMC3::GenVertexPtr v) {
62 e.add_attribute(HepMCStr::signal_process_vertex,std::make_shared<HepMC3::IntAttribute>(v->id()));
63 }
64
67 static void setPolarization(HepMC3::GenParticle & genp, double the, double phi) {
68 genp.add_attribute(HepMCStr::theta,std::make_shared<HepMC3::DoubleAttribute>(the));
69 genp.add_attribute(HepMCStr::phi,std::make_shared<HepMC3::DoubleAttribute>(phi));
70 }
71
74 static void setColourLine(HepMC3::GenParticle & p, int indx, int coline) {
75 p.add_attribute(HepMCStr::flow + std::to_string(indx),std::make_shared<HepMC3::IntAttribute>(coline));
76 }
78 static void setBeamParticles(HepMC3::GenEvent & e, HepMC3::GenParticlePtr p1, HepMC3::GenParticlePtr p2) {
79 p1->set_status(4);
80 p2->set_status(4);
81 e.set_beam_particles(std::move(p1),std::move(p2));
82 }
83
84 static HepMC3::GenParticlePtr newParticle(const Lorentz5Momentum & p,
85 long id, int status, Energy unit) {
86 // Note that according to the documentation the momentum is stored in a
87 // HepLorentzVector in GeV (event though the CLHEP standard is MeV).
88 LorentzVector<double> p_scalar = p/unit;
89 HepMC3::GenParticlePtr genp = std::make_shared<HepMC3::GenParticle>(HepMC::FourVector(p_scalar.x(),p_scalar.y(),p_scalar.z(),p_scalar.e()), id, status);
90 genp->set_generated_mass(p.mass()/unit);
91 return genp;
92 }
95 static void setPosition( HepMC3::GenVertex & v, const LorentzPoint & p, Length unit) {
96 LorentzVector<double> p_scaled = p/unit;
97 v.set_position(HepMC::FourVector(p_scaled.x(),p_scaled.y(),p_scaled.z(),p_scaled.t()));
98 }
99
101 static HepMC3::GenVertexPtr newVertex() {
102 return std::make_shared<HepMC3::GenVertex>();
103 }
104 };
105}
106#else
107namespace ThePEG {
108 template<>
109 struct HepMCTraits<HepMC::GenEvent>
110 : public HepMCTraitsBase<HepMC::GenEvent,
111 HepMC::GenParticle,
112 HepMC::GenVertex,
113 HepMC::Polarization,
114 HepMC::PdfInfo>
115 {
116 static bool hasUnits() {
117 return true;
118 }
119 };
120}
121#endif
122
123void convert_to_HepMC(const ThePEG::Event & event, HepMC::GenEvent & evt, bool nocopies,ThePEG::Energy eunit, ThePEG::Length lunit){
124 ThePEG::HepMCConverter<HepMC::GenEvent>::convert(event, evt, nocopies, eunit, lunit);
125}
Scalar phi() const
phi method
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
void convert_to_HepMC(const ThePEG::Event &event, HepMC::GenEvent &evt, bool nocopies, ThePEG::Energy eunit, ThePEG::Length lunit)
const std::string event_scale
const std::string phi
const std::string signal_process_vertex
const std::string theta
const std::string alphaQED
const std::string alphaQCD
const std::string flow
HepMC3::FourVector FourVector
HepMC3::GenEvent GenEvent
Definition GenEvent.h:39