Version: SMASH-3.4
isoparticletype.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2022
3  * SMASH Team
4  *
5  * GNU General Public License (GPLv3 or later)
6  */
7 
8 #ifndef SRC_INCLUDE_SMASH_ISOPARTICLETYPE_H_
9 #define SRC_INCLUDE_SMASH_ISOPARTICLETYPE_H_
10 
11 #include <filesystem>
12 #include <string>
13 #include <unordered_map>
14 #include <vector>
15 
16 #include "particletype.h"
17 #include "sha256.h"
18 #include "tabulation.h"
19 
20 namespace smash {
21 
22 /**
23  * \ingroup data
24  *
25  * IsoParticleType is a class to represent isospin multiplets.
26  * It is similar to ParticleType, but refers to whole multiplets instead of
27  * single particle states.
28  */
30  public:
31  /**
32  * Creates a fully initialized IsoParticleType object.
33  *
34  * \param n The name of the multiplet.
35  * \param m The (average) mass of the multiplet.
36  * \param w The (average) width of the multiplet.
37  * \param s Twice the spin of the multiplet.
38  * \param p Parity of the multiplet.
39  */
40  IsoParticleType(const std::string &n, double m, double w, unsigned int s,
41  Parity p);
42 
43  /**
44  * Copies are not allowed as they break intended use. Instead use a const-ref
45  * or ParticleTypePtr (as returned from operator&).
46  */
47  IsoParticleType(const IsoParticleType &) = delete;
48  /// Assignment is not allowed, see copy constructor above
50 
51  /// Move constructor of IsoParticleType (needed for std::sort)
53  /// Move constructor of IsoParticleType "="-operator (needed for std::sort)
55 
56  /**
57  * Returns whether the two IsoParticleType objects have the same PDG code for
58  * their first state; if so, it is the same iso multiplet.
59  *
60  * \param rhs The other multiplet.
61  */
62  bool operator==(const IsoParticleType &rhs) const {
63  return states_[0]->pdgcode() == rhs.states_[0]->pdgcode();
64  }
65 
66  /// Returns the name of the multiplet.
67  const std::string &name() const { return name_; }
68 
69  /**
70  * Returns the name of the multiplet, after replacing "'" with "_prime"
71  *
72  * This function is meant to be used when creating file names. The motivation
73  * of this replacement is that handling files whose names
74  * contain an apostrophe "'" can be problematic, especially for administrators
75  * of computer clusters that rely on a set of well tested scripts to copy or
76  * move large amount of data between different storage devices.
77  *
78  */
79  const std::string name_filtered_prime() const {
80  std::string tmp_s = name_;
81  std::size_t found_position = tmp_s.find("'");
82  if (found_position != std::string::npos) {
83  tmp_s.erase(found_position, 1);
84  tmp_s.insert(found_position, "_prime");
85  }
86  return tmp_s;
87  }
88 
89  /// Returns the (average) multiplet mass.
90  double mass() const { return mass_; }
91 
92  /// Returns the (average) multiplet width.
93  double width() const { return width_; }
94 
95  /// Returns twice the total isospin of the multiplet.
96  int isospin() const { return states_.size() - 1; }
97 
98  /**
99  * Returns twice the spin of the multiplet. All particles in the multiplet
100  * are required to have the same spin.
101  */
102  unsigned int spin() const { return spin_; }
103 
104  /**
105  * \return The parity of the multiplet.
106  */
107  Parity parity() const { return parity_; }
108 
109  /**
110  * \return Is this a hadron multiplet?
111  */
112  bool is_hadron() const { return states_[0]->is_hadron(); }
113 
114  /// Returns list of states that form part of the multiplet.
115  ParticleTypePtrList get_states() const { return states_; }
116 
117  /**
118  * Add a new state to an existing multiplet
119  * (and check if isospin symmetry is fulfilled).
120  *
121  * \param type The particle state to be added.
122  */
123  void add_state(const ParticleType &type);
124 
125  /**
126  * Return a multiplet of antiparticles, if it is different from
127  * the original multiplet. Otherwise, return a nullptr.
128  */
129  const IsoParticleType *anti_multiplet() const;
130 
131  /**
132  * Check if there is a multiplet of antiparticles, which is different from
133  * the original multiplet.
134  */
135  bool has_anti_multiplet() const;
136 
137  /// Returns a list of all IsoParticleTypes.
138  static const IsoParticleTypeList &list_all();
139 
140  /// Returns a list of all IsoParticleTypes that are baryon
141  /// resonances.
142  static const std::vector<const IsoParticleType *> list_baryon_resonances();
143 
144  /**
145  * Returns the IsoParticleType pointer for the given \p name.
146  * If the particle type is not found, an invalid pointer is returned.
147  * You can convert the pointer to a bool to check whether it is valid.
148  *
149  * \param name The name of the particle type.
150  * \note The complexity of the search is \f$\mathcal O(\log N)\f$.
151  */
152  static const IsoParticleType *try_find(const std::string &name);
153 
154  /**
155  * Returns the IsoParticleType object for the given \p name.
156  *
157  * \param name The name of the of the particle type to be found.
158  * \throw ParticleNotFoundFailure if \p name not found.
159  * \note The complexity of the search is \f$\mathcal O(\log N)\f$.
160  */
161  static const IsoParticleType &find(const std::string &name);
162 
163  /**
164  * Returns the IsoParticleType object for the given \p type.
165  *
166  * \param type The particle type to be found.
167  * \throw ParticleNotFoundFailure if \p type not found.
168  * \note The complexity of the search is \f$\mathcal O(\log N)\f$.
169  */
170  static IsoParticleType *find(const ParticleType &type);
171 
172  /** \ingroup exception
173  *
174  * Throw when requested particle could not be found.
175  */
176  struct ParticleNotFoundFailure : public std::runtime_error {
177  using std::runtime_error::runtime_error;
178  };
179 
180  /**
181  * Returns whether the ParticleType with the given \p pdgcode exists.
182  *
183  * \param name The name of the particle type to be found.
184  * \note The complexity of the search is \f$\mathcal O(\log N)\f$.
185  */
186  static bool exists(const std::string &name);
187 
188  /**
189  * Returns the ParticleType object for the given \p name, by first finding the
190  * correct multiplet and then looking for the desired state.
191  *
192  * \param name The name of the particle state to be found.
193  * \throw std::runtime_error if \p name is not found.
194  */
195  static const ParticleTypePtr find_state(const std::string &name);
196 
197  /**
198  * Add a new multiplet to the global list of IsoParticleTypes, which contains
199  * \p type. If the multiplet exists already, the \p type will be added to
200  * it.
201  *
202  * \param type The multiplet to be created.
203  */
204  static void create_multiplet(const ParticleType &type);
205 
206  /**
207  * Tabulate all relevant integrals.
208  *
209  * \param hash The hash of the particle properties.
210  * This is used to determine whether a cached tabulation can be
211  * reused or not.
212  * \param tabulations_path The path to the directory where the tabulations are
213  * cached.
214  */
215  static void tabulate_integrals(sha256::Hash hash,
216  const std::filesystem::path &tabulations_path);
217 
218  /**
219  * Look up the tabulated resonance integral for the XX -> NR cross section.
220  *
221  * \param sqrts The center-of-mass energy.
222  */
223  double get_integral_NR(double sqrts);
224 
225  /**
226  * Look up the tabulated resonance integral for the XX -> RR cross section.
227  *
228  * \param type_res_2 Type of the two resonances in the final state.
229  * \param sqrts The center-of-mass energy.
230  */
231  double get_integral_RR(IsoParticleType *type_res_2, double sqrts);
232 
233  /**
234  * Look up the tabulated resonance integral for the XX -> RK cross section.
235  *
236  * \param sqrts The center-of-mass energy.
237  */
238  double get_integral_RK(double sqrts);
239 
240  /**
241  * Look up the tabulated resonance integral for the XX -> piR cross section.
242  *
243  * \param sqrts The center-of-mass energy.
244  */
245  double get_integral_piR(double sqrts);
246 
247  /**
248  * Look up the tabulated resonance integral for the XX -> rhoR cross section.
249  *
250  * \param sqrts The center-of-mass energy.
251  */
252  double get_integral_rhoR(double sqrts);
253 
254  private:
255  /// name of the multiplet
256  std::string name_;
257  /// (average) mass of the multiplet
258  double mass_;
259  /// (average) width of the multiplet
260  double width_;
261  /// twice the spin of the multiplet
262  unsigned int spin_;
263  /// parity of the multiplet
265  /// list of states that are contained in the multiplet
266  ParticleTypePtrList states_;
267 
268  /// A tabulation of the spectral integral for the dpi -> d'pi cross sections.
270  /// A tabulation of the spectral integral for the NK -> RK cross sections.
272  /**
273  * A tabulation for the NN -> NR cross sections,
274  * where R is a resonance from this multiplet.
275  */
277  /**
278  * A tabulation for the NN -> RΔ cross sections,
279  * where R is a resonance from this multiplet.
280  */
282  /**
283  * A tabulation for the ρρ integrals.
284  */
286 
287  /**
288  * Private version of the 'find' method that returns a non-const reference.
289  *
290  * \param[in] name The name of the of the particle type to be found.
291  * \throw ParticleNotFoundFailure if \p name not found.
292  */
293  static IsoParticleType &find_private(const std::string &name);
294 };
295 
296 } // namespace smash
297 
298 #endif // SRC_INCLUDE_SMASH_ISOPARTICLETYPE_H_
IsoParticleType is a class to represent isospin multiplets.
double mass_
(average) mass of the multiplet
void add_state(const ParticleType &type)
Add a new state to an existing multiplet (and check if isospin symmetry is fulfilled).
bool operator==(const IsoParticleType &rhs) const
Returns whether the two IsoParticleType objects have the same PDG code for their first state; if so,...
double width_
(average) width of the multiplet
static const IsoParticleType * try_find(const std::string &name)
Returns the IsoParticleType pointer for the given name.
IsoParticleType(IsoParticleType &&)=default
Move constructor of IsoParticleType (needed for std::sort)
Tabulation * XS_NR_tabulation_
A tabulation for the NN -> NR cross sections, where R is a resonance from this multiplet.
Tabulation * XS_rhoR_tabulation_
A tabulation for the ρρ integrals.
Parity parity_
parity of the multiplet
static bool exists(const std::string &name)
Returns whether the ParticleType with the given pdgcode exists.
double width() const
Returns the (average) multiplet width.
static const IsoParticleType & find(const std::string &name)
Returns the IsoParticleType object for the given name.
double get_integral_RR(IsoParticleType *type_res_2, double sqrts)
Look up the tabulated resonance integral for the XX -> RR cross section.
const std::string name_filtered_prime() const
Returns the name of the multiplet, after replacing "'" with "_prime".
static IsoParticleType & find_private(const std::string &name)
Private version of the 'find' method that returns a non-const reference.
static void tabulate_integrals(sha256::Hash hash, const std::filesystem::path &tabulations_path)
Tabulate all relevant integrals.
Tabulation * XS_piR_tabulation_
A tabulation of the spectral integral for the dpi -> d'pi cross sections.
int isospin() const
Returns twice the total isospin of the multiplet.
static void create_multiplet(const ParticleType &type)
Add a new multiplet to the global list of IsoParticleTypes, which contains type.
ParticleTypePtrList states_
list of states that are contained in the multiplet
bool has_anti_multiplet() const
Check if there is a multiplet of antiparticles, which is different from the original multiplet.
IsoParticleType(const std::string &n, double m, double w, unsigned int s, Parity p)
Creates a fully initialized IsoParticleType object.
IsoParticleType & operator=(const IsoParticleType &)=delete
Assignment is not allowed, see copy constructor above.
double get_integral_NR(double sqrts)
Look up the tabulated resonance integral for the XX -> NR cross section.
IsoParticleType(const IsoParticleType &)=delete
Copies are not allowed as they break intended use.
static const IsoParticleTypeList & list_all()
Returns a list of all IsoParticleTypes.
double mass() const
Returns the (average) multiplet mass.
Tabulation * XS_DeltaR_tabulation_
A tabulation for the NN -> RΔ cross sections, where R is a resonance from this multiplet.
const IsoParticleType * anti_multiplet() const
Return a multiplet of antiparticles, if it is different from the original multiplet.
IsoParticleType & operator=(IsoParticleType &&)=default
Move constructor of IsoParticleType "="-operator (needed for std::sort)
const std::string & name() const
Returns the name of the multiplet.
double get_integral_rhoR(double sqrts)
Look up the tabulated resonance integral for the XX -> rhoR cross section.
static const std::vector< const IsoParticleType * > list_baryon_resonances()
Returns a list of all IsoParticleTypes that are baryon resonances.
double get_integral_RK(double sqrts)
Look up the tabulated resonance integral for the XX -> RK cross section.
std::string name_
name of the multiplet
unsigned int spin() const
Returns twice the spin of the multiplet.
unsigned int spin_
twice the spin of the multiplet
ParticleTypePtrList get_states() const
Returns list of states that form part of the multiplet.
Tabulation * XS_RK_tabulation_
A tabulation of the spectral integral for the NK -> RK cross sections.
double get_integral_piR(double sqrts)
Look up the tabulated resonance integral for the XX -> piR cross section.
static const ParticleTypePtr find_state(const std::string &name)
Returns the ParticleType object for the given name, by first finding the correct multiplet and then l...
A pointer-like interface to global references to ParticleType objects.
Definition: particletype.h:731
Particle type contains the static properties of a particle species.
Definition: particletype.h:100
A class for storing a one-dimensional lookup table of floating-point values.
Definition: tabulation.h:30
constexpr int p
Proton.
constexpr int n
Neutron.
std::array< uint8_t, HASH_SIZE > Hash
A SHA256 hash.
Definition: sha256.h:25
Definition: action.h:24
Parity
Represent the parity of a particle type.
Definition: particletype.h:27
Throw when requested particle could not be found.