Version: SMASH-3.1
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 ASCII format containing initial conditions for hydrodynamic codes. More...
 
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::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 }
 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 std::filesystem::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 std::filesystem::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.

29  {
33 };
@ OscarFormat1999
Definition: oscaroutput.h:32
@ OscarFormat2013Extended
Definition: oscaroutput.h:31
@ OscarFormat2013
Definition: oscaroutput.h:30

◆ 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 };
@ OscarParticlesAtEventend
store the state at the end of each event (at_eventend)
Definition: oscaroutput.h:50
@ OscarParticlesAtEventendIfNotEmpty
store the state at the end of each event if it is not empty (at_eventend)
Definition: oscaroutput.h:52
@ OscarAtEventstart
store the state at the start of each event (at_eventstart)
Definition: oscaroutput.h:48
@ OscarInteractions
store interaction information (write_interaction)
Definition: oscaroutput.h:44
@ OscarParticlesIC
store the particles that are removed on the hypersurface
Definition: oscaroutput.h:54
@ OscarTimesteps
store the state after N timesteps (after_Nth_timestep)
Definition: oscaroutput.h:46

Function Documentation

◆ OscarOutput()

template<OscarOutputFormat Format, int Contents>
smash::OscarOutput< Format, Contents >::OscarOutput ( const std::filesystem::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

Reimplemented from 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 }
FILE * get()
Get the underlying FILE* pointer.
Definition: file.cc:27
int current_event_
Keep track of event number.
Definition: oscaroutput.h:129
void write(const Particles &particles)
Write the particle information of a list of particles to the output.
Definition: oscaroutput.cc:119
RenamingFilePtr file_
Full filepath of the output file.
Definition: oscaroutput.h:132

◆ 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

Reimplemented from 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 && !event.impose_kinematic_cut_for_SMASH_IC) {
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 }
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > logg
An array that stores all pre-configured Logger objects.
Definition: logging.cc:39
static constexpr int LHyperSurfaceCrossing
Definition: binaryoutput.cc:22

◆ 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 }
void write_particledata(const ParticleData &data)
Write single particle information line to output.
Definition: oscaroutput.cc:746
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 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_,
242  particles.size());
243  } else {
244  const size_t zero = 0;
245  std::fprintf(file_.get(), "%zu %zu %i\n", particles.size(), zero,
247  }
248  write(particles);
249  }
250 }

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

747  {
748  const FourVector pos = data.position();
749  const FourVector mom = data.momentum();
750  if (Format == OscarFormat2013) {
751  std::fprintf(file_.get(), "%g %g %g %g %g %.9g %.9g %.9g %.9g %s %i %i\n",
752  pos.x0(), pos.x1(), pos.x2(), pos.x3(), data.effective_mass(),
753  mom.x0(), mom.x1(), mom.x2(), mom.x3(),
754  data.pdgcode().string().c_str(), data.id(),
755  data.type().charge());
756  } else if (Format == OscarFormat2013Extended) {
757  const auto h = data.get_history();
758  std::fprintf(
759  file_.get(),
760  "%g %g %g %g %g %.9g %.9g %.9g"
761  " %.9g %s %i %i %i %g %g %i %i %g %s %s %i %i\n",
762  pos.x0(), pos.x1(), pos.x2(), pos.x3(), data.effective_mass(), mom.x0(),
763  mom.x1(), mom.x2(), mom.x3(), data.pdgcode().string().c_str(),
764  data.id(), data.type().charge(), h.collisions_per_particle,
765  data.formation_time(), data.xsec_scaling_factor(), h.id_process,
766  static_cast<int>(h.process_type), h.time_last_collision,
767  h.p1.string().c_str(), h.p2.string().c_str(),
768  data.type().baryon_number(), data.type().strangeness());
769  } else {
770  std::fprintf(file_.get(), "%i %s %i %g %g %g %g %g %g %g %g %g\n",
771  data.id(), data.pdgcode().string().c_str(), 0, mom.x1(),
772  mom.x2(), mom.x3(), mom.x0(), data.effective_mass(), pos.x1(),
773  pos.x2(), pos.x3(), pos.x0());
774  }
775 }

