Thermal-FIST
1.6
Package for hadron resonance gas model applications
Loading...
Searching...
No Matches
src
library
HRGEventGenerator
HepMCEventWriter.cpp
Go to the documentation of this file.
1
#include "
HRGEventGenerator/HepMCEventWriter.h
"
2
3
#include <string>
4
#include <iostream>
5
6
#include "ThermalFISTConfig.h"
7
8
namespace
thermalfist
{
9
10
HepMCEventWriter::HepMCEventWriter
(
const
std::string& filename)
11
{
12
if
(!filename.empty())
13
OpenFile
(filename);
14
}
15
16
HepMCEventWriter::~HepMCEventWriter
()
17
{
18
CloseFile
();
19
}
20
21
bool
HepMCEventWriter::OpenFile
(
const
std::string& filename)
22
{
23
if
(!
EventWriter::OpenFile
(filename))
24
return
false
;
25
26
m_fout
<< std::scientific;
27
m_fout
.precision(16);
28
29
if
(!
m_fout
.is_open())
30
return
false
;
31
32
const
std::string header =
"HepMC::Version "
+ std::string(
"3.01.01"
) +
"\nHepMC::Asciiv3-START_EVENT_LISTING\n"
;
33
m_fout
<< header;
34
35
m_fout
<<
"W "
<< 1 <<
"\n"
;
36
m_fout
<<
"N "
<<
"ImportanceSamplingWeight"
<<
"\n"
;
37
38
std::string version = std::to_string(ThermalFIST_VERSION_MAJOR) +
"."
+ std::to_string(ThermalFIST_VERSION_MINOR);
39
if
(ThermalFIST_VERSION_DEVEL != 0) {
40
version +=
"."
+ std::to_string(ThermalFIST_VERSION_DEVEL);
41
}
42
m_fout
<<
"T "
<<
"Thermal-FIST"
<<
"\\|"
;
43
m_fout
<< version <<
"\\|"
;
44
m_fout
<<
"ThermalFistEventGenerator"
<<
"\n"
;
45
46
return
true
;
47
}
48
49
void
HepMCEventWriter::CloseFile
()
50
{
51
if
(
m_fout
.is_open()) {
52
const
std::string footer(
"HepMC::Asciiv3-END_EVENT_LISTING\n\n"
);
53
m_fout
<< footer;
54
m_fout
.close();
55
}
56
}
57
58
bool
HepMCEventWriter::WriteEvent
(
const
SimpleEvent
& evt)
59
{
60
if
(!
m_fout
.is_open())
61
return
false
;
62
63
m_fout
<<
"E "
<<
m_EventNumber
++ <<
" "
<< 0 <<
" "
<< evt.
Particles
.size() <<
"\n"
;
64
m_fout
<<
"U "
<<
"GEV"
<<
" "
<<
"MM"
<<
"\n"
;
65
m_fout
<<
"W "
<< evt.
weight
<<
"\n"
;
66
67
for
(
int
ip = 0; ip < evt.
Particles
.size(); ++ip) {
68
const
SimpleParticle
& part = evt.
Particles
[ip];
69
m_fout
<<
"P "
<< ip + 1 <<
" "
<< 0 <<
" "
;
70
71
m_fout
<< part.
PDGID
<<
" "
;
72
m_fout
<< part.
px
<<
" "
<< part.
py
<<
" "
<< part.
pz
<<
" "
<< part.
p0
<<
" "
;
73
m_fout
<< part.
m
<<
" "
;
74
75
m_fout
<< 1 <<
"\n"
;
76
}
77
78
return
true
;
79
}
80
81
}
HepMCEventWriter.h
thermalfist::EventWriter::m_fout
std::ofstream m_fout
Definition
EventWriter.h:33
thermalfist::EventWriter::OpenFile
virtual bool OpenFile(const std::string &filename)
Definition
EventWriter.cpp:22
thermalfist::EventWriter::m_EventNumber
int m_EventNumber
Definition
EventWriter.h:34
thermalfist::HepMCEventWriter::~HepMCEventWriter
virtual ~HepMCEventWriter()
Definition
HepMCEventWriter.cpp:16
thermalfist::HepMCEventWriter::WriteEvent
virtual bool WriteEvent(const SimpleEvent &evt)
Definition
HepMCEventWriter.cpp:58
thermalfist::HepMCEventWriter::CloseFile
virtual void CloseFile()
Definition
HepMCEventWriter.cpp:49
thermalfist::HepMCEventWriter::OpenFile
virtual bool OpenFile(const std::string &filename)
Definition
HepMCEventWriter.cpp:21
thermalfist::HepMCEventWriter::HepMCEventWriter
HepMCEventWriter(const std::string &filename="")
Definition
HepMCEventWriter.cpp:10
thermalfist
The main namespace where all classes and functions of the Thermal-FIST library reside.
Definition
CosmicEoS.h:9
thermalfist::SimpleEvent
Structure holding information about a single event in the event generator.
Definition
SimpleEvent.h:20
thermalfist::SimpleEvent::weight
double weight
Event weight factor.
Definition
SimpleEvent.h:22
thermalfist::SimpleEvent::Particles
std::vector< SimpleParticle > Particles
Vector of all final particles in the event.
Definition
SimpleEvent.h:28
thermalfist::SimpleParticle
Structure holding information about a single particle in the event generator.
Definition
SimpleParticle.h:15
thermalfist::SimpleParticle::PDGID
long long PDGID
PDG code.
Definition
SimpleParticle.h:19
thermalfist::SimpleParticle::py
double py
Definition
SimpleParticle.h:16
thermalfist::SimpleParticle::p0
double p0
Energy (in GeV)
Definition
SimpleParticle.h:18
thermalfist::SimpleParticle::pz
double pz
3-momentum components (in GeV)
Definition
SimpleParticle.h:16
thermalfist::SimpleParticle::m
double m
Mass (in GeV)
Definition
SimpleParticle.h:17
thermalfist::SimpleParticle::px
double px
Definition
SimpleParticle.h:16
Generated by
1.13.2