Version: SMASH-1.5
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 61 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) 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 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...
 
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...
 

Constructor & Destructor 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.

Member Function Documentation

◆ 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 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  write(particles);
142  }
143 }
FILE * get()
Get the underlying FILE* pointer.
Definition: file.cc:27
int current_event_
Keep track of event number.
Definition: oscaroutput.h:121
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:124
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:

◆ at_eventend()

template<OscarOutputFormat Format, int Contents>
void smash::OscarOutput< Format, Contents >::at_eventend ( const Particles particles,
const int  event_number,
double  impact_parameter 
)
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.

Implements smash::OutputInterface.

Definition at line 146 of file oscaroutput.cc.

148  {
149  if (Format == OscarFormat2013 || Format == OscarFormat2013Extended) {
150  if (Contents & OscarParticlesAtEventend) {
151  std::fprintf(file_.get(), "# event %i out %zu\n", event_number + 1,
152  particles.size());
153  write(particles);
154  }
155  // Comment end of an event
156  std::fprintf(file_.get(), "# event %i end 0 impact %7.3f\n",
157  event_number + 1, impact_parameter);
158  } else {
159  /* OSCAR line prefix : initial particles; final particles; event id
160  * Last block of an event: initial = number of particles, final = 0
161  * Block ends with null interaction. */
162  const size_t zero = 0;
163  if (Contents & OscarParticlesAtEventend) {
164  std::fprintf(file_.get(), "%zu %zu %i\n", particles.size(), zero,
165  event_number + 1);
166  write(particles);
167  }
168  // Null interaction marks the end of an event
169  std::fprintf(file_.get(), "%zu %zu %i %7.3f\n", zero, zero,
170  event_number + 1, impact_parameter);
171  }
172  // Flush to disk
173  std::fflush(file_.get());
174 }
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
RenamingFilePtr file_
Full filepath of the output file.
Definition: oscaroutput.h:124
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:

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

178  {
179  if (Contents & OscarInteractions) {
180  if (Format == OscarFormat2013 || Format == OscarFormat2013Extended) {
181  std::fprintf(file_.get(),
182  "# interaction in %zu out %zu rho %12.7f weight %12.7g"
183  " partial %12.7f type %5i\n",
184  action.incoming_particles().size(),
185  action.outgoing_particles().size(), density,
186  action.get_total_weight(), action.get_partial_weight(),
187  static_cast<int>(action.get_type()));
188  } else {
189  /* OSCAR line prefix : initial final
190  * particle creation: 0 1
191  * particle 2<->2 collision: 2 2
192  * resonance formation: 2 1
193  * resonance decay: 1 2
194  * etc.*/
195  std::fprintf(file_.get(), "%zu %zu %12.7f %12.7f %12.7f %5i\n",
196  action.incoming_particles().size(),
197  action.outgoing_particles().size(), density,
198  action.get_total_weight(), action.get_partial_weight(),
199  static_cast<int>(action.get_type()));
200  }
201  for (const auto &p : action.incoming_particles()) {
203  }
204  for (const auto &p : action.outgoing_particles()) {
206  }
207  }
208 }
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:667
constexpr int p
Proton.
store interaction information (write_interaction)
Definition: oscaroutput.h:44
RenamingFilePtr file_
Full filepath of the output file.
Definition: oscaroutput.h:124
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 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 211 of file oscaroutput.cc.

212  {
213  if (Contents & OscarTimesteps) {
214  if (Format == OscarFormat2013 || Format == OscarFormat2013Extended) {
215  std::fprintf(file_.get(), "# event %i out %zu\n", current_event_ + 1,
216  particles.size());
217  } else {
218  const size_t zero = 0;
219  std::fprintf(file_.get(), "%zu %zu %i\n", particles.size(), zero,
220  current_event_ + 1);
221  }
222  write(particles);
223  }
224 }
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:121
RenamingFilePtr file_
Full filepath of the output file.
Definition: oscaroutput.h:124
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:

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

668  {
669  const FourVector pos = data.position();
670  const FourVector mom = data.momentum();
671  if (Format == OscarFormat2013) {
672  std::fprintf(file_.get(), "%g %g %g %g %g %.9g %.9g %.9g %.9g %s %i %i\n",
673  pos.x0(), pos.x1(), pos.x2(), pos.x3(), data.effective_mass(),
674  mom.x0(), mom.x1(), mom.x2(), mom.x3(),
675  data.pdgcode().string().c_str(), data.id(),
676  data.type().charge());
677  } else if (Format == OscarFormat2013Extended) {
678  const auto h = data.get_history();
679  std::fprintf(
680  file_.get(),
681  "%g %g %g %g %g %.9g %.9g %.9g"
682  " %.9g %s %i %i %i %g %g %i %i %g %s %s\n",
683  pos.x0(), pos.x1(), pos.x2(), pos.x3(), data.effective_mass(), mom.x0(),
684  mom.x1(), mom.x2(), mom.x3(), data.pdgcode().string().c_str(),
685  data.id(), data.type().charge(), h.collisions_per_particle,
686  data.formation_time(), data.xsec_scaling_factor(), h.id_process,
687  static_cast<int>(h.process_type), h.time_last_collision,
688  h.p1.string().c_str(), h.p2.string().c_str());
689  } else {
690  std::fprintf(file_.get(), "%i %s %i %g %g %g %g %g %g %g %g %g\n",
691  data.id(), data.pdgcode().string().c_str(), 0, mom.x1(),
692  mom.x2(), mom.x3(), mom.x0(), data.effective_mass(), pos.x1(),
693  pos.x2(), pos.x3(), pos.x0());
694  }
695 }
FILE * get()
Get the underlying FILE* pointer.
Definition: file.cc:27
RenamingFilePtr file_
Full filepath of the output file.
Definition: oscaroutput.h:124
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 }
void write_particledata(const ParticleData &data)
Write single particle information line to output.
Definition: oscaroutput.cc:667

Member Data 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 121 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 124 of file oscaroutput.h.


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