13 #include <boost/filesystem.hpp>
17 #include "smash/config.h"
25 static constexpr
int LOutput = LogArea::Output::id;
27 template <OscarOutputFormat Format,
int Contents>
29 const std::string &name)
84 std::fprintf(file_.get(),
85 "#!OSCAR2013 %s t x y z mass "
86 "p0 px py pz pdg ID charge\n",
88 std::fprintf(file_.get(),
89 "# Units: fm fm fm fm "
90 "GeV GeV GeV GeV GeV none none e\n");
91 std::fprintf(file_.get(),
"# %s\n", VERSION_MAJOR);
93 std::fprintf(file_.get(),
94 "#!OSCAR2013Extended %s t x y z mass p0 px py pz"
95 " pdg ID charge ncoll form_time xsecfac proc_id_origin"
96 " proc_type_origin time_last_coll pdg_mother1 pdg_mother2\n",
98 std::fprintf(file_.get(),
99 "# Units: fm fm fm fm GeV GeV GeV GeV GeV"
100 " none none e none fm none none none fm none none\n");
101 std::fprintf(file_.get(),
"# %s\n", VERSION_MAJOR);
103 const std::string &oscar_name =
104 name ==
"particle_lists" ?
"final_id_p_x" : name;
108 std::fprintf(file_.get(),
"# OSC1999A\n# %s\n# %s\n", oscar_name.c_str(),
110 std::fprintf(file_.get(),
"# Block format:\n");
111 std::fprintf(file_.get(),
"# nin nout event_number\n");
112 std::fprintf(file_.get(),
"# id pdg 0 px py pz p0 mass x y z t\n");
113 std::fprintf(file_.get(),
114 "# End of event: 0 0 event_number"
115 " impact_parameter\n");
116 std::fprintf(file_.get(),
"#\n");
120 template <OscarOutputFormat Format,
int Contents>
123 write_particledata(data);
127 template <OscarOutputFormat Format,
int Contents>
129 const int event_number) {
130 current_event_ = event_number;
133 std::fprintf(file_.get(),
"# event %i in %zu\n", event_number + 1,
139 const size_t zero = 0;
140 std::fprintf(file_.get(),
"%zu %zu %i\n", zero, particles.
size(),
151 template <OscarOutputFormat Format,
int Contents>
153 const int event_number,
154 double impact_parameter,
159 std::fprintf(file_.get(),
"# event %i out %zu\n", event_number + 1,
164 const char *empty_event_str = empty_event ?
"yes" :
"no";
165 std::fprintf(file_.get(),
"# event %i end 0 impact %7.3f empty %s\n",
166 event_number + 1, impact_parameter, empty_event_str);
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,
180 event_number + 1, impact_parameter);
183 std::fflush(file_.get());
188 if (particles.
size() != 0) {
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_ + 1,
244 const size_t zero = 0;
245 std::fprintf(file_.get(),
"%zu %zu %i\n", particles.
size(), zero,
703 template <OscarOutputFormat Format,
int Contents>
709 std::fprintf(file_.get(),
"%g %g %g %g %g %.9g %.9g %.9g %.9g %s %i %i\n",
711 mom.
x0(), mom.
x1(), mom.
x2(), mom.
x3(),
718 "%g %g %g %g %g %.9g %.9g %.9g"
719 " %.9g %s %i %i %i %g %g %i %i %g %s %s\n",
722 data.
id(), data.
type().
charge(), h.collisions_per_particle,
724 static_cast<int>(h.process_type), h.time_last_collision,
725 h.p1.string().c_str(), h.p2.string().c_str());
727 std::fprintf(file_.get(),
"%i %s %i %g %g %g %g %g %g %g %g %g\n",
730 pos.
x2(), pos.
x3(), pos.
x0());
746 template <
int Contents>
749 const std::string &name) {
752 if (modern_format && extended_format) {
753 return make_unique<OscarOutput<OscarFormat2013Extended, Contents>>(path,
755 }
else if (modern_format && !extended_format) {
756 return make_unique<OscarOutput<OscarFormat2013, Contents>>(path, name);
757 }
else if (!modern_format && !extended_format) {
758 return make_unique<OscarOutput<OscarFormat1999, Contents>>(path, name);
762 <<
"There is no extended Oscar1999 format.";
763 return make_unique<OscarOutput<OscarFormat1999, Contents>>(path, name);
769 const std::string &
format,
const std::string &content,
const bf::path &path,
772 throw std::invalid_argument(
"Creating Oscar output: unknown format");
774 const bool modern_format = (
format ==
"Oscar2013");
775 if (content ==
"Particles") {
777 return create_select_format<OscarParticlesAtEventend>(
778 modern_format, path, out_par,
"particle_lists");
780 return create_select_format<OscarParticlesAtEventendIfNotEmpty>(
781 modern_format, path, out_par,
"particle_lists");
786 modern_format, path, out_par,
"particle_lists");
788 }
else if (content ==
"Collisions") {
792 modern_format, path, out_par,
"full_event_history");
794 return create_select_format<OscarInteractions>(
795 modern_format, path, out_par,
"full_event_history");
797 }
else if (content ==
"Dileptons") {
803 return make_unique<OscarOutput<OscarFormat2013, OscarInteractions>>(
806 return make_unique<OscarOutput<OscarFormat1999, OscarInteractions>>(
810 <<
"Creating Oscar output: "
811 <<
"There is no extended Oscar1999 (dileptons) format.";
813 }
else if (content ==
"Photons") {
815 return make_unique<OscarOutput<OscarFormat2013, OscarInteractions>>(
822 return make_unique<OscarOutput<OscarFormat1999, OscarInteractions>>(
826 <<
"Creating Oscar output: "
827 <<
"There is no extended Oscar1999 (photons) format.";
829 }
else if (content ==
"Initial_Conditions") {
838 }
else if (!modern_format && !out_par.
ic_extended) {
842 }
else if (!modern_format && out_par.
ic_extended) {
844 <<
"Creating Oscar output: "
845 <<
"There is no extended Oscar1999 (initial conditions) format.";
849 throw std::invalid_argument(
"Create_oscar_output got unknown content.");