Version: SMASH-3.3
Output Classes

Classes

class  smash::BinaryOutputBase
 Base class for SMASH binary output. More...
 
class  smash::BinaryOutputCollisions
 Saves SMASH collision history to binary file. More...
 
class  smash::BinaryOutputParticles
 Writes the particle list at specific times to the binary file. More...
 
class  smash::BinaryOutputInitialConditions
 Writes the particles when crossing the hypersurface to the binary file. More...
 
class  smash::HepMcInterface
 Base class for output handlers that need the HepMC3 structure. More...
 
class  smash::HepMcOutput
 SMASH output to HepMC file. More...
 
class  smash::ICOutput
 SMASH output in a format containing initial conditions for hydrodynamic codes ("For_vHLLE"). More...
 
class  smash::OscarOutput< Format, Contents >
 
struct  smash::EventInfo
 Structure to contain custom data for output. More...
 
struct  smash::EventLabel
 Structure to contain information about the event and ensemble numbers. More...
 
class  smash::OutputInterface
 Abstraction of generic output. More...
 
class  smash::RivetOutput
 SMASH output to Rivet analyses. More...
 
class  smash::RootOutput
 
class  smash::ThermodynamicLatticeOutput
 Writes the thermodynamic quantities at lattice points versus time. More...
 
class  smash::ThermodynamicOutput
 Writes the thermodynamic quantities at a specified point versus time. More...
 
class  smash::VtkOutput
 SMASH output in a paraview format, intended for simple visualization. More...
 

Enumerations

enum  smash::OscarOutputFormat { smash::OscarFormat2013 , smash::OscarFormat2013Extended , smash::OscarFormat1999 , smash::ASCII }
 Selector for the output format of OscarOutput. More...
 
enum  smash::OscarOutputContents {
  smash::OscarInteractions = 0x001 , smash::OscarTimesteps = 0x002 , smash::OscarAtEventstart = 0x004 , smash::OscarParticlesAtEventend = 0x008 ,
  smash::OscarParticlesAtEventendIfNotEmpty = 0x010 , smash::OscarParticlesIC = 0x020
}
 Flags for the Contents template parameter of OscarOutput. More...
 

Functions

std::unique_ptr< OutputInterfacesmash::create_binary_output (const std::string &format, const std::string &content, const std::filesystem::path &path, const OutputParameters &out_par)
 Create a binary output object. More...
 
 smash::OscarOutput< Format, Contents >::OscarOutput (const std::filesystem::path &path, const std::string &name, const std::vector< std::string > quantities={})
 Create oscar output. More...
 
void smash::OscarOutput< Format, Contents >::at_eventstart (const Particles &particles, const EventLabel &event_label, const EventInfo &event) override
 Writes the initial particle information of an event to the oscar output. More...
 
void smash::OscarOutput< Format, Contents >::at_eventend (const Particles &particles, const EventLabel &event_label, const EventInfo &event) override
 Writes the final particle information of an event to the oscar output. More...
 
void smash::OscarOutput< Format, Contents >::at_interaction (const Action &action, const double density) override
 Writes a interaction prefix line and a line for every incoming and outgoing particle to the oscar output. More...
 
void smash::OscarOutput< Format, Contents >::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 a prefix line then write out all current particles. More...
 
void smash::OscarOutput< Format, Contents >::write_particledata (const ParticleData &data)
 Write single particle information line to output. More...
 
void smash::OscarOutput< Format, Contents >::write (const ToASCII::type &buffer)
 Write a ToASCII::type buffer to the output. More...
 
void smash::OscarOutput< Format, Contents >::write (const Particles &particles)
 Write the particle information of a list of particles to the output. More...
 
std::unique_ptr< OutputInterfacesmash::create_oscar_output (const std::string &format, const std::string &content, const std::filesystem::path &path, const OutputParameters &out_par)
 

Variables

RenamingFilePtr smash::OscarOutput< Format, Contents >::file_
 Full filepath of the output file. More...
 
OutputFormatter< ToASCIIsmash::OscarOutput< Format, Contents >::formatter_
 Formatter of the output. More...
 

Enumeration Type Documentation

◆ OscarOutputFormat

Selector for the output format of OscarOutput.

Enumerator
OscarFormat2013 
OscarFormat2013Extended 
OscarFormat1999 
ASCII 

