10 #ifndef SRC_INCLUDE_SMASH_ACTION_H_
11 #define SRC_INCLUDE_SMASH_ACTION_H_
25 static constexpr
int LAction = LogArea::Action::id;
44 Action(
const ParticleList &in_part,
double time)
75 Action(
const ParticleList &in_part,
const ParticleList &out_part,
140 template <
typename Branch>
142 ProcessBranchList<Branch> &subprocesses,
143 double &total_weight) {
144 if (
p->weight() > 0) {
145 total_weight +=
p->weight();
146 subprocesses.emplace_back(std::move(
p));
157 template <
typename Branch>
159 ProcessBranchList<Branch> &subprocesses,
160 double &total_weight) {
161 subprocesses.reserve(subprocesses.size() + pv.size());
162 for (
auto &proc : pv) {
163 if (proc->weight() > 0) {
164 total_weight += proc->weight();
165 subprocesses.emplace_back(std::move(proc));
316 const double res = (a - b - c) * (a - b - c) - 4. * b * c;
331 using std::invalid_argument::invalid_argument;
341 using std::runtime_error::runtime_error;
350 double sqrts,
const std::vector<double> &m,
351 std::vector<FourVector> &sampled_momenta);
406 template <
typename Branch>
408 double total_weight) {
410 double weight_sum = 0.;
413 for (
const auto &proc : subprocesses) {
414 weight_sum += proc->weight();
415 if (random_weight <= weight_sum) {
422 "Problem in choose_channel: ", subprocesses.size(),
" ",
423 weight_sum,
" ", total_weight,
" ",
425 random_weight,
"\n");
440 double kinetic_energy_cm)
const;
452 double kinetic_energy_cm);
532 inline std::vector<ActionPtr> &
operator+=(std::vector<ActionPtr> &lhs,
533 std::vector<ActionPtr> &&rhs) {
534 if (lhs.size() == 0) {
535 lhs = std::move(rhs);
537 lhs.insert(lhs.end(), std::make_move_iterator(rhs.begin()),
538 std::make_move_iterator(rhs.end()));
547 inline std::ostream &
operator<<(std::ostream &out,
const ActionPtr &action) {
548 return out << *action;
555 std::ostream &
operator<<(std::ostream &out,
const ActionList &actions);
Exception for a temporary bugfix for when multiparticle interactions do not have the necessary energy...
Action is the base class for a generic process that takes a number of incoming particles and transfor...
void sample_2body_phasespace()
Sample the full 2-body phase-space (masses, momenta, angles) in the center-of-mass frame for the fina...
FourVector total_momentum_of_outgoing_particles() const
Calculate the total kinetic momentum of the outgoing particles.
Action(const Action &)=delete
Copying is disabled. Use pointers or create a new Action.
void assign_formation_time_to_outgoing_particles()
Assign the formation time to the outgoing particles.
virtual ~Action()
Virtual Destructor.
int stochastic_position_idx_
This stores a randomly-chosen index to an incoming particle.
std::pair< FourVector, FourVector > get_potential_at_interaction_point() const
Get the skyrme and asymmetry potential at the interaction point.
virtual void sample_angles(std::pair< double, double > masses, double kinetic_energy_cm)
Sample final-state momenta in general X->2 processes (here: using an isotropical angular distribution...
ParticleList outgoing_particles_
Initially this stores only the PDG codes of final-state particles.
bool operator<(const Action &rhs) const
Determine whether one action takes place before another in time.
virtual ProcessType get_type() const
Get the process type.
const ParticleType & type_of_pout(const ParticleData &p_out) const
Get the type of a given particle.
FourVector total_momentum() const
Sum of 4-momenta of incoming particles.
virtual void sample_manybody_phasespace()
Sample the full n-body phase-space (masses, momenta, angles) in the center-of-mass frame for the fina...
const double time_of_execution_
Time at which the action is supposed to be performed (absolute time in the lab frame in fm).
virtual double get_total_weight() const =0
Return the total weight value, which is mainly used for the weight output entry.
void set_stochastic_pos_idx()
Setter function that stores a random incoming particle index latter used to determine the interaction...
virtual double perform(Particles *particles, uint32_t id_process)
Actually perform the action, e.g.
void update_incoming(const Particles &particles)
Update the incoming particles that are stored in this action to the state they have in the global par...
Action(const ParticleList &in_part, double time)
Construct an action object with incoming particles and relative time.
virtual double check_conservation(const uint32_t id_process) const
Check various conservation laws.
const ParticleList & incoming_particles() const
Get the list of particles that go into the action.
Action(const ParticleList &in_part, const ParticleList &out_part, double absolute_execution_time, ProcessType type)
Construct an action object with the incoming particles, absolute time, and the already known outgoing...
double time_of_execution() const
Get the time at which the action is supposed to be performed.
virtual void generate_final_state()=0
Generate the final state for this action.
void add_process(ProcessBranchPtr< Branch > &p, ProcessBranchList< Branch > &subprocesses, double &total_weight)
Add a new subprocess.
const Branch * choose_channel(const ProcessBranchList< Branch > &subprocesses, double total_weight)
Decide for a particular final-state channel via Monte-Carlo and return it as a ProcessBranch.
virtual double get_partial_weight() const =0
Return the specific weight for the chosen outgoing channel, which is mainly used for the partial weig...
double sqrt_s() const
Determine the total energy in the center-of-mass frame [GeV].
double box_length_
Box length: needed to determine coordinates of collision correctly in case of collision through the w...
ParticleList incoming_particles_
List with data of incoming particles.
FourVector get_interaction_point() const
Get the interaction point.
Action(const ParticleData &in_part, const ParticleData &out_part, double time, ProcessType type)
Construct an action object with the incoming particles, relative time, and the already known outgoing...
virtual std::pair< double, double > sample_masses(double kinetic_energy_cm) const
Sample final-state masses in general X->2 processes (thus also fixing the absolute c....
static double lambda_tilde(double a, double b, double c)
Little helper function that calculates the lambda function (sometimes written with a tilde to better ...
void add_processes(ProcessBranchList< Branch > pv, ProcessBranchList< Branch > &subprocesses, double &total_weight)
Add several new subprocesses at once.
ProcessType process_type_
type of process
const ParticleType & type_of_pout(const ParticleTypePtr &p_out) const
Get the particle type for given pointer to a particle type.
const ParticleList & outgoing_particles() const
Get the list of particles that resulted from the action.
bool is_valid(const Particles &particles) const
Check whether the action still applies.
static void sample_manybody_phasespace_impl(double sqrts, const std::vector< double > &m, std::vector< FourVector > &sampled_momenta)
Implementation of the full n-body phase-space sampling (masses, momenta, angles) in the center-of-mas...
bool is_pauli_blocked(const std::vector< Particles > &ensembles, const PauliBlocker &p_bl) const
Check if the action is Pauli-blocked.
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
double abs() const
calculate the lorentz invariant absolute value
ParticleData contains the dynamic information of a certain particle.
const ParticleType & type() const
Get the type of the particle.
A pointer-like interface to global references to ParticleType objects.
Particle type contains the static properties of a particle species.
The Particles class abstracts the storage and manipulation of particles.
A class that stores parameters needed for Pauli blocking, tabulates necessary integrals and computes ...
#define SMASH_SOURCE_LOCATION
Hackery that is required to output the location in the source code where the log statement occurs.
std::ostream & operator<<(std::ostream &out, const ActionPtr &action)
Convenience: dereferences the ActionPtr to Action.
friend std::ostream & operator<<(std::ostream &out, const Action &action)
Dispatches formatting to the virtual Action::format_debug_output function.
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > logg
An array that stores all pre-configured Logger objects.
virtual void format_debug_output(std::ostream &out) const =0
Writes information about this action to the out stream.
T uniform_int(T min, T max)
static constexpr int LAction
ProcessType
ProcessTypes are used to identify the type of the process.
std::vector< ActionPtr > & operator+=(std::vector< ActionPtr > &lhs, std::vector< ActionPtr > &&rhs)
Append vector of action pointers.