thepeg
is hosted by
Hepforge
,
IPPP Durham
ThePEG
2.3.0
Vectors
HepMCTraits.h
1
// -*- C++ -*-
2
//
3
// HepMCTraits.h is a part of ThePEG - Toolkit for HEP Event Generation
4
// Copyright (C) 1999-2019 Leif Lonnblad
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
#ifndef ThePEG_HepMCTraits_H
10
#define ThePEG_HepMCTraits_H
11
12
#ifdef HAVE_HEPMC3
13
#include "HepMC3/GenEvent.h"
14
namespace
HepMC3 {
15
class
GenEvent;
16
class
GenParticle;
17
class
GenVertex;
18
class
GenPdfInfo;
19
}
20
namespace
HepMC3 {
21
using
PdfInfo=GenPdfInfo;
22
using
Polarization=std::pair<double,double>;
23
}
24
namespace
HepMC=HepMC3;
25
#else
26
#include "HepMC/GenEvent.h"
27
namespace
HepMC {
28
29
class
GenEvent;
30
class
GenParticle;
31
class
GenVertex;
32
class
Polarization;
33
#ifndef HEPMC_GENPDFINFO_H
34
class
PdfInfo;
35
#endif
36
}
37
#endif
38
39
40
namespace
ThePEG
{
41
58
template
<
typename
HepMCEventT,
59
typename
HepMCParticleT,
typename
HepMCParticlePtrT,
60
typename
HepMCVertexT,
typename
HepMCVertexPtrT,
61
typename
HepMCPolarizationT,
typename
HepMCPdfInfoT>
62
63
struct
HepMCTraitsBase
{
64
66
typedef
HepMCParticleT
ParticleT
;
67
69
typedef
HepMCEventT
EventT
;
70
72
typedef
HepMCVertexT
VertexT
;
73
75
typedef
HepMCPolarizationT
PolarizationT
;
76
78
typedef
HepMCPdfInfoT
PdfInfoT
;
79
81
typedef
HepMCParticlePtrT
ParticlePtrT
;
82
84
typedef
HepMCVertexPtrT
VertexPtrT
;
85
87
static
EventT
*
newEvent
(
long
evno,
double
weight,
88
const
map<string,double>& optionalWeights) {
89
EventT
* e =
new
EventT
();
90
e->set_event_number(evno);
91
std::vector<std::string> wnames;
92
std::vector<double> wvalues;
93
94
wnames.push_back(
"Default"
);
95
wvalues.push_back(weight);
96
for
( map<string,double>::const_iterator w = optionalWeights.begin();
97
w != optionalWeights.end(); ++w ) {
98
wnames.push_back(w->first);
99
wvalues.push_back(w->second);
100
}
101
102
103
#ifdef HAVE_HEPMC3
104
e->run_info()->set_weight_names(wnames);
105
e->weights()=wvalues;
106
107
#else
108
#ifdef HEPMC_HAS_NAMED_WEIGHTS
109
for
(
size_t
i=0;i<wnames.size();i++) e->weights()[wnames[i]] = wvalues[i];
110
#else
111
e->weights()=wvalues;
112
#endif
113
#endif
114
115
116
117
return
e;
118
}
119
121
static
void
resetEvent
(
EventT
* e,
long
evno,
double
weight,
122
const
map<string,double>& optionalWeights) {
123
e->set_event_number(evno);
124
e->weights().clear();
125
std::vector<std::string> wnames;
126
std::vector<double> wvalues;
127
128
wnames.push_back(
"Default"
);
129
wvalues.push_back(weight);
130
for
( map<string,double>::const_iterator w = optionalWeights.begin();
131
w != optionalWeights.end(); ++w ) {
132
wnames.push_back(w->first);
133
wvalues.push_back(w->second);
134
}
135
136
137
#ifdef HAVE_HEPMC3
138
e->run_info()->set_weight_names(wnames);
139
e->weights()=wvalues;
140
141
#else
142
#ifdef HEPMC_HAS_NAMED_WEIGHTS
143
for
(
size_t
i=0;i<wnames.size();i++) e->weights()[wnames[i]] = wvalues[i];
144
#else
145
e->weights()=wvalues;
146
#endif
147
#endif
148
}
149
153
static
bool
hasUnits
() {
154
#ifdef HEPMC_HAS_UNITS
155
return
true
;
156
#else
157
return
false
;
158
#endif
159
}
160
164
static
Energy
defaultEnergyUnit
() {
165
#ifndef HEPMC_HAS_UNITS
166
return
GeV;
167
#else
168
return
HepMC::Units::default_momentum_unit() == HepMC::Units::GEV? GeV: MeV;
169
#endif
170
}
171
175
static
Length
defaultLengthUnit
() {
176
#ifndef HEPMC_HAS_UNITS
177
return
millimeter;
178
#else
179
return
HepMC::Units::default_length_unit() == HepMC::Units::MM?
180
millimeter: 10.0*millimeter;
181
#endif
182
}
183
188
static
Energy
momentumUnit
(
const
EventT
& e) {
189
#ifdef HEPMC_HAS_UNITS
190
return
e.momentum_unit() == HepMC::Units::MEV? MeV: GeV;
191
#else
192
return
GeV;
193
#endif
194
}
195
200
static
Length
lengthUnit
(
const
EventT
& e) {
201
#ifdef HEPMC_HAS_UNITS
202
return
e.length_unit() == HepMC::Units::CM? centimeter: millimeter;
203
#else
204
return
millimeter;
205
#endif
206
}
207
212
#ifdef HEPMC_HAS_UNITS
213
static
void
setUnits
(
EventT
& e,
Energy
momu,
Length
lenu) {
214
e.use_units(momu == MeV? HepMC::Units::MEV: HepMC::Units::GEV,
215
lenu == centimeter? HepMC::Units::CM: HepMC::Units::MM);
216
}
217
#else
218
static
void
setUnits
(
EventT
&,
Energy
,
Length
) {}
219
#endif
220
221
225
static
void
setScaleAndAlphas
(
EventT
& e,
Energy2
scale,
226
double
aS,
double
aEM,
Energy
unit) {
227
e.set_event_scale(sqrt(scale)/unit);
228
e.set_alphaQCD(aS);
229
e.set_alphaQED(aEM);
230
}
231
233
static
void
setSignalProcessVertex
(
EventT
& e,
VertexPtrT
v) {
234
e.set_signal_process_vertex(v);
235
}
236
238
static
void
addVertex
(
EventT
& e,
VertexPtrT
v) {
239
e.add_vertex(v);
240
}
241
246
static
ParticlePtrT
newParticle
(
const
Lorentz5Momentum
& p,
247
long
id
,
int
status,
Energy
unit) {
248
// Note that according to the documentation the momentum is stored in a
249
// HepLorentzVector in GeV (event though the CLHEP standard is MeV).
250
LorentzVector<double>
p_scalar = p/unit;
251
ParticlePtrT
genp =
252
new
ParticleT
(p_scalar,
id
, status);
253
genp->setGeneratedMass(p.
mass
()/unit);
254
return
genp;
255
}
256
259
static
void
setPolarization
(
ParticleT
& genp,
double
the,
double
phi) {
260
genp.set_polarization(
PolarizationT
(the, phi));
261
}
262
265
static
void
setColourLine
(
ParticleT
& p,
int
indx,
int
coline) {
266
p.set_flow(indx, coline);
267
}
268
270
static
VertexPtrT
newVertex
() {
271
return
new
VertexT
();
272
}
273
275
static
void
addIncoming
(
VertexT
& v,
ParticlePtrT
p) {
276
v.add_particle_in(p);
277
}
278
280
static
void
addOutgoing
(
VertexT
& v,
ParticlePtrT
p) {
281
v.add_particle_out(p);
282
}
283
286
static
void
setPosition
(
VertexT
& v,
const
LorentzPoint
& p,
Length
unit) {
287
LorentzVector<double>
p_scaled = p/unit;
288
v.set_position(p_scaled);
289
}
290
292
static
void
setBeamParticles
(
EventT
& e,
ParticlePtrT
p1,
ParticlePtrT
p2) {
293
e.set_beam_particles(p1,p2);
294
p1->set_status(4);
295
p2->set_status(4);
296
}
297
299
#ifdef HEPMC_HAS_PDF_INFO
300
static
void
setPdfInfo
(
EventT
& e,
int
id1,
int
id2,
double
x1,
double
x2,
301
double
scale,
double
xf1,
double
xf2) {
302
#ifdef HAVE_HEPMC3
303
304
HepMC::GenPdfInfoPtr pdfinfo = std::make_shared<HepMC::GenPdfInfo>();
305
pdfinfo->set(id1, id2, x1, x2, scale, xf1, xf2);
306
e.set_pdf_info(pdfinfo);
307
#else
308
e.set_pdf_info(
PdfInfoT
(id1, id2, x1, x2, scale, xf1, xf2));
309
#endif
310
}
311
#else
312
static
void
setPdfInfo
(
EventT
&,
int
,
int
,
double
,
double
,
313
double
,
double
,
double
) {}
314
#endif
315
317
#ifdef HAVE_HEPMC3
318
319
static
void
setCrossSection
(
EventT
& ev,
double
xs,
double
xserr) {
320
std::shared_ptr<HepMC::GenCrossSection> x = std::make_shared<HepMC::GenCrossSection>();
321
x->set_cross_section(xs,xserr);
322
ev.set_cross_section(x);
323
}
324
325
#else
326
327
#ifdef HEPMC_HAS_CROSS_SECTION
328
329
static
void
setCrossSection
(
EventT
& ev,
double
xs,
double
xserr) {
330
HepMC::GenCrossSection x;
331
x.set_cross_section(xs, xserr);
332
ev.set_cross_section(x);
333
}
334
335
#else
336
337
static
void
setCrossSection
(
EventT
&,
double
,
double
) {}
338
339
#endif
340
341
#endif
342
343
};
344
358
template
<
typename
HepMCEventT>
359
struct
HepMCTraits
{};
360
}
361
362
#endif
ThePEG::Lorentz5Vector< Energy >
ThePEG::Lorentz5Vector::mass
Value mass() const
Mass/invariant length component.
Definition:
Lorentz5Vector.h:224
ThePEG::LorentzVector
A 4-component Lorentz vector.
Definition:
LorentzVector.h:44
ThePEG::Qty< 0, 1, 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::setCrossSection
static void setCrossSection(EventT &, double, double)
Set the cross section info for the event.
Definition:
HepMCTraits.h:337
ThePEG::HepMCTraitsBase::setSignalProcessVertex
static void setSignalProcessVertex(EventT &e, VertexPtrT v)
Set the primary vertex, v, for the event e.
Definition:
HepMCTraits.h:233
ThePEG::HepMCTraitsBase::newParticle
static ParticlePtrT newParticle(const Lorentz5Momentum &p, long id, int status, Energy unit)
Create a new particle object with momentum p, PDG number id and status code status.
Definition:
HepMCTraits.h:246
ThePEG::HepMCTraitsBase::newEvent
static EventT * newEvent(long evno, double weight, const map< string, double > &optionalWeights)
Create an event object with number evno and weight.
Definition:
HepMCTraits.h:87
ThePEG::HepMCTraitsBase::PolarizationT
HepMCPolarizationT PolarizationT
Typedef of the polarization class.
Definition:
HepMCTraits.h:75
ThePEG::HepMCTraitsBase::EventT
HepMCEventT EventT
Typedef of the event class.
Definition:
HepMCTraits.h:69
ThePEG::HepMCTraitsBase::ParticlePtrT
HepMCParticlePtrT ParticlePtrT
Typedef of a particle pointer.
Definition:
HepMCTraits.h:81
ThePEG::HepMCTraitsBase::hasUnits
static bool hasUnits()
Return true if this version of HepMC accept user-defined units.
Definition:
HepMCTraits.h:153
ThePEG::HepMCTraitsBase::PdfInfoT
HepMCPdfInfoT PdfInfoT
Typedef of the PdfInfo class.
Definition:
HepMCTraits.h:78
ThePEG::HepMCTraitsBase::addVertex
static void addVertex(EventT &e, VertexPtrT v)
Set a vertex, v, for the event e.
Definition:
HepMCTraits.h:238
ThePEG::HepMCTraitsBase::setScaleAndAlphas
static void setScaleAndAlphas(EventT &e, Energy2 scale, double aS, double aEM, Energy unit)
Set the scale, (aS) and (aEM) for the event e.
Definition:
HepMCTraits.h:225
ThePEG::HepMCTraitsBase::VertexPtrT
HepMCVertexPtrT VertexPtrT
Typedef of a vertex pointer.
Definition:
HepMCTraits.h:84
ThePEG::HepMCTraitsBase::addIncoming
static void addIncoming(VertexT &v, ParticlePtrT p)
Add an incoming particle, p, to the vertex, v.
Definition:
HepMCTraits.h:275
ThePEG::HepMCTraitsBase::resetEvent
static void resetEvent(EventT *e, long evno, double weight, const map< string, double > &optionalWeights)
Reset event weight and number of a re-used GenEvent.
Definition:
HepMCTraits.h:121
ThePEG::HepMCTraitsBase::setPolarization
static void setPolarization(ParticleT &genp, double the, double phi)
Set the polarization directions, the and phi, for particle p.
Definition:
HepMCTraits.h:259
ThePEG::HepMCTraitsBase::defaultLengthUnit
static Length defaultLengthUnit()
Return the length unit used in the installed version of HepMC.
Definition:
HepMCTraits.h:175
ThePEG::HepMCTraitsBase::ParticleT
HepMCParticleT ParticleT
Typedef of the particle class.
Definition:
HepMCTraits.h:66
ThePEG::HepMCTraitsBase::setBeamParticles
static void setBeamParticles(EventT &e, ParticlePtrT p1, ParticlePtrT p2)
Set the beam particles for the event.
Definition:
HepMCTraits.h:292
ThePEG::HepMCTraitsBase::momentumUnit
static Energy momentumUnit(const EventT &e)
Return the momentum unit used by a given GenEvent object.
Definition:
HepMCTraits.h:188
ThePEG::HepMCTraitsBase::setColourLine
static void setColourLine(ParticleT &p, int indx, int coline)
Set the colour line (with index indx) to coline for particle p.
Definition:
HepMCTraits.h:265
ThePEG::HepMCTraitsBase::lengthUnit
static Length lengthUnit(const EventT &e)
Return the length unit used by a given GenEvent object.
Definition:
HepMCTraits.h:200
ThePEG::HepMCTraitsBase::setPosition
static void setPosition(VertexT &v, const LorentzPoint &p, Length unit)
Set the position p for the vertex, v.
Definition:
HepMCTraits.h:286
ThePEG::HepMCTraitsBase::setUnits
static void setUnits(EventT &, Energy, Length)
Set the units to be used by the given GenEvent object.
Definition:
HepMCTraits.h:218
ThePEG::HepMCTraitsBase::setPdfInfo
static void setPdfInfo(EventT &, int, int, double, double, double, double, double)
Set the PDF info for the event.
Definition:
HepMCTraits.h:312
ThePEG::HepMCTraitsBase::newVertex
static VertexPtrT newVertex()
Create a new vertex.
Definition:
HepMCTraits.h:270
ThePEG::HepMCTraitsBase::defaultEnergyUnit
static Energy defaultEnergyUnit()
Return the energy unit used in the installed version of HepMC.
Definition:
HepMCTraits.h:164
ThePEG::HepMCTraitsBase::VertexT
HepMCVertexT VertexT
Typedef of the vertex class.
Definition:
HepMCTraits.h:72
ThePEG::HepMCTraitsBase::addOutgoing
static void addOutgoing(VertexT &v, ParticlePtrT p)
Add an outgoing particle, p, to the vertex, v.
Definition:
HepMCTraits.h:280
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:02 for ThePEG by
1.9.6