Version: SMASH-2.0
Output Classes

Classes

class  smash::BinaryOutputBase
 
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::HepMcOutput
 SMASH output to HepMC file. More...
 
class  smash::ICOutput
 
class  smash::OscarOutput< Format, Contents >
 
struct  smash::EventInfo
 Structure to contain custom data for output. More...
 
class  smash::OutputInterface
 Abstraction of generic output. More...
 
class  smash::RootOutput
 
class  smash::ThermodynamicOutput
 Writes the thermodynamic quantities at a specified point versus time. More...
 
class  smash::VtkOutput
 

Enumerations

enum  smash::OscarOutputFormat { smash::OscarFormat2013, smash::OscarFormat2013Extended, smash::OscarFormat1999 }
 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

 smash::OscarOutput< Format, Contents >::OscarOutput (const bf::path &path, const std::string &name)
 Create oscar output. More...
 
void smash::OscarOutput< Format, Contents >::at_eventstart (const Particles &particles, const int event_number, 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 int event_number, const EventInfo &) 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 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 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 bf::path &path, const OutputParameters &out_par)
 

Variables

int smash::OscarOutput< Format, Contents >::current_event_ = 0
 Keep track of event number. More...
 
RenamingFilePtr smash::OscarOutput< Format, Contents >::file_
 Full filepath of the output file. More...
 

Enumeration Type Documentation

◆ OscarOutputFormat

Selector for the output format of OscarOutput.

Enumerator
OscarFormat2013 
OscarFormat2013Extended 
OscarFormat1999 

Definition at line 29 of file oscaroutput.h.

◆ 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 42 of file oscaroutput.h.

42  {
44  OscarInteractions = 0x001,
46  OscarTimesteps = 0x002,
48  OscarAtEventstart = 0x004,
54  OscarParticlesIC = 0x020
55 };

Function Documentation

◆ OscarOutput()

template<OscarOutputFormat Format, int Contents>
smash::OscarOutput< Format, Contents >::OscarOutput ( const bf::path &  path,
const std::string &  name 
)

Create oscar output.

Parameters
[in]pathOutput path.
[in]nameName of the ouput.

◆ at_eventstart()

template<OscarOutputFormat Format, int Contents>
void smash::OscarOutput< Format, Contents >::at_eventstart ( const Particles particles,
const int  event_number,
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_numberNumber of event.
[in]eventEvent info, see event_info

Implements smash::OutputInterface.

Definition at line 126 of file oscaroutput.cc.

128  {
129  current_event_ = event_number;
130  if (Contents & OscarAtEventstart) {
131  if (Format == OscarFormat2013 || Format == OscarFormat2013Extended) {
132  std::fprintf(file_.get(), "# event %i in %zu\n", event_number,
133  particles.size());
134  } else {
135  /* OSCAR line prefix : initial particles; final particles; event id
136  * First block of an event: initial = 0, final = number of particles
137  */
138  const size_t zero = 0;
139  std::fprintf(file_.get(), "%zu %zu %i\n", zero, particles.size(),
140  event_number);
141  }
142  if (!(Contents & OscarParticlesIC)) {
143  // We do not want the inital particle list to be printed in case of IC
144  // output
145  write(particles);
146  }
147  }
148 }
Here is the call graph for this function:

◆ at_eventend()

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

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

Parameters
[in]particlesCurrent list of particles.
[in]event_numberNumber of event.
[in]eventEvent info, see event_info

Implements smash::OutputInterface.

Definition at line 151 of file oscaroutput.cc.

153  {
154  if (Format == OscarFormat2013 || Format == OscarFormat2013Extended) {
155  if (Contents & OscarParticlesAtEventend ||
156  (Contents & OscarParticlesAtEventendIfNotEmpty && !event.empty_event)) {
157  std::fprintf(file_.get(), "# event %i out %zu\n", event_number,
158  particles.size());
159  write(particles);
160  }
161  // Comment end of an event
162  const char *empty_event_str = event.empty_event ? "no" : "yes";
163  std::fprintf(
164  file_.get(),
165  "# event %i end 0 impact %7.3f scattering_projectile_target %s\n",
166  event_number, event.impact_parameter, empty_event_str);
167  } else {
168  /* OSCAR line prefix : initial particles; final particles; event id
169  * Last block of an event: initial = number of particles, final = 0
170  * Block ends with null interaction. */
171  const size_t zero = 0;
172  if (Contents & OscarParticlesAtEventend ||
173  (Contents & OscarParticlesAtEventendIfNotEmpty && !event.empty_event)) {
174  std::fprintf(file_.get(), "%zu %zu %i\n", particles.size(), zero,
175  event_number);
176  write(particles);
177  }
178  // Null interaction marks the end of an event
179  std::fprintf(file_.get(), "%zu %zu %i %7.3f\n", zero, zero, event_number,
180  event.impact_parameter);
181  }
182  // Flush to disk
183  std::fflush(file_.get());
184 
185  if (Contents & OscarParticlesIC) {
186  // If the runtime is too short some particles might not yet have
187  // reached the hypersurface. Warning is printed.
188  if (particles.size() != 0) {
190  "End time might be too small for initial conditions output. "
191  "Hypersurface has not yet been crossed by ",
192  particles.size(), " particle(s).");
193  }
194  }
195 }
Here is the call graph for this function:

