Version: SMASH-1.7
smash::OscarOutput< Format, Contents > Class Template Reference

#include <oscaroutput.h>

template<OscarOutputFormat Format, int Contents>
class smash::OscarOutput< Format, Contents >

Template Parameters
FormatDetermines the variant of OSCAR formatting that is used. See OscarOutputFormat.
ContentsDetermines what information will be written to file. This integer is a bitflag that can be constructed from ORing enumerators from OscarOutputContents together.

Definition at line 63 of file oscaroutput.h.

Inheritance diagram for smash::OscarOutput< Format, Contents >:
[legend]
Collaboration diagram for smash::OscarOutput< Format, Contents >:
[legend]

Public Member Functions

 OscarOutput (const bf::path &path, const std::string &name)
 Create oscar output. More...
 
void at_eventstart (const Particles &particles, const int event_number) override
 Writes the initial particle information of an event to the oscar output. More...
 
void 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 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 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...
 
- Public Member Functions inherited from smash::OutputInterface
 OutputInterface (std::string name)
 Construct output interface. More...
 
virtual ~OutputInterface ()=default
 
virtual void thermodynamics_output (const ThermodynamicQuantity tq, const DensityType dt, RectangularLattice< DensityOnLattice > &lattice)
 Output to write thermodynamics from the lattice. More...
 
virtual void thermodynamics_output (const ThermodynamicQuantity tq, const DensityType dt, RectangularLattice< EnergyMomentumTensor > &lattice)
 Output to write energy-momentum tensor and related quantities from the lattice. More...
 
virtual void thermodynamics_output (const GrandCanThermalizer &gct)
 Output to write energy-momentum tensor and related quantities from the thermalizer class. More...
 
bool is_dilepton_output () const
 Get, whether this is the dilepton output? More...
 
bool is_photon_output () const
 Get, whether this is the photon output? More...
 
bool is_IC_output () const
 Get, whether this is the IC output? More...
 
const char * to_string (const ThermodynamicQuantity tq)
 Convert thermodynamic quantities to strings. More...
 
const char * to_string (const DensityType dens_type)
 Convert density types to strings. More...
 

Private Member Functions

void write_particledata (const ParticleData &data)
 Write single particle information line to output. More...
 
void write (const Particles &particles)
 Write the particle information of a list of particles to the output. More...
 

Private Attributes

int current_event_ = 0
 Keep track of event number. More...
 
RenamingFilePtr file_
 Full filepath of the output file. More...
 

Additional Inherited Members

- Protected Attributes inherited from smash::OutputInterface
const bool is_dilepton_output_
 Is this the dilepton output? More...
 
const bool is_photon_output_
 Is this the photon output? More...
 
const bool is_IC_output_
 Is this the IC output? More...
 

Constructor & Destructor Documentation

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.

Member Function Documentation

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 126 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 + 1,
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 + 1);
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:126
store the particles that are removed on the hypersurface
Definition: oscaroutput.h:52
store the state at the start of each event (at_eventstart)
Definition: oscaroutput.h:48
RenamingFilePtr file_
Full filepath of the output file.
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

Here is the call graph for this function:

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

153  {
154  if (Format == OscarFormat2013 || Format == OscarFormat2013Extended) {
155  if (Contents & OscarParticlesAtEventend) {
156  std::fprintf(file_.get(), "# event %i out %zu\n", event_number + 1,
157  particles.size());
158  write(particles);
159  }
160  // Comment end of an event
161  const char *empty_event_str = empty_event ? "yes" : "no";
162  std::fprintf(file_.get(), "# event %i end 0 impact %7.3f empty %s\n",
163  event_number + 1, impact_parameter, empty_event_str);
164  } else {
165  /* OSCAR line prefix : initial particles; final particles; event id
166  * Last block of an event: initial = number of particles, final = 0
167  * Block ends with null interaction. */
168  const size_t zero = 0;
169  if (Contents & OscarParticlesAtEventend) {
170  std::fprintf(file_.get(), "%zu %zu %i\n", particles.size(), zero,
171  event_number + 1);
172  write(particles);
173  }
174  // Null interaction marks the end of an event
175  std::fprintf(file_.get(), "%zu %zu %i %7.3f\n", zero, zero,
176  event_number + 1, impact_parameter);
177  }
178  // Flush to disk
179  std::fflush(file_.get());
180 
181  if (Contents == OscarParticlesIC) {
182  const auto &log = logger<LogArea::HyperSurfaceCrossing>();
183  // If the runtime is too short some particles might not yet have
184  // reached the hypersurface. Warning is printed.
185  if (particles.size() != 0) {
186  log.warn(
187  "End time might be too small for initial conditions output. "
188  "Hypersurface has not yet been crossed by ",
189  particles.size(), " particle(s).");
190  }
191  }
192 }
store the state at the end of each event (at_eventend)
Definition: oscaroutput.h:50
FILE * get()
Get the underlying FILE* pointer.
Definition: file.cc:27
store the particles that are removed on the hypersurface
Definition: oscaroutput.h:52
RenamingFilePtr file_
Full filepath of the output file.
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

