Version: SMASH-2.2
decayactionsfinder.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2014-2022
4  * SMASH Team
5  *
6  * GNU General Public License (GPLv3 or later)
7  *
8  */
9 
11 
12 #include "smash/constants.h"
13 #include "smash/cxx14compat.h"
14 #include "smash/decayaction.h"
15 #include "smash/decaymodes.h"
16 #include "smash/fourvector.h"
17 #include "smash/random.h"
18 
19 namespace smash {
20 
22  const ParticleList &search_list, double dt, const double,
23  const std::vector<FourVector> &) const {
24  ActionList actions;
25  /* for short time steps this seems reasonable to expect
26  * less than 10 decays in most time steps */
27  actions.reserve(10);
28 
29  for (const auto &p : search_list) {
30  if (p.type().is_stable()) {
31  continue; // particle doesn't decay
32  }
33 
34  DecayBranchList processes = p.type().get_partial_widths(
35  p.momentum(), p.position().threevec(), WhichDecaymodes::Hadronic);
36  // total decay width (mass-dependent)
37  const double width = total_weight<DecayBranch>(processes);
38 
39  // check if there are any (hadronic) decays
40  if (!(width > 0.0)) {
41  continue;
42  }
43 
44  constexpr double one_over_hbarc = 1. / hbarc;
45 
46  /* The decay_time is sampled from an exponential distribution.
47  * Even though it may seem suspicious that it is sampled every
48  * timestep, it can be proven that this still overall obeys
49  * the exponential decay law.
50  */
51  double decay_time =
52  res_lifetime_factor_ * random::exponential<double>(
53  /* The clock goes slower in the rest
54  * frame of the resonance */
55  one_over_hbarc * p.inverse_gamma() * width);
56  /* If the particle is not yet formed, shift the decay time by the time it
57  * takes the particle to form */
58  if (p.xsec_scaling_factor() < 1.0) {
59  decay_time += p.formation_time() - p.position().x0();
60  }
61  if (decay_time < dt) {
62  /* => decay_time ∈ [0, dt[
63  * => the particle decays in this timestep. */
64  auto act = make_unique<DecayAction>(p, decay_time);
65  act->add_decays(std::move(processes));
66  actions.emplace_back(std::move(act));
67  }
68  }
69  return actions;
70 }
71 
72 ActionList DecayActionsFinder::find_final_actions(const Particles &search_list,
73  bool /*only_res*/) const {
74  ActionList actions;
75 
76  for (const auto &p : search_list) {
77  if (!do_final_weak_decays_ && p.type().is_stable()) {
78  continue; // particle is stable with respect to strong interaction
79  }
80 
81  if (p.type().decay_modes().is_empty()) {
82  continue; // particle cannot decay (not even e.m. or weakly)
83  }
84 
85  auto act = make_unique<DecayAction>(p, 0.);
86  act->add_decays(p.type().get_partial_widths(
87  p.momentum(), p.position().threevec(), WhichDecaymodes::All));
88  actions.emplace_back(std::move(act));
89  }
90  return actions;
91 }
92 
93 } // namespace smash
const double res_lifetime_factor_
Multiplicative factor to be applied to resonance lifetimes.
const bool do_final_weak_decays_
Do weak decays at the end? Weak here means all non-strong decays, so electro-magnetic decays are done...
ActionList find_final_actions(const Particles &search_list, bool only_res=false) const override
Force all resonances to decay at the end of the simulation.
ActionList find_actions_in_cell(const ParticleList &search_list, double dt, const double, const std::vector< FourVector > &) const override
Check the whole particle list for decays.
The Particles class abstracts the storage and manipulation of particles.
Definition: particles.h:33
Collection of useful constants that are known at compile time.
constexpr int p
Proton.
Definition: action.h:24
constexpr double hbarc
GeV <-> fm conversion factor.
Definition: constants.h:25
@ Hadronic
Ignore dilepton decay modes widths.
@ All
All decay mode widths.