Version: SMASH-3.4
decaymodes.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2018,2020
3  * SMASH Team
4  *
5  * GNU General Public License (GPLv3 or later)
6  */
7 #ifndef SRC_INCLUDE_SMASH_DECAYMODES_H_
8 #define SRC_INCLUDE_SMASH_DECAYMODES_H_
9 
10 #include <stdexcept>
11 #include <string>
12 #include <utility>
13 #include <vector>
14 
15 #include "processbranch.h"
16 
17 namespace smash {
18 
19 /**
20  * \ingroup data
21  *
22  * The DecayModes class is used to store and update information about decay
23  * branches (i.e. the possible children a mother particle can decay into),
24  * including their relative weights.
25  *
26  * If you want to find a DecayModes object for a specific particle type use
27  * ParticleType::decay_modes().
28  */
29 class DecayModes {
30  public:
31  /**
32  * Add a decay mode using all necessary information
33  *
34  * \param[in] mother the particle which decays
35  * \param[in] ratio the weight to add to the current mode
36  * \param[in] L angular momentum
37  * \param[in] particle_types a list of the products of the decay
38  */
39  void add_mode(ParticleTypePtr mother, double ratio, int L,
40  ParticleTypePtrList particle_types);
41 
42  /**
43  * Add a decay mode from an already existing decay branch
44  *
45  * \param[in] branch the decay branch to add
46  */
47  void add_mode(DecayBranchPtr branch) {
48  decay_modes_.push_back(std::move(branch));
49  }
50 
51  /**
52  * Renormalize the branching ratios to add up to 1.
53  *
54  * \param[in] name the name of the decaying particle
55  * \return if the branching ratios were renormalized by more than 1%
56  */
57  bool renormalize(const std::string &name);
58 
59  /// \return true if empty (i.e. no decay modes)
60  bool is_empty() const { return decay_modes_.empty(); }
61 
62  /// \return pass out the decay modes list
63  const DecayBranchList &decay_mode_list() const { return decay_modes_; }
64 
65  /**
66  * Loads the DecayModes map as described in the \p input string.
67  *
68  * It does sanity checking - that the particles it talks about are in the
69  * ParticleType map.
70  *
71  * \param[in] input the full decaymodes input file, as a string
72  * \throw MissingDecays if there are no decays specified for an unstable
73  * particle
74  * \throw LoadFailure if there are duplicate entries detailing decaymodes
75  * for the same particle, or if the angular momentum is
76  * smaller than 0 or larger than 4
77  * \throw InvalidDecay if product of the decay does not exist in the
78  * particle list or as an isospin multiplet, or if
79  * decay is forbidden by isospin or charge conservation,
80  * or if sum of the minimum mass of products is less
81  * than the pole mass of the mother particle
82  * \throw runtime_error if there are less than 2 or more than 3 products
83  * to a given decay branch, or if a branch cannot be
84  * found to be part of an isospin multiplet
85  */
86  static void load_decaymodes(const std::string &input);
87 
88  /**
89  * Retrieve a decay type.
90  *
91  * \param[in] mother the decaying particle
92  * \param[in] particle_types the products of the decay
93  * \param[in] L the angular momentum
94  * \return the corresponding DecayType object
95  * \throw InvalidDecay if there are less than 2 or more than 3 products
96  */
98  ParticleTypePtrList particle_types, int L);
99 
100  /// \ingroup exception
101  struct InvalidDecay : public std::invalid_argument {
102  using std::invalid_argument::invalid_argument;
103  };
104  /// \ingroup exception
105  struct LoadFailure : public std::runtime_error {
106  using std::runtime_error::runtime_error;
107  };
108  /// \ingroup exception
109  struct MissingDecays : public LoadFailure {
110  using LoadFailure::LoadFailure;
111  };
112  /// \ingroup exception
114  using LoadFailure::LoadFailure;
115  };
116 
117  private:
118  /**
119  * Vector of decay modes.
120  * Each mode consists of a vector of the pdg codes of decay products
121  * and a ratio of this decay mode compared to all possible modes
122  */
123  DecayBranchList decay_modes_;
124 
125  /// allow ParticleType::decay_modes to access all_decay_modes
126  friend const DecayModes &ParticleType::decay_modes() const;
127 
128  /**
129  * A list of all DecayModes objects using the same indexing as
130  * all_particle_types.
131  */
132  static std::vector<DecayModes> *all_decay_modes;
133 };
134 
135 } // namespace smash
136 
137 #endif // SRC_INCLUDE_SMASH_DECAYMODES_H_
The DecayModes class is used to store and update information about decay branches (i....
Definition: decaymodes.h:29
const DecayBranchList & decay_mode_list() const
Definition: decaymodes.h:63
void add_mode(DecayBranchPtr branch)
Add a decay mode from an already existing decay branch.
Definition: decaymodes.h:47
bool is_empty() const
Definition: decaymodes.h:60
void add_mode(ParticleTypePtr mother, double ratio, int L, ParticleTypePtrList particle_types)
Add a decay mode using all necessary information.
Definition: decaymodes.cc:29
bool renormalize(const std::string &name)
Renormalize the branching ratios to add up to 1.
Definition: decaymodes.cc:98
static std::vector< DecayModes > * all_decay_modes
A list of all DecayModes objects using the same indexing as all_particle_types.
Definition: decaymodes.h:132
DecayBranchList decay_modes_
Vector of decay modes.
Definition: decaymodes.h:123
static DecayType * get_decay_type(ParticleTypePtr mother, ParticleTypePtrList particle_types, int L)
Retrieve a decay type.
Definition: decaymodes.cc:43
static void load_decaymodes(const std::string &input)
Loads the DecayModes map as described in the input string.
Definition: decaymodes.cc:163
DecayType is the abstract base class for all decay types.
Definition: decaytype.h:23
A pointer-like interface to global references to ParticleType objects.
Definition: particletype.h:731
const DecayModes & decay_modes() const
Definition: action.h:24