Version: SMASH-3.1
outputparameters.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2023
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 "logging.h"
20 
21 namespace smash {
22 static constexpr int LExperiment = LogArea::Experiment::id;
23 
30  std::optional<std::map<std::string, std::string>> logs{std::nullopt};
32  std::optional<std::vector<std::string>> paths{std::nullopt};
34  std::optional<std::vector<std::string>> preloads{std::nullopt};
36  std::optional<std::vector<std::string>> analyses{std::nullopt};
38  std::optional<std::vector<std::string>> to_be_enabled_weights{std::nullopt};
40  std::optional<std::vector<std::string>> to_be_disabled_weights{std::nullopt};
42  std::optional<std::array<double, 2>> cross_sections{std::nullopt};
44  std::optional<std::string> nominal_weight_name{std::nullopt};
46  std::optional<double> cap_on_weights{std::nullopt};
48  std::optional<double> nlo_smearing{std::nullopt};
50  std::optional<bool> no_multi_weight{std::nullopt};
52  bool ignore_beams{true};
55 };
56 
66  td_rho_eckart(false),
67  td_tmn(false),
68  td_tmn_landau(false),
69  td_v_landau(false),
70  td_jQBS(false),
71  td_smearing(true),
72  td_only_participants(false),
73  part_extended(false),
75  coll_extended(false),
76  coll_printstartend(false),
77  dil_extended(false),
78  photons_extended(false),
79  ic_extended(false),
80  rivet_parameters{} {}
81 
85 
86  if (conf.has_value({"Thermodynamics"})) {
87  auto thermo_conf = conf.extract_sub_configuration({"Thermodynamics"});
88  if (thermo_conf.has_value({"Position"})) {
89  const std::array<double, 3> a = thermo_conf.take({"Position"});
90  td_position = ThreeVector(a[0], a[1], a[2]);
91  }
92  std::set<ThermodynamicQuantity> quan = thermo_conf.take({"Quantities"});
94  td_tmn = (quan.count(ThermodynamicQuantity::Tmn) > 0);
97  td_jQBS = (quan.count(ThermodynamicQuantity::j_QBS) > 0);
98  td_dens_type = thermo_conf.take({"Type"}, DensityType::Baryon);
101  logg[LExperiment].warn(
102  "Requested Thermodynamics output with Density type None. ",
103  "Change the density type to avoid output being dropped.");
104  }
105  td_smearing = thermo_conf.take({"Smearing"}, true);
106  td_only_participants = thermo_conf.take({"Only_Participants"}, false);
107  }
108 
109  if (conf.has_value({"Particles"})) {
110  part_extended = conf.take({"Particles", "Extended"}, false);
112  conf.take({"Particles", "Only_Final"}, OutputOnlyFinal::Yes);
113  }
114 
115  if (conf.has_value({"Collisions"})) {
116  coll_extended = conf.take({"Collisions", "Extended"}, false);
117  coll_printstartend = conf.take({"Collisions", "Print_Start_End"}, false);
118  }
119 
120  if (conf.has_value({"Dileptons"})) {
121  dil_extended = conf.take({"Dileptons", "Extended"}, false);
122  }
123 
124  if (conf.has_value({"Photons"})) {
125  photons_extended = conf.take({"Photons", "Extended"}, false);
126  }
127 
128  if (conf.has_value({"Initial_Conditions"})) {
129  ic_extended = conf.take({"Initial_Conditions", "Extended"}, false);
130  }
131 
132  if (conf.has_value({"Rivet"})) {
133  auto rivet_conf = conf.extract_sub_configuration({"Rivet"});
134  logg[LOutput].debug() << "Reading Rivet section from configuration:\n"
135  << rivet_conf.to_string() << "\n";
136 
137  /*
138  * std::optional<T> can be assigned from a value using the
139  * template<class U = T> optional& operator=( U&& value );
140  * which is a perfect-forwarded assignment. However, in more complex cases
141  * like here where we use a Configuration::Value object returned by
142  * Configuration::take as value, it might be sometimes needed to
143  * explicitly specify the type U. It is then advantageous to use
144  * std::make_optional. When T is a built-in type, an assignment would work
145  * (although not that mentioned above), but std::make_optional also works.
146  * Note that GNU compiler has a buggy implementation of std::make_optional
147  * in versions from 8.1 till 8.3 and hence we use here make_optional and
148  * not std::make_optional. For faulty GNU versions the implementation
149  * shipped within smash namespace is then used, while in all other cases
150  * std::make_optional is used.
151  */
152  if (rivet_conf.has_value({"Logging"})) {
153  rivet_parameters.logs =
154  make_optional<std::map<std::string, std::string>>(
155  rivet_conf.take({"Logging"}));
156  }
157  if (rivet_conf.has_value({"Paths"})) {
158  rivet_parameters.paths =
159  make_optional<std::vector<std::string>>(rivet_conf.take({"Paths"}));
160  }
161  if (rivet_conf.has_value({"Preloads"})) {
162  rivet_parameters.preloads = make_optional<std::vector<std::string>>(
163  rivet_conf.take({"Preloads"}));
164  }
165  if (rivet_conf.has_value({"Analyses"})) {
166  rivet_parameters.analyses = make_optional<std::vector<std::string>>(
167  rivet_conf.take({"Analyses"}));
168  }
169  if (rivet_conf.has_value({"Cross_Section"})) {
170  rivet_parameters.cross_sections = make_optional<std::array<double, 2>>(
171  rivet_conf.take({"Cross_Section"}));
172  }
173  rivet_parameters.ignore_beams = rivet_conf.take({"Ignore_Beams"}, true);
174  if (rivet_conf.has_value({"Weights"})) {
175  rivet_parameters.any_weight_parameter_was_given = true;
176  if (rivet_conf.has_value({"Weights", "Select"})) {
177  rivet_parameters.to_be_enabled_weights =
178  make_optional<std::vector<std::string>>(
179  rivet_conf.take({"Weights", "Select"}));
180  }
181  if (rivet_conf.has_value({"Weights", "Deselect"})) {
182  rivet_parameters.to_be_disabled_weights =
183  make_optional<std::vector<std::string>>(
184  rivet_conf.take({"Weights", "Deselect"}));
185  }
186  if (rivet_conf.has_value({"Weights", "Nominal"})) {
187  rivet_parameters.nominal_weight_name = make_optional<std::string>(
188  rivet_conf.take({"Weights", "Nominal"}));
189  }
190  if (rivet_conf.has_value({"Weights", "Cap"})) {
191  rivet_parameters.cap_on_weights =
192  make_optional<double>(rivet_conf.take({"Weights", "Cap"}));
193  }
194  if (rivet_conf.has_value({"Weights", "NLO_Smearing"})) {
195  rivet_parameters.nlo_smearing = make_optional<double>(
196  rivet_conf.take({"Weights", "NLO_Smearing"}));
197  }
198  if (rivet_conf.has_value({"Weights", "No_Multi"})) {
199  rivet_parameters.no_multi_weight =
200  make_optional<bool>(rivet_conf.take({"Weights", "No_Multi"}));
201  }
202  }
203  logg[LOutput].debug() << "After processing configuration:\n"
204  << rivet_conf.to_string() << "\n";
205  }
206  }
207 
213  bool get_coll_extended(std::string name) const {
214  if (name == "Collisions") {
215  return coll_extended;
216  } else if (name == "Dileptons") {
217  return dil_extended;
218  } else if (name == "Photons") {
219  return photons_extended;
220  } else {
221  return false; // error
222  }
223  }
224 
227 
230 
233 
235  bool td_tmn;
236 
242 
245 
247  bool td_jQBS;
248 
254 
260 
263 
266 
269 
272 
275 
278 
281 
284 };
285 
286 } // namespace smash
287 
288 #endif // SRC_INCLUDE_SMASH_OUTPUTPARAMETERS_H_
Interface to the SMASH configuration files.
bool has_value(std::initializer_list< const char * > keys) const
Return whether there is a non-empty value behind the requested keys.
Configuration extract_sub_configuration(std::initializer_list< const char * > keys, Configuration::GetEmpty empty_if_not_existing=Configuration::GetEmpty::No)
Create a new configuration from a then-removed section of the present object.
Value take(std::initializer_list< const char * > keys)
The default interface for SMASH to read configuration values.
The ThreeVector class represents a physical three-vector with the components .
Definition: threevector.h:31
@ 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.
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.cc:39
Definition: action.h:24
static constexpr int LExperiment
static constexpr int LOutput
DensityType
Allows to choose which kind of density to calculate.
Definition: density.h:36
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_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.
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 get_coll_extended(std::string name) const
Pass correct extended flag to binary collision output constructor.
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.