17 #include "smash/config.h"
23 template <OscarOutputFormat Format,
int Contents>
25 const std::string &name)
80 std::fprintf(file_.get(),
81 "#!OSCAR2013 %s t x y z mass "
82 "p0 px py pz pdg ID charge\n",
84 std::fprintf(file_.get(),
85 "# Units: fm fm fm fm "
86 "GeV GeV GeV GeV GeV none none e\n");
87 std::fprintf(file_.get(),
"# %s\n", SMASH_VERSION);
89 std::fprintf(file_.get(),
90 "#!OSCAR2013Extended %s t x y z mass p0 px py pz"
91 " pdg ID charge ncoll form_time xsecfac proc_id_origin"
92 " proc_type_origin time_last_coll pdg_mother1 pdg_mother2"
95 std::fprintf(file_.get(),
96 "# Units: fm fm fm fm GeV GeV GeV GeV GeV"
97 " none none e none fm none none none fm none none none\n");
98 std::fprintf(file_.get(),
"# %s\n", SMASH_VERSION);
100 const std::string &oscar_name =
101 name ==
"particle_lists" ?
"final_id_p_x" : name;
105 std::fprintf(file_.get(),
"# OSC1999A\n# %s\n# %s\n", oscar_name.c_str(),
107 std::fprintf(file_.get(),
"# Block format:\n");
108 std::fprintf(file_.get(),
"# nin nout event_number\n");
109 std::fprintf(file_.get(),
"# id pdg 0 px py pz p0 mass x y z t\n");
110 std::fprintf(file_.get(),
111 "# End of event: 0 0 event_number"
112 " impact_parameter\n");
113 std::fprintf(file_.get(),
"#\n");
117 template <OscarOutputFormat Format,
int Contents>
120 write_particledata(data);
124 template <OscarOutputFormat Format,
int Contents>
126 const int event_number,
128 current_event_ = event_number;
131 std::fprintf(file_.get(),
"# event %i in %zu\n", event_number,
137 const size_t zero = 0;
138 std::fprintf(file_.get(),
"%zu %zu %i\n", zero, particles.
size(),
149 template <OscarOutputFormat Format,
int Contents>
151 const int event_number,
156 std::fprintf(file_.get(),
"# event %i out %zu\n", event_number,
161 const char *empty_event_str =
event.empty_event ?
"no" :
"yes";
164 "# event %i end 0 impact %7.3f scattering_projectile_target %s\n",
170 const size_t zero = 0;
173 std::fprintf(file_.get(),
"%zu %zu %i\n", particles.
size(), zero,
178 std::fprintf(file_.get(),
"%zu %zu %i %7.3f\n", zero, zero, event_number,
182 std::fflush(file_.get());
189 "End time might be too small for initial conditions output. "
190 "Hypersurface has not yet been crossed by ",
191 particles.
size(),
" particle(s).");
196 template <OscarOutputFormat Format,
int Contents>
198 const double density) {
201 std::fprintf(file_.get(),
202 "# interaction in %zu out %zu rho %12.7f weight %12.7g"
203 " partial %12.7f type %5i\n",
207 static_cast<int>(action.
get_type()));
215 std::fprintf(file_.get(),
"%zu %zu %12.7f %12.7f %12.7f %5i\n",
219 static_cast<int>(action.
get_type()));
222 write_particledata(
p);
225 write_particledata(
p);
229 write_particledata(
p);
234 template <OscarOutputFormat Format,
int Contents>
236 const Particles &particles,
const std::unique_ptr<Clock> &,
240 std::fprintf(file_.get(),
"# event %i out %zu\n", current_event_,
243 const size_t zero = 0;
244 std::fprintf(file_.get(),
"%zu %zu %i\n", particles.
size(), zero,
744 template <OscarOutputFormat Format,
int Contents>
750 std::fprintf(file_.get(),
"%g %g %g %g %g %.9g %.9g %.9g %.9g %s %i %i\n",
752 mom.
x0(), mom.
x1(), mom.
x2(), mom.
x3(),
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",
761 mom.
x0(), mom.
x1(), mom.
x2(), mom.
x3(),
763 data.
type().
charge(), h.collisions_per_particle,
765 h.id_process,
static_cast<int>(h.process_type),
766 h.time_last_collision, h.p1.string().c_str(),
769 std::fprintf(file_.get(),
"%i %s %i %g %g %g %g %g %g %g %g %g\n",
772 pos.
x2(), pos.
x3(), pos.
x0());
788 template <
int Contents>
790 bool modern_format,
const std::filesystem::path &path,
794 if (modern_format && extended_format) {
795 return std::make_unique<OscarOutput<OscarFormat2013Extended, Contents>>(
797 }
else if (modern_format && !extended_format) {
798 return std::make_unique<OscarOutput<OscarFormat2013, Contents>>(path, name);
799 }
else if (!modern_format && !extended_format) {
800 return std::make_unique<OscarOutput<OscarFormat1999, Contents>>(path, name);
804 <<
"There is no extended Oscar1999 format.";
805 return std::make_unique<OscarOutput<OscarFormat1999, Contents>>(path, name);
811 const std::string &
format,
const std::string &content,
814 throw std::invalid_argument(
"Creating Oscar output: unknown format");
816 const bool modern_format = (
format ==
"Oscar2013");
817 if (content ==
"Particles") {
819 return create_select_format<OscarParticlesAtEventend>(
820 modern_format, path, out_par,
"particle_lists");
822 return create_select_format<OscarParticlesAtEventendIfNotEmpty>(
823 modern_format, path, out_par,
"particle_lists");
828 modern_format, path, out_par,
"particle_lists");
830 }
else if (content ==
"Collisions") {
834 modern_format, path, out_par,
"full_event_history");
836 return create_select_format<OscarInteractions>(
837 modern_format, path, out_par,
"full_event_history");
839 }
else if (content ==
"Dileptons") {
841 return std::make_unique<
845 return std::make_unique<OscarOutput<OscarFormat2013, OscarInteractions>>(
848 return std::make_unique<OscarOutput<OscarFormat1999, OscarInteractions>>(
852 <<
"Creating Oscar output: "
853 <<
"There is no extended Oscar1999 (dileptons) format.";
855 }
else if (content ==
"Photons") {
857 return std::make_unique<OscarOutput<OscarFormat2013, OscarInteractions>>(
860 return std::make_unique<
864 return std::make_unique<OscarOutput<OscarFormat1999, OscarInteractions>>(
868 <<
"Creating Oscar output: "
869 <<
"There is no extended Oscar1999 (photons) format.";
871 }
else if (content ==
"Initial_Conditions") {
873 return std::make_unique<
880 }
else if (!modern_format && !out_par.
ic_extended) {
881 return std::make_unique<
884 }
else if (!modern_format && out_par.
ic_extended) {
886 <<
"Creating Oscar output: "
887 <<
"There is no extended Oscar1999 (initial conditions) format.";
891 throw std::invalid_argument(
"Create_oscar_output got unknown content.");
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.
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.
PdgCode pdgcode() const
Get the pdgcode of the particle.
const ParticleType & type() const
Get the type of the particle.
double xsec_scaling_factor(double delta_time=0.) const
Return the cross section scaling factor at a given time.
const FourVector & momentum() const
Get the particle's 4-momentum.
double formation_time() const
Get the absolute formation time of the particle.
double effective_mass() const
Get the particle's effective mass.
int32_t id() const
Get the id of the particle.
HistoryData get_history() const
Get history information.
const FourVector & position() const
Get the particle's position in Minkowski space.
int32_t charge() const
The charge of the particle.
int baryon_number() const
The Particles class abstracts the storage and manipulation of particles.
std::string string() const
@ IfNotEmpty
Print only final-state particles, and those only if the event is not empty.
@ Yes
Print only final-state particles.
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > logg
An array that stores all pre-configured Logger objects.
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...
std::unique_ptr< OutputInterface > create_oscar_output(const std::string &format, const std::string &content, const std::filesystem::path &path, const OutputParameters &out_par)
OscarOutput(const std::filesystem::path &path, const std::string &name)
Create oscar output.
@ 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)
@ OscarAtEventstart
store the state at the start of each event (at_eventstart)
@ OscarInteractions
store interaction information (write_interaction)
@ OscarParticlesIC
store the particles that are removed on the hypersurface
@ OscarTimesteps
store the state after N timesteps (after_Nth_timestep)
@ OscarFormat2013Extended
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...
static constexpr int LHyperSurfaceCrossing
static constexpr int LOutput
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.
bool dil_extended
Extended format for dilepton output.
bool coll_extended
Extended format for collisions output.
bool part_extended
Extended format for particles output.
bool photons_extended
Extended format for photon output.
OutputOnlyFinal part_only_final
Print only final particles in event.
bool ic_extended
Extended initial conditions output.
bool coll_printstartend
Print initial and final particles in event into collision output.