14 #include <boost/filesystem.hpp>
18 #include "smash/config.h"
25 template <OscarOutputFormat Format,
int Contents>
27 const std::string &name)
82 std::fprintf(file_.get(),
83 "#!OSCAR2013 %s t x y z mass "
84 "p0 px py pz pdg ID charge\n",
86 std::fprintf(file_.get(),
87 "# Units: fm fm fm fm "
88 "GeV GeV GeV GeV GeV none none e\n");
89 std::fprintf(file_.get(),
"# %s\n", VERSION_MAJOR);
91 std::fprintf(file_.get(),
92 "#!OSCAR2013Extended %s t x y z mass p0 px py pz"
93 " pdg ID charge ncoll form_time xsecfac proc_id_origin"
94 " proc_type_origin time_last_coll pdg_mother1 pdg_mother2\n",
96 std::fprintf(file_.get(),
97 "# Units: fm fm fm fm GeV GeV GeV GeV GeV"
98 " none none e none fm none none none fm none none\n");
99 std::fprintf(file_.get(),
"# %s\n", VERSION_MAJOR);
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());
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_,
244 const size_t zero = 0;
245 std::fprintf(file_.get(),
"%zu %zu %i\n", particles.
size(), zero,
704 template <OscarOutputFormat Format,
int Contents>
710 std::fprintf(file_.get(),
"%g %g %g %g %g %.9g %.9g %.9g %.9g %s %i %i\n",
712 mom.
x0(), mom.
x1(), mom.
x2(), mom.
x3(),
719 "%g %g %g %g %g %.9g %.9g %.9g"
720 " %.9g %s %i %i %i %g %g %i %i %g %s %s\n",
723 data.
id(), data.
type().
charge(), h.collisions_per_particle,
725 static_cast<int>(h.process_type), h.time_last_collision,
726 h.p1.string().c_str(), h.p2.string().c_str());
728 std::fprintf(file_.get(),
"%i %s %i %g %g %g %g %g %g %g %g %g\n",
731 pos.
x2(), pos.
x3(), pos.
x0());
747 template <
int Contents>
750 const std::string &name) {
753 if (modern_format && extended_format) {
754 return make_unique<OscarOutput<OscarFormat2013Extended, Contents>>(path,
756 }
else if (modern_format && !extended_format) {
757 return make_unique<OscarOutput<OscarFormat2013, Contents>>(path, name);
758 }
else if (!modern_format && !extended_format) {
759 return make_unique<OscarOutput<OscarFormat1999, Contents>>(path, name);
763 <<
"There is no extended Oscar1999 format.";
764 return make_unique<OscarOutput<OscarFormat1999, Contents>>(path, name);
770 const std::string &
format,
const std::string &content,
const bf::path &path,
773 throw std::invalid_argument(
"Creating Oscar output: unknown format");
775 const bool modern_format = (
format ==
"Oscar2013");
776 if (content ==
"Particles") {
778 return create_select_format<OscarParticlesAtEventend>(
779 modern_format, path, out_par,
"particle_lists");
781 return create_select_format<OscarParticlesAtEventendIfNotEmpty>(
782 modern_format, path, out_par,
"particle_lists");
787 modern_format, path, out_par,
"particle_lists");
789 }
else if (content ==
"Collisions") {
793 modern_format, path, out_par,
"full_event_history");
795 return create_select_format<OscarInteractions>(
796 modern_format, path, out_par,
"full_event_history");
798 }
else if (content ==
"Dileptons") {
804 return make_unique<OscarOutput<OscarFormat2013, OscarInteractions>>(
807 return make_unique<OscarOutput<OscarFormat1999, OscarInteractions>>(
811 <<
"Creating Oscar output: "
812 <<
"There is no extended Oscar1999 (dileptons) format.";
814 }
else if (content ==
"Photons") {
816 return make_unique<OscarOutput<OscarFormat2013, OscarInteractions>>(
823 return make_unique<OscarOutput<OscarFormat1999, OscarInteractions>>(
827 <<
"Creating Oscar output: "
828 <<
"There is no extended Oscar1999 (photons) format.";
830 }
else if (content ==
"Initial_Conditions") {
839 }
else if (!modern_format && !out_par.
ic_extended) {
843 }
else if (!modern_format && out_par.
ic_extended) {
845 <<
"Creating Oscar output: "
846 <<
"There is no extended Oscar1999 (initial conditions) format.";
850 throw std::invalid_argument(
"Create_oscar_output got unknown content.");