#include <rootoutput.h>
SMASH supports ROOT output as an option (see http://root.cern.ch). The ROOT framework needs to be installed before building SMASH, otherwise ROOT support will be disabled.
This class produces a file Particles.root, which contains a ROOT TTree. The TTree contains information about particles from all SMASH events comprising a simulation. If Collisions output is requested, this class also produces a file Collisions.root, which contains a ROOT TTRee with information about all collisions.
See ROOT format for more informatioon.
Definition at line 46 of file rootoutput.h.
Public Member Functions | |
| RootOutput (const std::filesystem::path &path, const std::string &name, const OutputParameters &out_par) | |
| Construct ROOT output. More... | |
| ~RootOutput () | |
| Destructor. More... | |
| void | at_eventstart (const Particles &particles, const EventLabel &event_label, const EventInfo &event) override |
| update event number and writes intermediate particles to a tree. More... | |
| void | at_eventend (const Particles &particles, const EventLabel &event_label, const EventInfo &event) override |
| update event number and impact parameter, and writes intermediate particles to a tree. More... | |
| void | at_intermediate_time (const Particles &particles, const std::unique_ptr< Clock > &clock, const DensityParameters &dens_param, const EventLabel &event_label, const EventInfo &event) override |
| Writes intermediate particles to a tree defined by treename, if it is allowed (i.e., particles_only_final_ is No). More... | |
| void | at_interaction (const Action &action, const double density) override |
| Writes collisions to a tree defined by treename. More... | |
Public Member Functions inherited from smash::OutputInterface | |
| OutputInterface (std::string name) | |
| Construct output interface. More... | |
| virtual | ~OutputInterface ()=0 |
| Pure virtual destructor to make class abstract and prevent its instantiation. More... | |
| virtual void | at_eventstart (const std::vector< Particles > &, int) |
| Output launched at event start after initialization, when particles are generated but not yet propagated. More... | |
| virtual void | at_eventstart (const int, const ThermodynamicQuantity, const DensityType, RectangularLattice< DensityOnLattice >) |
| Output launched at event start after initialization, when particles are generated but not yet propagated. More... | |
| virtual void | at_eventstart (const int, const ThermodynamicQuantity, const DensityType, RectangularLattice< EnergyMomentumTensor >) |
| Output launched at event start after initialization, when particles are generated but not yet propagated. More... | |
| virtual void | at_eventend (const ThermodynamicQuantity) |
| Output launched at event end. More... | |
| virtual void | at_eventend (const std::vector< Particles > &, const int) |
| Output launched at event end. More... | |
| virtual void | at_intermediate_time (const std::vector< Particles > &, const std::unique_ptr< Clock > &, const DensityParameters &) |
| Output launched after every N'th timestep. More... | |
| virtual void | thermodynamics_output (const ThermodynamicQuantity, const DensityType, RectangularLattice< DensityOnLattice > &) |
| Output to write thermodynamics from the lattice. More... | |
| virtual void | thermodynamics_output (const ThermodynamicQuantity, const DensityType, RectangularLattice< EnergyMomentumTensor > &) |
| Output to write energy-momentum tensor and related quantities from the lattice. More... | |
| virtual void | thermodynamics_lattice_output (RectangularLattice< DensityOnLattice > &, const double) |
| Output to write thermodynamics from the lattice. More... | |
| virtual void | thermodynamics_lattice_output (RectangularLattice< DensityOnLattice > &, const double, const std::vector< Particles > &, const DensityParameters &) |
| Output to write thermodynamics from the lattice. More... | |
| virtual void | thermodynamics_lattice_output (const ThermodynamicQuantity, RectangularLattice< EnergyMomentumTensor > &, const double) |
| Output to write energy-momentum tensor and related quantities from the lattice. More... | |
| virtual void | thermodynamics_output (const GrandCanThermalizer &) |
| Output to write energy-momentum tensor and related quantities from the thermalizer class. More... | |
| virtual void | fields_output (const std::string, const std::string, RectangularLattice< std::pair< ThreeVector, ThreeVector >> &) |
| Write fields in vtk output Fields are a pair of threevectors for example electric and magnetic field. More... | |
| bool | is_dilepton_output () const |
| Get, whether this is the dilepton output? More... | |
| bool | is_photon_output () const |
| Get, whether this is the photon output? More... | |
| bool | is_IC_output () const |
| Get, whether this is the IC output? More... | |
| const char * | to_string (const ThermodynamicQuantity tq) |
| Convert thermodynamic quantities to strings. More... | |
| const char * | to_string (const DensityType dens_type) |
| Convert density types to strings. More... | |
Private Member Functions | |
| template<typename T > | |
| void | particles_to_tree (T &particles) |
| Writes particles to a tree defined by treename. More... | |
| 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. More... | |
Private Attributes | |
| const std::filesystem::path | filename_ |
| Filename of output. More... | |
| std::filesystem::path | filename_unfinished_ |
| Filename of output as long as simulation is still running. More... | |
| std::unique_ptr< TFile > | root_out_file_ |
| Pointer to root output file. More... | |
| TTree * | particles_tree_ |
| TTree for particles output. More... | |
| TTree * | collisions_tree_ |
| TTree for collision output. More... | |
| int | output_counter_ = 0 |
| Number of output in a given event. More... | |
| int | current_event_ = 0 |
| Number of current event. More... | |
| int | current_ensemble_ = 0 |
| Number of current ensemble. More... | |
Static Private Attributes | |
| static const int | max_buffer_size_ = 500000 |
| Maximal buffer size. More... | |
Buffer for filling TTree | |
| int | ev_ {} |
| Property that is written to ROOT output. More... | |
| int | ens_ {} |
| Property that is written to ROOT output. More... | |
| int | tcounter_ {} |
| Property that is written to ROOT output. More... | |
| int | npart_ {} |
| Property that is written to ROOT output. More... | |
| int | test_p_ {} |
| Property that is written to ROOT output. More... | |
| double | modus_l_ {} |
| Property that is written to ROOT output. More... | |
| double | current_t_ {} |
| Property that is written to ROOT output. More... | |
| double | impact_b_ {} |
| Property that is written to ROOT output. More... | |
| bool | empty_event_ {} |
| Property that is written to ROOT output. More... | |
| std::vector< int > | id_ = std::vector<int>(max_buffer_size_, 0) |
| Property that is written to ROOT output. More... | |
| std::vector< int > | pdgcode_ = std::vector<int>(max_buffer_size_, 0) |
| Property that is written to ROOT output. More... | |
| std::vector< int > | charge_ = std::vector<int>(max_buffer_size_, 0) |
| Property that is written to ROOT output. More... | |
| std::vector< double > | formation_time_ |
| Property that is written to ROOT output. More... | |
| std::vector< double > | time_last_collision_ |
| Property that is written to ROOT output. More... | |
| std::vector< double > | p0_ = std::vector<double>(max_buffer_size_, 0.0) |
| Property that is written to ROOT output. More... | |
| std::vector< double > | px_ = std::vector<double>(max_buffer_size_, 0.0) |
| Property that is written to ROOT output. More... | |
| std::vector< double > | py_ = std::vector<double>(max_buffer_size_, 0.0) |
| Property that is written to ROOT output. More... | |
| std::vector< double > | pz_ = std::vector<double>(max_buffer_size_, 0.0) |
| Property that is written to ROOT output. More... | |
| std::vector< double > | t_ = std::vector<double>(max_buffer_size_, 0.0) |
| Property that is written to ROOT output. More... | |
| std::vector< double > | x_ = std::vector<double>(max_buffer_size_, 0.0) |
| Property that is written to ROOT output. More... | |
| std::vector< double > | y_ = std::vector<double>(max_buffer_size_, 0.0) |
| Property that is written to ROOT output. More... | |
| std::vector< double > | z_ = std::vector<double>(max_buffer_size_, 0.0) |
| Property that is written to ROOT output. More... | |
| double | E_kinetic_tot_ {} |
| Property that is written to ROOT output. More... | |
| double | E_fields_tot_ {} |
| Property that is written to ROOT output. More... | |
| double | E_tot_ {} |
| Property that is written to ROOT output. More... | |
| std::vector< int > | coll_per_part_ = std::vector<int>(max_buffer_size_, 0) |
| Property that is written to ROOT output. More... | |
| std::vector< double > | xsec_factor_ = std::vector<double>(max_buffer_size_, 0.0) |
| Property that is written to ROOT output. More... | |
| std::vector< int > | proc_id_origin_ = std::vector<int>(max_buffer_size_, 0) |
| Property that is written to ROOT output. More... | |
| std::vector< int > | proc_type_origin_ = std::vector<int>(max_buffer_size_, 0) |
| Property that is written to ROOT output. More... | |
| std::vector< int > | pdg_mother1_ = std::vector<int>(max_buffer_size_, 0) |
| Property that is written to ROOT output. More... | |
| std::vector< int > | pdg_mother2_ = std::vector<int>(max_buffer_size_, 0) |
| Property that is written to ROOT output. More... | |
| std::vector< int > | baryon_number_ = std::vector<int>(max_buffer_size_, 0) |
| Property that is written to ROOT output. More... | |
| std::vector< int > | strangeness_ = std::vector<int>(max_buffer_size_, 0) |
| Property that is written to ROOT output. More... | |
| int | nin_ {} |
| Property that is written to ROOT output. More... | |
| int | nout_ {} |
| Property that is written to ROOT output. More... | |
| double | wgt_ {} |
| Property that is written to ROOT output. More... | |
| double | par_wgt_ {} |
| Property that is written to ROOT output. More... | |
| bool | write_collisions_ |
| Option to write collisions tree. More... | |
| bool | write_particles_ |
| Option to write particles tree. More... | |
| bool | write_initial_conditions_ |
| Option to write particles tree for initial conditions. More... | |
| OutputOnlyFinal | particles_only_final_ |
| Print only final particles in the event (no intermediate output). More... | |
| int | autosave_frequency_ = -1 |
| ROOT file cannot be read if it was not properly closed and finalized. More... | |
| const bool | part_extended_ |
| Whether extended particle output is on. More... | |
| const bool | coll_extended_ |
| Whether extended collisions output is on. More... | |
| const bool | ic_extended_ |
| Whether extended ic output is on. More... | |
| void | init_trees () |
| Basic initialization routine, creating the TTree objects for particles and collisions. More... | |
Additional Inherited Members | |
Protected Attributes inherited from smash::OutputInterface | |
| const bool | is_dilepton_output_ |
| Is this the dilepton output? More... | |
| const bool | is_photon_output_ |
| Is this the photon output? More... | |
| const bool | is_IC_output_ |
| Is this the IC output? More... | |
| smash::RootOutput::RootOutput | ( | const std::filesystem::path & | path, |
| const std::string & | name, | ||
| const OutputParameters & | out_par | ||
| ) |
Construct ROOT output.
| [in] | path | Output path. |
| [in] | name | Name of the ouput. |
| [in] | out_par | A structure containing parameters of the output. |
Definition at line 266 of file rootoutput.cc.
| smash::RootOutput::~RootOutput | ( | ) |
Destructor.
RootOutput destructor.
Writes root objects (here TTrees) to file and closes it.
Definition at line 393 of file rootoutput.cc.
|
overridevirtual |
update event number and writes intermediate particles to a tree.
| [in] | particles | Particles to be written to output. |
| [in] | event_label | Numbers of event and ensemble. |
| [in] | event | Event info, see event_info |
Reimplemented from smash::OutputInterface.
Definition at line 400 of file rootoutput.cc.
|
overridevirtual |
update event number and impact parameter, and writes intermediate particles to a tree.
| [in] | particles | Particles to be written to output. |
| [in] | event_label | Numbers of event and ensemble. |
| [in] | event | Event info, see event_info |
Reimplemented from smash::OutputInterface.
Definition at line 443 of file rootoutput.cc.
|
overridevirtual |
Writes intermediate particles to a tree defined by treename, if it is allowed (i.e., particles_only_final_ is No).
| [in] | particles | Particles to be written to output. |
| [in] | clock | Unused, needed since inherited. |
| [in] | dens_param | Unused, needed since inherited. |
| [in] | event_label | Numbers of event and ensemble. |
| [in] | event | Event info, see event_info |
Reimplemented from smash::OutputInterface.
Definition at line 424 of file rootoutput.cc.
|
overridevirtual |
Writes collisions to a tree defined by treename.
| [in] | action | an Action object containing incoming, outgoing particles and type of interactions. |
| [in] | density | Unused, needed since inherited. |
Reimplemented from smash::OutputInterface.
Definition at line 485 of file rootoutput.cc.
|
private |
Writes particles to a tree defined by treename.
| [in] | particles | Particles or ParticleList to be written to output. |
Definition at line 500 of file rootoutput.cc.
|
private |
Writes collisions to a tree defined by treename.
| [in] | incoming | Incoming particles to be written to output. |
| [in] | outgoing | Outgoing particles to be written to output. |
| [in] | weight | Total weight of the collision. |
| [in] | partial_weight | Partial weight of the collision |
Definition at line 565 of file rootoutput.cc.
|
private |
Basic initialization routine, creating the TTree objects for particles and collisions.
Definition at line 285 of file rootoutput.cc.
|
private |
Filename of output.
Definition at line 102 of file rootoutput.h.
|
private |
Filename of output as long as simulation is still running.
Definition at line 104 of file rootoutput.h.
|
private |
Pointer to root output file.
Definition at line 106 of file rootoutput.h.
|
private |
TTree for particles output.
TFile takes ownership of all TTrees. That's why TTree is not a unique pointer.
Definition at line 113 of file rootoutput.h.
|
private |
TTree for collision output.
TFile takes ownership of all TTrees. That's why TTree is not a unique pointer.
Definition at line 120 of file rootoutput.h.
|
private |
Number of output in a given event.
Definition at line 138 of file rootoutput.h.
|
private |
Number of current event.
Definition at line 140 of file rootoutput.h.
|
private |
Number of current ensemble.
Definition at line 142 of file rootoutput.h.
|
staticprivate |
Maximal buffer size.
When the number of particles N exceeds the buffer size B, data is flushed to the ROOT file every B particles. This creates ceil(N/B) entries in the ROOT Tree at every output.
Definition at line 150 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 157 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 158 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 159 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 160 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 161 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 162 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 163 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 164 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 165 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 166 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 167 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 168 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 169 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 171 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 173 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 174 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 175 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 176 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 177 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 178 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 179 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 180 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 181 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 182 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 183 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 184 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 185 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 186 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 187 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 188 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 189 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 190 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 191 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 192 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 193 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 194 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 195 of file rootoutput.h.
|
private |
Option to write collisions tree.
Definition at line 199 of file rootoutput.h.
|
private |
Option to write particles tree.
Definition at line 202 of file rootoutput.h.
|
private |
Option to write particles tree for initial conditions.
Definition at line 205 of file rootoutput.h.
|
private |
Print only final particles in the event (no intermediate output).
Definition at line 208 of file rootoutput.h.
|
private |
ROOT file cannot be read if it was not properly closed and finalized.
It can happen that SMASH simulation crashed and ROOT file was not closed. To save results of simulation in such case, "AutoSave" is applied every N events. If multiple ensembles are used, N is divided by the number of ensembles per event. This makes sense especially in case of a large number of ensembles and, at the same time, it ensures that all ensembles belonging to the same event are saved. The autosave_frequency_ sets this N (at the moment N=1000 is hard-coded). Note that "AutoSave" operation is very time-consuming, so the autosave frequency is always a compromise between safety and speed.
Definition at line 222 of file rootoutput.h.
|
private |
Whether extended particle output is on.
Definition at line 225 of file rootoutput.h.
|
private |
Whether extended collisions output is on.
Definition at line 227 of file rootoutput.h.
|
private |
Whether extended ic output is on.
Definition at line 229 of file rootoutput.h.