template<typename Converter, std::enable_if_t< std::is_same_v< Converter, ToASCII >||std::is_same_v< Converter, ToBinary >, bool > = true>
class smash::OutputFormatter< Converter, >
A general-purpose formatter for output, supporting both ASCII and binary formats. 
This class allows the output of particle data in a flexible and configurable manner, either in human-readable ASCII format or compact binary format. It uses a template parameter Converter to determine the desired output format, which must conform to the interface of either ToASCII or ToBinary.
New quantities can be added for output by:
- Adding their corresponding getter to the constructor, which extracts the value from a 
ParticleData instance. 
- Adding the proper key-value pair to the 
units_ map, specifying the unit of the quantity. 
- Template Parameters
 - 
  
    | Converter | The desired output format. At the moment it must be either ToASCII or ToBinary.  | 
  
   
Definition at line 179 of file outputformatter.h.
template<typename Converter , std::enable_if_t< std::is_same_v< Converter, ToASCII >||std::is_same_v< Converter, ToBinary >, bool >  = true> 
 
Creates the formatter. 
This reduces the number of literal strings flying around in the codebase, and since this is called only once per output file, in the beginning of the run, there is almost no efficiency lost compared to having fixed strings.
- Parameters
 - 
  
    | [in] | in_quantities | list of quantities to be output. | 
  
   
- Exceptions
 - 
  
    | std::invalid_argument | if the list of quantities is empty  | 
    | std::invalid_argument | if unknown quantities exist in the list  | 
    | std::invalid_argument | if incompatible quantities exist in the list  | 
    | std::invalid_argument | if there are repeated quantities  | 
  
   
