thepeg
is hosted by
Hepforge
,
IPPP Durham
ThePEG
2.3.0
Config
HepMCHelper.h
1
// -*- C++ -*-
2
//
3
// HepMCHelper_HepMC.h is a part of ThePEG - A multi-purpose Monte Carlo event generator
4
// Copyright (C) 2002-2019 The Herwig Collaboration
5
//
6
// ThePEG is licenced under version 3 of the GPL, see COPYING for details.
7
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
8
//
9
//
10
// This is a helper header to implement HepMC conversions
11
//
12
#include "ThePEG/Vectors/HepMCTraits.h"
13
#ifdef HAVE_HEPMC3
14
#include "HepMC3/GenEvent.h"
15
#include "HepMC3/GenVertex.h"
16
#include "HepMC3/GenParticle.h"
17
#include "HepMC3/Version.h"
18
#include "HepMC3/WriterAscii.h"
19
#include "HepMC3/WriterHEPEVT.h"
20
#include "HepMC3/WriterAsciiHepMC2.h"
21
#ifdef HAVE_HEPMC3_WRITERROOT_H
22
#include "HepMC3/WriterRoot.h"
23
#endif
24
#ifdef HAVE_HEPMC3_WRITERROOTTREE_H
25
#include "HepMC3/WriterRootTree.h"
26
#endif
27
namespace
HepMC3 {
28
using
PdfInfo=GenPdfInfo;
29
using
Polarization=std::pair<double,double>;
30
}
31
namespace
HepMC=HepMC3;
32
#else
33
#include "HepMC/GenEvent.h"
34
#include "HepMC/GenVertex.h"
35
#include "HepMC/GenParticle.h"
36
#include "HepMC/Version.h"
37
#include "HepMC/IO_BaseClass.h"
38
#include "HepMC/IO_GenEvent.h"
39
#include "HepMC/IO_AsciiParticles.h"
40
namespace
HepMC {
41
#undef GenParticlePtr
42
#undef GenVertexPtr
43
typedef
GenParticle * GenParticlePtr;
44
typedef
GenVertex * GenVertexPtr;
45
}
46
#endif
47
namespace
ThePEG
{
51
#ifndef HAVE_HEPMC3
52
template
<>
53
struct
HepMCTraits
<HepMC::GenEvent>
54
:
public
HepMCTraitsBase
<HepMC::GenEvent,
55
HepMC::GenParticle,
56
HepMC::GenParticle *,
57
HepMC::GenVertex,
58
HepMC::GenVertex *,
59
HepMC::Polarization,
60
HepMC::PdfInfo>
61
{
62
#else
63
// This is version 3!
64
template
<>
65
struct
HepMCTraits
<HepMC::GenEvent>
66
:
public
HepMCTraitsBase
<HepMC::GenEvent,
67
HepMC::GenParticle,
68
HepMC::GenParticlePtr,
69
HepMC::GenVertex,
70
HepMC::GenVertexPtr,
71
HepMC::Polarization,
72
HepMC::PdfInfo>
73
{
74
76
static
EventT
* newEvent(
long
evno,
double
weight,
77
const
map<string,double>& optionalWeights) {
78
EventT
* e =
new
EventT
(HepMC::Units::GEV, HepMC::Units::MM);
79
e->set_event_number(evno);
80
e->set_event_number(evno);
81
//std::vector<std::string> wnames;
82
std::vector<double> wvalues;
83
84
//wnames.push_back("Default");
85
wvalues.push_back(weight);
86
for
( map<string,double>::const_iterator w = optionalWeights.begin();
87
w != optionalWeights.end(); ++w ) {
88
//wnames.push_back(w->first);
89
wvalues.push_back(w->second);
90
}
91
//e->run_info()->set_weight_names(wnames);
92
e->weights()=wvalues;
93
return
e;
94
}
95
97
static
VertexPtrT
newVertex() {
98
return
std::make_shared<VertexT>(
VertexT
());
99
}
100
104
static
void
setScaleAndAlphas(
EventT
& e,
Energy2
scale,
105
double
aS,
double
aEM,
Energy
unit) {
106
e.add_attribute(
"event_scale"
,std::make_shared<HepMC::DoubleAttribute>(sqrt(scale)/unit));
107
e.add_attribute(
"mpi"
,std::make_shared<HepMC::IntAttribute>(-1));
//Please fix it later, once ThePEG authors respond
108
e.add_attribute(
"signal_process_id"
,std::make_shared<HepMC::IntAttribute>(0));
//Please fix it later, once ThePEG authors respond
109
e.add_attribute(
"alphaQCD"
,std::make_shared<HepMC::DoubleAttribute>(aS));
110
e.add_attribute(
"alphaQED"
,std::make_shared<HepMC::DoubleAttribute>(aEM));
111
}
112
115
static
void
setColourLine(
ParticleT
& p,
int
indx,
int
coline) {
116
p.add_attribute(
"flow"
+std::to_string(indx),std::make_shared<HepMC::IntAttribute>(coline));
117
}
118
120
static
void
addIncoming(
VertexT
& v,
ParticlePtrT
p) {
121
v.add_particle_in(p);
122
}
123
125
static
void
addOutgoing(
VertexT
& v,
ParticlePtrT
p) {
126
v.add_particle_out(p);
127
}
128
130
static
void
setSignalProcessVertex(
EventT
& e,
VertexPtrT
v) {
131
e.add_vertex(v);
132
e.add_attribute(
"signal_process_vertex"
,
133
std::make_shared<HepMC::IntAttribute>(v->id()));
134
}
135
137
static
void
addVertex(
EventT
& e,
VertexPtrT
v) {
138
e.add_vertex(v);
139
}
140
142
static
void
setBeamParticles(
EventT
& e,
ParticlePtrT
p1,
ParticlePtrT
p2) {
143
// e.set_beam_particles(p1,p2);
144
p1->set_status(4);
145
p2->set_status(4);
146
e.set_beam_particles(p1, p2);
147
}
148
153
static
ParticlePtrT
newParticle(
const
Lorentz5Momentum
& p,
154
long
id
,
int
status,
Energy
unit) {
155
// Note that according to the documentation the momentum is stored in a
156
// HepLorentzVector in GeV (event though the CLHEP standard is MeV).
157
HepMC::FourVector p_scalar(p.x()/unit, p.y()/unit, p.z()/unit, p.e()/unit);
158
ParticlePtrT
genp = std::make_shared<ParticleT>(
ParticleT
(p_scalar,
id
, status));
159
genp->set_generated_mass(p.mass()/unit);
160
return
genp;
161
}
162
165
static
void
setPolarization(
ParticleT
& genp,
double
the,
double
phi) {
166
genp.add_attribute(
"theta"
,std::make_shared<HepMC::DoubleAttribute>(the));
167
genp.add_attribute(
"phi"
,std::make_shared<HepMC::DoubleAttribute>(phi));
168
}
169
172
static
void
setPosition(
VertexT
& v,
const
LorentzPoint
& p,
Length
unit) {
173
HepMC::FourVector v_scaled(p.x()/unit, p.y()/unit, p.z()/unit, p.e()/unit);
174
v.set_position(v_scaled);
175
}
176
177
#endif
178
179
};
180
}
ThePEG::Lorentz5Vector< Energy >
ThePEG::LorentzVector< Length >
ThePEG::Qty< 0, 2, 0 >
ThePEG
This is the main namespace within which all identifiers in ThePEG are declared.
Definition:
FactoryBase.h:28
ThePEG::HepMCTraitsBase
HepMCTraitsBase is a convenient base class for specializing the HepMCTraits class to deal with differ...
Definition:
HepMCTraits.h:63
ThePEG::HepMCTraitsBase< HepMC::GenEvent, HepMC::GenParticle, HepMC::GenParticle *, HepMC::GenVertex, HepMC::GenVertex *, HepMC::Polarization, HepMC::PdfInfo >::EventT
HepMC::GenEvent EventT
Typedef of the event class.
Definition:
HepMCTraits.h:69
ThePEG::HepMCTraitsBase< HepMC::GenEvent, HepMC::GenParticle, HepMC::GenParticle *, HepMC::GenVertex, HepMC::GenVertex *, HepMC::Polarization, HepMC::PdfInfo >::ParticlePtrT
HepMC::GenParticle * ParticlePtrT
Typedef of a particle pointer.
Definition:
HepMCTraits.h:81
ThePEG::HepMCTraitsBase< HepMC::GenEvent, HepMC::GenParticle, HepMC::GenParticle *, HepMC::GenVertex, HepMC::GenVertex *, HepMC::Polarization, HepMC::PdfInfo >::VertexPtrT
HepMC::GenVertex * VertexPtrT
Typedef of a vertex pointer.
Definition:
HepMCTraits.h:84
ThePEG::HepMCTraitsBase< HepMC::GenEvent, HepMC::GenParticle, HepMC::GenParticle *, HepMC::GenVertex, HepMC::GenVertex *, HepMC::Polarization, HepMC::PdfInfo >::ParticleT
HepMC::GenParticle ParticleT
Typedef of the particle class.
Definition:
HepMCTraits.h:66
ThePEG::HepMCTraitsBase< HepMC::GenEvent, HepMC::GenParticle, HepMC::GenParticle *, HepMC::GenVertex, HepMC::GenVertex *, HepMC::Polarization, HepMC::PdfInfo >::VertexT
HepMC::GenVertex VertexT
Typedef of the vertex class.
Definition:
HepMCTraits.h:72
ThePEG::HepMCTraits
The HepMCTraits class is used to deal with different flavours of HepMC in the HepMCConverter class.
Definition:
HepMCTraits.h:359
Generated on Thu Jun 20 2024 14:47:00 for ThePEG by
1.9.6