Version: SMASH-1.7
smash::RootOutput Class Reference

#include <rootoutput.h>

SMASH output to ROOT file

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, charge - electric charge of the particle, ev - number of event particle encountered in, tcounter - number of output block in a given event, npart - number of particles, impact_b - impact parameter, and empty_event - whether there was no interaction between the projectile and the target.

Here is an example of ROOT macro to read the ROOT output of SMASH:

int rootfile_analysis_example() {
// open SMASH output file to be read in
TFile *input_file = TFile::Open("../build/data/0/smash_run.root");
if (input_file->IsOpen()) {
printf("Successfully opened file %s\n", input_file->GetName());
} else {
printf("Error at opening file %s\n", input_file->GetName());
}
// Get a tree from file
TTree *tree = static_cast<TTree*>(input_file->Get("particles"));
// Get number of entries in a tree
Int_t nentries = tree->GetEntries();
printf("Number of entries in a tree is %d\n", nentries);
// This draws p_T distribution at initialization
// tree->Draw("sqrt(px*px + py*py)","tcounter==0");
// This draws 3D momentum space distribution at initialization
tree->Draw("px:py:pz","tcounter==0");
return 0;
}

For examples of extracting info from .root file see root.cern.ch To view ROOT file use TBrowser:

root -l
new 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 97 of file rootoutput.h.

Inheritance diagram for smash::RootOutput:
[legend]
Collaboration diagram for smash::RootOutput:
[legend]

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, bool empty_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) 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...
 
- Public Member Functions inherited from smash::OutputInterface
 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...
 
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...
 
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 write_initial_conditions_
 Option to write particles tree for initial conditions. 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...
 
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...
 
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< double, max_buffer_size_formation_time_
 Buffer for filling TTree. See class documentation for definitions. More...
 
std::array< double, max_buffer_size_xsec_factor_
 Buffer for filling TTree. See class documentation for definitions. More...
 
std::array< double, max_buffer_size_time_last_coll_
 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...
 
std::array< int, max_buffer_size_charge
 Buffer for filling TTree. See class documentation for definitions. More...
 
std::array< int, max_buffer_size_coll_per_part_
 Buffer for filling TTree. See class documentation for definitions. More...
 
std::array< int, max_buffer_size_proc_id_origin_
 Buffer for filling TTree. See class documentation for definitions. More...
 
std::array< int, max_buffer_size_proc_type_origin_
 Buffer for filling TTree. See class documentation for definitions. More...
 
std::array< int, max_buffer_size_pdg_mother1_
 Buffer for filling TTree. See class documentation for definitions. More...
 
std::array< int, max_buffer_size_pdg_mother2_
 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...
 
bool empty_event_
 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

- 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...
 

Constructor & Destructor Documentation

smash::RootOutput::RootOutput ( const bf::path &  path,
const std::string &  name,
const OutputParameters out_par 
)

Construct ROOT output.

Parameters
[in]pathOutput path.
[in]nameName of the ouput.
[in]out_parA structure containing parameters of the output.

Definition at line 86 of file rootoutput.cc.

88  : OutputInterface(name),
89  filename_(path / (name + ".root")),
90  write_collisions_(name == "Collisions" || name == "Dileptons" ||
91  name == "Photons"),
92  write_particles_(name == "Particles"),
93  write_initial_conditions_(name == "SMASH_IC"),
94  particles_only_final_(out_par.part_only_final),
95  autosave_frequency_(1000),
96  part_extended_(out_par.part_extended),
97  coll_extended_(out_par.coll_extended),
98  ic_extended_(out_par.ic_extended) {
100  filename_unfinished_ += ".unfinished";
102  make_unique<TFile>(filename_unfinished_.native().c_str(), "NEW");
103  init_trees();
104 }
const bf::path filename_
Filename of output.
Definition: rootoutput.h:150
bool write_initial_conditions_
Option to write particles tree for initial conditions.
Definition: rootoutput.h:211
bool write_particles_
Option to write particles tree.
Definition: rootoutput.h:208
std::unique_ptr< TFile > root_out_file_
Pointer to root output file.
Definition: rootoutput.h:154
void init_trees()
Basic initialization routine, creating the TTree objects for particles and collisions.
Definition: rootoutput.cc:106
const bool coll_extended_
Whether extended collisions output is on.
Definition: rootoutput.h:230
const bool part_extended_
Whether extended particle output is on.
Definition: rootoutput.h:228
const bool ic_extended_
Whether extended ic output is on.
Definition: rootoutput.h:232
bool write_collisions_
Option to write collisions tree.
Definition: rootoutput.h:205
bf::path filename_unfinished_
Filename of output as long as simulation is still running.
Definition: rootoutput.h:152
bool particles_only_final_
Print only final particles in the event, no intermediate output.
Definition: rootoutput.h:214
OutputInterface(std::string name)
Construct output interface.
int autosave_frequency_
Root file cannot be read if it was not properly closed and finalized.
Definition: rootoutput.h:225

Here is the call graph for this function:

smash::RootOutput::~RootOutput ( )

Destructor.

RootOutput destructor.

Writes root objects (here TTrees) to file and closes it.

Definition at line 197 of file rootoutput.cc.

197  {
198  // kOverwrite option prevents from writing extra TKey objects into root file
199  root_out_file_->Write("", TObject::kOverwrite);
200  root_out_file_->Close();
201  bf::rename(filename_unfinished_, filename_);
202 }
const bf::path filename_
Filename of output.
Definition: rootoutput.h:150
std::unique_ptr< TFile > root_out_file_
Pointer to root output file.
Definition: rootoutput.h:154
bf::path filename_unfinished_
Filename of output as long as simulation is still running.
Definition: rootoutput.h:152

Member Function Documentation

void smash::RootOutput::at_eventstart ( const Particles particles,
const int  event_number 
)
overridevirtual

update event number and writes intermediate particles to a tree.

Parameters
[in]particlesParticles to be written to output.
[in]event_numberevent number to be used in ROOT output.

Implements smash::OutputInterface.

Definition at line 204 of file rootoutput.cc.

205  {
206  // save event number
207  current_event_ = event_number;
208 
210  output_counter_ = 0;
211  // This is to have only one output of positive impact parameter per event
212  impact_b = -1.0;
213  empty_event_ = false;
214  particles_to_tree(particles);
215  output_counter_++;
216  }
217 }
void particles_to_tree(T &particles)
Writes particles to a tree defined by treename.
Definition: rootoutput.cc:274
bool empty_event_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:201
int current_event_
Number of current event.
Definition: rootoutput.h:188
bool write_particles_
Option to write particles tree.
Definition: rootoutput.h:208
int output_counter_
Number of output in a given event.
Definition: rootoutput.h:186
double impact_b
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:200
bool particles_only_final_
Print only final particles in the event, no intermediate output.
Definition: rootoutput.h:214

Here is the call graph for this function:

void smash::RootOutput::at_eventend ( const Particles particles,
const int  event_number,
double  impact_parameter,
bool  empty_event 
)
overridevirtual

update event number and impact parameter, and writes intermediate particles to a tree.

Parameters
[in]particlesParticles to be written to output.
[in]event_numberevent number to be used in ROOT output.
[in]impact_parameterevent number to be used in ROOT output. [fm]
[in]empty_eventWhether there was no interaction between the target and the projectile.

Implements smash::OutputInterface.

Definition at line 228 of file rootoutput.cc.

230  {
231  impact_b = impact_parameter;
232  empty_event_ = empty_event;
233  if (write_particles_) {
234  particles_to_tree(particles);
235  }
236  /* Forced regular dump from operational memory to disk. Very demanding!
237  * If program crashes written data will NOT be lost. */
240  particles_tree_->AutoSave("SaveSelf");
241  }
242  if (write_collisions_) {
243  collisions_tree_->AutoSave("SaveSelf");
244  }
245  }
246 
248  // If the runtime is too short some particles might not yet have
249  // reached the hypersurface. Warning is printed.
250  if (particles.size() != 0) {
251  const auto &log = logger<LogArea::HyperSurfaceCrossing>();
252  log.warn(
253  "End time might be too small for initial conditions output. "
254  "Hypersurface has not yet been crossed by ",
255  particles.size(), " particle(s).");
256  }
257  }
258 }
bool write_initial_conditions_
Option to write particles tree for initial conditions.
Definition: rootoutput.h:211
void particles_to_tree(T &particles)
Writes particles to a tree defined by treename.
Definition: rootoutput.cc:274
bool empty_event_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:201
int current_event_
Number of current event.
Definition: rootoutput.h:188
bool write_particles_
Option to write particles tree.
Definition: rootoutput.h:208
TTree * particles_tree_
TTree for particles output.
Definition: rootoutput.h:161
bool write_collisions_
Option to write collisions tree.
Definition: rootoutput.h:205
double impact_b
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:200
TTree * collisions_tree_
TTree for collision output.
Definition: rootoutput.h:168
int autosave_frequency_
Root file cannot be read if it was not properly closed and finalized.
Definition: rootoutput.h:225

