Version: SMASH-2.0
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_SMASH_ROOTOUTPUT_H_
11 #define SRC_INCLUDE_SMASH_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 
79 class RootOutput : public OutputInterface {
80  public:
88  RootOutput(const bf::path &path, const std::string &name,
89  const OutputParameters &out_par);
90 
92  ~RootOutput();
93 
100  void at_eventstart(const Particles &particles, const int event_number,
101  const EventInfo &event) override;
109  void at_eventend(const Particles &particles, const int event_number,
110  const EventInfo &event) override;
119  void at_intermediate_time(const Particles &particles,
120  const std::unique_ptr<Clock> &clock,
121  const DensityParameters &dens_param,
122  const EventInfo &event) override;
129  void at_interaction(const Action &action, const double density) override;
130 
131  private:
133  const bf::path filename_;
137  std::unique_ptr<TFile> root_out_file_;
156  template <typename T>
157  void particles_to_tree(T &particles);
165  void collisions_to_tree(const ParticleList &incoming,
166  const ParticleList &outgoing, const double weight,
167  const double partial_weight);
171  int current_event_ = 0;
172 
179  static const int max_buffer_size_;
180 
185  std::vector<double> p0_ = std::vector<double>(max_buffer_size_, 0.0);
187  std::vector<double> px_ = std::vector<double>(max_buffer_size_, 0.0);
188  std::vector<double> py_ = std::vector<double>(max_buffer_size_, 0.0);
189  std::vector<double> pz_ = std::vector<double>(max_buffer_size_, 0.0);
190  std::vector<double> t_ = std::vector<double>(max_buffer_size_, 0.0);
191  std::vector<double> x_ = std::vector<double>(max_buffer_size_, 0.0);
192  std::vector<double> y_ = std::vector<double>(max_buffer_size_, 0.0);
193  std::vector<double> z_ = std::vector<double>(max_buffer_size_, 0.0);
194  std::vector<double> formation_time_ =
195  std::vector<double>(max_buffer_size_, 0.0);
196  std::vector<double> xsec_factor_ = std::vector<double>(max_buffer_size_, 0.0);
197  std::vector<double> time_last_coll_ =
198  std::vector<double>(max_buffer_size_, 0.0);
199  std::vector<int> pdgcode_ = std::vector<int>(max_buffer_size_, 0);
200  std::vector<int> charge_ = std::vector<int>(max_buffer_size_, 0);
201  std::vector<int> coll_per_part_ = std::vector<int>(max_buffer_size_, 0);
202  std::vector<int> proc_id_origin_ = std::vector<int>(max_buffer_size_, 0);
203  std::vector<int> proc_type_origin_ = std::vector<int>(max_buffer_size_, 0);
204  std::vector<int> pdg_mother1_ = std::vector<int>(max_buffer_size_, 0);
205  std::vector<int> pdg_mother2_ = std::vector<int>(max_buffer_size_, 0);
211 
214 
217 
220 
223 
234 
236  const bool part_extended_;
238  const bool coll_extended_;
240  const bool ic_extended_;
241 
246  void init_trees();
247 };
248 
249 } // namespace smash
250 
251 #endif // SRC_INCLUDE_SMASH_ROOTOUTPUT_H_
smash::RootOutput::~RootOutput
~RootOutput()
Destructor.
Definition: rootoutput.cc:340
smash
Definition: action.h:24
smash::RootOutput::wgt_
double wgt_
Property that is written to ROOT output.
Definition: rootoutput.h:207
smash::RootOutput::filename_unfinished_
bf::path filename_unfinished_
Filename of output as long as simulation is still running.
Definition: rootoutput.h:135
smash::RootOutput::charge_
std::vector< int > charge_
Property that is written to ROOT output.
Definition: rootoutput.h:200
smash::RootOutput::E_tot_
double E_tot_
Property that is written to ROOT output.
Definition: rootoutput.h:208
outputparameters.h
smash::RootOutput::pdg_mother1_
std::vector< int > pdg_mother1_
Property that is written to ROOT output.
Definition: rootoutput.h:204
smash::RootOutput::coll_extended_
const bool coll_extended_
Whether extended collisions output is on.
Definition: rootoutput.h:238
smash::DensityParameters
A class to pre-calculate and store parameters relevant for density calculation.
Definition: density.h:108
smash::RootOutput::y_
std::vector< double > y_
Property that is written to ROOT output.
Definition: rootoutput.h:192
smash::RootOutput::z_
std::vector< double > z_
Property that is written to ROOT output.
Definition: rootoutput.h:193
OutputOnlyFinal
OutputOnlyFinal
Whether and when only final state particles should be printed.
Definition: forwarddeclarations.h:205
smash::RootOutput::proc_id_origin_
std::vector< int > proc_id_origin_
Property that is written to ROOT output.
Definition: rootoutput.h:202
smash::RootOutput::pdg_mother2_
std::vector< int > pdg_mother2_
Property that is written to ROOT output.
Definition: rootoutput.h:205
smash::RootOutput::xsec_factor_
std::vector< double > xsec_factor_
Property that is written to ROOT output.
Definition: rootoutput.h:196
smash::RootOutput::p0_
std::vector< double > p0_
Property that is written to ROOT output.
Definition: rootoutput.h:186
smash::RootOutput::at_eventend
void at_eventend(const Particles &particles, const int event_number, const EventInfo &event) override
update event number and impact parameter, and writes intermediate particles to a tree.
Definition: rootoutput.cc:386
smash::RootOutput::ev_
int ev_
Property that is written to ROOT output.
Definition: rootoutput.h:206
smash::RootOutput::py_
std::vector< double > py_
Property that is written to ROOT output.
Definition: rootoutput.h:188
smash::RootOutput::RootOutput
RootOutput(const bf::path &path, const std::string &name, const OutputParameters &out_par)
Construct ROOT output.
Definition: rootoutput.cc:225
smash::RootOutput::filename_
const bf::path filename_
Filename of output.
Definition: rootoutput.h:133
smash::RootOutput::E_fields_tot_
double E_fields_tot_
Property that is written to ROOT output.
Definition: rootoutput.h:208
smash::RootOutput::write_initial_conditions_
bool write_initial_conditions_
Option to write particles tree for initial conditions.
Definition: rootoutput.h:219
smash::RootOutput::pz_
std::vector< double > pz_
Property that is written to ROOT output.
Definition: rootoutput.h:189
smash::RootOutput::formation_time_
std::vector< double > formation_time_
Property that is written to ROOT output.
Definition: rootoutput.h:194
smash::RootOutput::test_p_
int test_p_
Property that is written to ROOT output.
Definition: rootoutput.h:206
smash::EventInfo
Structure to contain custom data for output.
Definition: outputinterface.h:35
smash::RootOutput::init_trees
void init_trees()
Basic initialization routine, creating the TTree objects for particles and collisions.
Definition: rootoutput.cc:245
smash::RootOutput::current_t_
double current_t_
Property that is written to ROOT output.
Definition: rootoutput.h:207
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:426
forwarddeclarations.h
smash::RootOutput::output_counter_
int output_counter_
Number of output in a given event.
Definition: rootoutput.h:169
outputinterface.h
smash::RootOutput::autosave_frequency_
int autosave_frequency_
Root file cannot be read if it was not properly closed and finalized.
Definition: rootoutput.h:233
smash::RootOutput::empty_event_
bool empty_event_
Property that is written to ROOT output.
Definition: rootoutput.h:209
smash::OutputParameters
Helper structure for Experiment to hold output options and parameters.
Definition: outputparameters.h:25
smash::RootOutput::nout_
int nout_
Property that is written to ROOT output.
Definition: rootoutput.h:206
smash::RootOutput::write_particles_
bool write_particles_
Option to write particles tree.
Definition: rootoutput.h:216
smash::RootOutput::coll_per_part_
std::vector< int > coll_per_part_
Property that is written to ROOT output.
Definition: rootoutput.h:201
smash::OutputInterface
Abstraction of generic output.
Definition: outputinterface.h:65
smash::RootOutput::at_eventstart
void at_eventstart(const Particles &particles, const int event_number, const EventInfo &event) override
update event number and writes intermediate particles to a tree.
Definition: rootoutput.cc:347
smash::RootOutput::pdgcode_
std::vector< int > pdgcode_
Property that is written to ROOT output.
Definition: rootoutput.h:199
smash::RootOutput::npart_
int npart_
Property that is written to ROOT output.
Definition: rootoutput.h:206
smash::RootOutput::modus_l_
double modus_l_
Property that is written to ROOT output.
Definition: rootoutput.h:207
smash::RootOutput::collisions_tree_
TTree * collisions_tree_
TTree for collision output.
Definition: rootoutput.h:151
smash::RootOutput::impact_b_
double impact_b_
Property that is written to ROOT output.
Definition: rootoutput.h:207
smash::RootOutput::write_collisions_
bool write_collisions_
Option to write collisions tree.
Definition: rootoutput.h:213
smash::RootOutput::current_event_
int current_event_
Number of current event.
Definition: rootoutput.h:171
smash::RootOutput
Definition: rootoutput.h:79
smash::RootOutput::px_
std::vector< double > px_
Property that is written to ROOT output.
Definition: rootoutput.h:187
smash::RootOutput::t_
std::vector< double > t_
Property that is written to ROOT output.
Definition: rootoutput.h:190
smash::RootOutput::time_last_coll_
std::vector< double > time_last_coll_
Property that is written to ROOT output.
Definition: rootoutput.h:197
smash::RootOutput::root_out_file_
std::unique_ptr< TFile > root_out_file_
Pointer to root output file.
Definition: rootoutput.h:137
smash::Particles
Definition: particles.h:33
smash::RootOutput::particles_tree_
TTree * particles_tree_
TTree for particles output.
Definition: rootoutput.h:144
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:501
smash::RootOutput::part_extended_
const bool part_extended_
Whether extended particle output is on.
Definition: rootoutput.h:236
smash::Action
Definition: action.h:35
smash::RootOutput::nin_
int nin_
Property that is written to ROOT output.
Definition: rootoutput.h:206
smash::RootOutput::at_intermediate_time
void at_intermediate_time(const Particles &particles, const std::unique_ptr< Clock > &clock, const DensityParameters &dens_param, const EventInfo &event) override
Writes intermediate particles to a tree defined by treename, if it is allowed (i.e....
Definition: rootoutput.cc:369
smash::RootOutput::par_wgt_
double par_wgt_
Property that is written to ROOT output.
Definition: rootoutput.h:207
configuration.h
smash::RootOutput::max_buffer_size_
static const int max_buffer_size_
Maximal buffer size.
Definition: rootoutput.h:179
smash::RootOutput::particles_to_tree
void particles_to_tree(T &particles)
Writes particles to a tree defined by treename.
Definition: rootoutput.cc:440
smash::RootOutput::particles_only_final_
OutputOnlyFinal particles_only_final_
Print only final particles in the event, no intermediate output.
Definition: rootoutput.h:222
smash::RootOutput::E_kinetic_tot_
double E_kinetic_tot_
Property that is written to ROOT output.
Definition: rootoutput.h:208
smash::RootOutput::tcounter_
int tcounter_
Property that is written to ROOT output.
Definition: rootoutput.h:206
smash::RootOutput::ic_extended_
const bool ic_extended_
Whether extended ic output is on.
Definition: rootoutput.h:240
smash::RootOutput::x_
std::vector< double > x_
Property that is written to ROOT output.
Definition: rootoutput.h:191
smash::RootOutput::proc_type_origin_
std::vector< int > proc_type_origin_
Property that is written to ROOT output.
Definition: rootoutput.h:203