36 double time_last_coll,
37 const ParticleList &plist) {
101 assert(!(std::isnan(v.
x1()) || std::isnan(v.
x2()) || std::isnan(v.
x3())));
114 constexpr
double mean = 0.0;
115 constexpr
double sigma = 0.75;
129 return smash_NaN<double>;
132 double time_of_interest =
position_.
x0() + delta_time;
134 double scaling_factor;
164 return scaling_factor;
169 return out <<
p.type().name() <<
" (" << std::setw(5) <<
p.type().pdgcode()
170 <<
")" << std::right <<
"{id:" << field<6> <<
p.id()
171 <<
", process:" << field<4> <<
p.id_process()
172 <<
", pos [fm]:" <<
p.position() <<
", mom [GeV]:" <<
p.momentum()
173 <<
", formation time [fm]:" <<
p.formation_time()
174 <<
", cross section scaling factor:" <<
p.xsec_scaling_factor()
178 std::ostream &
operator<<(std::ostream &out,
const ParticleList &particle_list) {
179 auto column = out.tellp();
181 for (
const auto &
p : particle_list) {
182 if (out.tellp() - column >= 201) {
184 column = out.tellp();
187 out << std::setw(5) << std::setprecision(3) <<
p.momentum().abs3()
197 for (
const auto &
p : particle_list.
list) {
212 const FourVector &four_momentum,
int log_area,
bool &mass_warning,
213 bool &on_shell_warning) {
216 logg[log_area].fatal() <<
"Input particle has at least one nan value in "
217 "position and/or momentum four vector.";
218 throw std::invalid_argument(
219 "Invalid input (nan) for particle position or momentum.");
223 static const auto emph = einhard::Yellow_t_::ANSI();
224 static const auto restore_default = einhard::NoColor_t_::ANSI();
225 auto prepare_needed_warnings = [&mass_warning, &on_shell_warning, &mass,
227 std::array<std::optional<std::string>, 2> warnings{};
229 warnings[0] =
"Provided mass of stable particle " +
p.type().name() +
231 " [GeV] is inconsistent with value = " +
233 "particles file.\nForcing E = sqrt(p^2 + m^2)" +
234 ", where m is the mass contained in the particles file." +
235 "\nFurther warnings about discrepancies between the " +
236 "input mass and the mass contained in the particles file" +
237 " will be suppressed.\n" + emph +
"Please make sure" +
238 " that changing input particle properties is an " +
239 "acceptable behavior." + restore_default;
241 if (on_shell_warning) {
242 std::stringstream ss{};
245 "Provided 4-momentum " + ss.str() +
" [GeV] and mass " +
246 std::to_string(mass) +
" [GeV] do not satisfy E^2 - p^2 = m^2.\n" +
247 "This may originate from the lack of numerical" +
248 " precision in the input. Setting E to sqrt(p^2 + " +
249 "m^2).\nFurther warnings about E != sqrt(p^2 + m^2) will" +
250 " be suppressed.\n" + emph +
"Please make sure that setting " +
251 "particles back on the mass shell is an acceptable behavior." +
256 auto warn_if_needed = [&log_area](
bool &flag,
257 const std::optional<std::string> &message) {
259 logg[log_area].warn(message.value());
263 auto is_particle_stable_and_with_invalid_mass =
265 return p.type().is_stable() &&
268 auto is_particle_off_its_mass_shell = [&mass](
const ParticleData &
p) {
269 return std::abs(
p.momentum().sqr() - mass * mass) >
really_small;
274 const auto warnings = prepare_needed_warnings(smash_particle);
275 if (is_particle_stable_and_with_invalid_mass(smash_particle)) {
276 warn_if_needed(mass_warning, warnings[0]);
277 smash_particle.set_4momentum(smash_particle.pole_mass(),
280 smash_particle.set_4momentum(four_momentum);
281 if (is_particle_off_its_mass_shell(smash_particle)) {
282 warn_if_needed(on_shell_warning, warnings[1]);
283 smash_particle.set_4momentum(mass, four_momentum.
threevec());
288 smash_particle.set_4position(four_position);
289 smash_particle.set_formation_time(four_position.
x0());
290 smash_particle.set_cross_section_scaling_factor(1.0);
292 return smash_particle;
304 auto get_propagated_position = [&time](
const ParticleData &
p) {
305 const double t =
p.position().x0();
307 return p.position() + u * (time - t);
309 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.
@ MultiParticleThreeToTwo
See here for a short description.
@ StringSoftDoubleDiffractive
See here for a short description.
@ Fluidization
See here for a short description.
@ Bremsstrahlung
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.
@ 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.
@ StringHard
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.