Here is the call graph for this function:

void smash::RootOutput::at_intermediate_time ( const Particles particles,
const std::unique_ptr< Clock > &  clock,
const DensityParameters dens_param 
)
overridevirtual

Writes intermediate particles to a tree defined by treename, if it is allowed (i.e., particles_only_final_ is false).

Parameters
[in]particlesParticles to be written to output.
[in]clockUnused, needed since inherited.
[in]dens_paramUnused, needed since inherited.

Reimplemented from smash::OutputInterface.

Definition at line 219 of file rootoutput.cc.

221  {
223  particles_to_tree(particles);
224  output_counter_++;
225  }
226 }
void particles_to_tree(T &particles)
Writes particles to a tree defined by treename.
Definition: rootoutput.cc:274
bool write_particles_
Option to write particles tree.
Definition: rootoutput.h:208
int output_counter_
Number of output in a given event.
Definition: rootoutput.h:186
bool particles_only_final_
Print only final particles in the event, no intermediate output.
Definition: rootoutput.h:214

Here is the call graph for this function:

void smash::RootOutput::at_interaction ( const Action action,
const double  density 
)
overridevirtual

Writes collisions to a tree defined by treename.

Parameters
[in]actionan Action object containing incoming, outgoing particles and type of interactions.
[in]densityUnused, needed since inherited.

Reimplemented from smash::OutputInterface.

Definition at line 260 of file rootoutput.cc.

261  {
262  if (write_collisions_) {
263  collisions_to_tree(action.incoming_particles(), action.outgoing_particles(),
264  action.get_total_weight(), action.get_partial_weight());
265  }
266 
268  action.get_type() == ProcessType::HyperSurfaceCrossing) {
269  particles_to_tree(action.incoming_particles());
270  }
271 }
bool write_initial_conditions_
Option to write particles tree for initial conditions.
Definition: rootoutput.h:211
void particles_to_tree(T &particles)
Writes particles to a tree defined by treename.
Definition: rootoutput.cc:274
Hypersurface crossing Particles are removed from the evolution and printed to a separate output to se...
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:322
bool write_collisions_
Option to write collisions tree.
Definition: rootoutput.h:205

Here is the call graph for this function:

template<typename T >
void smash::RootOutput::particles_to_tree ( T &  particles)
private

Writes particles to a tree defined by treename.

Parameters
[in]particlesParticles or ParticleList to be written to output.

Definition at line 274 of file rootoutput.cc.