Definition at line 31 of file oscaroutput.h.

31  {
35  ASCII
36 };
@ OscarFormat1999
Definition: oscaroutput.h:34
@ OscarFormat2013Extended
Definition: oscaroutput.h:33
@ ASCII
Definition: oscaroutput.h:35
@ OscarFormat2013
Definition: oscaroutput.h:32

◆ OscarOutputContents

Flags for the Contents template parameter of OscarOutput.

Flags can be combined with binary OR operators to some arbitrary int. That's why the values of the enumerators are written out (in hexadecimal), to ensure every flag occupies a single bit.

Enumerator
OscarInteractions 

store interaction information (write_interaction)

OscarTimesteps 

store the state after N timesteps (after_Nth_timestep)

OscarAtEventstart 

store the state at the start of each event (at_eventstart)

OscarParticlesAtEventend 

store the state at the end of each event (at_eventend)

OscarParticlesAtEventendIfNotEmpty 

store the state at the end of each event if it is not empty (at_eventend)

OscarParticlesIC 

store the particles that are removed on the hypersurface

Definition at line 45 of file oscaroutput.h.

45  {
47  OscarInteractions = 0x001,
49  OscarTimesteps = 0x002,
51  OscarAtEventstart = 0x004,
57  OscarParticlesIC = 0x020
58 };
@ OscarParticlesAtEventend
store the state at the end of each event (at_eventend)
Definition: oscaroutput.h:53
@ OscarParticlesAtEventendIfNotEmpty
store the state at the end of each event if it is not empty (at_eventend)
Definition: oscaroutput.h:55
@ OscarAtEventstart
store the state at the start of each event (at_eventstart)
Definition: oscaroutput.h:51
@ OscarInteractions
store interaction information (write_interaction)
Definition: oscaroutput.h:47
@ OscarParticlesIC
store the particles that are removed on the hypersurface
Definition: oscaroutput.h:57
@ OscarTimesteps
store the state after N timesteps (after_Nth_timestep)
Definition: oscaroutput.h:49

Function Documentation

◆ create_binary_output()

std::unique_ptr< OutputInterface > smash::create_binary_output ( const std::string &  format,
const std::string &  content,
const std::filesystem::path &  path,
const OutputParameters out_par 
)

Create a binary output object.

This is a helper function for the Experiment class to facilitate the logic when creating the output objects.

Parameters
[in]formatThe output format as string, e.g. "Oscar2013"
[in]contentThe output content as string, e.g. "Particles"
[in]pathThe path to the output directory
[in]out_parThe output parameters object containing output metadata
Returns
A std::unique_ptr<OutputInterface> polymorphically initialised to the correct binary output object.

Definition at line 467 of file binaryoutput.cc.

469  {
470  const auto quantities =
471  get_list_of_binary_quantities(content, format, out_par);
472  if (content == "Particles") {
473  return std::make_unique<BinaryOutputParticles>(path, content, out_par,
474  quantities);
475  } else if (content == "Collisions" || content == "Dileptons" ||
476  content == "Photons") {
477  return std::make_unique<BinaryOutputCollisions>(path, content, out_par,
478  quantities);
479  } else if (content == "Initial_Conditions") {
480  return std::make_unique<BinaryOutputInitialConditions>(path, content,
481  quantities);
482  } else {
483  throw std::invalid_argument("Binary output not available for '" + content +
484  "' content.");
485  }
486 }
FormattingHelper< T > format(const T &value, const char *unit, int width=-1, int precision=-1)
Acts as a stream modifier for std::ostream to output an object with an optional suffix string and wit...
Definition: logging.h:217
static auto get_list_of_binary_quantities(const std::string &content, const std::string &format, const OutputParameters &parameters)

◆ OscarOutput()

template<OscarOutputFormat Format, int Contents>
smash::OscarOutput< Format, Contents >::OscarOutput ( const std::filesystem::path &  path,
const std::string &  name,
const std::vector< std::string >  quantities = {} 
)

Create oscar output.

Parameters
[in]pathOutput path.
[in]nameName of the ouput.
[in]quantitiesList of quantities present in the output file.

◆ at_eventstart()

template<OscarOutputFormat Format, int Contents>
void smash::OscarOutput< Format, Contents >::at_eventstart ( const Particles particles,
const EventLabel event_label,
const EventInfo event 
)
overridevirtual

