Version: SMASH-1.8
rootoutput.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2014-2020
4  * SMASH Team
5  *
6  * GNU General Public License (GPLv3 or later)
7  *
8  */
9 
10 #ifndef SRC_INCLUDE_ROOTOUTPUT_H_
11 #define SRC_INCLUDE_ROOTOUTPUT_H_
12 
13 #include <memory>
14 #include <string>
15 #include <vector>
16 
17 #include <boost/filesystem.hpp>
18 #include "TFile.h"
19 #include "TTree.h"
20 
21 #include "configuration.h"
22 #include "forwarddeclarations.h"
23 #include "outputinterface.h"
24 #include "outputparameters.h"
25 
26 namespace smash {
27 class Particles;
28 
97 class RootOutput : public OutputInterface {
98  public:
106  RootOutput(const bf::path &path, const std::string &name,
107  const OutputParameters &out_par);
108 
110  ~RootOutput();
111 
117  void at_eventstart(const Particles &particles,
118  const int event_number) override;
128  void at_eventend(const Particles &particles, const int event_number,
129  double impact_parameter, bool empty_event) override;
137  void at_intermediate_time(const Particles &particles,
138  const std::unique_ptr<Clock> &clock,
139  const DensityParameters &dens_param) override;
146  void at_interaction(const Action &action, const double density) override;
147 
148  private:
150  const bf::path filename_;
154  std::unique_ptr<TFile> root_out_file_;
173  template <typename T>
174  void particles_to_tree(T &particles);
182  void collisions_to_tree(const ParticleList &incoming,
183  const ParticleList &outgoing, const double weight,
184  const double partial_weight);
188  int current_event_ = 0;
189 
191  static const int max_buffer_size_ = 10000;
192 
197  std::array<double, max_buffer_size_> p0, px, py, pz, t, x, y, z,
200  std::array<int, max_buffer_size_> pdgcode, charge, coll_per_part_,
203  double wgt, par_wgt, impact_b;
206 
209 
212 
215 
218 
229 
231  const bool part_extended_;
233  const bool coll_extended_;
235  const bool ic_extended_;
236 
241  void init_trees();
242 };
243 
244 } // namespace smash
245 
246 #endif // SRC_INCLUDE_ROOTOUTPUT_H_
smash::RootOutput::~RootOutput
~RootOutput()
Destructor.
Definition: rootoutput.cc:194
smash
Definition: action.h:24
smash::RootOutput::npart
int npart
Property that is written to ROOT output.
Definition: rootoutput.h:202
smash::RootOutput::filename_unfinished_
bf::path filename_unfinished_
Filename of output as long as simulation is still running.
Definition: rootoutput.h:152
outputparameters.h
smash::RootOutput::pdgcode
std::array< int, max_buffer_size_ > pdgcode
Property that is written to ROOT output.
Definition: rootoutput.h:200
smash::RootOutput::coll_extended_
const bool coll_extended_
Whether extended collisions output is on.
Definition: rootoutput.h:233
smash::DensityParameters
A class to pre-calculate and store parameters relevant for density calculation.
Definition: density.h:107
smash::RootOutput::impact_b
double impact_b
Property that is written to ROOT output.
Definition: rootoutput.h:203
smash::RootOutput::ev
int ev
Property that is written to ROOT output.
Definition: rootoutput.h:202
OutputOnlyFinal
OutputOnlyFinal
Whether and when only final state particles should be printed.
Definition: forwarddeclarations.h:200
smash::RootOutput::nout
int nout
Property that is written to ROOT output.
Definition: rootoutput.h:202
smash::RootOutput::z
std::array< double, max_buffer_size_ > z
Property that is written to ROOT output.
Definition: rootoutput.h:198
smash::RootOutput::y
std::array< double, max_buffer_size_ > y
Property that is written to ROOT output.
Definition: rootoutput.h:198
smash::RootOutput::formation_time_
std::array< double, max_buffer_size_ > formation_time_
Property that is written to ROOT output.
Definition: rootoutput.h:198
smash::RootOutput::RootOutput
RootOutput(const bf::path &path, const std::string &name, const OutputParameters &out_par)
Construct ROOT output.
Definition: rootoutput.cc:87
smash::RootOutput::filename_
const bf::path filename_
Filename of output.
Definition: rootoutput.h:150
smash::RootOutput::write_initial_conditions_
bool write_initial_conditions_
Option to write particles tree for initial conditions.
Definition: rootoutput.h:214
smash::RootOutput::init_trees
void init_trees()
Basic initialization routine, creating the TTree objects for particles and collisions.
Definition: rootoutput.cc:107
smash::RootOutput::at_interaction
void at_interaction(const Action &action, const double density) override
Writes collisions to a tree defined by treename.
Definition: rootoutput.cc:257
forwarddeclarations.h
smash::RootOutput::output_counter_
int output_counter_
Number of output in a given event.
Definition: rootoutput.h:186
outputinterface.h
smash::RootOutput::wgt
double wgt
Property that is written to ROOT output.
Definition: rootoutput.h:203
smash::RootOutput::autosave_frequency_
int autosave_frequency_
Root file cannot be read if it was not properly closed and finalized.
Definition: rootoutput.h:228
smash::RootOutput::empty_event_
bool empty_event_
Property that is written to ROOT output.
Definition: rootoutput.h:204
smash::OutputParameters
Helper structure for Experiment to hold output options and parameters.
Definition: outputparameters.h:25
smash::RootOutput::coll_per_part_
std::array< int, max_buffer_size_ > coll_per_part_
Property that is written to ROOT output.
Definition: rootoutput.h:200
smash::RootOutput::at_eventend
void at_eventend(const Particles &particles, const int event_number, double impact_parameter, bool empty_event) override
update event number and impact parameter, and writes intermediate particles to a tree.
Definition: rootoutput.cc:225
smash::RootOutput::write_particles_
bool write_particles_
Option to write particles tree.
Definition: rootoutput.h:211
smash::OutputInterface
Abstraction of generic output.
Definition: outputinterface.h:35
smash::RootOutput::charge
std::array< int, max_buffer_size_ > charge
Property that is written to ROOT output.
Definition: rootoutput.h:200
smash::RootOutput::x
std::array< double, max_buffer_size_ > x
Property that is written to ROOT output.
Definition: rootoutput.h:198
smash::RootOutput::collisions_tree_
TTree * collisions_tree_
TTree for collision output.
Definition: rootoutput.h:168
smash::RootOutput::px
std::array< double, max_buffer_size_ > px
Property that is written to ROOT output.
Definition: rootoutput.h:198
smash::RootOutput::nin
int nin
Property that is written to ROOT output.
Definition: rootoutput.h:202
smash::RootOutput::py
std::array< double, max_buffer_size_ > py
Property that is written to ROOT output.
Definition: rootoutput.h:198
smash::RootOutput::write_collisions_
bool write_collisions_
Option to write collisions tree.
Definition: rootoutput.h:208
smash::RootOutput::current_event_
int current_event_
Number of current event.
Definition: rootoutput.h:188
smash::RootOutput
Definition: rootoutput.h:97
smash::RootOutput::xsec_factor_
std::array< double, max_buffer_size_ > xsec_factor_
Property that is written to ROOT output.
Definition: rootoutput.h:198
smash::RootOutput::par_wgt
double par_wgt
Property that is written to ROOT output.
Definition: rootoutput.h:203
smash::RootOutput::pdg_mother1_
std::array< int, max_buffer_size_ > pdg_mother1_
Property that is written to ROOT output.
Definition: rootoutput.h:200
smash::RootOutput::root_out_file_
std::unique_ptr< TFile > root_out_file_
Pointer to root output file.
Definition: rootoutput.h:154
smash::Particles
Definition: particles.h:33
smash::RootOutput::at_intermediate_time
void at_intermediate_time(const Particles &particles, const std::unique_ptr< Clock > &clock, const DensityParameters &dens_param) override
Writes intermediate particles to a tree defined by treename, if it is allowed (i.e....
Definition: rootoutput.cc:216
smash::RootOutput::particles_tree_
TTree * particles_tree_
TTree for particles output.
Definition: rootoutput.h:161
smash::RootOutput::collisions_to_tree
void collisions_to_tree(const ParticleList &incoming, const ParticleList &outgoing, const double weight, const double partial_weight)
Writes collisions to a tree defined by treename.
Definition: rootoutput.cc:319
smash::RootOutput::p0
std::array< double, max_buffer_size_ > p0
Property that is written to ROOT output.
Definition: rootoutput.h:198
smash::RootOutput::part_extended_
const bool part_extended_
Whether extended particle output is on.
Definition: rootoutput.h:231
smash::Action
Definition: action.h:35
configuration.h
smash::RootOutput::max_buffer_size_
static const int max_buffer_size_
Maximal buffer size.
Definition: rootoutput.h:191
smash::RootOutput::time_last_coll_
std::array< double, max_buffer_size_ > time_last_coll_
Property that is written to ROOT output.
Definition: rootoutput.h:198
smash::RootOutput::particles_to_tree
void particles_to_tree(T &particles)
Writes particles to a tree defined by treename.
Definition: rootoutput.cc:271
smash::RootOutput::tcounter
int tcounter
Property that is written to ROOT output.
Definition: rootoutput.h:202
smash::RootOutput::particles_only_final_
OutputOnlyFinal particles_only_final_
Print only final particles in the event, no intermediate output.
Definition: rootoutput.h:217
smash::RootOutput::at_eventstart
void at_eventstart(const Particles &particles, const int event_number) override
update event number and writes intermediate particles to a tree.
Definition: rootoutput.cc:201
smash::RootOutput::proc_id_origin_
std::array< int, max_buffer_size_ > proc_id_origin_
Property that is written to ROOT output.
Definition: rootoutput.h:200
smash::RootOutput::pz
std::array< double, max_buffer_size_ > pz
Property that is written to ROOT output.
Definition: rootoutput.h:198
smash::RootOutput::ic_extended_
const bool ic_extended_
Whether extended ic output is on.
Definition: rootoutput.h:235
smash::RootOutput::t
std::array< double, max_buffer_size_ > t
Property that is written to ROOT output.
Definition: rootoutput.h:198
smash::RootOutput::proc_type_origin_
std::array< int, max_buffer_size_ > proc_type_origin_
Property that is written to ROOT output.
Definition: rootoutput.h:200
smash::RootOutput::pdg_mother2_
std::array< int, max_buffer_size_ > pdg_mother2_
Property that is written to ROOT output.
Definition: rootoutput.h:200