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"
93 " baryon_number strangeness\n",
97 "# Units: fm fm fm fm GeV GeV GeV GeV GeV"
98 " none none e none fm none none none fm none none none none\n");
99 std::fprintf(file_.get(),
"# %s\n", SMASH_VERSION);
101 const std::string &oscar_name =
102 name ==
"particle_lists" ?
"final_id_p_x" : name;
106 std::fprintf(file_.get(),
"# OSC1999A\n# %s\n# %s\n", oscar_name.c_str(),
108 std::fprintf(file_.get(),
"# Block format:\n");
109 std::fprintf(file_.get(),
"# nin nout event_number\n");
110 std::fprintf(file_.get(),
"# id pdg 0 px py pz p0 mass x y z t\n");
111 std::fprintf(file_.get(),
112 "# End of event: 0 0 event_number"
113 " impact_parameter\n");
114 std::fprintf(file_.get(),
"#\n");
118 template <OscarOutputFormat Format,
int Contents>
121 write_particledata(data);
125 template <OscarOutputFormat Format,
int Contents>
127 const int event_number,
129 current_event_ = event_number;
132 std::fprintf(file_.get(),
"# event %i in %zu\n", event_number,
138 const size_t zero = 0;
139 std::fprintf(file_.get(),
"%zu %zu %i\n", zero, particles.
size(),
150 template <OscarOutputFormat Format,
int Contents>
152 const int event_number,
157 std::fprintf(file_.get(),
"# event %i out %zu\n", event_number,
162 const char *empty_event_str =
event.empty_event ?
"no" :
"yes";
165 "# event %i end 0 impact %7.3f scattering_projectile_target %s\n",
171 const size_t zero = 0;
174 std::fprintf(file_.get(),
"%zu %zu %i\n", particles.
size(), zero,
179 std::fprintf(file_.get(),
"%zu %zu %i %7.3f\n", zero, zero, event_number,
183 std::fflush(file_.get());
190 "End time might be too small for initial conditions output. "
191 "Hypersurface has not yet been crossed by ",
192 particles.
size(),
" particle(s).");
197 template <OscarOutputFormat Format,
int Contents>
199 const double density) {
202 std::fprintf(file_.get(),
203 "# interaction in %zu out %zu rho %12.7f weight %12.7g"
204 " partial %12.7f type %5i\n",
208 static_cast<int>(action.
get_type()));
216 std::fprintf(file_.get(),
"%zu %zu %12.7f %12.7f %12.7f %5i\n",
220 static_cast<int>(action.
get_type()));
223 write_particledata(
p);
226 write_particledata(
p);
230 write_particledata(
p);
235 template <OscarOutputFormat Format,
int Contents>
237 const Particles &particles,
const std::unique_ptr<Clock> &,
241 std::fprintf(file_.get(),
"# event %i out %zu\n", current_event_,
244 const size_t zero = 0;
245 std::fprintf(file_.get(),
"%zu %zu %i\n", particles.
size(), zero,
745 template <OscarOutputFormat Format,
int Contents>
751 std::fprintf(file_.get(),
"%g %g %g %g %g %.9g %.9g %.9g %.9g %s %i %i\n",
753 mom.
x0(), mom.
x1(), mom.
x2(), mom.
x3(),
760 "%g %g %g %g %g %.9g %.9g %.9g"
761 " %.9g %s %i %i %i %g %g %i %i %g %s %s %i %i\n",
764 data.
id(), data.
type().
charge(), h.collisions_per_particle,
766 static_cast<int>(h.process_type), h.time_last_collision,
767 h.p1.string().c_str(), h.p2.string().c_str(),
770 std::fprintf(file_.get(),
"%i %s %i %g %g %g %g %g %g %g %g %g\n",
773 pos.
x2(), pos.
x3(), pos.
x0());
789 template <
int Contents>
791 bool modern_format,
const std::filesystem::path &path,
795 if (modern_format && extended_format) {
796 return std::make_unique<OscarOutput<OscarFormat2013Extended, Contents>>(
798 }
else if (modern_format && !extended_format) {
799 return std::make_unique<OscarOutput<OscarFormat2013, Contents>>(path, name);
800 }
else if (!modern_format && !extended_format) {
801 return std::make_unique<OscarOutput<OscarFormat1999, Contents>>(path, name);
805 <<
"There is no extended Oscar1999 format.";
806 return std::make_unique<OscarOutput<OscarFormat1999, Contents>>(path, name);
812 const std::string &
format,
const std::string &content,
815 throw std::invalid_argument(
"Creating Oscar output: unknown format");
817 const bool modern_format = (
format ==
"Oscar2013");
818 if (content ==
"Particles") {
820 return create_select_format<OscarParticlesAtEventend>(
821 modern_format, path, out_par,
"particle_lists");
823 return create_select_format<OscarParticlesAtEventendIfNotEmpty>(
824 modern_format, path, out_par,
"particle_lists");
829 modern_format, path, out_par,
"particle_lists");
831 }
else if (content ==
"Collisions") {
835 modern_format, path, out_par,
"full_event_history");
837 return create_select_format<OscarInteractions>(
838 modern_format, path, out_par,
"full_event_history");
840 }
else if (content ==
"Dileptons") {
842 return std::make_unique<
846 return std::make_unique<OscarOutput<OscarFormat2013, OscarInteractions>>(
849 return std::make_unique<OscarOutput<OscarFormat1999, OscarInteractions>>(
853 <<
"Creating Oscar output: "
854 <<
"There is no extended Oscar1999 (dileptons) format.";
856 }
else if (content ==
"Photons") {
858 return std::make_unique<OscarOutput<OscarFormat2013, OscarInteractions>>(
861 return std::make_unique<
865 return std::make_unique<OscarOutput<OscarFormat1999, OscarInteractions>>(
869 <<
"Creating Oscar output: "
870 <<
"There is no extended Oscar1999 (photons) format.";
872 }
else if (content ==
"Initial_Conditions") {
874 return std::make_unique<
881 }
else if (!modern_format && !out_par.
ic_extended) {
882 return std::make_unique<
885 }
else if (!modern_format && out_par.
ic_extended) {
887 <<
"Creating Oscar output: "
888 <<
"There is no extended Oscar1999 (initial conditions) format.";
892 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.