◆ 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 std::filesystem::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 811 of file oscaroutput.cc.

813  {
814  if (format != "Oscar2013" && format != "Oscar1999") {
815  throw std::invalid_argument("Creating Oscar output: unknown format");
816  }
817  const bool modern_format = (format == "Oscar2013");
818  if (content == "Particles") {
819  if (out_par.part_only_final == OutputOnlyFinal::Yes) {
820  return create_select_format<OscarParticlesAtEventend>(
821  modern_format, path, out_par, "particle_lists");
822  } else if (out_par.part_only_final == OutputOnlyFinal::IfNotEmpty) {
823  return create_select_format<OscarParticlesAtEventendIfNotEmpty>(
824  modern_format, path, out_par, "particle_lists");
825 
826  } else { // out_par.part_only_final == OutputOnlyFinal::No
829  modern_format, path, out_par, "particle_lists");
830  }
831  } else if (content == "Collisions") {
832  if (out_par.coll_printstartend) {
835  modern_format, path, out_par, "full_event_history");
836  } else {
837  return create_select_format<OscarInteractions>(
838  modern_format, path, out_par, "full_event_history");
839  }
840  } else if (content == "Dileptons") {
841  if (modern_format && out_par.dil_extended) {
842  return std::make_unique<
843  OscarOutput<OscarFormat2013Extended, OscarInteractions>>(path,
844  "Dileptons");
845  } else if (modern_format && !out_par.dil_extended) {
846  return std::make_unique<OscarOutput<OscarFormat2013, OscarInteractions>>(
847  path, "Dileptons");
848  } else if (!modern_format && !out_par.dil_extended) {
849  return std::make_unique<OscarOutput<OscarFormat1999, OscarInteractions>>(
850  path, "Dileptons");
851  } else if (!modern_format && out_par.dil_extended) {
852  logg[LOutput].warn()
853  << "Creating Oscar output: "
854  << "There is no extended Oscar1999 (dileptons) format.";
855  }
856  } else if (content == "Photons") {
857  if (modern_format && !out_par.photons_extended) {
858  return std::make_unique<OscarOutput<OscarFormat2013, OscarInteractions>>(
859  path, "Photons");
860  } else if (modern_format && out_par.photons_extended) {
861  return std::make_unique<
862  OscarOutput<OscarFormat2013Extended, OscarInteractions>>(path,
863  "Photons");
864  } else if (!modern_format && !out_par.photons_extended) {
865  return std::make_unique<OscarOutput<OscarFormat1999, OscarInteractions>>(
866  path, "Photons");
867  } else if (!modern_format && out_par.photons_extended) {
868  logg[LOutput].warn()
869  << "Creating Oscar output: "
870  << "There is no extended Oscar1999 (photons) format.";
871  }
872  } else if (content == "Initial_Conditions") {
873  if (modern_format && !out_par.ic_extended) {
874  return std::make_unique<
875  OscarOutput<OscarFormat2013, OscarParticlesIC | OscarAtEventstart>>(
876  path, "SMASH_IC");
877  } else if (modern_format && out_par.ic_extended) {
878  return std::make_unique<OscarOutput<
880  path, "SMASH_IC");
881  } else if (!modern_format && !out_par.ic_extended) {
882  return std::make_unique<
883  OscarOutput<OscarFormat1999, OscarParticlesIC | OscarAtEventstart>>(
884  path, "SMASH_IC");
885  } else if (!modern_format && out_par.ic_extended) {
886  logg[LOutput].warn()
887  << "Creating Oscar output: "
888  << "There is no extended Oscar1999 (initial conditions) format.";
889  }
890  }
891 
892  throw std::invalid_argument("Create_oscar_output got unknown content.");
893 }
@ IfNotEmpty
Print only final-state particles, and those only if the event is not empty.
@ Yes
Print only final-state particles.
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
std::unique_ptr< OutputInterface > create_select_format(bool modern_format, const std::filesystem::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:790
static constexpr int LOutput

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.