Version: SMASH-3.1
rootoutput.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2014-2020,2022-2023
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 <filesystem>
14 #include <memory>
15 #include <string>
16 #include <vector>
17 
18 #include "TFile.h"
19 #include "TTree.h"
20 #include "configuration.h"
21 #include "forwarddeclarations.h"
22 #include "outputinterface.h"
23 #include "outputparameters.h"
24 
25 namespace smash {
26 class Particles;
27 
78 class RootOutput : public OutputInterface {
79  public:
87  RootOutput(const std::filesystem::path &path, const std::string &name,
88  const OutputParameters &out_par);
89 
91  ~RootOutput();
92 
99  void at_eventstart(const Particles &particles, const int event_number,
100  const EventInfo &event) override;
108  void at_eventend(const Particles &particles, const int event_number,
109  const EventInfo &event) override;
118  void at_intermediate_time(const Particles &particles,
119  const std::unique_ptr<Clock> &clock,
120  const DensityParameters &dens_param,
121  const EventInfo &event) override;
128  void at_interaction(const Action &action, const double density) override;
129 
130  private:
132  const std::filesystem::path filename_;
134  std::filesystem::path filename_unfinished_;
136  std::unique_ptr<TFile> root_out_file_;
155  template <typename T>
156  void particles_to_tree(T &particles);
164  void collisions_to_tree(const ParticleList &incoming,
165  const ParticleList &outgoing, const double weight,
166  const double partial_weight);
170  int current_event_ = 0;
171 
178  static const int max_buffer_size_;
179 
185  std::vector<double> p0_ = std::vector<double>(max_buffer_size_, 0.0);
186  std::vector<double> px_ = std::vector<double>(max_buffer_size_, 0.0);
187  std::vector<double> py_ = std::vector<double>(max_buffer_size_, 0.0);
188  std::vector<double> pz_ = std::vector<double>(max_buffer_size_, 0.0);
189  std::vector<double> t_ = std::vector<double>(max_buffer_size_, 0.0);
190  std::vector<double> x_ = std::vector<double>(max_buffer_size_, 0.0);
191  std::vector<double> y_ = std::vector<double>(max_buffer_size_, 0.0);
192  std::vector<double> z_ = std::vector<double>(max_buffer_size_, 0.0);
193  std::vector<double> formation_time_ =
194  std::vector<double>(max_buffer_size_, 0.0);
195  std::vector<double> xsec_factor_ = std::vector<double>(max_buffer_size_, 0.0);
196  std::vector<double> time_last_coll_ =
197  std::vector<double>(max_buffer_size_, 0.0);
198  std::vector<int> pdgcode_ = std::vector<int>(max_buffer_size_, 0);
199  std::vector<int> charge_ = std::vector<int>(max_buffer_size_, 0);
200  std::vector<int> coll_per_part_ = std::vector<int>(max_buffer_size_, 0);
201  std::vector<int> proc_id_origin_ = std::vector<int>(max_buffer_size_, 0);
202  std::vector<int> proc_type_origin_ = std::vector<int>(max_buffer_size_, 0);
203  std::vector<int> pdg_mother1_ = std::vector<int>(max_buffer_size_, 0);
204  std::vector<int> pdg_mother2_ = std::vector<int>(max_buffer_size_, 0);
205  std::vector<int> baryon_number_ = std::vector<int>(max_buffer_size_, 0);
206  std::vector<int> strangeness_ = std::vector<int>(max_buffer_size_, 0);
212 
215 
218 
221 
224 
235 
237  const bool part_extended_;
239  const bool coll_extended_;
241  const bool ic_extended_;
242 
247  void init_trees();
248 };
249 
250 } // namespace smash
251 
252 #endif // SRC_INCLUDE_SMASH_ROOTOUTPUT_H_
Action is the base class for a generic process that takes a number of incoming particles and transfor...
Definition: action.h:35
A class to pre-calculate and store parameters relevant for density calculation.
Definition: density.h:108
Abstraction of generic output.
The Particles class abstracts the storage and manipulation of particles.
Definition: particles.h:33
void at_interaction(const Action &action, const double density) override
Writes collisions to a tree defined by treename.
Definition: rootoutput.cc:441
std::vector< double > t_
Property that is written to ROOT output.
Definition: rootoutput.h:189
std::vector< double > y_
Property that is written to ROOT output.
Definition: rootoutput.h:191
double current_t_
Property that is written to ROOT output.
Definition: rootoutput.h:208
OutputOnlyFinal particles_only_final_
Print only final particles in the event, no intermediate output.
Definition: rootoutput.h:223
int current_event_
Number of current event.
Definition: rootoutput.h:170
TTree * collisions_tree_
TTree for collision output.
Definition: rootoutput.h:150
~RootOutput()
Destructor.
Definition: rootoutput.cc:355
double E_kinetic_tot_
Property that is written to ROOT output.
Definition: rootoutput.h:209
int test_p_
Property that is written to ROOT output.
Definition: rootoutput.h:207
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:518
int autosave_frequency_
Root file cannot be read if it was not properly closed and finalized.
Definition: rootoutput.h:234
std::vector< int > proc_type_origin_
Property that is written to ROOT output.
Definition: rootoutput.h:202
double modus_l_
Property that is written to ROOT output.
Definition: rootoutput.h:208
std::vector< double > time_last_coll_
Property that is written to ROOT output.
Definition: rootoutput.h:196
std::vector< int > coll_per_part_
Property that is written to ROOT output.
Definition: rootoutput.h:200
int tcounter_
Property that is written to ROOT output.
Definition: rootoutput.h:207
std::vector< int > baryon_number_
Property that is written to ROOT output.
Definition: rootoutput.h:205
int npart_
Property that is written to ROOT output.
Definition: rootoutput.h:207
std::vector< int > pdg_mother1_
Property that is written to ROOT output.
Definition: rootoutput.h:203
int nin_
Property that is written to ROOT output.
Definition: rootoutput.h:207
int ev_
Property that is written to ROOT output.
Definition: rootoutput.h:207
bool write_collisions_
Option to write collisions tree.
Definition: rootoutput.h:214
std::vector< int > charge_
Property that is written to ROOT output.
Definition: rootoutput.h:199
std::vector< double > px_
Property that is written to ROOT output.
Definition: rootoutput.h:186
const std::filesystem::path filename_
Filename of output.
Definition: rootoutput.h:132
std::vector< int > strangeness_
Property that is written to ROOT output.
Definition: rootoutput.h:206
bool write_initial_conditions_
Option to write particles tree for initial conditions.
Definition: rootoutput.h:220
double wgt_
Property that is written to ROOT output.
Definition: rootoutput.h:208
std::vector< double > py_
Property that is written to ROOT output.
Definition: rootoutput.h:187
std::vector< int > proc_id_origin_
Property that is written to ROOT output.
Definition: rootoutput.h:201
void particles_to_tree(T &particles)
Writes particles to a tree defined by treename.
Definition: rootoutput.cc:455
const bool part_extended_
Whether extended particle output is on.
Definition: rootoutput.h:237
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:362
double impact_b_
Property that is written to ROOT output.
Definition: rootoutput.h:208
RootOutput(const std::filesystem::path &path, const std::string &name, const OutputParameters &out_par)
Construct ROOT output.
Definition: rootoutput.cc:232
std::vector< double > z_
Property that is written to ROOT output.
Definition: rootoutput.h:192
std::vector< double > formation_time_
Property that is written to ROOT output.
Definition: rootoutput.h:193
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:401
std::vector< double > x_
Property that is written to ROOT output.
Definition: rootoutput.h:190
std::vector< double > p0_
Property that is written to ROOT output.
Definition: rootoutput.h:185
bool empty_event_
Property that is written to ROOT output.
Definition: rootoutput.h:210
static const int max_buffer_size_
Maximal buffer size.
Definition: rootoutput.h:178
std::unique_ptr< TFile > root_out_file_
Pointer to root output file.
Definition: rootoutput.h:136
std::vector< double > xsec_factor_
Property that is written to ROOT output.
Definition: rootoutput.h:195
double E_fields_tot_
Property that is written to ROOT output.
Definition: rootoutput.h:209
std::filesystem::path filename_unfinished_
Filename of output as long as simulation is still running.
Definition: rootoutput.h:134
const bool coll_extended_
Whether extended collisions output is on.
Definition: rootoutput.h:239
double par_wgt_
Property that is written to ROOT output.
Definition: rootoutput.h:208
void init_trees()
Basic initialization routine, creating the TTree objects for particles and collisions.
Definition: rootoutput.cc:252
int output_counter_
Number of output in a given event.
Definition: rootoutput.h:168
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:384
double E_tot_
Property that is written to ROOT output.
Definition: rootoutput.h:209
TTree * particles_tree_
TTree for particles output.
Definition: rootoutput.h:143
std::vector< double > pz_
Property that is written to ROOT output.
Definition: rootoutput.h:188
int nout_
Property that is written to ROOT output.
Definition: rootoutput.h:207
const bool ic_extended_
Whether extended ic output is on.
Definition: rootoutput.h:241
bool write_particles_
Option to write particles tree.
Definition: rootoutput.h:217
std::vector< int > pdgcode_
Property that is written to ROOT output.
Definition: rootoutput.h:198
std::vector< int > pdg_mother2_
Property that is written to ROOT output.
Definition: rootoutput.h:204
OutputOnlyFinal
Whether and when only final state particles should be printed.
Definition: action.h:24
Structure to contain custom data for output.
Helper structure for Experiment to hold output options and parameters.