274  {
275  int i = 0;
276 
278  ev = current_event_;
279 
280  for (const auto &p : particles) {
281  // Buffer full - flush to tree, else fill with particles
282  if (i >= max_buffer_size_) {
284  i = 0;
285  particles_tree_->Fill();
286  } else {
287  t[i] = p.position().x0();
288  x[i] = p.position().x1();
289  y[i] = p.position().x2();
290  z[i] = p.position().x3();
291 
292  p0[i] = p.momentum().x0();
293  px[i] = p.momentum().x1();
294  py[i] = p.momentum().x2();
295  pz[i] = p.momentum().x3();
296 
297  pdgcode[i] = p.pdgcode().get_decimal();
298  charge[i] = p.type().charge();
299 
300  if (part_extended_ || ic_extended_) {
301  const auto h = p.get_history();
302  formation_time_[i] = p.formation_time();
303  xsec_factor_[i] = p.xsec_scaling_factor();
304  time_last_coll_[i] = h.time_last_collision;
305  coll_per_part_[i] = h.collisions_per_particle;
306  proc_id_origin_[i] = h.id_process;
307  proc_type_origin_[i] = static_cast<int>(h.process_type);
308  pdg_mother1_[i] = h.p1.get_decimal();
309  pdg_mother2_[i] = h.p2.get_decimal();
310  }
311 
312  i++;
313  }
314  }
315  // Flush rest to tree
316  if (i > 0) {
317  npart = i;
318  particles_tree_->Fill();
319  }
320 }
std::array< double, max_buffer_size_ > formation_time_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
int current_event_
Number of current event.
Definition: rootoutput.h:188
std::array< int, max_buffer_size_ > proc_id_origin_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:197
std::array< double, max_buffer_size_ > py
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
std::array< double, max_buffer_size_ > x
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
int npart
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:199
std::array< double, max_buffer_size_ > p0
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
std::array< double, max_buffer_size_ > time_last_coll_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
TTree * particles_tree_
TTree for particles output.
Definition: rootoutput.h:161
const bool part_extended_
Whether extended particle output is on.
Definition: rootoutput.h:228
std::array< double, max_buffer_size_ > t
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
int output_counter_
Number of output in a given event.
Definition: rootoutput.h:186
std::array< double, max_buffer_size_ > z
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
std::array< int, max_buffer_size_ > proc_type_origin_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:197
std::array< double, max_buffer_size_ > y
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
const bool ic_extended_
Whether extended ic output is on.
Definition: rootoutput.h:232
std::array< double, max_buffer_size_ > px
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
constexpr int p
Proton.
int tcounter
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:199
std::array< double, max_buffer_size_ > xsec_factor_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
std::array< int, max_buffer_size_ > charge
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:197
std::array< int, max_buffer_size_ > pdg_mother1_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:197
int ev
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:199
std::array< double, max_buffer_size_ > pz
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
std::array< int, max_buffer_size_ > pdgcode
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:197
std::array< int, max_buffer_size_ > coll_per_part_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:197
static const int max_buffer_size_
Maximal buffer size.
Definition: rootoutput.h:191
std::array< int, max_buffer_size_ > pdg_mother2_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:197

Here is the caller graph for this function:

void smash::RootOutput::collisions_to_tree ( const ParticleList &  incoming,
const ParticleList &  outgoing,
const double  weight,
const double  partial_weight 
)
private

Writes collisions to a tree defined by treename.

Parameters
[in]incomingIncoming particles to be written to output.
[in]outgoingOutgoing particles to be written to output.
[in]weightTotal weight of the collision.
[in]partial_weightPartial weight of the collision

Definition at line 322 of file rootoutput.cc.

325  {
326  ev = current_event_;
327  nin = incoming.size();
328  nout = outgoing.size();
329  npart = nin + nout;
330  wgt = weight;
331  par_wgt = partial_weight;
332 
333  int i = 0;
334 
335  /* It is assumed that nin + nout < max_buffer_size_
336  * This is true for any possible reaction for current buffer size: 10000
337  * But if one wants initial/final particles written to collisions
338  * then implementation should be updated. */
339 
340  for (const ParticleList &plist : {incoming, outgoing}) {
341  for (const auto &p : plist) {
342  t[i] = p.position().x0();
343  x[i] = p.position().x1();
344  y[i] = p.position().x2();
345  z[i] = p.position().x3();
346 
347  p0[i] = p.momentum().x0();
348  px[i] = p.momentum().x1();
349  py[i] = p.momentum().x2();
350  pz[i] = p.momentum().x3();
351 
352  pdgcode[i] = p.pdgcode().get_decimal();
353  charge[i] = p.type().charge();
354 
355  if (coll_extended_) {
356  const auto h = p.get_history();
357  formation_time_[i] = p.formation_time();
358  xsec_factor_[i] = p.xsec_scaling_factor();
359  time_last_coll_[i] = h.time_last_collision;
360  coll_per_part_[i] = h.collisions_per_particle;
361  proc_id_origin_[i] = h.id_process;
362  proc_type_origin_[i] = static_cast<int>(h.process_type);
363  pdg_mother1_[i] = h.p1.get_decimal();
364  pdg_mother2_[i] = h.p2.get_decimal();
365  }
366 
367  i++;
368  }
369  }
370 
371  collisions_tree_->Fill();
372 }
std::array< double, max_buffer_size_ > formation_time_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
int nout
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:199
int current_event_
Number of current event.
Definition: rootoutput.h:188
std::array< int, max_buffer_size_ > proc_id_origin_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:197
std::array< double, max_buffer_size_ > py
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
std::array< double, max_buffer_size_ > x
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
int npart
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:199
std::array< double, max_buffer_size_ > p0
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
std::array< double, max_buffer_size_ > time_last_coll_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
int nin
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:199
const bool coll_extended_
Whether extended collisions output is on.
Definition: rootoutput.h:230
std::array< double, max_buffer_size_ > t
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
std::array< double, max_buffer_size_ > z
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
std::array< int, max_buffer_size_ > proc_type_origin_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:197
std::array< double, max_buffer_size_ > y
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
std::array< double, max_buffer_size_ > px
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
double wgt
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:200
constexpr int p
Proton.
TTree * collisions_tree_
TTree for collision output.
Definition: rootoutput.h:168
std::array< double, max_buffer_size_ > xsec_factor_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
std::array< int, max_buffer_size_ > charge
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:197
std::array< int, max_buffer_size_ > pdg_mother1_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:197
int ev
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:199
std::array< double, max_buffer_size_ > pz
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
std::array< int, max_buffer_size_ > pdgcode
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:197
std::array< int, max_buffer_size_ > coll_per_part_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:197
std::array< int, max_buffer_size_ > pdg_mother2_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:197
double par_wgt
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:200

