Version: SMASH-1.6
particletype.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2019
3  * SMASH Team
4  *
5  * GNU General Public License (GPLv3 or later)
6  */
7 #ifndef SRC_INCLUDE_PARTICLETYPE_H_
8 #define SRC_INCLUDE_PARTICLETYPE_H_
9 
10 #include <cassert>
11 #include <string>
12 #include <utility>
13 #include <vector>
14 
15 #include "forwarddeclarations.h"
16 #include "macros.h"
17 #include "pdgcode.h"
18 
19 namespace smash {
20 
24 enum class Parity {
26  Pos,
28  Neg
29 };
30 
32 enum class WhichDecaymodes {
34  All,
36  Hadronic,
38  Dileptons
39 };
40 
46  switch (p) {
47  case Parity::Pos:
48  return Parity::Neg;
49  case Parity::Neg:
50  return Parity::Pos;
51  }
52  // This is unreachable and should be optimized away.
53  // It is required to silence a compiler warning.
54  throw std::runtime_error("unreachable");
55 }
56 
62 inline Parity operator*(Parity x, Parity y) {
63  if (x == y) {
64  return Parity::Pos;
65  } else {
66  return Parity::Neg;
67  }
68 }
69 
75 inline void operator*=(Parity &x, Parity y) {
76  if (x == y) {
77  x = Parity::Pos;
78  } else {
79  x = Parity::Neg;
80  }
81 }
82 
97 class ParticleType {
98  public:
105  // If this is changed, make sure to update the userguide in
106  // `include/configuration.h`.
107  static constexpr double width_cutoff = 1e-5;
108 
122  ParticleType(std::string n, double m, double w, Parity p, PdgCode id);
123 
128  ParticleType(const ParticleType &) = delete;
130  ParticleType &operator=(const ParticleType &) = delete;
131 
133  ParticleType(ParticleType &&) = default;
135  ParticleType &operator=(ParticleType &&) = default;
136 
138  const DecayModes &decay_modes() const;
139 
141  const std::string &name() const { return name_; }
142 
144  double mass() const { return mass_; }
145 
147  double mass_sqr() const { return mass_ * mass_; }
148 
150  double width_at_pole() const { return width_; }
151 
153  Parity parity() const { return parity_; }
154 
156  PdgCode pdgcode() const { return pdgcode_; }
157 
159  bool has_antiparticle() const { return pdgcode_.has_antiparticle(); }
160 
162  ParticleTypePtr get_antiparticle() const;
163 
165  int antiparticle_sign() const { return pdgcode_.antiparticle_sign(); }
166 
173  int isospin() const;
174 
176  int isospin3() const { return I3_; }
177 
179  double isospin3_rel() const {
180  unsigned int I = isospin();
181  return (I == 0) ? 0 : static_cast<double>(isospin3()) / I;
182  }
183 
185  IsoParticleType *iso_multiplet() const { return iso_multiplet_; }
186 
188  int32_t charge() const { return charge_; }
189 
191  unsigned int spin() const { return pdgcode_.spin(); }
192 
194  bool is_hadron() const { return pdgcode_.is_hadron(); }
195 
197  bool is_lepton() const { return pdgcode_.is_lepton(); }
198 
200  bool is_baryon() const { return pdgcode_.is_baryon(); }
201 
203  bool is_meson() const { return pdgcode_.is_meson(); }
204 
206  int baryon_number() const { return pdgcode_.baryon_number(); }
207 
209  int strangeness() const { return pdgcode_.strangeness(); }
210 
212  bool is_nucleon() const { return pdgcode_.is_nucleon(); }
213 
215  bool is_Delta() const { return pdgcode_.is_Delta(); }
216 
218  bool is_rho() const { return pdgcode_.is_rho(); }
219 
221  inline bool is_Nstar() const {
222  return is_baryon() && isospin() == 1 && !pdgcode_.is_nucleon() &&
223  pdgcode_.strangeness() == 0 && pdgcode_.charmness() == 0;
224  }
225 
227  bool is_Nstar1535() const { return pdgcode_.is_Nstar1535(); }
228 
230  inline bool is_Deltastar() const {
231  return is_baryon() && isospin() == 3 && !pdgcode_.is_Delta() &&
232  pdgcode_.strangeness() == 0 && pdgcode_.charmness() == 0;
233  }
234 
236  inline bool is_stable() const { return width_ < width_cutoff; }
237 
239  inline bool is_nucleus() const { return pdgcode_.is_nucleus(); }
240 
242  inline bool is_deuteron() const { return pdgcode_.is_deuteron(); }
243 
245  inline bool is_dprime() const {
246  return is_nucleus() && std::abs(pdgcode_.get_decimal()) == 1000010021;
247  }
248 
259  double min_mass_kinematic() const;
260 
272  double min_mass_spectral() const;
273 
282  double partial_width(const double m, const DecayBranch *mode) const;
283 
290  double total_width(const double m) const;
291 
299  bool wanted_decaymode(const DecayType &t, WhichDecaymodes wh) const;
300 
310  DecayBranchList get_partial_widths(const FourVector p, const ThreeVector x,
311  WhichDecaymodes wh) const;
312 
322  double get_partial_width(const double m, const ParticleType &t_a,
323  const ParticleType &t_b) const;
324 
336  double get_partial_in_width(const double m, const ParticleData &p_a,
337  const ParticleData &p_b) const;
338 
353  double spectral_function(double m) const;
354 
363  double spectral_function_no_norm(double m) const;
364 
370  double spectral_function_const_width(double m) const;
371 
382  double spectral_function_simple(double m) const;
383 
394  double sample_resonance_mass(const double mass_stable,
395  const double cms_energy, int L = 0) const;
396 
407  std::pair<double, double> sample_resonance_masses(const ParticleType &t2,
408  const double cms_energy,
409  int L = 0) const;
410 
417  void dump_width_and_spectral_function() const;
418 
426  static const ParticleTypeList &list_all();
427 
429  static ParticleTypePtrList &list_nucleons();
431  static ParticleTypePtrList &list_anti_nucleons();
436  static ParticleTypePtrList &list_Deltas();
441  static ParticleTypePtrList &list_anti_Deltas();
446  static ParticleTypePtrList &list_baryon_resonances();
451  static ParticleTypePtrList &list_light_nuclei();
452 
467  static const ParticleTypePtr try_find(PdgCode pdgcode);
468 
482  static const ParticleType &find(PdgCode pdgcode);
483 
485  struct PdgNotFoundFailure : public std::runtime_error {
486  using std::runtime_error::runtime_error;
487  };
488 
495  static bool exists(PdgCode pdgcode);
496 
503  static bool exists(const std::string &name);
504 
518  static void create_type_list(const std::string &particles);
519 
524  bool operator==(const ParticleType &rhs) const {
525  return pdgcode() == rhs.pdgcode();
526  }
531  bool operator!=(const ParticleType &rhs) const {
532  return pdgcode() != rhs.pdgcode();
533  }
540  bool operator<(const ParticleType &rhs) const {
541  return pdgcode() < rhs.pdgcode();
542  }
543 
545  static void check_consistency();
546 
588  ParticleTypePtr operator&() const;
589 
591  struct LoadFailure : public std::runtime_error {
592  using std::runtime_error::runtime_error;
593  };
594 
595  private:
597  std::string name_;
599  double mass_;
601  double width_;
612  mutable double min_mass_kinematic_;
619  mutable double min_mass_spectral_;
622  mutable double norm_factor_ = -1.;
624  int32_t charge_;
626  mutable int isospin_;
628  int I3_;
629 
631  IsoParticleType *iso_multiplet_ = nullptr;
632 
634  mutable double max_factor1_ = 1.;
636  mutable double max_factor2_ = 1.;
637 
644  friend std::ostream &operator<<(std::ostream &out, const ParticleType &type);
645 };
646 
655  public:
657  const ParticleType &operator*() const { return lookup(); }
658 
660  const ParticleType *operator->() const {
661  // this requires std::addressof because &lookup() would call
662  // ParticleType::operator& and return ParticleTypePtr again
663  return std::addressof(lookup());
664  }
665 
667  ParticleTypePtr() = default;
668 
673  bool operator==(const ParticleTypePtr &rhs) const {
674  return index_ == rhs.index_;
675  }
676 
681  bool operator!=(const ParticleTypePtr &rhs) const {
682  return index_ != rhs.index_;
683  }
690  bool operator<(const ParticleTypePtr &rhs) const {
691  return index_ < rhs.index_;
692  }
693 
695  operator bool() const { return index_ != 0xffff; }
696 
697  private:
704 
709  explicit ParticleTypePtr(std::uint16_t i) : index_(i) {}
710 
722  const ParticleType &lookup() const {
723  assert(index_ != 0xffff);
724  return ParticleType::list_all()[index_];
725  }
726 
732  std::uint16_t index_ = 0xffff;
733 };
734 
736  assert(has_antiparticle());
737  return &find(pdgcode_.get_antiparticle());
738 }
739 
740 } // namespace smash
741 
742 #endif // SRC_INCLUDE_PARTICLETYPE_H_
bool is_Delta() const
Definition: particletype.h:215
const ParticleType & lookup() const
Helper function that does the ParticleType lookup from the stored index.
Definition: particletype.h:722
int isospin3() const
Definition: particletype.h:176
int I3_
Isospin projection of the particle; filled automatically from pdgcode_.
Definition: particletype.h:628
The ThreeVector class represents a physical three-vector with the components .
Definition: threevector.h:30
bool has_antiparticle() const
Definition: particletype.h:159
void operator*=(Parity &x, Parity y)
Definition: particletype.h:75
PdgCode pdgcode_
PDG Code of the particle.
Definition: particletype.h:605
int baryon_number() const
Definition: particletype.h:206
Parity parity_
Parity of the particle.
Definition: particletype.h:603
bool is_stable() const
Definition: particletype.h:236
bool operator!=(const ParticleType &rhs) const
Definition: particletype.h:531
bool is_Nstar() const
Definition: particletype.h:221
bool operator<(const ParticleTypePtr &rhs) const
"Less than" operator
Definition: particletype.h:690
bool operator<(const ParticleType &rhs) const
"Less than" operator for sorting the ParticleType list (by PDG code)
Definition: particletype.h:540
bool is_lepton() const
Definition: particletype.h:197
Parity
Represent the parity of a particle type.
Definition: particletype.h:24
std::string name_
name of the particle
Definition: particletype.h:597
EnergyMomentumTensor operator-(EnergyMomentumTensor a, const EnergyMomentumTensor &b)
Direct subtraction operator.
bool is_baryon() const
Definition: particletype.h:200
double mass_
pole mass of the particle
Definition: particletype.h:599
bool is_hadron() const
Definition: particletype.h:194
DecayType is the abstract base class for all decay types.
Definition: decaytype.h:23
bool operator!=(const ParticleTypePtr &rhs) const
Definition: particletype.h:681
ParticleTypePtr operator&() const
Returns an object that acts like a pointer, except that it requires only 2 bytes and inhibits pointer...
Definition: particletype.cc:61
IsoParticleType * iso_multiplet() const
Definition: particletype.h:185
static const ParticleTypeList & list_all()
Definition: particletype.cc:55
double mass() const
Definition: particletype.h:144
bool is_nucleon() const
Definition: particletype.h:212
const std::string & name() const
Definition: particletype.h:141
const ParticleType * operator->() const
Definition: particletype.h:660
bool operator==(const ParticleType &rhs) const
Definition: particletype.h:524
Particle type contains the static properties of a particle species.
Definition: particletype.h:97
IsoParticleType is a class to represent isospin multiplets.
WhichDecaymodes
Decide which decay mode widths are returned in get partical widths.
Definition: particletype.h:32
bool is_nucleus() const
Definition: particletype.h:239
Ignore dilepton decay modes widths.
bool is_dprime() const
Definition: particletype.h:245
EnergyMomentumTensor operator*(EnergyMomentumTensor a, const double b)
Direct multiplication operator.
PdgCode stores a Particle Data Group Particle Numbering Scheme particle type number.
Definition: pdgcode.h:108
double min_mass_spectral_
minimum mass, where the spectral function is non-zero Mutable, because it is initialized at first cal...
Definition: particletype.h:619
bool operator==(const ParticleTypePtr &rhs) const
Definition: particletype.h:673
Only return dilepton decays widths.
double mass_sqr() const
Definition: particletype.h:147
int strangeness() const
Definition: particletype.h:209
Negative parity.
ParticleTypePtr get_antiparticle() const
Definition: particletype.h:735
bool is_meson() const
Definition: particletype.h:203
int32_t charge() const
The charge of the particle.
Definition: particletype.h:188
DecayBranch is a derivative of ProcessBranch, which is used to represent decay channels.
All decay mode widths.
bool is_Nstar1535() const
Definition: particletype.h:227
bool is_deuteron() const
Definition: particletype.h:242
PdgCode pdgcode() const
Definition: particletype.h:156
int antiparticle_sign() const
Definition: particletype.h:165
constexpr int p
Proton.
std::uint16_t index_
Stores the index of the references ParticleType object in the global vector.
Definition: particletype.h:732
const ParticleType & operator*() const
Definition: particletype.h:657
double width_at_pole() const
Definition: particletype.h:150
int32_t charge_
Charge of the particle; filled automatically from pdgcode_.
Definition: particletype.h:624
int isospin_
Isospin of the particle; filled automatically from pdgcode_.
Definition: particletype.h:626
A pointer-like interface to global references to ParticleType objects.
Definition: particletype.h:654
double width_
width of the particle
Definition: particletype.h:601
double isospin3_rel() const
Definition: particletype.h:179
Parity parity() const
Definition: particletype.h:153
constexpr int n
Neutron.
double min_mass_kinematic_
minimum kinematically allowed mass of the particle Mutable, because it is initialized at first call o...
Definition: particletype.h:612
std::ostream & operator<<(std::ostream &out, const ActionPtr &action)
Convenience: dereferences the ActionPtr to Action.
Definition: action.h:463
The DecayModes class is used to store and update information about decay branches (i...
Definition: decaymodes.h:29
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
Definition: fourvector.h:32
unsigned int spin() const
Definition: particletype.h:191
bool is_rho() const
Definition: particletype.h:218
ParticleData contains the dynamic information of a certain particle.
Definition: particledata.h:52
ParticleTypePtr(std::uint16_t i)
Constructs a pointer to the ParticleType object at offset i.
Definition: particletype.h:709
Positive parity.
Definition: action.h:24
bool is_Deltastar() const
Definition: particletype.h:230