#include <rootoutput.h>
SMASH supports ROOT output as an option (see http://root.cern.ch).
The ROOT framework needs to be installed when building SMASH, otherwise ROOT support will be disabled.
This class produces file smash_run.root, which contains a ROOT TTree. TTree contains information about particles during simulation from all SMASH events. Output is happening in blocks. All particles in a block are at the same time and in the same event. However, it is possible that different blocks are at the same time and from the same event. Particle information is stored in TBranches. For each particle characteristic there is a separate branch. Currently these are t,x,y,z (coordinates), p0,px,py,pz (4-momentum), pdgid - PDG code of particle, that characterizes its sort, ev - number of event particle encountered in, tcounter - number of output block in a given event, npart - number of particles and impact_b - impact parameter.
Here is an example of ROOT macro to read the ROOT output of SMASH:
For examples of extracting info from .root file see root.cern.ch To view ROOT file use TBrowser:
If option write_collisions is set True, then in addition to particles TTree a collision TTree is created. Information about each collision is written as one leaf: nin, nout - number of incoming and outgoing particles, ev - event number, weight - total weight of the collision (wgt), partial_weight - partial weight of the collision (par_wgt), (t,x,y,z), (p0,px,py,pz) - arrays of dimension nin+nout that contain coordinates and momenta.
Definition at line 94 of file rootoutput.h.
Public Member Functions | |
RootOutput (const bf::path &path, const std::string &name, const OutputParameters &out_par) | |
Construct ROOT output. More... | |
~RootOutput () | |
Destructor. More... | |
void | at_eventstart (const Particles &particles, const int event_number) override |
update event number and writes intermediate particles to a tree. More... | |
void | at_eventend (const Particles &particles, const int event_number, double impact_parameter) override |
update event number and impact parameter, and writes intermediate particles to a tree. More... | |
void | at_intermediate_time (const Particles &particles, const Clock &clock, const DensityParameters &dens_param) override |
Writes intermediate particles to a tree defined by treename, if it is allowed (i.e., particles_only_final_ is false). More... | |
void | at_interaction (const Action &action, const double density) override |
Writes collisions to a tree defined by treename. More... | |
![]() | |
OutputInterface (std::string name) | |
Construct output interface. More... | |
virtual | ~OutputInterface ()=default |
virtual void | thermodynamics_output (const ThermodynamicQuantity tq, const DensityType dt, RectangularLattice< DensityOnLattice > &lattice) |
Output to write thermodynamics from the lattice. More... | |
virtual void | thermodynamics_output (const ThermodynamicQuantity tq, const DensityType dt, RectangularLattice< EnergyMomentumTensor > &lattice) |
Output to write energy-momentum tensor and related quantities from the lattice. More... | |
virtual void | thermodynamics_output (const GrandCanThermalizer &gct) |
Output to write energy-momentum tensor and related quantities from the thermalizer class. 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... | |
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 | |
void | particles_to_tree (const Particles &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... | |
void | init_trees () |
Basic initialization routine, creating the TTree objects for particles and collisions. More... | |
Private Attributes | |
const bf::path | filename_ |
Filename of output. More... | |
bf::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... | |
bool | write_collisions_ |
Option to write collisions tree. More... | |
bool | write_particles_ |
Option to write particles tree. More... | |
bool | particles_only_final_ |
Print only final particles in the event, no intermediate output. More... | |
int | autosave_frequency_ |
Root file cannot be read if it was not properly closed and finalized. More... | |
std::array< double, max_buffer_size_ > | p0 |
Buffer for filling TTree. See class documentation for definitions. More... | |
std::array< double, max_buffer_size_ > | px |
Buffer for filling TTree. See class documentation for definitions. More... | |
std::array< double, max_buffer_size_ > | py |
Buffer for filling TTree. See class documentation for definitions. More... | |
std::array< double, max_buffer_size_ > | pz |
Buffer for filling TTree. See class documentation for definitions. More... | |
std::array< double, max_buffer_size_ > | t |
Buffer for filling TTree. See class documentation for definitions. More... | |
std::array< double, max_buffer_size_ > | x |
Buffer for filling TTree. See class documentation for definitions. More... | |
std::array< double, max_buffer_size_ > | y |
Buffer for filling TTree. See class documentation for definitions. More... | |
std::array< double, max_buffer_size_ > | z |
Buffer for filling TTree. See class documentation for definitions. More... | |
std::array< int, max_buffer_size_ > | pdgcode |
Buffer for filling TTree. See class documentation for definitions. More... | |
int | npart |
Buffer for filling TTree. See class documentation for definitions. More... | |
int | tcounter |
Buffer for filling TTree. See class documentation for definitions. More... | |
int | ev |
Buffer for filling TTree. See class documentation for definitions. More... | |
int | nin |
Buffer for filling TTree. See class documentation for definitions. More... | |
int | nout |
Buffer for filling TTree. See class documentation for definitions. More... | |
double | wgt |
Buffer for filling TTree. See class documentation for definitions. More... | |
double | par_wgt |
Buffer for filling TTree. See class documentation for definitions. More... | |
double | impact_b |
Buffer for filling TTree. See class documentation for definitions. More... | |
Static Private Attributes | |
static const int | max_buffer_size_ = 10000 |
Maximal buffer size. More... | |
Additional Inherited Members | |
![]() | |
const bool | is_dilepton_output_ |
Is this the dilepton output? More... | |
const bool | is_photon_output_ |
Is this the photon output? More... | |
smash::RootOutput::RootOutput | ( | const bf::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 79 of file rootoutput.cc.
smash::RootOutput::~RootOutput | ( | ) |
Destructor.
RootOutput destructor.
Writes root objects (here TTrees) to file and closes it.
Definition at line 149 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_number | event number to be used in ROOT output. |
Implements smash::OutputInterface.
Definition at line 156 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_number | event number to be used in ROOT output. |
[in] | impact_parameter | event number to be used in ROOT output. [fm] |
Implements smash::OutputInterface.
Definition at line 178 of file rootoutput.cc.
|
overridevirtual |
Writes intermediate particles to a tree defined by treename, if it is allowed (i.e., particles_only_final_ is false).
[in] | particles | Particles to be written to output. |
[in] | clock | Unused, needed since inherited. |
[in] | dens_param | Unused, needed since inherited. |
Reimplemented from smash::OutputInterface.
Definition at line 170 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 197 of file rootoutput.cc.
|
private |
Writes particles to a tree defined by treename.
[in] | particles | Particles to be written to output. |
Definition at line 205 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 240 of file rootoutput.cc.
|
private |
Basic initialization routine, creating the TTree objects for particles and collisions.
Definition at line 99 of file rootoutput.cc.
|
private |
Filename of output.
Definition at line 144 of file rootoutput.h.
|
private |
Filename of output as long as simulation is still running.
Definition at line 146 of file rootoutput.h.
|
private |
Pointer to root output file.
Definition at line 148 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 155 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 162 of file rootoutput.h.
|
private |
Number of output in a given event.
Definition at line 179 of file rootoutput.h.
|
private |
Number of current event.
Definition at line 181 of file rootoutput.h.
|
staticprivate |
Maximal buffer size.
Definition at line 184 of file rootoutput.h.
|
private |
Buffer for filling TTree. See class documentation for definitions.
Definition at line 188 of file rootoutput.h.
|
private |
Buffer for filling TTree. See class documentation for definitions.
Definition at line 188 of file rootoutput.h.
|
private |
Buffer for filling TTree. See class documentation for definitions.
Definition at line 188 of file rootoutput.h.
|
private |
Buffer for filling TTree. See class documentation for definitions.
Definition at line 188 of file rootoutput.h.
|
private |
Buffer for filling TTree. See class documentation for definitions.
Definition at line 188 of file rootoutput.h.
|
private |
Buffer for filling TTree. See class documentation for definitions.
Definition at line 188 of file rootoutput.h.
|
private |
Buffer for filling TTree. See class documentation for definitions.
Definition at line 188 of file rootoutput.h.
|
private |
Buffer for filling TTree. See class documentation for definitions.
Definition at line 188 of file rootoutput.h.
|
private |
Buffer for filling TTree. See class documentation for definitions.
Definition at line 189 of file rootoutput.h.
|
private |
Buffer for filling TTree. See class documentation for definitions.
Definition at line 190 of file rootoutput.h.
|
private |
Buffer for filling TTree. See class documentation for definitions.
Definition at line 190 of file rootoutput.h.
|
private |
Buffer for filling TTree. See class documentation for definitions.
Definition at line 190 of file rootoutput.h.
|
private |
Buffer for filling TTree. See class documentation for definitions.
Definition at line 190 of file rootoutput.h.
|
private |
Buffer for filling TTree. See class documentation for definitions.
Definition at line 190 of file rootoutput.h.
|
private |
Buffer for filling TTree. See class documentation for definitions.
Definition at line 191 of file rootoutput.h.
|
private |
Buffer for filling TTree. See class documentation for definitions.
Definition at line 191 of file rootoutput.h.
|
private |
Buffer for filling TTree. See class documentation for definitions.
Definition at line 191 of file rootoutput.h.
|
private |
Option to write collisions tree.
Definition at line 195 of file rootoutput.h.
|
private |
Option to write particles tree.
Definition at line 198 of file rootoutput.h.
|
private |
Print only final particles in the event, no intermediate output.
Definition at line 201 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. The autosave_frequency_ sets this N (default N = 1000). Note that "AutoSave" operation is very time-consuming, so the Autosave_Frequency is always a compromise between safety and speed.
Definition at line 212 of file rootoutput.h.