Here is the caller graph for this function:

void smash::RootOutput::init_trees ( )
private

Basic initialization routine, creating the TTree objects for particles and collisions.

Definition at line 106 of file rootoutput.cc.

106  {
108  particles_tree_ = new TTree("particles", "particles");
109 
110  particles_tree_->Branch("npart", &npart, "npart/I");
111  particles_tree_->Branch("impact_b", &impact_b, "impact_b/D");
112  particles_tree_->Branch("empty_event", &empty_event_, "empty_event/O");
113  particles_tree_->Branch("ev", &ev, "ev/I");
114  particles_tree_->Branch("tcounter", &tcounter, "tcounter/I");
115 
116  particles_tree_->Branch("pdgcode", &pdgcode[0], "pdgcode[npart]/I");
117  particles_tree_->Branch("charge", &charge[0], "charge[npart]/I");
118 
119  particles_tree_->Branch("p0", &p0[0], "p0[npart]/D");
120  particles_tree_->Branch("px", &px[0], "px[npart]/D");
121  particles_tree_->Branch("py", &py[0], "py[npart]/D");
122  particles_tree_->Branch("pz", &pz[0], "pz[npart]/D");
123 
124  particles_tree_->Branch("t", &t[0], "t[npart]/D");
125  particles_tree_->Branch("x", &x[0], "x[npart]/D");
126  particles_tree_->Branch("y", &y[0], "y[npart]/D");
127  particles_tree_->Branch("z", &z[0], "z[npart]/D");
128 
129  if (part_extended_ || ic_extended_) {
130  particles_tree_->Branch("coll_per_part", &coll_per_part_[0],
131  "coll_per_part[npart]/I");
132  particles_tree_->Branch("formation_time", &formation_time_[0],
133  "formation_time[npart]/D");
134  particles_tree_->Branch("xsec_factor", &xsec_factor_[0],
135  "xsec_factor[npart]/D");
136  particles_tree_->Branch("proc_id_origin", &proc_id_origin_[0],
137  "proc_id_origin[npart]/I");
138  particles_tree_->Branch("proc_type_origin", &proc_type_origin_[0],
139  "proc_type_origin[npart]/I");
140  particles_tree_->Branch("time_last_coll", &time_last_coll_[0],
141  "time_last_coll[npart]/D");
142  particles_tree_->Branch("pdg_mother1", &pdg_mother1_[0],
143  "pdg_mother1[npart]/I");
144  particles_tree_->Branch("pdg_mother2", &pdg_mother2_[0],
145  "pdg_mother2[npart]/I");
146  }
147  }
148 
149  if (write_collisions_) {
150  collisions_tree_ = new TTree("collisions", "collisions");
151 
152  collisions_tree_->Branch("nin", &nin, "nin/I");
153  collisions_tree_->Branch("nout", &nout, "nout/I");
154  collisions_tree_->Branch("npart", &npart, "npart/I");
155  collisions_tree_->Branch("ev", &ev, "ev/I");
156  collisions_tree_->Branch("weight", &wgt, "weight/D");
157  collisions_tree_->Branch("partial_weight", &par_wgt, "partial_weight/D");
158 
159  collisions_tree_->Branch("pdgcode", &pdgcode[0], "pdgcode[npart]/I");
160  collisions_tree_->Branch("charge", &charge[0], "charge[npart]/I");
161 
162  collisions_tree_->Branch("p0", &p0[0], "p0[npart]/D");
163  collisions_tree_->Branch("px", &px[0], "px[npart]/D");
164  collisions_tree_->Branch("py", &py[0], "py[npart]/D");
165  collisions_tree_->Branch("pz", &pz[0], "pz[npart]/D");
166 
167  collisions_tree_->Branch("t", &t[0], "t[npart]/D");
168  collisions_tree_->Branch("x", &x[0], "x[npart]/D");
169  collisions_tree_->Branch("y", &y[0], "y[npart]/D");
170  collisions_tree_->Branch("z", &z[0], "z[npart]/D");
171 
172  if (coll_extended_) {
173  collisions_tree_->Branch("coll_per_part", &coll_per_part_[0],
174  "coll_per_part[npart]/I");
175  collisions_tree_->Branch("formation_time", &formation_time_[0],
176  "formation_time[npart]/D");
177  collisions_tree_->Branch("xsec_factor", &xsec_factor_[0],
178  "xsec_factor[npart]/D");
179  collisions_tree_->Branch("proc_id_origin", &proc_id_origin_[0],
180  "proc_id_origin[npart]/I");
181  collisions_tree_->Branch("proc_type_origin", &proc_type_origin_[0],
182  "proc_type_origin[npart]/I");
183  collisions_tree_->Branch("time_last_coll", &time_last_coll_[0],
184  "time_last_coll[npart]/D");
185  collisions_tree_->Branch("pdg_mother1", &pdg_mother1_[0],
186  "pdg_mother1[npart]/I");
187  collisions_tree_->Branch("pdg_mother2", &pdg_mother2_[0],
188  "pdg_mother2[npart]/I");
189  }
190  }
191 }
std::array< double, max_buffer_size_ > formation_time_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
bool write_initial_conditions_
Option to write particles tree for initial conditions.
Definition: rootoutput.h:211
int nout
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:199
bool empty_event_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:201
std::array< int, max_buffer_size_ > proc_id_origin_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:197
bool write_particles_
Option to write particles tree.
Definition: rootoutput.h:208
std::array< double, max_buffer_size_ > py
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
std::array< double, max_buffer_size_ > x
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
int npart
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:199
std::array< double, max_buffer_size_ > p0
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
std::array< double, max_buffer_size_ > time_last_coll_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
TTree * particles_tree_
TTree for particles output.
Definition: rootoutput.h:161
int nin
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:199
const bool coll_extended_
Whether extended collisions output is on.
Definition: rootoutput.h:230
const bool part_extended_
Whether extended particle output is on.
Definition: rootoutput.h:228
std::array< double, max_buffer_size_ > t
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
std::array< double, max_buffer_size_ > z
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
std::array< int, max_buffer_size_ > proc_type_origin_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:197
std::array< double, max_buffer_size_ > y
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
const bool ic_extended_
Whether extended ic output is on.
Definition: rootoutput.h:232
bool write_collisions_
Option to write collisions tree.
Definition: rootoutput.h:205
std::array< double, max_buffer_size_ > px
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
double wgt
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:200
double impact_b
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:200
TTree * collisions_tree_
TTree for collision output.
Definition: rootoutput.h:168
int tcounter
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:199
std::array< double, max_buffer_size_ > xsec_factor_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
std::array< int, max_buffer_size_ > charge
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:197
std::array< int, max_buffer_size_ > pdg_mother1_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:197
int ev
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:199
std::array< double, max_buffer_size_ > pz
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:195
std::array< int, max_buffer_size_ > pdgcode
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:197
std::array< int, max_buffer_size_ > coll_per_part_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:197
std::array< int, max_buffer_size_ > pdg_mother2_
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:197
double par_wgt
Buffer for filling TTree. See class documentation for definitions.
Definition: rootoutput.h:200

