17 #include "smash/config.h"
136 const std::string &mode,
137 const std::string &name,
138 bool extended_format)
139 :
OutputInterface(name), file_{path, mode}, extended_(extended_format) {
140 std::fwrite(
"SMSH", 4, 1,
file_.
get());
142 std::uint16_t format_variant =
static_cast<uint16_t
>(
extended_);
143 write(format_variant);
144 write(SMASH_VERSION);
149 std::fwrite(&c,
sizeof(
char), 1,
file_.
get());
153 const auto size = smash::numeric_cast<uint32_t>(s.size());
154 std::fwrite(&size,
sizeof(std::uint32_t), 1,
file_.
get());
155 std::fwrite(s.c_str(), s.size(), 1,
file_.
get());
159 std::fwrite(&x,
sizeof(x), 1,
file_.
get());
167 for (
const auto &
p : particles) {
173 for (
const auto &
p : particles) {
180 double mass =
p.effective_mass();
181 std::fwrite(&mass,
sizeof(mass), 1,
file_.
get());
183 write(
p.pdgcode().get_decimal());
187 const auto history =
p.get_history();
188 write(history.collisions_per_particle);
189 write(
p.formation_time());
190 write(
p.xsec_scaling_factor());
191 write(history.id_process);
192 write(
static_cast<int32_t
>(history.process_type));
193 write(history.time_last_collision);
194 write(history.p1.get_decimal());
195 write(history.p2.get_decimal());
196 write(
p.type().baryon_number());
201 const std::filesystem::path &path, std::string name,
204 path / ((name ==
"Collisions" ?
"collisions_binary" : name) +
".bin"),
205 "wb", name, out_par.get_coll_extended(name)),
206 print_start_end_(out_par.coll_printstartend) {}
210 const char pchar =
'p';
212 std::fwrite(&pchar,
sizeof(
char), 1,
file_.
get());
219 const int32_t event_number,
221 const char pchar =
'p';
223 std::fwrite(&pchar,
sizeof(
char), 1,
file_.
get());
229 const char fchar =
'f';
230 std::fwrite(&fchar,
sizeof(
char), 1,
file_.
get());
233 const char empty =
event.empty_event;
241 const double density) {
242 const char ichar =
'i';
243 std::fwrite(&ichar,
sizeof(
char), 1,
file_.
get());
246 std::fwrite(&density,
sizeof(
double), 1,
file_.
get());
248 std::fwrite(&weight,
sizeof(
double), 1,
file_.
get());
250 std::fwrite(&partial_weight,
sizeof(
double), 1,
file_.
get());
251 const auto type =
static_cast<uint32_t
>(action.
get_type());
252 std::fwrite(&type,
sizeof(uint32_t), 1,
file_.
get());
261 out_par.part_extended),
262 only_final_(out_par.part_only_final) {}
266 const char pchar =
'p';
268 std::fwrite(&pchar,
sizeof(
char), 1,
file_.
get());
275 const int event_number,
277 const char pchar =
'p';
279 std::fwrite(&pchar,
sizeof(
char), 1,
file_.
get());
285 const char fchar =
'f';
286 std::fwrite(&fchar,
sizeof(
char), 1,
file_.
get());
289 const char empty =
event.empty_event;
297 const std::unique_ptr<Clock> &,
300 const char pchar =
'p';
302 std::fwrite(&pchar,
sizeof(
char), 1,
file_.
get());
309 const std::filesystem::path &path, std::string name,
311 :
BinaryOutputBase(path /
"SMASH_IC.bin",
"wb", name, out_par.ic_extended) {
318 const int event_number,
321 const char fchar =
'f';
322 std::fwrite(&fchar,
sizeof(
char), 1,
file_.
get());
325 const char empty =
event.empty_event;
335 "End time might be too small for initial conditions output. "
336 "Hypersurface has not yet been crossed by ",
337 particles.
size(),
" particle(s).");
344 const char pchar =
'p';
345 std::fwrite(&pchar,
sizeof(
char), 1,
file_.
get());
Action is the base class for a generic process that takes a number of incoming particles and transfor...
virtual ProcessType get_type() const
Get the process type.
virtual double get_total_weight() const =0
Return the total weight value, which is mainly used for the weight output entry.
const ParticleList & incoming_particles() const
Get the list of particles that go into the action.
virtual double get_partial_weight() const =0
Return the specific weight for the chosen outgoing channel, which is mainly used for the partial weig...
const ParticleList & outgoing_particles() const
Get the list of particles that resulted from the action.
Base class for SMASH binary output.
BinaryOutputBase(const std::filesystem::path &path, const std::string &mode, const std::string &name, bool extended_format)
Create binary output base.
bool extended_
Option for extended output.
void write(const char c)
Write byte to binary output.
void write_particledata(const ParticleData &p)
Write particle data to binary output.
const uint16_t format_version_
Binary file format version number.
RenamingFilePtr file_
Binary particles output file path.
void at_interaction(const Action &action, const double density) override
Writes an interaction block, including information about the incoming and outgoing particles,...
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.
bool print_start_end_
Write initial and final particles additonally to collisions?
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.
BinaryOutputCollisions(const std::filesystem::path &path, std::string name, const OutputParameters &out_par)
Create binary particle output.
void at_eventstart(const Particles &, const int, const EventInfo &) override
Writes the initial particle information of an event to the binary output.
void at_interaction(const Action &action, const double) override
Writes particles that are removed when crossing the hypersurface to the output.
void at_eventend(const Particles &particles, const int event_number, const EventInfo &event) override
Writes the final particle information of an event to the binary output.
BinaryOutputInitialConditions(const std::filesystem::path &path, std::string name, const OutputParameters &out_par)
Create binary initial conditions particle output.
void at_eventstart(const Particles &particles, const int event_number, const EventInfo &event) override
Writes the initial particle information of an event to the binary output.
OutputOnlyFinal only_final_
Whether final- or initial-state particles should be written.
void at_intermediate_time(const Particles &particles, const std::unique_ptr< Clock > &clock, const DensityParameters &dens_param, const EventInfo &event) override
Writes particles at each time interval; fixed by option OUTPUT_INTERVAL.
BinaryOutputParticles(const std::filesystem::path &path, std::string name, const OutputParameters &out_par)
Create binary particle output.
void at_eventend(const Particles &particles, const int event_number, const EventInfo &event) override
Writes the final particle information of an event to the binary output.
A class to pre-calculate and store parameters relevant for density calculation.
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
Abstraction of generic output.
ParticleData contains the dynamic information of a certain particle.
The Particles class abstracts the storage and manipulation of particles.
FILE * get()
Get the underlying FILE* pointer.
@ IfNotEmpty
Print only final-state particles, and those only if the event is not empty.
@ No
Print initial, intermediate and final-state particles.
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > logg
An array that stores all pre-configured Logger objects.
static constexpr int LHyperSurfaceCrossing
@ HyperSurfaceCrossing
See here for a short description.
Structure to contain custom data for output.
bool empty_event
True if no collisions happened.
bool impose_kinematic_cut_for_SMASH_IC
Whether or not kinematic cuts are employed for SMASH IC.
double impact_parameter
Impact parameter for collider modus, otherwise dummy.
Helper structure for Experiment to hold output options and parameters.