36 double time_last_coll,
37 const ParticleList &plist) {
105 assert(!(std::isnan(v.
x1()) || std::isnan(v.
x2()) || std::isnan(v.
x3())));
118 constexpr
double mean = 0.0;
119 constexpr
double sigma = 0.75;
133 return smash_NaN<double>;
136 double time_of_interest =
position_.
x0() + delta_time;
138 double scaling_factor;
168 return scaling_factor;
173 return out <<
p.type().name() <<
" (" << std::setw(5) <<
p.type().pdgcode()
174 <<
")" << std::right <<
"{id:" << field<6> <<
p.id()
175 <<
", process:" << field<4> <<
p.id_process()
176 <<
", pos [fm]:" <<
p.position() <<
", mom [GeV]:" <<
p.momentum()
177 <<
", formation time [fm]:" <<
p.formation_time()
178 <<
", cross section scaling factor:" <<
p.xsec_scaling_factor()
182 std::ostream &
operator<<(std::ostream &out,
const ParticleList &particle_list) {
183 auto column = out.tellp();
185 for (
const auto &
p : particle_list) {
186 if (out.tellp() - column >= 201) {
188 column = out.tellp();
191 out << std::setw(5) << std::setprecision(3) <<
p.momentum().abs3()
201 for (
const auto &
p : particle_list.
list) {
216 const FourVector &four_momentum,
int log_area,
bool &mass_warning,
217 bool &on_shell_warning) {
220 logg[log_area].fatal() <<
"Input particle has at least one nan value in "
221 "position and/or momentum four vector.";
222 throw std::invalid_argument(
223 "Invalid input (nan) for particle position or momentum.");
227 static const auto emph = einhard::Yellow_t_::ANSI();
228 static const auto restore_default = einhard::NoColor_t_::ANSI();
229 auto prepare_needed_warnings = [&mass_warning, &on_shell_warning, &mass,
231 std::array<std::optional<std::string>, 2> warnings{};
233 warnings[0] =
"Provided mass of stable particle " +
p.type().name() +
235 " [GeV] is inconsistent with value = " +
237 "particles file.\nForcing E = sqrt(p^2 + m^2)" +
238 ", where m is the mass contained in the particles file." +
239 "\nFurther warnings about discrepancies between the " +
240 "input mass and the mass contained in the particles file" +
241 " will be suppressed.\n" + emph +
"Please make sure" +
242 " that changing input particle properties is an " +
243 "acceptable behavior." + restore_default;
245 if (on_shell_warning) {
246 std::stringstream ss{};
249 "Provided 4-momentum " + ss.str() +
" [GeV] and mass " +
250 std::to_string(mass) +
" [GeV] do not satisfy E^2 - p^2 = m^2.\n" +
251 "This may originate from the lack of numerical" +
252 " precision in the input. Setting E to sqrt(p^2 + " +
253 "m^2).\nFurther warnings about E != sqrt(p^2 + m^2) will" +
254 " be suppressed.\n" + emph +
"Please make sure that setting " +
255 "particles back on the mass shell is an acceptable behavior." +
260 auto warn_if_needed = [&log_area](
bool &flag,
261 const std::optional<std::string> &message) {
263 logg[log_area].warn(message.value());
267 auto is_particle_stable_and_with_invalid_mass =
269 return p.type().is_stable() &&
272 auto is_particle_off_its_mass_shell = [&mass](
const ParticleData &
p) {
273 return std::abs(
p.momentum().sqr() - mass * mass) >
really_small;
278 const auto warnings = prepare_needed_warnings(smash_particle);
279 if (is_particle_stable_and_with_invalid_mass(smash_particle)) {
280 warn_if_needed(mass_warning, warnings[0]);
281 smash_particle.set_4momentum(smash_particle.pole_mass(),
284 smash_particle.set_4momentum(four_momentum);
285 if (is_particle_off_its_mass_shell(smash_particle)) {
286 warn_if_needed(on_shell_warning, warnings[1]);
287 smash_particle.set_4momentum(mass, four_momentum.
threevec());
292 smash_particle.set_4position(four_position);
293 smash_particle.set_formation_time(four_position.
x0());
294 smash_particle.set_cross_section_scaling_factor(1.0);
296 return smash_particle;
308 auto get_propagated_position = [&time](
const ParticleData &
p) {
309 const double t =
p.position().x0();
311 return p.position() + u * (time - t);
313 return get_propagated_position(p1) == get_propagated_position(p2);
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
double abs() const
calculate the lorentz invariant absolute value
FourVector lorentz_boost(const ThreeVector &v) const
Returns the FourVector boosted with velocity v.
ThreeVector threevec() const
ParticleData contains the dynamic information of a certain particle.
double formation_time_
Formation time at which the particle is fully formed given as an absolute value in the computational ...
PdgCode pdgcode() const
Get the pdgcode of the particle.
void set_history(HistoryData &&history)
Set history_ from rvalue reference.
double begin_formation_time_
time when the cross section scaling factor starts to increase to 1
double xsec_scaling_factor(double delta_time=0.) const
Return the cross section scaling factor at a given time.
static double formation_power_
Power with which the cross section scaling factor grows in time.
const FourVector & momentum() const
Get the particle's 4-momentum.
ThreeVector velocity() const
Get the velocity 3-vector.
double initial_xsec_scaling_factor_
Initial cross section scaling factor.
FourVector spin_vector_
Pauli-Lubanski vector (mean spin 4-vector) of the particle.
double effective_mass() const
Get the particle's effective mass.
FourVector position_
position in space: x0, x1, x2, x3 as t, x, y, z
double pole_mass() const
Get the particle's pole mass ("on-shell").
int spin() const
Get the (maximum positive) spin s of a particle in multiples of 1/2.
HistoryData history_
history information
void set_unpolarized_spin_vector()
Set the 4 components of the spin vector such that the particle is unpolarized.
static const ParticleType & find(PdgCode pdgcode)
Returns the ParticleType object for the given pdgcode.
PdgCode stores a Particle Data Group Particle Numbering Scheme particle type number.
The ThreeVector class represents a physical three-vector with the components .
Collection of useful constants that are known at compile time.
std::ostream & operator<<(std::ostream &out, const ActionPtr &action)
Convenience: dereferences the ActionPtr to Action.
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > & logg
An array that stores all pre-configured Logger objects.
double normal(const T &mean, const T &sigma)
Returns a random number drawn from a normal distribution.
ProcessType
ProcessTypes are used to identify the type of the process.
@ FluidizationNoRemoval
See here for a short description.
@ FailedString
See here for a short description.
@ TwoToOne
See here for a short description.
@ StringHardSingleDiffractiveAX
See here for a short description.
@ MultiParticleThreeToTwo
See here for a short description.
@ BremsstrahlungPhoton
See here for a short description.
@ StringSoftDoubleDiffractive
See here for a short description.
@ Fluidization
See here for a short description.
@ BremsstrahlungDilepton
See here for a short description.
@ Thermalization
See here for a short description.
@ Freeforall
See here for a short description.
@ Decay
See here for a short description.
@ TwoToFive
See here for a short description.
@ None
See here for a short description.
@ StringSoftSingleDiffractiveXB
See here for a short description.
@ TwoToTwo
See here for a short description.
@ Wall
See here for a short description.
@ Elastic
See here for a short description.
@ TwoToFour
See here for a short description.
@ StringHardNonDiffractive
See here for a short description.
@ StringSoftAnnihilation
See here for a short description.
@ MultiParticleThreeMesonsToOne
See here for a short description.
@ StringSoftNonDiffractive
See here for a short description.
@ MultiParticleFourToTwo
See here for a short description.
@ StringSoftSingleDiffractiveAX
See here for a short description.
@ StringHardSingleDiffractiveXB
See here for a short description.
@ StringHardDoubleDiffractive
See here for a short description.
@ TwoToThree
See here for a short description.
@ MultiParticleFiveToTwo
See here for a short description.
bool are_particles_identical_at_given_time(const ParticleData &p1, const ParticleData &p2, double time)
Utility function to compare two ParticleData instances with respect to their PDG code,...
std::string to_string(ThermodynamicQuantity quantity)
Convert a ThermodynamicQuantity enum value to its corresponding string.
bool is_any_nan(const T &collection)
Returns whether any element in a collection is NaN.
ParticleData create_valid_smash_particle_matching_provided_quantities(PdgCode pdgcode, double mass, const FourVector &four_position, const FourVector &four_momentum, int log_area, bool &mass_warning, bool &on_shell_warning)
This function creates a SMASH particle validating the provided information.
constexpr double really_small
Numerical error tolerance.
Generic numerical functions.
double time_last_collision
Time of the last action (excluding walls), time of kinetic freeze_out for HBT analysis this time shou...
int32_t id_process
id of the last action
PdgCode p2
PdgCode of the second parent particles.
PdgCode p1
PdgCode of the first parent particles.
int32_t collisions_per_particle
Collision counter per particle, zero only for initially present particles.
ProcessType process_type
type of the last action
const ParticleList & list
Particle list.