Thermal-FIST  1.3
Package for hadron resonance gas model applications
SimpleEvent.cpp
Go to the documentation of this file.
1 /*
2  * Thermal-FIST package
3  *
4  * Copyright (c) 2015-2019 Volodymyr Vovchenko
5  *
6  * GNU General Public License (GPLv3 or later)
7  */
9 
10 #include <iomanip>
11 
12 namespace thermalfist {
13 
14  void SimpleEvent::writeToFile(std::ofstream & fout, const EventOutputConfig& config, int eventnumber)
15  {
16  fout << "Event " << eventnumber << std::endl;
17  fout << "Weight: " << weight << std::endl;
18 
19  fout << std::setw(20) << "pdgid"
20  << std::setw(20) << "px[GeV]"
21  << std::setw(20) << "py[GeV]"
22  << std::setw(20) << "pz[GeV]";
23 
24  if (config.printEnergy)
25  fout << std::setw(20) << "p0[GeV]";
26 
27  if (config.printMotherPdg)
28  fout << std::setw(20) << "mother_pdgid";
29 
30  if (config.printDecayEpoch)
31  fout << std::setw(20) << "decay_epoch";
32 
33  fout << std::endl;
34 
35  for (size_t i = 0; i < Particles.size(); ++i) {
36  fout << std::setw(20) << Particles[i].PDGID
37  << std::setw(20) << Particles[i].px
38  << std::setw(20) << Particles[i].py
39  << std::setw(20) << Particles[i].pz;
40 
41  if (config.printEnergy)
42  fout << std::setw(20) << Particles[i].p0;
43 
44  if (config.printMotherPdg)
45  fout << std::setw(20) << Particles[i].MotherPDGID;
46 
47  if (config.printDecayEpoch)
48  fout << std::setw(20) << Particles[i].epoch;
49 
50  fout << std::endl;
51  }
52 
53  fout << std::scientific;
54 
55  if (config.printPhotonsLeptons) {
56  for (size_t i = 0; i < PhotonsLeptons.size(); ++i) {
57  fout << std::setw(20) << PhotonsLeptons[i].PDGID
58  << std::setw(20) << PhotonsLeptons[i].px
59  << std::setw(20) << PhotonsLeptons[i].py
60  << std::setw(20) << PhotonsLeptons[i].pz;
61 
62  if (config.printEnergy)
63  fout << std::setw(20) << PhotonsLeptons[i].p0;
64 
65  if (config.printMotherPdg)
66  fout << std::setw(20) << PhotonsLeptons[i].MotherPDGID;
67 
68  if (config.printDecayEpoch)
69  fout << std::setw(20) << PhotonsLeptons[i].epoch;
70 
71  fout << std::endl;
72  }
73  }
74  fout << std::endl;
75  fout << std::fixed;
76  }
77 
79  {
80  for (size_t i = 0; i < Particles.size(); ++i)
81  Particles[i].RapidityBoost(dY);
82  }
83 
85  {
86  SimpleEvent ret;
87  ret.Particles.reserve(evt1.Particles.size() + evt2.Particles.size());
88  ret.Particles.insert(ret.Particles.end(), evt1.Particles.begin(), evt1.Particles.end());
89  ret.Particles.insert(ret.Particles.end(), evt2.Particles.begin(), evt2.Particles.end());
90 
91  ret.AllParticles.reserve(evt1.AllParticles.size() + evt2.AllParticles.size());
92  ret.AllParticles.insert(ret.AllParticles.end(), evt1.AllParticles.begin(), evt1.AllParticles.end());
93  ret.AllParticles.insert(ret.AllParticles.end(), evt2.AllParticles.begin(), evt2.AllParticles.end());
94 
95  ret.DecayMap.reserve(evt1.DecayMap.size() + evt2.DecayMap.size());
96  ret.DecayMap.insert(ret.DecayMap.end(), evt1.DecayMap.begin(), evt1.DecayMap.end());
97  ret.DecayMap.insert(ret.DecayMap.end(), evt2.DecayMap.begin(), evt2.DecayMap.end());
98 
99  ret.DecayMapFinal.reserve(evt1.DecayMapFinal.size() + evt2.DecayMapFinal.size());
100  ret.DecayMapFinal.insert(ret.DecayMapFinal.end(), evt1.DecayMapFinal.begin(), evt1.DecayMapFinal.end());
101  ret.DecayMapFinal.insert(ret.DecayMapFinal.end(), evt2.DecayMapFinal.begin(), evt2.DecayMapFinal.end());
102 
103  // TODO: check if proper to combine weights like that
104  ret.weight = evt1.weight * evt2.weight;
105  ret.logweight = evt1.logweight + evt2.logweight;
106 
107  return ret;
108  }
109 
110 } // namespace thermalfist
void RapidityBoost(double dY)
Rapidity boost by Y -> Y + dY for all particles.
Definition: SimpleEvent.cpp:78
bool printDecayEpoch
Print the number of succesive decays before the particle was produced.
Definition: SimpleEvent.h:64
Configuration for the event output.
Definition: SimpleEvent.h:52
Structure holding information about a single event in the event generator.
Definition: SimpleEvent.h:19
bool printEnergy
Output the particle&#39;s energy in addition to its 3-momentum.
Definition: SimpleEvent.h:55
std::vector< SimpleParticle > AllParticles
Vector of all particles which ever appeared in the event (including those that decay and photons/lept...
Definition: SimpleEvent.h:30
std::vector< SimpleParticle > PhotonsLeptons
Vector of all decay photons/leptons.
Definition: SimpleEvent.h:33
double logweight
Log of the event weight factor.
Definition: SimpleEvent.h:24
bool printPhotonsLeptons
Output photons and leptons, if any.
Definition: SimpleEvent.h:61
bool printMotherPdg
Output the pdg code of the mother particle.
Definition: SimpleEvent.h:58
std::vector< SimpleParticle > Particles
Vector of all final particles in the event.
Definition: SimpleEvent.h:27
std::vector< int > DecayMap
Definition: SimpleEvent.h:37
void writeToFile(std::ofstream &fout, const EventOutputConfig &config=EventOutputConfig(), int eventnumber=1)
Writes the event to an output file stream.
Definition: SimpleEvent.cpp:14
The main namespace where all classes and functions of the Thermal-FIST library reside.
std::vector< int > DecayMapFinal
Vector for each Particles element pointing to the index of the primordial resonance from which this p...
Definition: SimpleEvent.h:40
double weight
Event weight factor.
Definition: SimpleEvent.h:21
static SimpleEvent MergeEvents(const SimpleEvent &evt1, const SimpleEvent &evt2)
Merge particles from two events (e.g. two patches, two canonical volumes, etc.)
Definition: SimpleEvent.cpp:84