Version: SMASH-2.0
smash::BinaryOutputCollisions Class Reference

#include <binaryoutput.h>

Saves SMASH collision history to binary file.

This class writes each collision, decay and box wall crossing to the output file. Optionally, one can also write the initial and final particle lists to the same file. The output file is binary and has a block structure.

Details of the output format can be found on the wiki in the User Guide section, look for binary output.

Definition at line 136 of file binaryoutput.h.

Inheritance diagram for smash::BinaryOutputCollisions:
[legend]
Collaboration diagram for smash::BinaryOutputCollisions:
[legend]

Public Member Functions

 BinaryOutputCollisions (const bf::path &path, std::string name, const OutputParameters &out_par)
 Create binary particle output. More...
 
void at_eventstart (const Particles &particles, const int event_number, const EventInfo &event) override
 Writes the initial particle information list of an event to the binary output. More...
 
void at_eventend (const Particles &particles, const int32_t event_number, const EventInfo &event) override
 Writes the final particle information list of an event to the binary output. More...
 
void at_interaction (const Action &action, const double density) override
 Writes an interaction block, including information about the incoming and outgoing particles, to the binary output. More...
 
- Public Member Functions inherited from smash::OutputInterface
 OutputInterface (std::string name)
 Construct output interface. More...
 
virtual ~OutputInterface ()=default
 
virtual void at_eventend (const Particles &particles, const int event_number, const EventInfo &info)=0
 Output launched at event end. More...
 
virtual void at_intermediate_time (const Particles &particles, const std::unique_ptr< Clock > &clock, const DensityParameters &dens_param, const EventInfo &info)
 Output launched after every N'th timestep. More...
 
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 Attributes

bool print_start_end_
 Write initial and final particles additonally to collisions? More...
 

Additional Inherited Members

- Protected Member Functions inherited from smash::BinaryOutputBase
 BinaryOutputBase (const bf::path &path, const std::string &mode, const std::string &name, bool extended_format)
 Create binary output base. More...
 
void write (const char c)
 Write byte to binary output. More...
 
void write (const std::string &s)
 Write string to binary output. More...
 
void write (const double x)
 Write double to binary output. More...
 
void write (const FourVector &v)
 Write four-vector to binary output. More...
 
void write (const std::int32_t x)
 Write integer (32 bit) to binary output. More...
 
void write (const std::uint32_t x)
 Write unsigned integer (32 bit) to binary output. More...
 
void write (const std::uint16_t x)
 Write unsigned integer (16 bit) to binary output. More...
 
void write (const size_t x)
 Write a std::size_t to binary output. More...
 
void write (const Particles &particles)
 Write particle data of each particle in particles to binary output. More...
 
void write (const ParticleList &particles)
 Write each particle data entry to binary output. More...
 
void write_particledata (const ParticleData &p)
 Write particle data to binary output. More...
 
- Protected Attributes inherited from smash::BinaryOutputBase
RenamingFilePtr file_
 Binary particles output file path. More...
 
- 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

◆ BinaryOutputCollisions()

smash::BinaryOutputCollisions::BinaryOutputCollisions ( const bf::path &  path,
std::string  name,
const OutputParameters out_par 
)

Create binary particle output.

Parameters
[in]pathOutput path.
[in]nameName of the output.
[in]out_parA structure containing parameters of the output.

Definition at line 198 of file binaryoutput.cc.

202  path / ((name == "Collisions" ? "collisions_binary" : name) + ".bin"),
203  "wb", name, out_par.get_coll_extended(name)),
204  print_start_end_(out_par.coll_printstartend) {}

Member Function Documentation

◆ at_eventstart()

void smash::BinaryOutputCollisions::at_eventstart ( const Particles particles,
const int  event_number,
const EventInfo event 
)
overridevirtual

Writes the initial particle information list of an event to the binary output.

Parameters
[in]particlesCurrent list of all particles.
[in]event_numberUnused, needed since inherited.
[in]eventEvent info, see event_info

Implements smash::OutputInterface.

Definition at line 206 of file binaryoutput.cc.

207  {
208  const char pchar = 'p';
209  if (print_start_end_) {
210  std::fwrite(&pchar, sizeof(char), 1, file_.get());
211  write(particles.size());
212  write(particles);
213  }
214 }
Here is the call graph for this function:

◆ at_eventend()

void smash::BinaryOutputCollisions::at_eventend ( const Particles particles,
const int32_t  event_number,
const EventInfo event 
)
override

Writes the final particle information list of an event to the binary output.

Parameters
[in]particlesCurrent list of particles.
[in]event_numberNumber of event.
[in]eventEvent info, see event_info

Definition at line 216 of file binaryoutput.cc.

218  {
219  const char pchar = 'p';
220  if (print_start_end_) {
221  std::fwrite(&pchar, sizeof(char), 1, file_.get());
222  write(particles.size());
223  write(particles);
224  }
225 
226  // Event end line
227  const char fchar = 'f';
228  std::fwrite(&fchar, sizeof(char), 1, file_.get());
229  write(event_number);
230  write(event.impact_parameter);
231  const char empty = event.empty_event;
232  write(empty);
233 
234  // Flush to disk
235  std::fflush(file_.get());
236 }
Here is the call graph for this function:

◆ at_interaction()

void smash::BinaryOutputCollisions::at_interaction ( const Action action,
const double  density 
)
overridevirtual

Writes an interaction block, including information about the incoming and outgoing particles, to the binary output.

Parameters
[in]actionAction that holds the information of the interaction.
[in]densityDensity at the interaction point.

Reimplemented from smash::OutputInterface.

Definition at line 238 of file binaryoutput.cc.

239  {
240  const char ichar = 'i';
241  std::fwrite(&ichar, sizeof(char), 1, file_.get());
242  write(action.incoming_particles().size());
243  write(action.outgoing_particles().size());
244  std::fwrite(&density, sizeof(double), 1, file_.get());
245  const double weight = action.get_total_weight();
246  std::fwrite(&weight, sizeof(double), 1, file_.get());
247  const double partial_weight = action.get_partial_weight();
248  std::fwrite(&partial_weight, sizeof(double), 1, file_.get());
249  const auto type = static_cast<uint32_t>(action.get_type());
250  std::fwrite(&type, sizeof(uint32_t), 1, file_.get());
251  write(action.incoming_particles());
252  write(action.outgoing_particles());
253 }
Here is the call graph for this function:

Member Data Documentation

◆ print_start_end_

bool smash::BinaryOutputCollisions::print_start_end_
private

Write initial and final particles additonally to collisions?

Definition at line 178 of file binaryoutput.h.


The documentation for this class was generated from the following files:
smash::BinaryOutputBase::BinaryOutputBase
BinaryOutputBase(const bf::path &path, const std::string &mode, const std::string &name, bool extended_format)
Create binary output base.
Definition: binaryoutput.cc:134
smash::RenamingFilePtr::get
FILE * get()
Get the underlying FILE* pointer.
Definition: file.cc:27
smash::BinaryOutputBase::file_
RenamingFilePtr file_
Binary particles output file path.
Definition: binaryoutput.h:115
smash::BinaryOutputBase::write
void write(const char c)
Write byte to binary output.
Definition: binaryoutput.cc:147
smash::BinaryOutputCollisions::print_start_end_
bool print_start_end_
Write initial and final particles additonally to collisions?
Definition: binaryoutput.h:178