Definition at line 194 of file outputformatter.h.
  198       if (quantity == 
"t") {
 
  199         getters_.push_back([
this](
const ParticleData& in) {
 
  200           return this->
converter_.as_double(in.position()[0]);
 
  202       } 
else if (quantity == 
"x") {
 
  203         getters_.push_back([
this](
const ParticleData& in) {
 
  204           return this->
converter_.as_double(in.position()[1]);
 
  206       } 
else if (quantity == 
"y") {
 
  207         getters_.push_back([
this](
const ParticleData& in) {
 
  208           return this->
converter_.as_double(in.position()[2]);
 
  210       } 
else if (quantity == 
"z") {
 
  211         getters_.push_back([
this](
const ParticleData& in) {
 
  212           return this->
converter_.as_double(in.position()[3]);
 
  214       } 
else if (quantity == 
"mass") {
 
  215         getters_.push_back([
this](
const ParticleData& in) {
 
  216           return this->
converter_.as_double(in.effective_mass());
 
  218       } 
else if (quantity == 
"p0") {
 
  219         getters_.push_back([
this](
const ParticleData& in) {
 
  220           return this->
converter_.as_precise_double(in.momentum()[0]);
 
  222       } 
else if (quantity == 
"px") {
 
  223         getters_.push_back([
this](
const ParticleData& in) {
 
  224           return this->
converter_.as_precise_double(in.momentum()[1]);
 
  226       } 
else if (quantity == 
"py") {
 
  227         getters_.push_back([
this](
const ParticleData& in) {
 
  228           return this->
converter_.as_precise_double(in.momentum()[2]);
 
  230       } 
else if (quantity == 
"pz") {
 
  231         getters_.push_back([
this](
const ParticleData& in) {
 
  232           return this->
converter_.as_precise_double(in.momentum()[3]);
 
  234       } 
else if (quantity == 
"pdg") {
 
  235         getters_.push_back([
this](
const ParticleData& in) {
 
  236           return this->
converter_.as_integer(in.pdgcode().get_decimal());
 
  238       } 
else if (quantity == 
"ID" || quantity == 
"id") {
 
  239         getters_.push_back([
this](
const ParticleData& in) {
 
  242       } 
else if (quantity == 
"charge") {
 
  243         getters_.push_back([
this](
const ParticleData& in) {
 
  244           return this->
converter_.as_integer(in.type().charge());
 
  246       } 
else if (quantity == 
"ncoll") {
 
  247         getters_.push_back([
this](
const ParticleData& in) {
 
  249               in.get_history().collisions_per_particle);
 
  251       } 
else if (quantity == 
"form_time") {
 
  252         getters_.push_back([
this](
const ParticleData& in) {
 
  253           return this->
converter_.as_double(in.formation_time());
 
  255       } 
else if (quantity == 
"xsecfac") {
 
  256         getters_.push_back([
this](
const ParticleData& in) {
 
  257           return this->
converter_.as_double(in.xsec_scaling_factor());
 
  259       } 
else if (quantity == 
"proc_id_origin") {
 
  260         getters_.push_back([
this](
const ParticleData& in) {
 
  261           return this->
converter_.as_integer(in.get_history().id_process);
 
  263       } 
else if (quantity == 
"proc_type_origin") {
 
  264         getters_.push_back([
this](
const ParticleData& in) {
 
  266               static_cast<int>(in.get_history().process_type));
 
  268       } 
else if (quantity == 
"time_last_coll") {
 
  269         getters_.push_back([
this](
const ParticleData& in) {
 
  271               in.get_history().time_last_collision);
 
  273       } 
else if (quantity == 
"pdg_mother1") {
 
  274         getters_.push_back([
this](
const ParticleData& in) {
 
  275           return this->
converter_.as_integer(in.get_history().p1.get_decimal());
 
  277       } 
else if (quantity == 
"pdg_mother2") {
 
  278         getters_.push_back([
this](
const ParticleData& in) {
 
  279           return this->
converter_.as_integer(in.get_history().p2.get_decimal());
 
  281       } 
else if (quantity == 
"baryon_number") {
 
  282         getters_.push_back([
this](
const ParticleData& in) {
 
  283           return this->
converter_.as_integer(in.pdgcode().baryon_number());
 
  285       } 
else if (quantity == 
"strangeness") {
 
  286         getters_.push_back([
this](
const ParticleData& in) {
 
  287           return this->
converter_.as_integer(in.pdgcode().strangeness());
 
  289       } 
else if (quantity == 
"0") {  
 
  290         getters_.push_back([
this]([[maybe_unused]] 
const ParticleData& in) {
 
 
 
 
template<typename Converter , std::enable_if_t< std::is_same_v< Converter, ToASCII >||std::is_same_v< Converter, ToBinary >, bool >  = true> 
 
Produces the line with formatted data for the body of the output file. 
- Parameters
 - 
  
    | [in] | p | particle whose information is to be written.  | 
  
   
- Returns
 - string with formatted data separated by a space. 
 
Definition at line 319 of file outputformatter.h.
  320     return std::accumulate(
 
  322         [&
p](
const std::string& ss, 
const auto& getter) {
 
  323           return ss.empty() ? getter(
p) : ss + 
" " + getter(
p);
 
 
 
 
template<typename Converter , std::enable_if_t< std::is_same_v< Converter, ToASCII >||std::is_same_v< Converter, ToBinary >, bool >  = true> 
 
Checks whether the quantities requested are known and unique. 
Definition at line 393 of file outputformatter.h.
  395       throw std::invalid_argument(
 
  396           "OutputFormatter: Empty quantities handed over to the class.");
 
  398     std::string error_message{};
 
  399     std::string repeated{};
 
  402         repeated += 
"'" + quantity + 
"',";
 
  405     if (!repeated.empty()) {
 
  406       error_message += 
"Repeated \"Quantities\": " + repeated +
 
  407                        " please fix the configuration file.\n";
 
  409     std::string unknown{};
 
  411       if (
units_.count(quantity) == 0) {
 
  412         unknown += 
"'" + quantity + 
"',";
 
  415     if (!unknown.empty()) {
 
  416       error_message += 
"Unknown \"Quantities\": " + unknown +
 
  417                        " please fix the configuration file.\n";
 
  419     if (!repeated.empty() || !unknown.empty())
 
  420       throw std::invalid_argument(error_message);
 
  422     const bool oscar1999_id_is_given =
 
  425     const bool oscar2013_id_is_given =
 
  428     if (oscar1999_id_is_given && oscar2013_id_is_given) {
 
  429       throw std::invalid_argument(
 
  430           "Both 'id' and 'ID' cannot be provided in the \"Quantities\" key " 
  431           "together. Please, fix the configuration file.");
 
 
 
 
template<typename Converter , std::enable_if_t< std::is_same_v< Converter, ToASCII >||std::is_same_v< Converter, ToBinary >, bool >  = true> 
 
Initial value:= {
      {"t", "fm"},
      {"x", "fm"},
      {"y", "fm"},
      {"z", "fm"},
      {"mass", "GeV"},
      {"p0", "GeV"},
      {"px", "GeV"},
      {"py", "GeV"},
      {"pz", "GeV"},
      {"pdg", "none"},
      {"ID", "none"},
      {"id", "none"},  
      {"charge", "e"},
      {"ncoll", "none"},
      {"form_time", "fm"},
      {"xsecfac", "none"},
      {"proc_id_origin", "none"},
      {"proc_type_origin", "none"},
      {"time_last_coll", "fm"},
      {"pdg_mother1", "none"},
      {"pdg_mother2", "none"},
      {"baryon_number", "none"},
      {"strangeness", "none"},
      {"0", "0"}}
 
Map with known quantities and corresponding units. 
Definition at line 366 of file outputformatter.h.