◆ 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 198 of file oscaroutput.cc.

199  {
200  if (Contents & OscarInteractions) {
201  if (Format == OscarFormat2013 || Format == OscarFormat2013Extended) {
202  std::fprintf(file_.get(),
203  "# interaction in %zu out %zu rho %12.7f weight %12.7g"
204  " partial %12.7f type %5i\n",
205  action.incoming_particles().size(),
206  action.outgoing_particles().size(), density,
207  action.get_total_weight(), action.get_partial_weight(),
208  static_cast<int>(action.get_type()));
209  } else {
210  /* OSCAR line prefix : initial final
211  * particle creation: 0 1
212  * particle 2<->2 collision: 2 2
213  * resonance formation: 2 1
214  * resonance decay: 1 2
215  * etc.*/
216  std::fprintf(file_.get(), "%zu %zu %12.7f %12.7f %12.7f %5i\n",
217  action.incoming_particles().size(),
218  action.outgoing_particles().size(), density,
219  action.get_total_weight(), action.get_partial_weight(),
220  static_cast<int>(action.get_type()));
221  }
222  for (const auto &p : action.incoming_particles()) {
224  }
225  for (const auto &p : action.outgoing_particles()) {
227  }
228  } else if (Contents & OscarParticlesIC) {
229  for (const auto &p : action.incoming_particles()) {
231  }
232  }
233 }
Here is the call graph for this function:

◆ 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 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]eventEvent info, see event_info

Reimplemented from smash::OutputInterface.

Definition at line 236 of file oscaroutput.cc.

238  {
239  if (Contents & OscarTimesteps) {
240  if (Format == OscarFormat2013 || Format == OscarFormat2013Extended) {
241  std::fprintf(file_.get(), "# event %i out %zu\n", current_event_ + 1,
242  particles.size());
243  } else {
244  const size_t zero = 0;
245  std::fprintf(file_.get(), "%zu %zu %i\n", particles.size(), zero,
246  current_event_ + 1);
247  }
248  write(particles);
249  }
250 }
Here is the call graph for this function:

◆ 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 705 of file oscaroutput.cc.

