The interfaces in this group are used for debug and informational console output.
SMASH uses the einhard logging library for debug and info/warn/error output to stdout. This library builds upon the C++ ostream classes and thus uses stream operators for converting objects into a text representation.
The einhard library supports named output streams (which simply means they automatically add the name to the prefix string). We use this feature to define log areas in SMASH that can be configured independently. The einhard::Logger class supports two options: colorization and verbosity. For colorization we stay with the default of auto-detecting a color-terminal. For verbosity we use a Configuration object to set the verbosity of each area independently. This way we have control over the amount of debug output at runtime and without the need to touch the code/recompile.
To output something from your code do the following:
logg[LAreaName].trace(source_location);
logg[LAreaName].debug(
"particle",
p);
logg[LAreaName].warn(
"Something happened.");
Note that LAreaName
needs to be declared within the smash namespace of the respective file in a form of (using PauliBlocking as an example area):
The einhard::Logger class supports two ways of writing to an output stream: Use stream operators or pass the list of objects for output as parameters. Thus
log.debug(
"particle: ",
p);
and
log.debug() <<
"particle: " <<
p;
are equivalent (except for a small optimization opportunity in the former variant, that could make it slightly more efficient). You can see, though, that the former variant is more concise and often much easier to type than the stream operators.
|
#define | DECLARE_LOGAREA(id__, name__) |
| Declares the necessary interface to identify a new log area. More...
|
|
#define | SMASH_SOURCE_LOCATION __FILE__ ":" + std::to_string(__LINE__) + " (" + __func__ + ')' |
| Hackery that is required to output the location in the source code where the log statement occurs. More...
|
|
|
using | smash::LogArea::AreaTuple = std::tuple< Main, Experiment, Box, Collider, Sphere, Action, InputParser, ParticleType, FindScatter, Clock, DecayModes, Resonances, ScatterAction, Distributions, Propagation, Grid, List, Nucleus, Density, PauliBlocking, Tmn, Fpe, Lattice, Sampling, Pythia, GrandcanThermalizer, CrossSections, Output, HadronGasEos, HyperSurfaceCrossing, InitialConditions, ScatterActionMulti > |
| This type collects all existing log areas so they will be created with the correct log level automatically. More...
|
|
|
virtual void | smash::Action::format_debug_output (std::ostream &out) const =0 |
|
std::ostream & | smash::operator<< (std::ostream &out, const ActionPtr &action) |
|
std::ostream & | smash::operator<< (std::ostream &out, const ActionList &actions) |
|
std::ostream & | smash::operator<< (std::ostream &out, const Angles &a) |
|
void | smash::DecayAction::format_debug_output (std::ostream &out) const override |
|
std::ostream & | smash::operator<< (std::ostream &, const EnergyMomentumTensor &) |
|
std::ostream & | smash::operator<< (std::ostream &os, const FourVector &vec) |
|
template<int w = 9, int p = w - 3, typename CharT , typename Traits > |
std::basic_ostream< CharT, Traits > & | smash::field (std::basic_ostream< CharT, Traits > &s) |
|
void | smash::create_all_loggers (Configuration config) |
| Called from main() right after the Configuration object is fully set up to create all logger objects (as defined by LogArea::AreaTuple) with the correct area names and log levels. More...
|
|
einhard::LogLevel | smash::default_loglevel () |
|
void | smash::set_default_loglevel (einhard::LogLevel level) |
| Set the default log level (what will be returned from subsequent default_loglevel calls). More...
|
|
template<typename T > |
FormattingHelper< T > | smash::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 with a given field width and precision. More...
|
|
static Node | YAML::convert< einhard::LogLevel >::encode (const einhard::LogLevel &x) |
| Convert from einhard::LogLevel to YAML::Node. More...
|
|
static bool | YAML::convert< einhard::LogLevel >::decode (const Node &node, einhard::LogLevel &x) |
| Convert from YAML::Node to einhard::LogLevel. More...
|
|
std::ostream & | smash::operator<< (std::ostream &s, const ParticleData &p) |
|
std::ostream & | smash::operator<< (std::ostream &out, const ParticleList &particle_list) |
|
PrintParticleListDetailed | smash::detailed (const ParticleList &list) |
|
std::ostream & | smash::operator<< (std::ostream &out, const PrintParticleListDetailed &particle_list) |
|
std::ostream & | smash::operator<< (std::ostream &is, const PdgCode &code) |
|
std::ostream & | smash::operator<< (std::ostream &os, ProcessType process_type) |
|
std::ostream & | smash::operator<< (std::ostream &os, const CollisionBranch &cbranch) |
|
void | smash::ScatterAction::format_debug_output (std::ostream &out) const override |
|
std::ostream & | smash::operator<< (std::ostream &, const ThreeVector &) |
|
|
std::ostream & | smash::Action::operator<< (std::ostream &out, const Action &action) |
|
std::ostream & | smash::BoxModus::operator<< (std::ostream &out, const BoxModus &m) |
|
std::ostream & | smash::ColliderModus::operator<< (std::ostream &, const ColliderModus &) |
|
std::ostream & | smash::Experiment< Modus >::operator<< (std::ostream &out, const Experiment &e) |
| Creates a verbose textual description of the setup of the Experiment. More...
|
|
std::ostream & | smash::ListModus::operator<< (std::ostream &, const ListModus &) |
|
std::ostream & | smash::FormattingHelper< T >::operator<< (std::ostream &out, const FormattingHelper &h) |
| Nicely formatted output. More...
|
|
std::ostream & | smash::Nucleus::operator<< (std::ostream &, const Nucleus &) |
|
std::ostream & | smash::Particles::operator<< (std::ostream &out, const Particles &particles) |
|
std::ostream & | smash::ParticleType::operator<< (std::ostream &out, const ParticleType &type) |
|
std::ostream & | smash::SphereModus::operator<< (std::ostream &, const SphereModus &) |
|
◆ DECLARE_LOGAREA
#define DECLARE_LOGAREA |
( |
|
id__, |
|
|
|
name__ |
|
) |
| |
Value: struct name__ { \
static constexpr int id = id__; \
static constexpr const char *textual() { return #name__; } \
static constexpr int textual_length() { return sizeof(#name__) - 1; } \
}
Declares the necessary interface to identify a new log area.
Definition at line 168 of file logging.h.
◆ SMASH_SOURCE_LOCATION
#define SMASH_SOURCE_LOCATION __FILE__ ":" + std::to_string(__LINE__) + " (" + __func__ + ')' |
Hackery that is required to output the location in the source code where the log statement occurs.
Definition at line 243 of file logging.h.
◆ AreaTuple
using smash::LogArea::AreaTuple = typedef std::tuple<Main, Experiment, Box, Collider, Sphere, Action, InputParser, ParticleType, FindScatter, Clock, DecayModes, Resonances, ScatterAction, Distributions, Propagation, Grid, List, Nucleus, Density, PauliBlocking, Tmn, Fpe, Lattice, Sampling, Pythia, GrandcanThermalizer, CrossSections, Output, HadronGasEos, HyperSurfaceCrossing, InitialConditions, ScatterActionMulti> |
This type collects all existing log areas so they will be created with the correct log level automatically.
Definition at line 226 of file logging.h.
◆ format_debug_output() [1/3]
virtual void smash::Action::format_debug_output |
( |
std::ostream & |
out | ) |
const |
|
protectedpure virtual |
◆ operator<<() [1/12]
std::ostream& smash::operator<< |
( |
std::ostream & |
out, |
|
|
const ActionPtr & |
action |
|
) |
| |
|
inline |
Convenience: dereferences the ActionPtr to Action.
Definition at line 518 of file action.h.
519 return out << *action;
◆ operator<<() [2/12]
std::ostream & smash::operator<< |
( |
std::ostream & |
out, |
|
|
const ActionList & |
actions |
|
) |
| |
Writes multiple actions to the out
stream.
Definition at line 375 of file action.cc.
376 out <<
"ActionList {\n";
377 for (
const auto &a : actions) {
378 out <<
"- " << a <<
'\n';
◆ operator<<() [3/12]
std::ostream& smash::operator<< |
( |
std::ostream & |
out, |
|
|
const Angles & |
a |
|
) |
| |
|
inline |
Creates output for an Angles object in the form "φ: 0.1294, cos ϑ: 0.423".
Definition at line 184 of file angles.h.
185 return out <<
"φ:" <<
field << a.phi() <<
", cos ϑ:" <<
field << a.costheta();
◆ format_debug_output() [2/3]
void smash::DecayAction::format_debug_output |
( |
std::ostream & |
out | ) |
const |
|
overrideprotectedvirtual |
◆ operator<<() [4/12]
Prints out 4x4 tensor to the output stream.
- Parameters
-
[in] | out | Location of output |
[in] | Tmn | Energy-momentum tensor |
Definition at line 144 of file energymomentumtensor.cc.
146 for (
size_t mu = 0; mu < 4; mu++) {
147 for (
size_t nu = 0; nu < 4; nu++) {
148 out << std::setprecision(3) << std::setw(12) << std::fixed
149 <<
Tmn[EnergyMomentumTensor::tmn_index(mu, nu)];
◆ operator<<() [5/12]
std::ostream & smash::operator<< |
( |
std::ostream & |
os, |
|
|
const FourVector & |
vec |
|
) |
| |
Writes the four components of the vector to the output stream.
- Parameters
-
[in] | os | The ostream into which to output |
[in] | vec | The FourVector to write into os |
Definition at line 36 of file fourvector.cc.
◆ field()
template<int w = 9, int p = w - 3, typename CharT , typename Traits >
std::basic_ostream<CharT, Traits>& smash::field |
( |
std::basic_ostream< CharT, Traits > & |
s | ) |
|
|
inline |
Stream modifier to align the next object to a specific width w
.
- Template Parameters
-
w | The number of characters the field should have in the output. |
p | The floating precision. |
CharT | Character type of the output stream. |
Traits | Traits of the output stream. |
- Parameters
-
[in,out] | s | The output stream. |
- Returns
- The output stream.
Definition at line 30 of file iomanipulators.h.
33 s.setf(std::ios_base::fixed, std::ios_base::floatfield);
◆ create_all_loggers()
Called from main() right after the Configuration object is fully set up to create all logger objects (as defined by LogArea::AreaTuple) with the correct area names and log levels.
- Parameters
-
config | A configuration object with the log area names as toplevel keys. |
Definition at line 118 of file logging.cc.
119 create_all_loggers_impl<std::tuple_size<LogArea::AreaTuple>::value>(config);
◆ default_loglevel()
- Returns
- The default log level to use if no specific level is configured.
Definition at line 22 of file logging.cc.
◆ set_default_loglevel()
Set the default log level (what will be returned from subsequent default_loglevel calls).
- Parameters
-
Definition at line 24 of file logging.cc.
◆ format()
template<typename T >
FormattingHelper<T> smash::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 with a given field width and precision.
- Template Parameters
-
T | Value that is being formatted. |
- Parameters
-
value | The object to be written to the stream. |
unit | An optional suffix string, typically used for a unit. May be nullptr. |
width | The field width to use for value . |
precision | The precision to use for value . |
Definition at line 307 of file logging.h.
309 return {value, width, precision, unit};
◆ encode()
◆ decode()
Convert from YAML::Node to einhard::LogLevel.
- Parameters
-
[in] | node | YAML node. |
[out] | x | Where the corresponding log level will be stored if the conversion was successful. |
- Returns
- Whether the conversion was successful.
Definition at line 345 of file logging.h.
346 if (!node.IsScalar()) {
◆ operator<<() [6/12]
std::ostream & smash::operator<< |
( |
std::ostream & |
s, |
|
|
const ParticleData & |
p |
|
) |
| |
Writes the state of the particle to the output stream.
Definition at line 114 of file particledata.cc.
116 return out <<
p.type().name() <<
" (" << std::setw(5) <<
p.type().pdgcode()
117 <<
")" << std::right <<
"{id:" << field<6> <<
p.id()
118 <<
", process:" << field<4> <<
p.id_process()
119 <<
", pos [fm]:" <<
p.position() <<
", mom [GeV]:" <<
p.momentum()
120 <<
", formation time [fm]:" <<
p.formation_time()
121 <<
", cross section scaling factor:" <<
p.xsec_scaling_factor()
◆ operator<<() [7/12]
std::ostream & smash::operator<< |
( |
std::ostream & |
out, |
|
|
const ParticleList & |
particle_list |
|
) |
| |
Writes a compact overview over the particles in the particle_list
argument to the stream.
Definition at line 125 of file particledata.cc.
126 auto column = out.tellp();
128 for (
const auto &
p : particle_list) {
129 if (out.tellp() - column >= 201) {
131 column = out.tellp();
134 out << std::setw(5) << std::setprecision(3) <<
p.momentum().abs3()
◆ detailed()
Request the ParticleList to be printed in full detail (i.e. one full ParticleData printout per line).
Definition at line 486 of file particledata.h.
◆ operator<<() [8/12]
Writes a detailed overview over the particles in the particle_list
argument to the stream. This overload is selected via the function detailed.
Definition at line 140 of file particledata.cc.
144 for (
const auto &
p : particle_list.list) {
◆ operator<<() [9/12]
std::ostream & smash::operator<< |
( |
std::ostream & |
is, |
|
|
const PdgCode & |
code |
|
) |
| |
Writes the textual representation of the PDG code to the output stream.
Definition at line 88 of file pdgcode.cc.
89 return s << code.string();
◆ operator<<() [10/12]
std::ostream & smash::operator<< |
( |
std::ostream & |
os, |
|
|
ProcessType |
process_type |
|
) |
| |
Writes the textual representation of the process_type
to the output stream os
.
Definition at line 86 of file processbranch.cc.
87 switch (process_type) {
88 case ProcessType::None:
94 case ProcessType::TwoToOne:
97 case ProcessType::TwoToTwo:
100 case ProcessType::StringSoftSingleDiffractiveAX:
101 case ProcessType::StringSoftSingleDiffractiveXB:
102 case ProcessType::StringSoftDoubleDiffractive:
103 case ProcessType::StringSoftAnnihilation:
104 case ProcessType::StringSoftNonDiffractive:
105 os <<
"Soft String Excitation";
107 case ProcessType::StringHard:
108 os <<
"Hard String via Pythia";
110 case ProcessType::Decay:
113 case ProcessType::Wall:
117 os <<
"Hypersurface crossing";
119 case ProcessType::MultiParticleThreeMesonsToOne:
120 os <<
"3MesonsToOne";
123 os.setstate(std::ios_base::failbit);
◆ operator<<() [11/12]
std::ostream & smash::operator<< |
( |
std::ostream & |
os, |
|
|
const CollisionBranch & |
cbranch |
|
) |
| |
Writes the textual representation of the Collision Branch cbranch
to the output stream os
.
Definition at line 55 of file processbranch.cc.
57 if (ptype == ProcessType::StringSoftSingleDiffractiveAX ||
58 ptype == ProcessType::StringSoftSingleDiffractiveXB) {
60 }
else if (ptype == ProcessType::StringSoftDoubleDiffractive) {
62 }
else if (ptype == ProcessType::StringSoftAnnihilation) {
64 }
else if (ptype == ProcessType::StringSoftNonDiffractive) {
66 }
else if (ptype == ProcessType::StringHard) {
68 }
else if (ptype == ProcessType::TwoToOne || ptype == ProcessType::TwoToTwo ||
70 ptype == ProcessType::MultiParticleThreeMesonsToOne) {
71 ParticleTypePtrList ptype_list = cbranch.particle_types();
76 std::sort(ptype_list.begin(), ptype_list.end());
77 for (
const auto& type : ptype_list) {
◆ format_debug_output() [3/3]
void smash::ScatterAction::format_debug_output |
( |
std::ostream & |
out | ) |
const |
|
overrideprotectedvirtual |
Writes information about this scatter action to the out
stream.
Implements smash::Action.
Definition at line 538 of file scatteraction.cc.
541 out <<
" (not performed)";
◆ operator<<() [12/12]
std::ostream & smash::operator<< |
( |
std::ostream & |
out, |
|
|
const ThreeVector & |
v |
|
) |
| |
Writes the three components of the vector to the output stream.
Definition at line 16 of file threevector.cc.
◆ value
Value that is being formatted.
Definition at line 267 of file logging.h.
◆ width
◆ precision
Precision that value is being formatted with.
Definition at line 271 of file logging.h.
◆ unit
Unit that is attached at the end of value.
Definition at line 273 of file logging.h.
◆ logg
An array that stores all pre-configured Logger objects.
The objects can be accessed via the logger function.
To access its elements use logg[LAreaName]
where AreaName is the respective areas name declared in loggin.h
. Note that LAreaName
needs to be declared within the smash namespace of the respective file in a form of (using PauliBlocking as an example area):
For further documentation see logging.h
.
Definition at line 39 of file logging.cc.
◆ operator<< [1/10]
std::ostream& operator<< |
( |
std::ostream & |
out, |
|
|
const Action & |
action |
|
) |
| |
|
friend |
◆ operator<< [2/10]
std::ostream& operator<< |
( |
std::ostream & |
out, |
|
|
const BoxModus & |
m |
|
) |
| |
|
friend |
Console output on startup of box specific parameters; writes the initial state for the box to the output stream.
- Parameters
-
[in] | out | The ostream into which to output |
[in] | m | The BoxModus object to write into out |
Definition at line 31 of file boxmodus.cc.
32 out <<
"-- Box Modus:\nSize of the box: (" << m.length_ <<
" fm)³\n";
34 out <<
"Thermal multiplicities "
35 <<
"(T = " << m.temperature_ <<
" GeV, muB = " << m.mub_
36 <<
" GeV, muS = " << m.mus_ <<
" GeV, muQ = " << m.muq_ <<
" GeV)\n";
38 for (
const auto &
p : m.init_multipl_) {
40 out << ptype->name() <<
" initial multiplicity " <<
p.second <<
'\n';
43 switch (m.initial_condition_) {
45 out <<
"All initial momenta = 3T = " << 3 * m.temperature_ <<
" GeV\n";
48 out <<
"Boltzmann momentum distribution with T = " << m.temperature_
52 out <<
"Fermi/Bose momentum distribution with T = " << m.temperature_
58 out <<
"Adding a " << ptype->name() <<
" as a jet in the middle "
59 <<
"of the box with " << m.jet_mom_ <<
" GeV initial momentum.\n";
◆ operator<< [3/10]
std::ostream& operator<< |
( |
std::ostream & |
out, |
|
|
const ColliderModus & |
m |
|
) |
| |
|
friend |
Writes the initial state for the ColliderModus to the output stream.
- Parameters
-
[in] | out | The ostream into which to output |
[in] | m | The ColliderModus object to write into out |
Definition at line 567 of file collidermodus.cc.
568 return out <<
"-- Collider Modus:\n"
569 <<
"sqrt(S) (nucleus-nucleus) = "
570 <<
format(std::sqrt(m.total_s_),
"GeV\n")
571 <<
"sqrt(S) (nucleon-nucleon) = " <<
format(m.sqrt_s_NN_,
"GeV\n")
573 << *m.projectile_ <<
"\nTarget:\n"
◆ operator<< [4/10]
template<typename Modus >
std::ostream& operator<< |
( |
std::ostream & |
out, |
|
|
const Experiment< Modus > & |
e |
|
) |
| |
|
friend |
Creates a verbose textual description of the setup of the Experiment.
Writes the initial state for the Experiment to the output stream. It automatically appends the output of the current Modus.
Definition at line 620 of file experiment.h.
621 out <<
"End time: " << e.end_time_ <<
" fm/c\n";
◆ operator<< [5/10]
std::ostream& operator<< |
( |
std::ostream & |
out, |
|
|
const ListModus & |
m |
|
) |
| |
|
friend |
Writes the initial state for the List to the output stream.
- Parameters
-
[in] | out | The ostream into which to output |
[in] | m | The ListModus object to write into out |
Definition at line 129 of file listmodus.cc.
130 out <<
"-- List Modus\nInput directory for external particle lists:\n"
131 << m.particle_list_file_directory_ <<
"\n";
◆ operator<< [6/10]
template<typename T >
std::ostream& operator<< |
( |
std::ostream & |
out, |
|
|
const FormattingHelper< T > & |
h |
|
) |
| |
|
friend |
Nicely formatted output.
- Parameters
-
Definition at line 279 of file logging.h.
282 out << std::setfill(
' ') << std::setw(h.width);
284 if (h.precision >= 0) {
285 out << std::setprecision(h.precision);
289 out <<
' ' << h.unit;
◆ operator<< [7/10]
std::ostream& operator<< |
( |
std::ostream & |
out, |
|
|
const Nucleus & |
n |
|
) |
| |
|
friend |
Writes the state of the Nucleus object to the output stream.
Definition at line 509 of file nucleus.cc.
510 return out <<
" #particles #testparticles mass [GeV] "
511 "radius [fm] diffusiveness [fm]\n"
512 <<
format(
n.number_of_particles(),
nullptr, 12)
514 <<
format(
n.get_nuclear_radius(),
nullptr, 14)
515 <<
format(
n.get_diffusiveness(),
nullptr, 20);
◆ operator<< [8/10]
std::ostream& operator<< |
( |
std::ostream & |
out, |
|
|
const Particles & |
particles |
|
) |
| |
|
friend |
Print effective mass and type name for all particles to the stream.
- Parameters
-
[in] | out | The ostream into which to output |
[in] | particles | The Particles object to write into out |
Definition at line 148 of file particles.cc.
149 out << particles.size() <<
" Particles:\n";
150 for (
unsigned i = 0; i < particles.data_size_; ++i) {
151 const auto &
p = particles.data_[i];
155 out << std::setw(5) << std::setprecision(3) <<
p.momentum().abs3()
◆ operator<< [9/10]
std::ostream& operator<< |
( |
std::ostream & |
out, |
|
|
const ParticleType & |
type |
|
) |
| |
|
friend |
Writes all information about the particle type to the output stream.
- Parameters
-
[out] | out | The ostream into which to output |
[in] | type | The ParticleType object to write into out |
Definition at line 761 of file particletype.cc.
762 const PdgCode &pdg = type.pdgcode();
763 return out << type.name() << std::setfill(
' ') << std::right
764 <<
"[ mass:" << field<6> << type.mass()
765 <<
", width:" << field<6> << type.width_at_pole()
766 <<
", PDG:" << field<6> << pdg
767 <<
", charge:" << field<3> << pdg.charge()
768 <<
", spin:" << field<2> << pdg.spin() <<
"/2 ]";
◆ operator<< [10/10]
std::ostream& operator<< |
( |
std::ostream & |
out, |
|
|
const SphereModus & |
m |
|
) |
| |
|
friend |
Writes the initial state for the Sphere to the output stream.
- Parameters
-
[in] | out | The ostream into which to output |
[in] | m | The SphereModus object to write into out |
Definition at line 189 of file spheremodus.cc.
190 out <<
"-- Sphere Modus:\nRadius of the sphere: " << m.radius_ <<
" fm\n";
191 if (m.use_thermal_) {
192 out <<
"Thermal multiplicities (T = " << m.sphere_temperature_
193 <<
" GeV, muB = " << m.mub_ <<
" GeV, muS = " << m.mus_ <<
" GeV)\n";
195 for (
const auto &
p : m.init_multipl_) {
197 out << ptype->name() <<
" initial multiplicity " <<
p.second <<
'\n';
200 switch (m.init_distr_) {
202 out <<
"Boltzmann momentum distribution with T = "
203 << m.sphere_temperature_ <<
" GeV.\n";
206 out <<
"Fermi/Bose momentum distribution with T = "
207 << m.sphere_temperature_ <<
" GeV.\n";
210 out <<
"Sphere Initial Condition is IC_ES";
213 out <<
"Sphere Initial Condition is IC_1M";
216 out <<
"Sphere Initial Condition is IC_2M";
219 out <<
"Sphere Initial Condition is IC_Massive";
224 out <<
"Adding a " << ptype->name() <<
" as a jet in the middle "
225 <<
"of the sphere with " << m.jet_mom_ <<
" GeV initial momentum.\n";