Version: SMASH-3.0
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 125 of file oscaroutput.cc.

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

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

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

198  {
199  if (Contents & OscarInteractions) {
200  if (Format == OscarFormat2013 || Format == OscarFormat2013Extended) {
201  std::fprintf(file_.get(),
202  "# interaction in %zu out %zu rho %12.7f weight %12.7g"
203  " partial %12.7f type %5i\n",
204  action.incoming_particles().size(),
205  action.outgoing_particles().size(), density,
206  action.get_total_weight(), action.get_partial_weight(),
207  static_cast<int>(action.get_type()));
208  } else {
209  /* OSCAR line prefix : initial final
210  * particle creation: 0 1
211  * particle 2<->2 collision: 2 2
212  * resonance formation: 2 1
213  * resonance decay: 1 2
214  * etc.*/
215  std::fprintf(file_.get(), "%zu %zu %12.7f %12.7f %12.7f %5i\n",
216  action.incoming_particles().size(),
217  action.outgoing_particles().size(), density,
218  action.get_total_weight(), action.get_partial_weight(),
219  static_cast<int>(action.get_type()));
220  }
221  for (const auto &p : action.incoming_particles()) {
223  }
224  for (const auto &p : action.outgoing_particles()) {
226  }
227  } else if (Contents & OscarParticlesIC) {
228  for (const auto &p : action.incoming_particles()) {
230  }
231  }
232 }
void write_particledata(const ParticleData &data)
Write single particle information line to output.
Definition: oscaroutput.cc:745
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 235 of file oscaroutput.cc.

237  {
238  if (Contents & OscarTimesteps) {
239  if (Format == OscarFormat2013 || Format == OscarFormat2013Extended) {
240  std::fprintf(file_.get(), "# event %i out %zu\n", current_event_,
241  particles.size());
242  } else {
243  const size_t zero = 0;
244  std::fprintf(file_.get(), "%zu %zu %i\n", particles.size(), zero,
246  }
247  write(particles);
248  }
249 }

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

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

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

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

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

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