Here is the caller graph for this function:

Member Data Documentation

const bf::path smash::RootOutput::filename_
private

Filename of output.

Definition at line 150 of file rootoutput.h.

bf::path smash::RootOutput::filename_unfinished_
private

Filename of output as long as simulation is still running.

Definition at line 152 of file rootoutput.h.

std::unique_ptr<TFile> smash::RootOutput::root_out_file_
private

Pointer to root output file.

Definition at line 154 of file rootoutput.h.

TTree* smash::RootOutput::particles_tree_
private

TTree for particles output.

TFile takes ownership of all TTrees. That's why TTree is not a unique pointer.

Definition at line 161 of file rootoutput.h.

TTree* smash::RootOutput::collisions_tree_
private

TTree for collision output.

TFile takes ownership of all TTrees. That's why TTree is not a unique pointer.

Definition at line 168 of file rootoutput.h.

int smash::RootOutput::output_counter_ = 0
private

Number of output in a given event.

Definition at line 186 of file rootoutput.h.

int smash::RootOutput::current_event_ = 0
private

Number of current event.

Definition at line 188 of file rootoutput.h.

const int smash::RootOutput::max_buffer_size_ = 10000
staticprivate

Maximal buffer size.

Definition at line 191 of file rootoutput.h.

std::array<double, max_buffer_size_> smash::RootOutput::p0
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 195 of file rootoutput.h.

