Version: SMASH-1.8
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::ICOutput
 
class  smash::OscarOutput< Format, Contents >
 
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) 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, double impact_parameter, bool empty_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) 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 
)
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.

Implements smash::OutputInterface.

Definition at line 128 of file oscaroutput.cc.

129  {
130  current_event_ = event_number;
131  if (Contents & OscarAtEventstart) {
132  if (Format == OscarFormat2013 || Format == OscarFormat2013Extended) {
133  std::fprintf(file_.get(), "# event %i in %zu\n", event_number + 1,
134  particles.size());
135  } else {
136  /* OSCAR line prefix : initial particles; final particles; event id
137  * First block of an event: initial = 0, final = number of particles
138  */
139  const size_t zero = 0;
140  std::fprintf(file_.get(), "%zu %zu %i\n", zero, particles.size(),
141  event_number + 1);
142  }
143  if (!(Contents & OscarParticlesIC)) {
144  // We do not want the inital particle list to be printed in case of IC
145  // output
146  write(particles);
147  }
148  }
149 }
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,
double  impact_parameter,
bool  empty_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]impact_parameterImpact parameter of this event.
[in]empty_eventWhether there was no interaction between the target and the projectile.

Implements smash::OutputInterface.

Definition at line 152 of file oscaroutput.cc.

155  {
156  if (Format == OscarFormat2013 || Format == OscarFormat2013Extended) {
157  if (Contents & OscarParticlesAtEventend ||
158  (Contents & OscarParticlesAtEventendIfNotEmpty && !empty_event)) {
159  std::fprintf(file_.get(), "# event %i out %zu\n", event_number + 1,
160  particles.size());
161  write(particles);
162  }
163  // Comment end of an event
164  const char *empty_event_str = empty_event ? "yes" : "no";
165  std::fprintf(file_.get(), "# event %i end 0 impact %7.3f empty %s\n",
166  event_number + 1, 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 && !empty_event)) {
174  std::fprintf(file_.get(), "%zu %zu %i\n", particles.size(), zero,
175  event_number + 1);
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,
180  event_number + 1, 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 
)
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.

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

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

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

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

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

smash::LOutput
static constexpr int LOutput
Definition: oscaroutput.cc:25
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:704
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:304
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:18
smash::OscarOutput::write
void write(const Particles &particles)
Write the particle information of a list of particles to the output.
Definition: oscaroutput.cc:121
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:747
smash::OscarOutput::file_
RenamingFilePtr file_
Full filepath of the output file.
Definition: oscaroutput.h:131
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:128