706  {
707  const FourVector pos = data.position();
708  const FourVector mom = data.momentum();
709  if (Format == OscarFormat2013) {
710  std::fprintf(file_.get(), "%g %g %g %g %g %.9g %.9g %.9g %.9g %s %i %i\n",
711  pos.x0(), pos.x1(), pos.x2(), pos.x3(), data.effective_mass(),
712  mom.x0(), mom.x1(), mom.x2(), mom.x3(),
713  data.pdgcode().string().c_str(), data.id(),
714  data.type().charge());
715  } else if (Format == OscarFormat2013Extended) {
716  const auto h = data.get_history();
717  std::fprintf(
718  file_.get(),
719  "%g %g %g %g %g %.9g %.9g %.9g"
720  " %.9g %s %i %i %i %g %g %i %i %g %s %s\n",
721  pos.x0(), pos.x1(), pos.x2(), pos.x3(), data.effective_mass(), mom.x0(),
722  mom.x1(), mom.x2(), mom.x3(), data.pdgcode().string().c_str(),
723  data.id(), data.type().charge(), h.collisions_per_particle,
724  data.formation_time(), data.xsec_scaling_factor(), h.id_process,
725  static_cast<int>(h.process_type), h.time_last_collision,
726  h.p1.string().c_str(), h.p2.string().c_str());
727  } else {
728  std::fprintf(file_.get(), "%i %s %i %g %g %g %g %g %g %g %g %g\n",
729  data.id(), data.pdgcode().string().c_str(), 0, mom.x1(),
730  mom.x2(), mom.x3(), mom.x0(), data.effective_mass(), pos.x1(),
731  pos.x2(), pos.x3(), pos.x0());
732  }
733 }
Here is the call graph for this function:

◆ write()

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 119 of file oscaroutput.cc.

119  {
120  for (const ParticleData &data : particles) {
121  write_particledata(data);
122  }
123 }

◆ create_oscar_output()

std::unique_ptr< OutputInterface > smash::create_oscar_output ( const std::string &  format,
const std::string &  content,
const bf::path &  path,
const OutputParameters out_par 
)
Returns
A new OscarOutput object using information from config to select the correct implementation.
Parameters
[in]formatA string: "Oscar2013" or "Oscar1999"
[in]contentA string: "Particles", "Collisions", "Photons" or "Dileptons".
[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 769 of file oscaroutput.cc.

771  {
772  if (format != "Oscar2013" && format != "Oscar1999") {
773  throw std::invalid_argument("Creating Oscar output: unknown format");
774  }
775  const bool modern_format = (format == "Oscar2013");
776  if (content == "Particles") {
777  if (out_par.part_only_final == OutputOnlyFinal::Yes) {
778  return create_select_format<OscarParticlesAtEventend>(
779  modern_format, path, out_par, "particle_lists");
780  } else if (out_par.part_only_final == OutputOnlyFinal::IfNotEmpty) {
781  return create_select_format<OscarParticlesAtEventendIfNotEmpty>(
782  modern_format, path, out_par, "particle_lists");
783 
784  } else { // out_par.part_only_final == OutputOnlyFinal::No
787  modern_format, path, out_par, "particle_lists");
788  }
789  } else if (content == "Collisions") {
790  if (out_par.coll_printstartend) {
793  modern_format, path, out_par, "full_event_history");
794  } else {
795  return create_select_format<OscarInteractions>(
796  modern_format, path, out_par, "full_event_history");
797  }
798  } else if (content == "Dileptons") {
799  if (modern_format && out_par.dil_extended) {
800  return make_unique<
801  OscarOutput<OscarFormat2013Extended, OscarInteractions>>(path,
802  "Dileptons");
803  } else if (modern_format && !out_par.dil_extended) {
804  return make_unique<OscarOutput<OscarFormat2013, OscarInteractions>>(
805  path, "Dileptons");
806  } else if (!modern_format && !out_par.dil_extended) {
807  return make_unique<OscarOutput<OscarFormat1999, OscarInteractions>>(
808  path, "Dileptons");
809  } else if (!modern_format && out_par.dil_extended) {
810  logg[LOutput].warn()
811  << "Creating Oscar output: "
812  << "There is no extended Oscar1999 (dileptons) format.";
813  }
814  } else if (content == "Photons") {
815  if (modern_format && !out_par.photons_extended) {
816  return make_unique<OscarOutput<OscarFormat2013, OscarInteractions>>(
817  path, "Photons");
818  } else if (modern_format && out_par.photons_extended) {
819  return make_unique<
820  OscarOutput<OscarFormat2013Extended, OscarInteractions>>(path,
821  "Photons");
822  } else if (!modern_format && !out_par.photons_extended) {
823  return make_unique<OscarOutput<OscarFormat1999, OscarInteractions>>(
824  path, "Photons");
825  } else if (!modern_format && out_par.photons_extended) {
826  logg[LOutput].warn()
827  << "Creating Oscar output: "
828  << "There is no extended Oscar1999 (photons) format.";
829  }
830  } else if (content == "Initial_Conditions") {
831  if (modern_format && !out_par.ic_extended) {
832  return make_unique<
833  OscarOutput<OscarFormat2013, OscarParticlesIC | OscarAtEventstart>>(
834  path, "SMASH_IC");
835  } else if (modern_format && out_par.ic_extended) {
836  return make_unique<OscarOutput<OscarFormat2013Extended,
838  path, "SMASH_IC");
839  } else if (!modern_format && !out_par.ic_extended) {
840  return make_unique<
841  OscarOutput<OscarFormat1999, OscarParticlesIC | OscarAtEventstart>>(
842  path, "SMASH_IC");
843  } else if (!modern_format && out_par.ic_extended) {
844  logg[LOutput].warn()
845  << "Creating Oscar output: "
846  << "There is no extended Oscar1999 (initial conditions) format.";
847  }
848  }
849 
850  throw std::invalid_argument("Create_oscar_output got unknown content.");
851 }
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ current_event_

