13 #include <boost/filesystem.hpp> 17 #include "smash/config.h" 25 template <OscarOutputFormat Format,
int Contents>
27 const std::string &name)
28 : OutputInterface(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) {
128 current_event_ = event_number;
131 std::fprintf(file_.get(),
"# event %i in %zu\n", event_number + 1,
137 const size_t zero = 0;
138 std::fprintf(file_.get(),
"%zu %zu %i\n", zero, particles.
size(),
145 template <OscarOutputFormat Format,
int Contents>
147 const int event_number,
148 double impact_parameter) {
151 std::fprintf(file_.get(),
"# event %i out %zu\n", event_number + 1,
156 std::fprintf(file_.get(),
"# event %i end 0 impact %7.3f\n",
157 event_number + 1, impact_parameter);
162 const size_t zero = 0;
164 std::fprintf(file_.get(),
"%zu %zu %i\n", particles.
size(), zero,
169 std::fprintf(file_.get(),
"%zu %zu %i %7.3f\n", zero, zero,
170 event_number + 1, impact_parameter);
173 std::fflush(file_.get());
176 template <OscarOutputFormat Format,
int Contents>
178 const double density) {
181 std::fprintf(file_.get(),
182 "# interaction in %zu out %zu rho %12.7f weight %12.7g" 183 " partial %12.7f type %5i\n",
187 static_cast<int>(action.
get_type()));
195 std::fprintf(file_.get(),
"%zu %zu %12.7f %12.7f %12.7f %5i\n",
199 static_cast<int>(action.
get_type()));
202 write_particledata(
p);
205 write_particledata(
p);
210 template <OscarOutputFormat Format,
int Contents>
215 std::fprintf(file_.get(),
"# event %i out %zu\n", current_event_ + 1,
218 const size_t zero = 0;
219 std::fprintf(file_.get(),
"%zu %zu %i\n", particles.
size(), zero,
669 template <OscarOutputFormat Format,
int Contents>
675 std::fprintf(file_.get(),
"%g %g %g %g %g %.9g %.9g %.9g %.9g %s %i %i\n",
677 mom.
x0(), mom.
x1(), mom.
x2(), mom.
x3(),
684 "%g %g %g %g %g %.9g %.9g %.9g" 685 " %.9g %s %i %i %i %g %g %i %i %g %s %s\n",
688 data.
id(), data.
type().
charge(), h.collisions_per_particle,
690 static_cast<int>(h.process_type), h.time_last_collision,
691 h.p1.string().c_str(), h.p2.string().c_str());
693 std::fprintf(file_.get(),
"%i %s %i %g %g %g %g %g %g %g %g %g\n",
696 pos.
x2(), pos.
x3(), pos.
x0());
712 template <
int Contents>
715 const std::string &name) {
716 const auto &log = logger<LogArea::Output>();
719 if (modern_format && extended_format) {
720 return make_unique<OscarOutput<OscarFormat2013Extended, Contents>>(path,
722 }
else if (modern_format && !extended_format) {
723 return make_unique<OscarOutput<OscarFormat2013, Contents>>(path, name);
724 }
else if (!modern_format && !extended_format) {
725 return make_unique<OscarOutput<OscarFormat1999, Contents>>(path, name);
728 log.warn() <<
"Creating Oscar output: " 729 <<
"There is no extended Oscar1999 format.";
730 return make_unique<OscarOutput<OscarFormat1999, Contents>>(path, name);
736 const std::string &
format,
const std::string &content,
const bf::path &path,
738 const auto &log = logger<LogArea::Output>();
739 if (format !=
"Oscar2013" && format !=
"Oscar1999") {
740 throw std::invalid_argument(
"Creating Oscar output: unknown format");
742 const bool modern_format = (format ==
"Oscar2013");
743 if (content ==
"Particles") {
745 return create_select_format<OscarParticlesAtEventend>(
746 modern_format, path, out_par,
"particle_lists");
750 modern_format, path, out_par,
"particle_lists");
752 }
else if (content ==
"Collisions") {
756 modern_format, path, out_par,
"full_event_history");
758 return create_select_format<OscarInteractions>(
759 modern_format, path, out_par,
"full_event_history");
761 }
else if (content ==
"Dileptons") {
767 return make_unique<OscarOutput<OscarFormat2013, OscarInteractions>>(
770 return make_unique<OscarOutput<OscarFormat1999, OscarInteractions>>(
773 log.warn() <<
"Creating Oscar output: " 774 <<
"There is no extended Oscar1999 (dileptons) format.";
776 }
else if (content ==
"Photons") {
778 return make_unique<OscarOutput<OscarFormat2013, OscarInteractions>>(
785 return make_unique<OscarOutput<OscarFormat1999, OscarInteractions>>(
788 log.warn() <<
"Creating Oscar output: " 789 <<
"There is no extended Oscar1999 (photons) format.";
793 throw std::invalid_argument(
"Create_oscar_output got unknown content.");
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...
store the state at the end of each event (at_eventend)
double formation_time() const
Get the absolute formation time of the particle.
A class to pre-calculate and store parameters relevant for density calculation.
PdgCode pdgcode() const
Get the pdgcode of the particle.
void at_eventend(const Particles &particles, const int event_number, double impact_parameter) override
Writes the final particle information of an event to the oscar output.
std::unique_ptr< T > make_unique(Args &&...args)
Definition for make_unique Is in C++14's standard library; necessary for older compilers.
const FourVector & position() const
Get the particle's position in Minkowski space.
bool part_extended
Extended format for particles output.
virtual double get_partial_weight() const =0
Return the specific weight for the chosen outgoing channel, which is mainly used for the partial weig...
virtual ProcessType get_type() const
Get the process type.
void write_particledata(const ParticleData &data)
Write single particle information line to output.
double effective_mass() const
Get the particle's effective mass.
void at_intermediate_time(const Particles &particles, const Clock &clock, const DensityParameters &dens_param) override
Writes a prefix line then write out all current particles.
bool coll_printstartend
Print initial and final particles in event into collision output.
std::unique_ptr< OutputInterface > create_oscar_output(const std::string &format, const std::string &content, const bf::path &path, const OutputParameters &out_par)
HistoryData get_history() const
Get history information.
store the state after N timesteps (after_Nth_timestep)
double xsec_scaling_factor(double delta_time=0.) const
Return the cross section scaling factor at a given time.
bool photons_extended
Extended format for photon output.
bool part_only_final
Print only final particles in event.
bool coll_extended
Extended format for collisions output.
OscarOutput(const bf::path &path, const std::string &name)
Create oscar output.
Helper structure for Experiment to hold output options and parameters.
const ParticleType & type() const
Get the type of the particle.
Clock tracks the time in the simulation.
Action is the base class for a generic process that takes a number of incoming particles and transfor...
virtual double get_total_weight() const =0
Return the total weight value, which is mainly used for the weight output entry.
int32_t charge() const
The charge of the particle.
void at_eventstart(const Particles &particles, const int event_number) override
Writes the initial particle information of an event to the oscar output.
bool dil_extended
Extended format for dilepton output.
store the state at the start of each event (at_eventstart)
void at_interaction(const Action &action, const double density) override
Writes a interaction prefix line and a line for every incoming and outgoing particle to the oscar out...
std::unique_ptr< OutputInterface > create_select_format(bool modern_format, const bf::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...
store interaction information (write_interaction)
const ParticleList & incoming_particles() const
Get the list of particles that go into the action.
The Particles class abstracts the storage and manipulation of particles.
const ParticleList & outgoing_particles() const
Get the list of particles that resulted from the action.
int32_t id() const
Get the id of the particle.
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
void write(const Particles &particles)
Write the particle information of a list of particles to the output.
ParticleData contains the dynamic information of a certain particle.
const FourVector & momentum() const
Get the particle's 4-momentum.
std::string string() const