Writes the initial particle information of an event to the oscar output.

Parameters
[in]particlesCurrent list of all particles.
[in]event_labelNumbers of event and ensemble.
[in]eventEvent info, see event_info

Reimplemented from smash::OutputInterface.

Definition at line 136 of file oscaroutput.cc.

138  {
139  // We do not want the inital particle list or number to be printed in case of
140  // IC output
141  if (Contents & OscarAtEventstart && !(Contents & OscarParticlesIC)) {
142  if (Format == ASCII || Format == OscarFormat2013 ||
143  Format == OscarFormat2013Extended) {
144  std::fprintf(file_.get(), "# event %i ensemble %i in %zu\n",
145  event_label.event_number, event_label.ensemble_number,
146  particles.size());
147  } else {
148  /* OSCAR line prefix : initial particles; final particles; event id
149  * First block of an event: initial = 0, final = number of particles
150  */
151  const size_t zero = 0;
152  std::fprintf(file_.get(), "%zu %zu %i %i\n", zero, particles.size(),
153  event_label.event_number, event_label.ensemble_number);
154  }
155  write(particles);
156  } else if (Contents & OscarParticlesIC) {
157  if (Format == ASCII || Format == OscarFormat2013 ||
158  Format == OscarFormat2013Extended) {
159  std::fprintf(file_.get(), "# event %i ensemble %i start\n",
160  event_label.event_number, event_label.ensemble_number);
161  } else if (Format == OscarFormat1999) {
162  const size_t zero = 0;
163  std::fprintf(file_.get(), "%zu %zu %i %i\n", zero, zero,
164  event_label.event_number, event_label.ensemble_number);
165  }
166  }
167 }
FILE * get()
Get the underlying FILE* pointer.
Definition: file.cc:27
RenamingFilePtr file_
Full filepath of the output file.
Definition: oscaroutput.h:142
void write(const ToASCII::type &buffer)
Write a ToASCII::type buffer to the output.
Definition: oscaroutput.cc:870

◆ at_eventend()

template<OscarOutputFormat Format, int Contents>
void smash::OscarOutput< Format, Contents >::at_eventend ( const Particles particles,
const EventLabel event_label,
const EventInfo event 
)
overridevirtual

Writes the final particle information of an event to the oscar output.

Parameters
[in]particlesCurrent list of particles.
[in]event_labelNumbers of event and ensemble.
[in]eventEvent info, see event_info

Reimplemented from smash::OutputInterface.

Definition at line 170 of file oscaroutput.cc.

172  {
173  if (Format == ASCII || Format == OscarFormat2013 ||
174  Format == OscarFormat2013Extended) {
175  if (Contents & OscarParticlesAtEventend ||
176  (Contents & OscarParticlesAtEventendIfNotEmpty && !event.empty_event)) {
177  std::fprintf(file_.get(), "# event %i ensemble %i out %zu\n",
178  event_label.event_number, event_label.ensemble_number,
179  particles.size());
180  write(particles);
181  }
182  // Comment end of an event
183  if (!(Contents & OscarParticlesIC)) {
184  const char *empty_event_str = event.empty_event ? "no" : "yes";
185  std::fprintf(file_.get(),
186  "# event %i ensemble %i end 0 impact %7.3f "
187  "scattering_projectile_target %s\n",
188  event_label.event_number, event_label.ensemble_number,
189  event.impact_parameter, empty_event_str);
190  } else {
191  std::fprintf(file_.get(), "# event %i ensemble %i end\n",
192  event_label.event_number, event_label.ensemble_number);
193  }
194  } else {
195  /* OSCAR line prefix : initial particles; final particles; event id
196  * Last block of an event: initial = number of particles, final = 0
197  * Block ends with null interaction. */
198  const size_t zero = 0;
199  if (Contents & OscarParticlesAtEventend ||
200  (Contents & OscarParticlesAtEventendIfNotEmpty && !event.empty_event)) {
201  std::fprintf(file_.get(), "%zu %zu %i %i\n", particles.size(), zero,
202  event_label.event_number, event_label.ensemble_number);
203  write(particles);
204  }
205  // Null interaction marks the end of an event
206  std::fprintf(file_.get(), "%zu %zu %i %i %7.3f\n", zero, zero,
207  event_label.event_number, event_label.ensemble_number,
208  event.impact_parameter);
209  }
210  // Flush to disk
211  std::fflush(file_.get());
212 }