template<OscarOutputFormat Format, int Contents>
int smash::OscarOutput< Format, Contents >::current_event_ = 0
private

Keep track of event number.

Definition at line 129 of file oscaroutput.h.

◆ file_

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

Full filepath of the output file.

Definition at line 132 of file oscaroutput.h.

smash::LOutput
static constexpr int LOutput
Definition: oscaroutput.cc:23
smash::OscarTimesteps
store the state after N timesteps (after_Nth_timestep)
Definition: oscaroutput.h:46
smash::OscarFormat2013Extended
Definition: oscaroutput.h:31
smash::OscarOutput::write_particledata
void write_particledata(const ParticleData &data)
Write single particle information line to output.
Definition: oscaroutput.cc:705
smash::logg
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > logg
An array that stores all pre-configured Logger objects.
Definition: logging.cc:39
smash::RenamingFilePtr::get
FILE * get()
Get the underlying FILE* pointer.
Definition: file.cc:27
OutputOnlyFinal::IfNotEmpty
Print only final-state particles, and those only if the event is not empty.
smash::format
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:307
smash::make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition for make_unique Is in C++14's standard library; necessary for older compilers.
Definition: cxx14compat.h:25
smash::OscarFormat1999
Definition: oscaroutput.h:32
smash::LHyperSurfaceCrossing
static constexpr int LHyperSurfaceCrossing
Definition: hypersurfacecrossingaction.cc:16
smash::OscarOutput::write
void write(const Particles &particles)
Write the particle information of a list of particles to the output.
Definition: oscaroutput.cc:119
OutputOnlyFinal::Yes
Print only final-state particles.
smash::anonymous_namespace{oscaroutput.cc}::create_select_format
std::unique_ptr< OutputInterface > create_select_format(bool modern_format, const bf::path &path, const OutputParameters &out_par, const std::string &name)
Helper function that creates the oscar output with the format selected by create_oscar_output (except...
Definition: oscaroutput.cc:748
smash::OscarOutput::file_
RenamingFilePtr file_
Full filepath of the output file.
Definition: oscaroutput.h:132
smash::OscarParticlesAtEventendIfNotEmpty
store the state at the end of each event if it is not empty (at_eventend)
Definition: oscaroutput.h:52
smash::OscarInteractions
store interaction information (write_interaction)
Definition: oscaroutput.h:44
smash::OscarAtEventstart
store the state at the start of each event (at_eventstart)
Definition: oscaroutput.h:48
smash::OscarFormat2013
Definition: oscaroutput.h:30
smash::OscarParticlesIC
store the particles that are removed on the hypersurface
Definition: oscaroutput.h:54
smash::pdg::p
constexpr int p
Proton.
Definition: pdgcode_constants.h:28
smash::OscarParticlesAtEventend
store the state at the end of each event (at_eventend)
Definition: oscaroutput.h:50
smash::OscarOutput::current_event_
int current_event_
Keep track of event number.
Definition: oscaroutput.h:129