Here is the call graph for this function:

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

196  {
197  if (Contents & OscarInteractions) {
198  if (Format == OscarFormat2013 || Format == OscarFormat2013Extended) {
199  std::fprintf(file_.get(),
200  "# interaction in %zu out %zu rho %12.7f weight %12.7g"
201  " partial %12.7f type %5i\n",
202  action.incoming_particles().size(),
203  action.outgoing_particles().size(), density,
204  action.get_total_weight(), action.get_partial_weight(),
205  static_cast<int>(action.get_type()));
206  } else {
207  /* OSCAR line prefix : initial final
208  * particle creation: 0 1
209  * particle 2<->2 collision: 2 2
210  * resonance formation: 2 1
211  * resonance decay: 1 2
212  * etc.*/
213  std::fprintf(file_.get(), "%zu %zu %12.7f %12.7f %12.7f %5i\n",
214  action.incoming_particles().size(),
215  action.outgoing_particles().size(), density,
216  action.get_total_weight(), action.get_partial_weight(),
217  static_cast<int>(action.get_type()));
218  }
219  for (const auto &p : action.incoming_particles()) {
221  }
222  for (const auto &p : action.outgoing_particles()) {
224  }
225  } else if (Contents == OscarParticlesIC) {
226  for (const auto &p : action.incoming_particles()) {
228  }
229  }
230 }
FILE * get()
Get the underlying FILE* pointer.
Definition: file.cc:27
void write_particledata(const ParticleData &data)
Write single particle information line to output.
Definition: oscaroutput.cc:700
store the particles that are removed on the hypersurface
Definition: oscaroutput.h:52
constexpr int p
Proton.
store interaction information (write_interaction)
Definition: oscaroutput.h:44
RenamingFilePtr file_
Full filepath of the output file.
Definition: oscaroutput.h:129

Here is the call graph for this function:

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

235  {
236  if (Contents & OscarTimesteps) {
237  if (Format == OscarFormat2013 || Format == OscarFormat2013Extended) {
238  std::fprintf(file_.get(), "# event %i out %zu\n", current_event_ + 1,
239  particles.size());
240  } else {
241  const size_t zero = 0;
242  std::fprintf(file_.get(), "%zu %zu %i\n", particles.size(), zero,
243  current_event_ + 1);
244  }
245  write(particles);
246  }
247 }
FILE * get()
Get the underlying FILE* pointer.
Definition: file.cc:27
store the state after N timesteps (after_Nth_timestep)
Definition: oscaroutput.h:46
int current_event_
Keep track of event number.
Definition: oscaroutput.h:126
RenamingFilePtr file_
Full filepath of the output file.
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

Here is the call graph for this function:

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

701  {
702  const FourVector pos = data.position();
703  const FourVector mom = data.momentum();
704  if (Format == OscarFormat2013) {
705  std::fprintf(file_.get(), "%g %g %g %g %g %.9g %.9g %.9g %.9g %s %i %i\n",
706  pos.x0(), pos.x1(), pos.x2(), pos.x3(), data.effective_mass(),
707  mom.x0(), mom.x1(), mom.x2(), mom.x3(),
708  data.pdgcode().string().c_str(), data.id(),
709  data.type().charge());
710  } else if (Format == OscarFormat2013Extended) {
711  const auto h = data.get_history();
712  std::fprintf(
713  file_.get(),
714  "%g %g %g %g %g %.9g %.9g %.9g"
715  " %.9g %s %i %i %i %g %g %i %i %g %s %s\n",
716  pos.x0(), pos.x1(), pos.x2(), pos.x3(), data.effective_mass(), mom.x0(),
717  mom.x1(), mom.x2(), mom.x3(), data.pdgcode().string().c_str(),
718  data.id(), data.type().charge(), h.collisions_per_particle,
719  data.formation_time(), data.xsec_scaling_factor(), h.id_process,
720  static_cast<int>(h.process_type), h.time_last_collision,
721  h.p1.string().c_str(), h.p2.string().c_str());
722  } else {
723  std::fprintf(file_.get(), "%i %s %i %g %g %g %g %g %g %g %g %g\n",
724  data.id(), data.pdgcode().string().c_str(), 0, mom.x1(),
725  mom.x2(), mom.x3(), mom.x0(), data.effective_mass(), pos.x1(),
726  pos.x2(), pos.x3(), pos.x0());
727  }
728 }
FILE * get()
Get the underlying FILE* pointer.
Definition: file.cc:27
RenamingFilePtr file_
Full filepath of the output file.
Definition: oscaroutput.h:129

Here is the call graph for this function:

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 }
void write_particledata(const ParticleData &data)
Write single particle information line to output.
Definition: oscaroutput.cc:700

Member Data Documentation

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

Keep track of event number.

Definition at line 126 of file oscaroutput.h.

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

Full filepath of the output file.

Definition at line 129 of file oscaroutput.h.


The documentation for this class was generated from the following files: