#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 file Particles.root, which contains a ROOT TTree. TTree contains information about particles from all SMASH events comprising a simulation. 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), pdgcode - PDG code of the particle, characterizing its type, charge - electric charge of the particle, ev - event number in a given block, tcounter - number of the output block in a given event, npart - number of particles in the block, test_p - number of testpartciles per particle, modus_l - modus length, current_t - time associated with the output block, in fm/c, impact_b - impact parameter of the event, empty_event - whether there was no interaction between the projectile and the target, E_kinetic_tot - total kinetic energy in the system, E_fields_tot - total mean field energy * test_p, E_total - sum of E_kinetic_tot and E_fields_tot.
This class also produces file Collisions.root, organized in the same way, with a few additional fields: nin and nout - characterize number of incoming and outgoing particles in the reaction, with nin + nout = npart, weight - an action weight, whose meaning depends on the type of action: For collisions it is the total cross section, for decays it is the total decay width and for dilepton decays it is the shining weight.
If "Collisions:" section is present, then in addition to a file Particles.root with particles TTree, another file Collisions.root is created. It contains information about each collision, 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 79 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, const EventInfo &event) override |
update event number and writes intermediate particles to a tree. More... | |
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. More... | |
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., 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... | |
![]() | |
OutputInterface (std::string name) | |
Construct output interface. More... | |
virtual | ~OutputInterface ()=default |
virtual void | at_eventstart (const std::vector< Particles > &ensembles, int event_number) |
Output launched at event start after initialization, when particles are generated but not yet propagated. More... | |
virtual void | at_eventstart (const int event_number, const ThermodynamicQuantity tq, const DensityType dens_type, RectangularLattice< DensityOnLattice > lattice) |
Output launched at event start after initialization, when particles are generated but not yet propagated. More... | |
virtual void | at_eventstart (const int event_number, const ThermodynamicQuantity tq, const DensityType dens_type, RectangularLattice< EnergyMomentumTensor > lattice) |
Output launched atevent start after initialization, when particles are generated but not yet propagated. More... | |
virtual void | at_eventend (const int event_number, const ThermodynamicQuantity tq, const DensityType dens_type) |
Output launched at event end. More... | |
virtual void | at_eventend (const ThermodynamicQuantity tq) |
Output launched at event end. More... | |
virtual void | at_eventend (const std::vector< Particles > &ensembles, const int event_number) |
Output launched at event end. More... | |
virtual void | at_intermediate_time (const std::vector< Particles > &ensembles, const std::unique_ptr< Clock > &clock, const DensityParameters &dens_param) |
Output launched after every N'th timestep. More... | |
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_lattice_output (RectangularLattice< DensityOnLattice > &lattice, const double current_time) |
Output to write thermodynamics from the lattice. More... | |
virtual void | thermodynamics_lattice_output (RectangularLattice< DensityOnLattice > &lattice, const double current_time, const std::vector< Particles > &ensembles, const DensityParameters &dens_param) |
Output to write thermodynamics from the lattice. More... | |
virtual void | thermodynamics_lattice_output (const ThermodynamicQuantity tq, RectangularLattice< EnergyMomentumTensor > &lattice, const double current_time) |
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... | |
virtual void | fields_output (const std::string name1, const std::string name2, RectangularLattice< std::pair< ThreeVector, ThreeVector >> &lat) |
Write fields in vtk output. 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 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... | |
Static Private Attributes | |
static const int | max_buffer_size_ = 500000 |
Maximal buffer size. More... | |
Buffer for filling TTree | |
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... | |
std::vector< double > | formation_time_ |
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< double > | time_last_coll_ |
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< int > | coll_per_part_ = std::vector<int>(max_buffer_size_, 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... | |
int | npart_ |
Property that is written to ROOT output. More... | |
int | tcounter_ |
Property that is written to ROOT output. More... | |
int | ev_ |
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... | |
int | test_p_ |
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... | |
double | impact_b_ |
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 | 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... | |
bool | empty_event_ |
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_ |
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 | |
![]() | |
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 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 230 of file rootoutput.cc.
smash::RootOutput::~RootOutput | ( | ) |
Destructor.
RootOutput destructor.
Writes root objects (here TTrees) to file and closes it.
Definition at line 345 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. |
[in] | event | Event info, see event_info |
Reimplemented from smash::OutputInterface.
Definition at line 352 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] | event | Event info, see event_info |
Reimplemented from smash::OutputInterface.
Definition at line 391 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 | Event info, see event_info |
Reimplemented from smash::OutputInterface.
Definition at line 374 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 431 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 445 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 506 of file rootoutput.cc.
|
private |
Basic initialization routine, creating the TTree objects for particles and collisions.
Definition at line 250 of file rootoutput.cc.
|
private |
Filename of output.
Definition at line 133 of file rootoutput.h.
|
private |
Filename of output as long as simulation is still running.
Definition at line 135 of file rootoutput.h.
|
private |
Pointer to root output file.
Definition at line 137 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 144 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 151 of file rootoutput.h.
|
private |
Number of output in a given event.
Definition at line 169 of file rootoutput.h.
|
private |
Number of current event.
Definition at line 171 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 179 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 196 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 197 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 199 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 200 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 201 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 202 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 203 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 204 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 205 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 206 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 206 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 206 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 206 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 206 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 206 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 207 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 207 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 207 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 207 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 207 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 208 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 208 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 208 of file rootoutput.h.
|
private |
Property that is written to ROOT output.
Definition at line 209 of file rootoutput.h.
|
private |
Option to write collisions tree.
Definition at line 213 of file rootoutput.h.
|
private |
Option to write particles tree.
Definition at line 216 of file rootoutput.h.
|
private |
Option to write particles tree for initial conditions.
Definition at line 219 of file rootoutput.h.
|
private |
Print only final particles in the event, no intermediate output.
Definition at line 222 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 233 of file rootoutput.h.
|
private |
Whether extended particle output is on.
Definition at line 236 of file rootoutput.h.
|
private |
Whether extended collisions output is on.
Definition at line 238 of file rootoutput.h.
|
private |
Whether extended ic output is on.
Definition at line 240 of file rootoutput.h.