Version: SMASH-2.1
particletype.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2020
3  * SMASH Team
4  *
5  * GNU General Public License (GPLv3 or later)
6  */
7 #ifndef SRC_INCLUDE_SMASH_PARTICLETYPE_H_
8 #define SRC_INCLUDE_SMASH_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;
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 
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 
186 
188  int32_t charge() const { return charge_; }
189 
191  unsigned int spin() const { return pdgcode_.spin(); }
192 
194  unsigned int spin_degeneracy() const { return pdgcode_.spin_degeneracy(); }
195 
197  bool is_hadron() const { return pdgcode_.is_hadron(); }
198 
200  bool is_lepton() const { return pdgcode_.is_lepton(); }
201 
203  bool is_baryon() const { return pdgcode_.is_baryon(); }
204 
206  bool is_meson() const { return pdgcode_.is_meson(); }
207 
209  int baryon_number() const { return pdgcode_.baryon_number(); }
210 
212  int strangeness() const { return pdgcode_.strangeness(); }
213 
215  bool is_nucleon() const { return pdgcode_.is_nucleon(); }
216 
218  bool is_Delta() const { return pdgcode_.is_Delta(); }
219 
221  bool is_rho() const { return pdgcode_.is_rho(); }
222 
224  inline bool is_Nstar() const {
225  return is_baryon() && isospin() == 1 && !pdgcode_.is_nucleon() &&
226  pdgcode_.strangeness() == 0 && pdgcode_.charmness() == 0;
227  }
228 
230  bool is_Nstar1535() const { return pdgcode_.is_Nstar1535(); }
231 
233  inline bool is_Deltastar() const {
234  return is_baryon() && isospin() == 3 && !pdgcode_.is_Delta() &&
235  pdgcode_.strangeness() == 0 && pdgcode_.charmness() == 0;
236  }
237 
239  inline bool is_stable() const { return width_ < width_cutoff; }
240 
242  inline bool is_nucleus() const { return pdgcode_.is_nucleus(); }
243 
245  inline bool is_deuteron() const { return pdgcode_.is_deuteron(); }
246 
248  inline bool is_dprime() const {
249  return is_nucleus() && std::abs(pdgcode_.get_decimal()) == 1000010021;
250  }
251 
262  double min_mass_kinematic() const;
263 
279  double min_mass_spectral() const;
280 
289  double partial_width(const double m, const DecayBranch *mode) const;
290 
297  double total_width(const double m) const;
298 
306  bool wanted_decaymode(const DecayType &t, WhichDecaymodes wh) const;
307 
317  DecayBranchList get_partial_widths(const FourVector p, const ThreeVector x,
318  WhichDecaymodes wh) const;
319 
328  double get_partial_width(const double m,
329  const ParticleTypePtrList dlist) const;
330 
342  double get_partial_in_width(const double m, const ParticleData &p_a,
343  const ParticleData &p_b) const;
344 
359  double spectral_function(double m) const;
360 
369  double spectral_function_no_norm(double m) const;
370 
376  double spectral_function_const_width(double m) const;
377 
388  double spectral_function_simple(double m) const;
389 
400  double sample_resonance_mass(const double mass_stable,
401  const double cms_energy, int L = 0) const;
402 
413  std::pair<double, double> sample_resonance_masses(const ParticleType &t2,
414  const double cms_energy,
415  int L = 0) const;
416 
424 
432  static const ParticleTypeList &list_all();
433 
435  static ParticleTypePtrList &list_nucleons();
437  static ParticleTypePtrList &list_anti_nucleons();
442  static ParticleTypePtrList &list_Deltas();
447  static ParticleTypePtrList &list_anti_Deltas();
452  static ParticleTypePtrList &list_baryon_resonances();
457  static ParticleTypePtrList &list_light_nuclei();
458 
473  static const ParticleTypePtr try_find(PdgCode pdgcode);
474 
488  static const ParticleType &find(PdgCode pdgcode);
489 
491  struct PdgNotFoundFailure : public std::runtime_error {
492  using std::runtime_error::runtime_error;
493  };
494 
501  static bool exists(PdgCode pdgcode);
502 
509  static bool exists(const std::string &name);
510 
524  static void create_type_list(const std::string &particles);
525 
530  bool operator==(const ParticleType &rhs) const {
531  return pdgcode() == rhs.pdgcode();
532  }
537  bool operator!=(const ParticleType &rhs) const {
538  return pdgcode() != rhs.pdgcode();
539  }
546  bool operator<(const ParticleType &rhs) const {
547  return pdgcode() < rhs.pdgcode();
548  }
549 
556  static void check_consistency();
557 
599  ParticleTypePtr operator&() const;
600 
602  struct LoadFailure : public std::runtime_error {
603  using std::runtime_error::runtime_error;
604  };
605 
606  private:
608  std::string name_;
610  double mass_;
612  double width_;
623  mutable double min_mass_kinematic_;
630  mutable double min_mass_spectral_;
633  mutable double norm_factor_ = -1.;
635  int32_t charge_;
637  mutable int isospin_;
639  int I3_;
640 
643 
645  mutable double max_factor1_ = 1.;
647  mutable double max_factor2_ = 1.;
648 
655  friend std::ostream &operator<<(std::ostream &out, const ParticleType &type);
656 };
657 
666  public:
668  const ParticleType &operator*() const { return lookup(); }
669 
671  const ParticleType *operator->() const {
672  // this requires std::addressof because &lookup() would call
673  // ParticleType::operator& and return ParticleTypePtr again
674  return std::addressof(lookup());
675  }
676 
678  ParticleTypePtr() = default;
679 
684  bool operator==(const ParticleTypePtr &rhs) const {
685  return index_ == rhs.index_;
686  }
687 
692  bool operator!=(const ParticleTypePtr &rhs) const {
693  return index_ != rhs.index_;
694  }
701  bool operator<(const ParticleTypePtr &rhs) const {
702  return index_ < rhs.index_;
703  }
704 
706  operator bool() const { return index_ != 0xffff; }
707 
708  private:
715 
720  explicit ParticleTypePtr(std::uint16_t i) : index_(i) {}
721 
733  const ParticleType &lookup() const {
734  assert(index_ != 0xffff);
735  return ParticleType::list_all()[index_];
736  }
737 
743  std::uint16_t index_ = 0xffff;
744 };
745 
747  assert(has_antiparticle());
748  return &find(pdgcode_.get_antiparticle());
749 }
750 
751 } // namespace smash
752 
753 #endif // SRC_INCLUDE_SMASH_PARTICLETYPE_H_
DecayBranch is a derivative of ProcessBranch, which is used to represent decay channels.
The DecayModes class is used to store and update information about decay branches (i....
Definition: decaymodes.h:29
DecayType is the abstract base class for all decay types.
Definition: decaytype.h:23
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
Definition: fourvector.h:33
IsoParticleType is a class to represent isospin multiplets.
ParticleData contains the dynamic information of a certain particle.
Definition: particledata.h:58
A pointer-like interface to global references to ParticleType objects.
Definition: particletype.h:665
bool operator==(const ParticleTypePtr &rhs) const
Definition: particletype.h:684
const ParticleType & operator*() const
Definition: particletype.h:668
bool operator<(const ParticleTypePtr &rhs) const
"Less than" operator
Definition: particletype.h:701
ParticleTypePtr()=default
Default construction initializes with an invalid index.
bool operator!=(const ParticleTypePtr &rhs) const
Definition: particletype.h:692
const ParticleType & lookup() const
Helper function that does the ParticleType lookup from the stored index.
Definition: particletype.h:733
std::uint16_t index_
Stores the index of the references ParticleType object in the global vector.
Definition: particletype.h:743
const ParticleType * operator->() const
Definition: particletype.h:671
ParticleTypePtr(std::uint16_t i)
Constructs a pointer to the ParticleType object at offset i.
Definition: particletype.h:720
Particle type contains the static properties of a particle species.
Definition: particletype.h:97
double min_mass_spectral_
minimum mass, where the spectral function is non-zero Mutable, because it is initialized at first cal...
Definition: particletype.h:630
double min_mass_spectral() const
The minimum mass of the resonance, where the spectral function is non-zero.
IsoParticleType * iso_multiplet_
Container for the isospin multiplet information.
Definition: particletype.h:642
int I3_
Isospin projection of the particle; filled automatically from pdgcode_.
Definition: particletype.h:639
bool is_baryon() const
Definition: particletype.h:203
const DecayModes & decay_modes() const
double spectral_function(double m) const
Full spectral function of the resonance (relativistic Breit-Wigner distribution with mass-dependent ...
Parity parity_
Parity of the particle.
Definition: particletype.h:614
int isospin3() const
Definition: particletype.h:176
std::string name_
name of the particle
Definition: particletype.h:608
ParticleTypePtr get_antiparticle() const
Definition: particletype.h:746
bool is_Nstar() const
Definition: particletype.h:224
double sample_resonance_mass(const double mass_stable, const double cms_energy, int L=0) const
Resonance mass sampling for 2-particle final state with one resonance (type given by 'this') and one ...
double get_partial_width(const double m, const ParticleTypePtrList dlist) const
Get the mass-dependent partial width of a resonance with mass m, decaying into two given daughter par...
int strangeness() const
Definition: particletype.h:212
static const ParticleTypePtr try_find(PdgCode pdgcode)
Returns the ParticleTypePtr for the given pdgcode.
Definition: particletype.cc:89
void dump_width_and_spectral_function() const
Prints out width and spectral function versus mass to the standard output.
double total_width(const double m) const
Get the mass-dependent total width of a particle with mass m.
bool wanted_decaymode(const DecayType &t, WhichDecaymodes wh) const
Helper Function that containes the if-statement logic that decides if a decay mode is either a hadron...
static const ParticleType & find(PdgCode pdgcode)
Returns the ParticleType object for the given pdgcode.
Definition: particletype.cc:99
bool is_nucleus() const
Definition: particletype.h:242
double min_mass_kinematic() const
The minimum mass of the resonance that is kinematically allowed.
PdgCode pdgcode() const
Definition: particletype.h:156
static bool exists(PdgCode pdgcode)
static void check_consistency()
double max_factor2_
Maximum factor for double-res mass sampling, cf. sample_resonance_masses.
Definition: particletype.h:647
const std::string & name() const
Definition: particletype.h:141
double min_mass_kinematic_
minimum kinematically allowed mass of the particle Mutable, because it is initialized at first call o...
Definition: particletype.h:623
ParticleType & operator=(const ParticleType &)=delete
assignment is not allowed, see copy constructor above
int32_t charge() const
The charge of the particle.
Definition: particletype.h:188
int antiparticle_sign() const
Definition: particletype.h:165
double spectral_function_no_norm(double m) const
Full spectral function without normalization factor.
static ParticleTypePtrList & list_nucleons()
Definition: particletype.cc:69
bool is_rho() const
Definition: particletype.h:221
ParticleType & operator=(ParticleType &&)=default
move ctors are needed for std::sort
bool is_hadron() const
Definition: particletype.h:197
unsigned int spin_degeneracy() const
Definition: particletype.h:194
static ParticleTypePtrList & list_anti_nucleons()
Definition: particletype.cc:71
bool is_Nstar1535() const
Definition: particletype.h:230
static const ParticleTypeList & list_all()
Definition: particletype.cc:51
bool is_stable() const
Definition: particletype.h:239
int isospin_
Isospin of the particle; filled automatically from pdgcode_.
Definition: particletype.h:637
ParticleType(const ParticleType &)=delete
Copies are not allowed as they break intended use.
bool is_dprime() const
Definition: particletype.h:248
double isospin3_rel() const
Definition: particletype.h:179
double width_
width of the particle
Definition: particletype.h:612
bool operator<(const ParticleType &rhs) const
"Less than" operator for sorting the ParticleType list (by PDG code)
Definition: particletype.h:546
bool is_Delta() const
Definition: particletype.h:218
double spectral_function_simple(double m) const
This one is the most simple form of the spectral function, using a Cauchy distribution (non-relativis...
bool operator!=(const ParticleType &rhs) const
Definition: particletype.h:537
double width_at_pole() const
Definition: particletype.h:150
static ParticleTypePtrList & list_anti_Deltas()
Definition: particletype.cc:77
PdgCode pdgcode_
PDG Code of the particle.
Definition: particletype.h:616
bool has_antiparticle() const
Definition: particletype.h:159
ParticleType(std::string n, double m, double w, Parity p, PdgCode id)
Creates a fully initialized ParticleType object.
bool is_nucleon() const
Definition: particletype.h:215
double mass() const
Definition: particletype.h:144
static ParticleTypePtrList & list_baryon_resonances()
Definition: particletype.cc:81
static constexpr double width_cutoff
Decay width cutoff for considering a particle as stable.
Definition: particletype.h:107
DecayBranchList get_partial_widths(const FourVector p, const ThreeVector x, WhichDecaymodes wh) const
Get all the mass-dependent partial decay widths of a particle with mass m.
static ParticleTypePtrList & list_Deltas()
Definition: particletype.cc:75
bool is_lepton() const
Definition: particletype.h:200
bool is_deuteron() const
Definition: particletype.h:245
bool is_meson() const
Definition: particletype.h:206
int32_t charge_
Charge of the particle; filled automatically from pdgcode_.
Definition: particletype.h:635
double get_partial_in_width(const double m, const ParticleData &p_a, const ParticleData &p_b) const
Get the mass-dependent partial in-width of a resonance with mass m, decaying into two given daughter ...
static void create_type_list(const std::string &particles)
Initialize the global ParticleType list (list_all) from the given input data.
int isospin() const
Returns twice the isospin vector length .
unsigned int spin() const
Definition: particletype.h:191
double norm_factor_
This normalization factor ensures that the spectral function is normalized to unity,...
Definition: particletype.h:633
int baryon_number() const
Definition: particletype.h:209
ParticleTypePtr operator&() const
Returns an object that acts like a pointer, except that it requires only 2 bytes and inhibits pointer...
Definition: particletype.cc:57
bool operator==(const ParticleType &rhs) const
Definition: particletype.h:530
double max_factor1_
Maximum factor for single-res mass sampling, cf. sample_resonance_mass.
Definition: particletype.h:645
double spectral_function_const_width(double m) const
ParticleType(ParticleType &&)=default
move ctors are needed for std::sort
bool is_Deltastar() const
Definition: particletype.h:233
std::pair< double, double > sample_resonance_masses(const ParticleType &t2, const double cms_energy, int L=0) const
Resonance mass sampling for 2-particle final state with two resonances.
IsoParticleType * iso_multiplet() const
Definition: particletype.h:185
double mass_sqr() const
Definition: particletype.h:147
static ParticleTypePtrList & list_light_nuclei()
Definition: particletype.cc:85
double partial_width(const double m, const DecayBranch *mode) const
Get the mass-dependent partial decay width of a particle with mass m in a particular decay mode.
Parity parity() const
Definition: particletype.h:153
double mass_
pole mass of the particle
Definition: particletype.h:610
PdgCode stores a Particle Data Group Particle Numbering Scheme particle type number.
Definition: pdgcode.h:108
bool is_Nstar1535() const
Definition: pdgcode.h:342
bool is_rho() const
Definition: pdgcode.h:390
int antiparticle_sign() const
Definition: pdgcode.h:549
int baryon_number() const
Definition: pdgcode.h:308
bool is_meson() const
Definition: pdgcode.h:321
unsigned int spin() const
Definition: pdgcode.h:521
bool is_lepton() const
Definition: pdgcode.h:302
bool is_nucleus() const
Definition: pdgcode.h:291
bool is_deuteron() const
Definition: pdgcode.h:396
int charmness() const
Definition: pdgcode.h:465
int strangeness() const
Definition: pdgcode.h:458
int32_t get_decimal() const
Definition: pdgcode.h:667
bool is_baryon() const
Definition: pdgcode.h:318
bool is_nucleon() const
Definition: pdgcode.h:324
PdgCode get_antiparticle() const
Construct the antiparticle to a given PDG code.
Definition: pdgcode.h:259
bool is_hadron() const
Definition: pdgcode.h:297
bool is_Delta() const
Definition: pdgcode.h:348
bool has_antiparticle() const
Definition: pdgcode.h:405
unsigned int spin_degeneracy() const
Definition: pdgcode.h:542
The ThreeVector class represents a physical three-vector with the components .
Definition: threevector.h:31
friend std::ostream & operator<<(std::ostream &out, const ParticleType &type)
Writes all information about the particle type to the output stream.
constexpr int p
Proton.
constexpr int n
Neutron.
Definition: action.h:24
void operator*=(Parity &x, Parity y)
Definition: particletype.h:75
EnergyMomentumTensor operator-(EnergyMomentumTensor a, const EnergyMomentumTensor &b)
Direct subtraction operator.
Parity
Represent the parity of a particle type.
Definition: particletype.h:24
@ Neg
Negative parity.
@ Pos
Positive parity.
EnergyMomentumTensor operator*(EnergyMomentumTensor a, const double b)
Direct multiplication operator.
WhichDecaymodes
Decide which decay mode widths are returned in get partical widths.
Definition: particletype.h:32
@ Hadronic
Ignore dilepton decay modes widths.
@ Dileptons
Only return dilepton decays widths.
@ All
All decay mode widths.