Version: SMASH-3.4
outputparameters.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2026
3  * SMASH Team
4  *
5  * GNU General Public License (GPLv3 or later)
6  */
7 #ifndef SRC_INCLUDE_SMASH_OUTPUTPARAMETERS_H_
8 #define SRC_INCLUDE_SMASH_OUTPUTPARAMETERS_H_
9 
10 #include <map>
11 #include <set>
12 #include <string>
13 #include <vector>
14 
15 #include "configuration.h"
16 #include "cxx17compat.h"
17 #include "density.h"
18 #include "forwarddeclarations.h"
19 #include "input_keys.h"
20 #include "logging.h"
21 
22 namespace smash {
23 static constexpr int LExperiment = LogArea::Experiment::id;
24 
25 /**
26  * Helper structure for OutputParameters in order to store and hand over Rivet
27  * parameters. OutputParameters has one member of this type.
28  */
30  /// Logging in Rivet
31  std::optional<std::map<std::string, std::string>> logs{std::nullopt};
32  /// Paths to analyses libraries and data
33  std::optional<std::vector<std::string>> paths{std::nullopt};
34  /// Data files to pre-load e.g., for centrality configurations
35  std::optional<std::vector<std::string>> preloads{std::nullopt};
36  /// Analyses (including options) to add to run
37  std::optional<std::vector<std::string>> analyses{std::nullopt};
38  /// Weights to be enabled for processing
39  std::optional<std::vector<std::string>> to_be_enabled_weights{std::nullopt};
40  /// Weights to be disabled for processing
41  std::optional<std::vector<std::string>> to_be_disabled_weights{std::nullopt};
42  /// Cross sections
43  std::optional<std::array<double, 2>> cross_sections{std::nullopt};
44  /// Nominal weight name
45  std::optional<std::string> nominal_weight_name{std::nullopt};
46  /// Cap (maximum) on weights
47  std::optional<double> cap_on_weights{std::nullopt};
48  /// How to smear for NLO calculations
49  std::optional<double> nlo_smearing{std::nullopt};
50  /// Whether Rivet should not care about multi weights
51  std::optional<bool> no_multi_weight{std::nullopt};
52  /// Whether Rivet should ignore beams
53  bool ignore_beams{true};
54  /// Whether any weight parameter was specified
56 };
57 
58 /**
59  * Helper structure for Experiment to hold output options and parameters.
60  * Experiment has one member of this struct.
61  */
63  /// Default constructor, useful for tests
67  td_rho_eckart(false),
68  td_tmn(false),
69  td_tmn_landau(false),
70  td_v_landau(false),
71  td_jQBS(false),
72  td_smearing(true),
73  td_only_participants(false),
74  td_ignore_unformed(false),
75  part_extended(false),
77  coll_extended(false),
78  coll_printstartend(false),
79  dil_extended(false),
80  photons_extended(false),
81  ic_extended(false),
83  quantities{} {}
84 
85  /// Constructor from configuration
88 
90  auto thermo_conf = conf.extract_complete_sub_configuration(
92  if (thermo_conf.has_value(InputKeys::output_thermodynamics_position)) {
93  const std::array<double, 3> a =
95  td_position = ThreeVector(a[0], a[1], a[2]);
96  }
97  std::set<ThermodynamicQuantity> quan =
100  td_tmn = (quan.count(ThermodynamicQuantity::Tmn) > 0);
103  td_jQBS = (quan.count(ThermodynamicQuantity::j_QBS) > 0);
107  logg[LExperiment].warn(
108  "Requested Thermodynamics output with Density type None. ",
109  "Change the density type to avoid output being dropped.");
110  }
116  }
117 
118  /* Unconditionally take quantities from the configuration file. This is
119  * needed because the 'Format' key in the output content sub-section is
120  * taken before this object is instantiated and that might be the only
121  * present key making the sub-section disappear before the configuration is
122  * handed over to this constructor. As a positive consequence, the
123  * quantities map has always the entry set, at least to an empty list. This
124  * is assumed elsewhere in the code and it ensured here. */
125  const auto part_quantities =
127  quantities.insert({"Particles", part_quantities});
128  const auto coll_quantities =
130  quantities.insert({"Collisions", coll_quantities});
131  const auto dil_quantities =
133  quantities.insert({"Dileptons", dil_quantities});
134  const auto photons_quantities =
136  quantities.insert({"Photons", photons_quantities});
137  const auto IC_quantities =
139  quantities.insert({"Initial_Conditions", IC_quantities});
140  /* In the same spirit, always take also other particles and collisions keys.
141  * This makes the class behaviour bounded to the key default value and not
142  * to the class member initial value. */
147 
150  }
151 
154  }
155 
158  }
159 
161  auto rivet_conf =
163  /*
164  * std::optional<T> can be assigned from a value using the
165  * template<class U = T> optional& operator=( U&& value );
166  * which is a perfect-forwarded assignment. However, in more complex cases
167  * like here where we use a Configuration::Value object returned by
168  * Configuration::take as value, it might be sometimes needed to
169  * explicitly specify the type U. It is then advantageous to use
170  * std::make_optional. When T is a built-in type, an assignment would work
171  * (although not that mentioned above), but std::make_optional also works.
172  * Note that GNU compiler has a buggy implementation of std::make_optional
173  * in versions from 8.1 till 8.3 and hence we use here make_optional and
174  * not std::make_optional. For faulty GNU versions the implementation
175  * shipped within smash namespace is then used, while in all other cases
176  * std::make_optional is used.
177  */
178  if (rivet_conf.has_value(InputKeys::output_rivet_logging)) {
180  make_optional<std::map<std::string, std::string>>(
181  rivet_conf.take(InputKeys::output_rivet_logging));
182  }
183  if (rivet_conf.has_value(InputKeys::output_rivet_paths)) {
184  rivet_parameters.paths = make_optional<std::vector<std::string>>(
185  rivet_conf.take(InputKeys::output_rivet_paths));
186  }
187  if (rivet_conf.has_value(InputKeys::output_rivet_preloads)) {
188  rivet_parameters.preloads = make_optional<std::vector<std::string>>(
189  rivet_conf.take(InputKeys::output_rivet_preloads));
190  }
191  if (rivet_conf.has_value(InputKeys::output_rivet_analyses)) {
192  rivet_parameters.analyses = make_optional<std::vector<std::string>>(
193  rivet_conf.take(InputKeys::output_rivet_analyses));
194  }
195  if (rivet_conf.has_value(InputKeys::output_rivet_crossSection)) {
196  rivet_parameters.cross_sections = make_optional<std::array<double, 2>>(
197  rivet_conf.take(InputKeys::output_rivet_crossSection));
198  }
200  rivet_conf.take(InputKeys::output_rivet_ignoreBeams);
201  if (rivet_conf.has_section(InputSections::o_r_weights)) {
203  if (rivet_conf.has_value(InputKeys::output_rivet_weights_select)) {
205  make_optional<std::vector<std::string>>(
206  rivet_conf.take(InputKeys::output_rivet_weights_select));
207  }
208  if (rivet_conf.has_value(InputKeys::output_rivet_weights_deselect)) {
210  make_optional<std::vector<std::string>>(
212  }
213  if (rivet_conf.has_value(InputKeys::output_rivet_weights_nominal)) {
214  rivet_parameters.nominal_weight_name = make_optional<std::string>(
215  rivet_conf.take(InputKeys::output_rivet_weights_nominal));
216  }
217  if (rivet_conf.has_value(InputKeys::output_rivet_weights_cap)) {
218  rivet_parameters.cap_on_weights = make_optional<double>(
219  rivet_conf.take(InputKeys::output_rivet_weights_cap));
220  }
221  if (rivet_conf.has_value(InputKeys::output_rivet_weights_nloSmearing)) {
222  rivet_parameters.nlo_smearing = make_optional<double>(
224  }
225  if (rivet_conf.has_value(InputKeys::output_rivet_weights_noMulti)) {
226  rivet_parameters.no_multi_weight = make_optional<bool>(
227  rivet_conf.take(InputKeys::output_rivet_weights_noMulti));
228  }
229  }
230  }
231  }
232 
233  /// Point, where thermodynamic quantities are calculated
235 
236  /// Type (e.g., baryon/pion/hadron) of thermodynamic quantity
238 
239  /// Print out Eckart rest frame density of type td_dens_type or not?
241 
242  /// Print out energy-momentum tensor of type td_dens_type or not?
243  bool td_tmn;
244 
245  /**
246  * Print out energy-momentum tensor in Landau rest frame
247  * (of type td_dens_type) or not?
248  */
250 
251  /// Print out Landau velocity of type td_dens_type or not?
253 
254  /// Print out QBS 4-currents or not?
255  bool td_jQBS;
256 
257  /**
258  * Whether smearing is on or off; WARNING : if smearing is off,
259  * then final result is in GeV instead of GeV/fm3
260  */
262 
263  /**
264  * Flag reporting whether only participants are considered (true) or also
265  * spectators (false)
266  */
268 
269  /**
270  * Flag reporting whether unformed particles are ignored (true) or not
271  * (false)
272  */
274 
275  /// Extended format for particles output
277 
278  /// Print only final particles in event
280 
281  /// Extended format for collisions output
283 
284  /// Print initial and final particles in event into collision output
286 
287  /// Extended format for dilepton output
289 
290  /// Extended format for photon output
292 
293  /// Extended initial conditions output
295 
296  /// Rivet specfic parameters
298 
299  /**
300  * Map of quantities to be printed in the output. Keys are the different
301  * output contents. It is initialised in a way such that it is guaranteed that
302  * an entry for every content requested by the user exists. When the user
303  * requests the output content without specifying a list of quantities, the
304  * corresponding entry in the map will be an empty vector.
305  */
306  std::map<std::string, std::vector<std::string>> quantities;
307 };
308 
309 /**
310  * Struct that holds quantities required by default output standards.
311  */
313  /// Quantities output in OSCAR2013 format
314  inline static const std::vector<std::string> oscar2013 = {
315  "t", "x", "y", "z", "mass", "p0",
316  "px", "py", "pz", "pdg", "ID", "charge"};
317  /// Quantities output in Extended OSCAR2013 format
318  inline static const std::vector<std::string> oscar2013extended = {
319  "t",
320  "x",
321  "y",
322  "z",
323  "mass",
324  "p0",
325  "px",
326  "py",
327  "pz",
328  "pdg",
329  "ID",
330  "charge",
331  "ncoll",
332  "form_time",
333  "xsecfac",
334  "proc_id_origin",
335  "proc_type_origin",
336  "time_last_coll",
337  "pdg_mother1",
338  "pdg_mother2",
339  "baryon_number",
340  "strangeness"};
341  /// Quantities output in OSCAR1999 format
342  inline static const std::vector<std::string> oscar1999 = {
343  "id", "pdg", "0", "px", "py", "pz", "p0", "mass", "x", "y", "z", "t"};
344  /// Quantities output in initial conditions format for vHLLE
345  inline static const std::vector<std::string> ic_For_vHLLE = {
346  "tau", "x", "y", "eta", "mt", "px", "py",
347  "Rap", "pdg", "charge", "baryon_number", "strangeness"};
348 };
349 
350 } // namespace smash
351 
352 #endif // SRC_INCLUDE_SMASH_OUTPUTPARAMETERS_H_
Interface to the SMASH configuration files.
bool has_section(const KeyLabels &labels) const
Return whether there is a (possibly empty) section with the given labels.
Configuration extract_complete_sub_configuration(KeyLabels section, Configuration::GetEmpty empty_if_not_existing=Configuration::GetEmpty::No)
Alternative method to extract a sub-configuration, which retains the labels from the top-level in the...
T take(const Key< T > &key)
The default interface for SMASH to read configuration values.
The ThreeVector class represents a physical three-vector with the components .
Definition: threevector.h:31
@ None
Don't use time steps; propagate from action to action.
@ EckartDensity
Density in the Eckart frame.
@ Tmn
Energy-momentum tensor in lab frame.
@ LandauVelocity
Velocity of the Landau rest frame.
@ j_QBS
Electric (Q), baryonic (B) and strange (S) currents.
@ TmnLandau
Energy-momentum tensor in Landau rest frame.
DensityType
Allows to choose which kind of density to calculate.
OutputOnlyFinal
Whether and when only final state particles should be printed.
@ Yes
Print only final-state particles.
#define SMASH_SOURCE_LOCATION
Hackery that is required to output the location in the source code where the log statement occurs.
Definition: logging.h:153
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > & logg
An array that stores all pre-configured Logger objects.
Definition: logging.h:245
constexpr Section o_rivet
Subsection for the output Rivet content.
Definition: input_keys.h:220
constexpr Section o_initialConditions
Subsection for the output initial conditions content.
Definition: input_keys.h:213
constexpr Section o_thermodynamics
Subsection for the output thermodynamics content.
Definition: input_keys.h:224
constexpr Section o_r_weights
Subsection for the output Rivet weights information.
Definition: input_keys.h:222
constexpr Section o_photons
Subsection for the output photons content.
Definition: input_keys.h:218
constexpr Section o_dileptons
Subsection for the output dileptons content.
Definition: input_keys.h:211
Definition: action.h:24
static constexpr int LExperiment
static const Key< bool > output_initialConditions_extended
See user guide description for more information.
Definition: input_keys.h:6670
static const Key< std::vector< std::string > > output_rivet_weights_select
See user guide description for more information.
Definition: input_keys.h:6980
static const Key< bool > output_rivet_weights_noMulti
See user guide description for more information.
Definition: input_keys.h:6948
static const Key< std::string > output_rivet_weights_nominal
See user guide description for more information.
Definition: input_keys.h:6964
static const Key< std::set< ThermodynamicQuantity > > output_thermodynamics_quantites
See user guide description for more information.
Definition: input_keys.h:7105
static const Key< DensityType > output_thermodynamics_type
See user guide description for more information.
Definition: input_keys.h:7167
static const Key< bool > output_rivet_ignoreBeams
See user guide description for more information.
Definition: input_keys.h:6823
static const Key< bool > output_thermodynamics_ignoreUnformed
See user guide description for more information.
Definition: input_keys.h:7058
static const Key< std::vector< std::string > > output_initialConditions_quantities
See user guide description for more information.
Definition: input_keys.h:6690
static const Key< std::vector< std::string > > output_rivet_preloads
See user guide description for more information.
Definition: input_keys.h:6877
static const Key< double > output_rivet_weights_cap
See user guide description for more information.
Definition: input_keys.h:6898
static const Key< std::vector< std::string > > output_photons_quantities
See user guide description for more information.
Definition: input_keys.h:6640
static const Key< bool > output_particles_extended
See user guide description for more information.
Definition: input_keys.h:6430
static const Key< std::array< double, 3 > > output_thermodynamics_position
See user guide description for more information.
Definition: input_keys.h:7074
static const Key< std::vector< std::string > > output_rivet_paths
See user guide description for more information.
Definition: input_keys.h:6859
static const Key< bool > output_collisions_extended
See user guide description for more information.
Definition: input_keys.h:6502
static const Key< OutputOnlyFinal > output_particles_onlyFinal
See user guide description for more information.
Definition: input_keys.h:6479
static const Key< std::vector< std::string > > output_particles_quantities
See user guide description for more information.
Definition: input_keys.h:6449
static const Key< std::vector< std::string > > output_rivet_analyses
See user guide description for more information.
Definition: input_keys.h:6789
static const Key< bool > output_dileptons_extended
See user guide description for more information.
Definition: input_keys.h:6571
static const Key< bool > output_thermodynamics_onlyParticipants
See user guide description for more information.
Definition: input_keys.h:7034
static const Key< std::array< double, 2 > > output_rivet_crossSection
See user guide description for more information.
Definition: input_keys.h:6805
static const Key< std::vector< std::string > > output_rivet_weights_deselect
See user guide description for more information.
Definition: input_keys.h:6915
static const Key< bool > output_collisions_printStartEnd
See user guide description for more information.
Definition: input_keys.h:6549
static const Key< bool > output_thermodynamics_smearing
See user guide description for more information.
Definition: input_keys.h:7145
static const Key< std::map< std::string, std::string > > output_rivet_logging
See user guide description for more information.
Definition: input_keys.h:6842
static const Key< double > output_rivet_weights_nloSmearing
See user guide description for more information.
Definition: input_keys.h:6932
static const Key< std::vector< std::string > > output_dileptons_quantities
See user guide description for more information.
Definition: input_keys.h:6590
static const Key< bool > output_photons_extended
See user guide description for more information.
Definition: input_keys.h:6621
static const Key< std::vector< std::string > > output_collisions_quantities
See user guide description for more information.
Definition: input_keys.h:6522
Struct that holds quantities required by default output standards.
static const std::vector< std::string > oscar1999
Quantities output in OSCAR1999 format.
static const std::vector< std::string > ic_For_vHLLE
Quantities output in initial conditions format for vHLLE.
static const std::vector< std::string > oscar2013
Quantities output in OSCAR2013 format.
static const std::vector< std::string > oscar2013extended
Quantities output in Extended OSCAR2013 format.
Helper structure for Experiment to hold output options and parameters.
bool dil_extended
Extended format for dilepton output.
OutputParameters()
Default constructor, useful for tests.
bool coll_extended
Extended format for collisions output.
bool part_extended
Extended format for particles output.
bool photons_extended
Extended format for photon output.
bool td_ignore_unformed
Flag reporting whether unformed particles are ignored (true) or not (false)
bool td_v_landau
Print out Landau velocity of type td_dens_type or not?
bool td_tmn_landau
Print out energy-momentum tensor in Landau rest frame (of type td_dens_type) or not?
RivetOutputParameters rivet_parameters
Rivet specfic parameters.
std::map< std::string, std::vector< std::string > > quantities
Map of quantities to be printed in the output.
bool td_jQBS
Print out QBS 4-currents or not?
OutputOnlyFinal part_only_final
Print only final particles in event.
DensityType td_dens_type
Type (e.g., baryon/pion/hadron) of thermodynamic quantity.
OutputParameters(Configuration conf)
Constructor from configuration.
bool td_tmn
Print out energy-momentum tensor of type td_dens_type or not?
bool td_smearing
Whether smearing is on or off; WARNING : if smearing is off, then final result is in GeV instead of G...
bool td_rho_eckart
Print out Eckart rest frame density of type td_dens_type or not?
bool td_only_participants
Flag reporting whether only participants are considered (true) or also spectators (false)
bool ic_extended
Extended initial conditions output.
ThreeVector td_position
Point, where thermodynamic quantities are calculated.
bool coll_printstartend
Print initial and final particles in event into collision output.
Helper structure for OutputParameters in order to store and hand over Rivet parameters.
std::optional< std::vector< std::string > > to_be_enabled_weights
Weights to be enabled for processing.
std::optional< std::string > nominal_weight_name
Nominal weight name.
std::optional< std::map< std::string, std::string > > logs
Logging in Rivet.
std::optional< std::vector< std::string > > preloads
Data files to pre-load e.g., for centrality configurations.
std::optional< std::vector< std::string > > paths
Paths to analyses libraries and data.
std::optional< double > nlo_smearing
How to smear for NLO calculations.
std::optional< std::vector< std::string > > analyses
Analyses (including options) to add to run.
bool ignore_beams
Whether Rivet should ignore beams.
std::optional< double > cap_on_weights
Cap (maximum) on weights.
std::optional< bool > no_multi_weight
Whether Rivet should not care about multi weights.
std::optional< std::vector< std::string > > to_be_disabled_weights
Weights to be disabled for processing.
bool any_weight_parameter_was_given
Whether any weight parameter was specified.
std::optional< std::array< double, 2 > > cross_sections
Cross sections.