◆ at_interaction()

template<OscarOutputFormat Format, int Contents>
void smash::OscarOutput< Format, Contents >::at_interaction ( const Action action,
const double  density 
)
overridevirtual

Writes a interaction prefix line and a line for every incoming and outgoing particle to the oscar output.

Parameters
[in]actionAction that holds the information of the interaction.
[in]densityDensity at the interaction point.

Reimplemented from smash::OutputInterface.

Definition at line 215 of file oscaroutput.cc.

216  {
217  if (Contents & OscarInteractions) {
218  if (Format == ASCII || Format == OscarFormat2013 ||
219  Format == OscarFormat2013Extended) {
220  std::fprintf(file_.get(),
221  "# interaction in %zu out %zu rho %12.7f weight %12.7g"
222  " partial %12.7f type %5i\n",
223  action.incoming_particles().size(),
224  action.outgoing_particles().size(), density,
225  action.get_total_weight(), action.get_partial_weight(),
226  static_cast<int>(action.get_type()));
227  } else {
228  /* OSCAR line prefix : initial final
229  * particle creation: 0 1
230  * particle 2<->2 collision: 2 2
231  * resonance formation: 2 1
232  * resonance decay: 1 2
233  * etc.*/
234  std::fprintf(file_.get(), "%zu %zu %12.7f %12.7f %12.7f %5i\n",
235  action.incoming_particles().size(),
236  action.outgoing_particles().size(), density,
237  action.get_total_weight(), action.get_partial_weight(),
238  static_cast<int>(action.get_type()));
239  }
240  for (const auto &p : action.incoming_particles()) {
242  }
243  for (const auto &p : action.outgoing_particles()) {
245  }
246  } else if (Contents & OscarParticlesIC) {
247  for (const auto &p : action.incoming_particles()) {
249  }
250  }
251 }
void write_particledata(const ParticleData &data)
Write single particle information line to output.
Definition: oscaroutput.cc:863
constexpr int p
Proton.

◆ at_intermediate_time()

template<OscarOutputFormat Format, int Contents>
void smash::OscarOutput< Format, Contents >::at_intermediate_time ( const Particles particles,
const std::unique_ptr< Clock > &  clock,
const DensityParameters dens_param,
const EventLabel event_label,
const EventInfo event 
)
overridevirtual

Writes a prefix line then write out all current particles.

Parameters
[in]particlesCurrent list of particles.
[in]clockUnused, needed since inherited.
[in]dens_paramUnused, needed since inherited.
[in]event_labelNumbers of event and ensemble.
[in]eventEvent info, see event_info

Reimplemented from smash::OutputInterface.

Definition at line 254 of file oscaroutput.cc.

257  {
258  if (Contents & OscarTimesteps) {
259  if (Format == ASCII || Format == OscarFormat2013 ||
260  Format == OscarFormat2013Extended) {
261  std::fprintf(file_.get(), "# event %i ensemble %i out %zu\n",
262  event_label.event_number, event_label.ensemble_number,
263  particles.size());
264  } else {
265  const size_t zero = 0;
266  std::fprintf(file_.get(), "%zu %zu %i %i\n", particles.size(), zero,
267  event_label.event_number, event_label.ensemble_number);
268  }
269  write(particles);
270  }
271 }

◆ write_particledata()

template<OscarOutputFormat Format, int Contents>
void smash::OscarOutput< Format, Contents >::write_particledata ( const ParticleData data)
private

Write single particle information line to output.

Parameters
[in]dataData of particle.

Definition at line 863 of file oscaroutput.cc.

864  {
865  std::fprintf(file_.get(), "%s",
866  formatter_.single_particle_data(data).c_str());
867 }
OutputFormatter< ToASCII > formatter_
Formatter of the output.
Definition: oscaroutput.h:145

◆ write() [1/2]

template<OscarOutputFormat Format, int Contents>
void smash::OscarOutput< Format, Contents >::write ( const ToASCII::type buffer)
private

Write a ToASCII::type buffer to the output.

Parameters
[in]bufferBuffer containing the ASCII-formatted data to be written

Definition at line 870 of file oscaroutput.cc.

870  {
871  std::fprintf(file_.get(), "%s", buffer.c_str());
872 }