std::array<double, max_buffer_size_> smash::RootOutput::px
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 195 of file rootoutput.h.

std::array<double, max_buffer_size_> smash::RootOutput::py
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 195 of file rootoutput.h.

std::array<double, max_buffer_size_> smash::RootOutput::pz
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 195 of file rootoutput.h.

std::array<double, max_buffer_size_> smash::RootOutput::t
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 195 of file rootoutput.h.

std::array<double, max_buffer_size_> smash::RootOutput::x
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 195 of file rootoutput.h.

std::array<double, max_buffer_size_> smash::RootOutput::y
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 195 of file rootoutput.h.

std::array<double, max_buffer_size_> smash::RootOutput::z
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 195 of file rootoutput.h.

std::array<double, max_buffer_size_> smash::RootOutput::formation_time_
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 195 of file rootoutput.h.

std::array<double, max_buffer_size_> smash::RootOutput::xsec_factor_
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 195 of file rootoutput.h.

std::array<double, max_buffer_size_> smash::RootOutput::time_last_coll_
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 195 of file rootoutput.h.

std::array<int, max_buffer_size_> smash::RootOutput::pdgcode
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 197 of file rootoutput.h.

std::array<int, max_buffer_size_> smash::RootOutput::charge
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 197 of file rootoutput.h.

std::array<int, max_buffer_size_> smash::RootOutput::coll_per_part_
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 197 of file rootoutput.h.

std::array<int, max_buffer_size_> smash::RootOutput::proc_id_origin_
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 197 of file rootoutput.h.

std::array<int, max_buffer_size_> smash::RootOutput::proc_type_origin_
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 197 of file rootoutput.h.

std::array<int, max_buffer_size_> smash::RootOutput::pdg_mother1_
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 197 of file rootoutput.h.

std::array<int, max_buffer_size_> smash::RootOutput::pdg_mother2_
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 197 of file rootoutput.h.

int smash::RootOutput::npart
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 199 of file rootoutput.h.

int smash::RootOutput::tcounter
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 199 of file rootoutput.h.

int smash::RootOutput::ev
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 199 of file rootoutput.h.

int smash::RootOutput::nin
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 199 of file rootoutput.h.

int smash::RootOutput::nout
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 199 of file rootoutput.h.

double smash::RootOutput::wgt
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 200 of file rootoutput.h.

double smash::RootOutput::par_wgt
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 200 of file rootoutput.h.

double smash::RootOutput::impact_b
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 200 of file rootoutput.h.

bool smash::RootOutput::empty_event_
private

Buffer for filling TTree. See class documentation for definitions.

Definition at line 201 of file rootoutput.h.

bool smash::RootOutput::write_collisions_
private

Option to write collisions tree.

Definition at line 205 of file rootoutput.h.

bool smash::RootOutput::write_particles_
private

Option to write particles tree.

Definition at line 208 of file rootoutput.h.

bool smash::RootOutput::write_initial_conditions_
private

Option to write particles tree for initial conditions.

Definition at line 211 of file rootoutput.h.

bool smash::RootOutput::particles_only_final_
private

Print only final particles in the event, no intermediate output.

Definition at line 214 of file rootoutput.h.

int smash::RootOutput::autosave_frequency_
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 225 of file rootoutput.h.

const bool smash::RootOutput::part_extended_
private

Whether extended particle output is on.

Definition at line 228 of file rootoutput.h.

const bool smash::RootOutput::coll_extended_
private

Whether extended collisions output is on.

Definition at line 230 of file rootoutput.h.

const bool smash::RootOutput::ic_extended_
private

Whether extended ic output is on.

Definition at line 232 of file rootoutput.h.


The documentation for this class was generated from the following files: