Version: SMASH-1.6
decayactionsfinder.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2014-2019
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"
16 #include "smash/fourvector.h"
17 #include "smash/particles.h"
18 #include "smash/random.h"
19 
20 namespace smash {
21 
23  const ParticleList &search_list, double dt) 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 = random::exponential<double>(
52  /* The clock goes slower in the rest
53  * frame of the resonance */
54  one_over_hbarc * p.inverse_gamma() * width);
55  /* If the particle is not yet formed, shift the decay time by the time it
56  * takes the particle to form */
57  if (p.xsec_scaling_factor() < 1.0) {
58  decay_time += p.formation_time() - p.position().x0();
59  }
60  if (decay_time < dt) {
61  /* => decay_time ∈ [0, dt[
62  * => the particle decays in this timestep. */
63  auto act = make_unique<DecayAction>(p, decay_time);
64  act->add_decays(std::move(processes));
65  actions.emplace_back(std::move(act));
66  }
67  }
68  return actions;
69 }
70 
71 ActionList DecayActionsFinder::find_final_actions(const Particles &search_list,
72  bool /*only_res*/) const {
73  ActionList actions;
74 
75  for (const auto &p : search_list) {
76  if (p.type().is_stable()) {
77  continue; // particle doesn't decay
78  }
79  auto act = make_unique<DecayAction>(p, 0.);
80  act->add_decays(p.type().get_partial_widths(
81  p.momentum(), p.position().threevec(), WhichDecaymodes::All));
82  actions.emplace_back(std::move(act));
83  }
84  return actions;
85 }
86 
87 } // namespace smash
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.
Collection of useful constants that are known at compile time.
constexpr double hbarc
GeV <-> fm conversion factor.
Definition: constants.h:25
Ignore dilepton decay modes widths.
All decay mode widths.
constexpr int p
Proton.
The Particles class abstracts the storage and manipulation of particles.
Definition: particles.h:33
Definition: action.h:24
ActionList find_actions_in_cell(const ParticleList &search_list, double dt) const override
Check the whole particle list for decays.