◆ write() [2/2]

template<OscarOutputFormat Format, int Contents>
void smash::OscarOutput< Format, Contents >::write ( const Particles particles)
inlineprivate

Write the particle information of a list of particles to the output.

One line per particle.

Parameters
[in]particlesList of particles to be written

Definition at line 129 of file oscaroutput.cc.

129  {
130  write_in_chunk<ToASCII>(
131  particles, formatter_,
132  [this](const ToASCII::type &buf) { this->write(buf); });
133 }
std::string type
Return type of this converter.

◆ create_oscar_output()

std::unique_ptr< OutputInterface > smash::create_oscar_output ( const std::string &  format,
const std::string &  content,
const std::filesystem::path &  path,
const OutputParameters out_par 
)
Returns
A new OscarOutput object using information from config to select the correct implementation.
Parameters
[in]formatThe output format as string, e.g. "Oscar2013"
[in]contentThe output content as string, e.g. "Particles"
[in]pathThe path to the output directory where the file(s) will be placed.
[in]out_parA structure containing parameters of the output, in particular if it is extended or not, if printing only final particles in event, etc.

Definition at line 918 of file oscaroutput.cc.

920  {
921  if (format != "Oscar2013" && format != "Oscar1999" && format != "ASCII") {
922  throw std::invalid_argument("Creating Oscar output: unknown format");
923  }
924  const bool modern_format = (format == "Oscar2013");
925  const bool custom_format = (format == "ASCII");
926  const auto &quantities = custom_format ? out_par.quantities.at(content)
927  : std::vector<std::string>{};
928 
929  if (content == "Particles") {
930  if (out_par.part_only_final == OutputOnlyFinal::Yes) {
931  return create_selected_format<OscarParticlesAtEventend>(
932  path, "particle_lists", modern_format, out_par.part_extended,
933  custom_format, quantities);
934  } else if (out_par.part_only_final == OutputOnlyFinal::IfNotEmpty) {
935  return create_selected_format<OscarParticlesAtEventendIfNotEmpty>(
936  path, "particle_lists", modern_format, out_par.part_extended,
937  custom_format, quantities);
938  } else { // out_par.part_only_final == OutputOnlyFinal::No
941  path, "particle_lists", modern_format, out_par.part_extended,
942  custom_format, quantities);
943  }
944  } else if (content == "Collisions") {
945  if (out_par.coll_printstartend) {
948  path, "full_event_history", modern_format, out_par.coll_extended,
949  custom_format, quantities);
950  } else {
951  return create_selected_format<OscarInteractions>(
952  path, "full_event_history", modern_format, out_par.coll_extended,
953  custom_format, quantities);
954  }
955  } else if (content == "Dileptons") {
956  return create_selected_format<OscarInteractions>(
957  path, "Dileptons", modern_format, out_par.dil_extended, custom_format,
958  quantities);
959  } else if (content == "Photons") {
960  return create_selected_format<OscarInteractions>(
961  path, "Photons", modern_format, out_par.photons_extended, custom_format,
962  quantities);
963  } else if (content == "Initial_Conditions") {
964  return create_selected_format<OscarParticlesIC | OscarAtEventstart>(
965  path, "SMASH_IC", modern_format, out_par.ic_extended, custom_format,
966  quantities);
967  }
968 
969  throw std::invalid_argument("Create_oscar_output got unknown content.");
970 }
@ IfNotEmpty
Print only final-state particles, and those only if the event is not empty.
@ Yes
Print only final-state particles.
std::unique_ptr< OutputInterface > create_selected_format(const std::filesystem::path &path, const std::string &name, bool modern_format, bool extended_format, bool custom_format, const std::vector< std::string > &quantities)
Helper function that creates the oscar output with the format selected by create_oscar_output.
Definition: oscaroutput.cc:890

Variable Documentation

◆ file_

template<OscarOutputFormat Format, int Contents>
RenamingFilePtr smash::OscarOutput< Format, Contents >::file_
private

Full filepath of the output file.

Definition at line 142 of file oscaroutput.h.

◆ formatter_

template<OscarOutputFormat Format, int Contents>
OutputFormatter<ToASCII> smash::OscarOutput< Format, Contents >::formatter_
private

Formatter of the output.

Definition at line 145 of file oscaroutput.h.