Version: SMASH-1.5
particletype.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2018
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 
36  switch (p) {
37  case Parity::Pos:
38  return Parity::Neg;
39  case Parity::Neg:
40  return Parity::Pos;
41  }
42  // This is unreachable and should be optimized away.
43  // It is required to silence a compiler warning.
44  throw std::runtime_error("unreachable");
45 }
46 
52 inline Parity operator*(Parity x, Parity y) {
53  if (x == y) {
54  return Parity::Pos;
55  } else {
56  return Parity::Neg;
57  }
58 }
59 
65 inline void operator*=(Parity &x, Parity y) {
66  if (x == y) {
67  x = Parity::Pos;
68  } else {
69  x = Parity::Neg;
70  }
71 }
72 
87 class ParticleType {
88  public:
95  // If this is changed, make sure to update the userguide in
96  // `include/configuration.h`.
97  static constexpr double width_cutoff = 1e-5;
98 
112  ParticleType(std::string n, double m, double w, Parity p, PdgCode id);
113 
118  ParticleType(const ParticleType &) = delete;
120  ParticleType &operator=(const ParticleType &) = delete;
121 
123  ParticleType(ParticleType &&) = default;
125  ParticleType &operator=(ParticleType &&) = default;
126 
128  const DecayModes &decay_modes() const;
129 
131  const std::string &name() const { return name_; }
132 
134  double mass() const { return mass_; }
135 
137  double mass_sqr() const { return mass_ * mass_; }
138 
140  double width_at_pole() const { return width_; }
141 
143  Parity parity() const { return parity_; }
144 
146  PdgCode pdgcode() const { return pdgcode_; }
147 
149  bool has_antiparticle() const { return pdgcode_.has_antiparticle(); }
150 
153 
155  int antiparticle_sign() const { return pdgcode_.antiparticle_sign(); }
156 
163  int isospin() const;
164 
166  int isospin3() const { return I3_; }
167 
169  double isospin3_rel() const {
170  unsigned int I = isospin();
171  return (I == 0) ? 0 : static_cast<double>(isospin3()) / I;
172  }
173 
176 
178  int charge() const { return charge_; }
179 
181  unsigned int spin() const { return pdgcode_.spin(); }
182 
184  bool is_hadron() const { return pdgcode_.is_hadron(); }
185 
187  bool is_lepton() const { return pdgcode_.is_lepton(); }
188 
190  bool is_baryon() const { return pdgcode_.is_baryon(); }
191 
193  bool is_meson() const { return pdgcode_.is_meson(); }
194 
196  int baryon_number() const { return pdgcode_.baryon_number(); }
197 
199  int strangeness() const { return pdgcode_.strangeness(); }
200 
202  bool is_nucleon() const { return pdgcode_.is_nucleon(); }
203 
205  bool is_Delta() const { return pdgcode_.is_Delta(); }
206 
208  bool is_rho() const { return pdgcode_.is_rho(); }
209 
211  inline bool is_Nstar() const {
212  return is_baryon() && isospin() == 1 && !pdgcode_.is_nucleon() &&
213  pdgcode_.strangeness() == 0 && pdgcode_.charmness() == 0;
214  }
215 
217  bool is_Nstar1535() const { return pdgcode_.is_Nstar1535(); }
218 
220  inline bool is_Deltastar() const {
221  return is_baryon() && isospin() == 3 && !pdgcode_.is_Delta() &&
222  pdgcode_.strangeness() == 0 && pdgcode_.charmness() == 0;
223  }
224 
226  inline bool is_stable() const { return width_ < width_cutoff; }
227 
229  inline bool is_nucleus() const { return pdgcode_.is_nucleus(); }
230 
232  inline bool is_deuteron() const { return pdgcode_.is_deuteron(); }
233 
235  inline bool is_dprime() const {
236  return is_nucleus() && std::abs(pdgcode_.get_decimal()) == 1000010021;
237  }
238 
249  double min_mass_kinematic() const;
250 
262  double min_mass_spectral() const;
263 
272  double partial_width(const double m, const DecayBranch *mode) const;
273 
280  double total_width(const double m) const;
281 
290  DecayBranchList get_partial_widths(const double m) const;
291 
304  DecayBranchList get_partial_widths_hadronic(const FourVector p,
305  const ThreeVector x) const;
306 
317  DecayBranchList get_partial_widths_dilepton(const double m) const;
318 
328  double get_partial_width(const double m, const ParticleType &t_a,
329  const ParticleType &t_b) 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 
551  static void check_consistency();
552 
594  ParticleTypePtr operator&() const;
595 
597  struct LoadFailure : public std::runtime_error {
598  using std::runtime_error::runtime_error;
599  };
600 
601  private:
603  std::string name_;
605  double mass_;
607  double width_;
618  mutable double min_mass_kinematic_;
625  mutable double min_mass_spectral_;
628  mutable double norm_factor_ = -1.;
630  int charge_;
632  mutable int isospin_;
634  int I3_;
635 
638 
640  mutable double max_factor1_ = 1.;
642  mutable double max_factor2_ = 1.;
643 
650  friend std::ostream &operator<<(std::ostream &out, const ParticleType &type);
651 };
652 
661  public:
663  const ParticleType &operator*() const { return lookup(); }
664 
666  const ParticleType *operator->() const {
667  // this requires std::addressof because &lookup() would call
668  // ParticleType::operator& and return ParticleTypePtr again
669  return std::addressof(lookup());
670  }
671 
673  ParticleTypePtr() = default;
674 
679  bool operator==(const ParticleTypePtr &rhs) const {
680  return index_ == rhs.index_;
681  }
682 
687  bool operator!=(const ParticleTypePtr &rhs) const {
688  return index_ != rhs.index_;
689  }
696  bool operator<(const ParticleTypePtr &rhs) const {
697  return index_ < rhs.index_;
698  }
699 
701  operator bool() const { return index_ != 0xffff; }
702 
703  private:
710 
715  explicit ParticleTypePtr(std::uint16_t i) : index_(i) {}
716 
728  const ParticleType &lookup() const {
729  assert(index_ != 0xffff);
730  return ParticleType::list_all()[index_];
731  }
732 
738  std::uint16_t index_ = 0xffff;
739 };
740 
742  assert(has_antiparticle());
743  return &find(pdgcode_.get_antiparticle());
744 }
745 
746 } // namespace smash
747 
748 #endif // SRC_INCLUDE_PARTICLETYPE_H_
unsigned int spin() const
Definition: pdgcode.h:509
double mass() const
Definition: particletype.h:134
double mass_sqr() const
Definition: particletype.h:137
bool is_Delta() const
Definition: pdgcode.h:336
bool is_Deltastar() const
Definition: particletype.h:220
int I3_
Isospin projection of the particle; filled automatically from pdgcode_.
Definition: particletype.h:634
static ParticleTypePtrList & list_baryon_resonances()
Definition: particletype.cc:85
int antiparticle_sign() const
Definition: pdgcode.h:537
The ThreeVector class represents a physical three-vector with the components .
Definition: threevector.h:30
double min_mass_spectral() const
The minimum mass of the resonance, where the spectral function is non-zero.
bool is_Nstar1535() const
Definition: pdgcode.h:330
IsoParticleType * iso_multiplet() const
Definition: particletype.h:175
bool is_lepton() const
Definition: pdgcode.h:302
static ParticleTypePtrList & list_Deltas()
Definition: particletype.cc:79
static bool exists(PdgCode pdgcode)
void operator*=(Parity &x, Parity y)
Definition: particletype.h:65
PdgCode get_antiparticle() const
Construct the antiparticle to a given PDG code.
Definition: pdgcode.h:259
PdgCode pdgcode_
PDG Code of the particle.
Definition: particletype.h:611
int get_decimal() const
Definition: pdgcode.h:655
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 &#39;this&#39;) and one ...
bool operator<(const ParticleType &rhs) const
"Less than" operator for sorting the ParticleType list (by PDG code)
Definition: particletype.h:546
Parity parity_
Parity of the particle.
Definition: particletype.h:609
static ParticleTypePtrList & list_light_nuclei()
Definition: particletype.cc:89
static void check_consistency()
bool operator!=(const ParticleType &rhs) const
Definition: particletype.h:537
bool is_Delta() const
Definition: particletype.h:205
double width_at_pole() const
Definition: particletype.h:140
bool is_nucleon() const
Definition: pdgcode.h:324
static ParticleTypePtrList & list_anti_nucleons()
Definition: particletype.cc:75
bool is_deuteron() const
Definition: particletype.h:232
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 ...
int isospin3() const
Definition: particletype.h:166
double total_width(const double m) const
Get the mass-dependent total width of a particle with mass m.
void dump_width_and_spectral_function() const
Prints out width and spectral function versus mass to the standard output.
bool is_nucleus() const
Definition: particletype.h:229
Parity parity() const
Definition: particletype.h:143
double max_factor2_
Maximum factor for double-res mass sampling, cf. sample_resonance_masses.
Definition: particletype.h:642
bool operator==(const ParticleType &rhs) const
Definition: particletype.h:530
Parity
Represent the parity of a particle type.
Definition: particletype.h:24
std::string name_
name of the particle
Definition: particletype.h:603
double spectral_function(double m) const
Full spectral function of the resonance (relativistic Breit-Wigner distribution with mass-dependent ...
bool is_baryon() const
Definition: particletype.h:190
bool is_nucleus() const
Definition: pdgcode.h:291
EnergyMomentumTensor operator-(EnergyMomentumTensor a, const EnergyMomentumTensor &b)
Direct subtraction operator.
bool operator<(const ParticleTypePtr &rhs) const
"Less than" operator
Definition: particletype.h:696
double mass_
pole mass of the particle
Definition: particletype.h:605
double isospin3_rel() const
Definition: particletype.h:169
friend std::ostream & operator<<(std::ostream &out, const ParticleType &type)
Writes all information about the particle type to the output stream.
bool is_nucleon() const
Definition: particletype.h:202
static constexpr double width_cutoff
Decay width cutoff for considering a particle as stable.
Definition: particletype.h:97
static const ParticleType & find(PdgCode pdgcode)
Returns the ParticleType object for the given pdgcode.
bool is_meson() const
Definition: particletype.h:193
static const ParticleTypeList & list_all()
Definition: particletype.cc:55
ParticleTypePtr operator &() const
Returns an object that acts like a pointer, except that it requires only 2 bytes and inhibits pointer...
int charge() const
The charge of the particle.
Definition: particletype.h:178
int baryon_number() const
Definition: particletype.h:196
bool is_rho() const
Definition: pdgcode.h:378
bool is_stable() const
Definition: particletype.h:226
Particle type contains the static properties of a particle species.
Definition: particletype.h:87
IsoParticleType is a class to represent isospin multiplets.
int strangeness() const
Definition: pdgcode.h:446
DecayBranchList get_partial_widths_dilepton(const double m) const
Get the mass-dependent dilepton partial decay widths of a particle with mass m.
int strangeness() const
Definition: particletype.h:199
const ParticleType & operator*() const
Definition: particletype.h:663
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:625
const ParticleType & lookup() const
Helper function that does the ParticleType lookup from the stored index.
Definition: particletype.h:728
bool operator!=(const ParticleTypePtr &rhs) const
Definition: particletype.h:687
double max_factor1_
Maximum factor for single-res mass sampling, cf. sample_resonance_mass.
Definition: particletype.h:640
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.
Negative parity.
ParticleTypePtr get_antiparticle() const
Definition: particletype.h:741
int charge_
Charge of the particle; filled automatically from pdgcode_.
Definition: particletype.h:630
DecayBranch is a derivative of ProcessBranch, which is used to represent decay channels.
static void create_type_list(const std::string &particles)
Initialize the global ParticleType list (list_all) from the given input data.
unsigned int spin() const
Definition: particletype.h:181
bool is_baryon() const
Definition: pdgcode.h:318
double norm_factor_
This normalization factor ensures that the spectral function is normalized to unity, when integrated over its full domain.
Definition: particletype.h:628
const ParticleType * operator->() const
Definition: particletype.h:666
bool is_Nstar() const
Definition: particletype.h:211
ParticleTypePtr()=default
Default construction initializes with an invalid index.
bool has_antiparticle() const
Definition: particletype.h:149
const DecayModes & decay_modes() const
constexpr int p
Proton.
std::uint16_t index_
Stores the index of the references ParticleType object in the global vector.
Definition: particletype.h:738
bool is_lepton() const
Definition: particletype.h:187
int isospin() const
Returns twice the isospin vector length .
int charmness() const
Definition: pdgcode.h:453
ParticleType & operator=(const ParticleType &)=delete
assignment is not allowed, see copy constructor above
static const ParticleTypePtr try_find(PdgCode pdgcode)
Returns the ParticleTypePtr for the given pdgcode.
Definition: particletype.cc:93
double spectral_function_const_width(double m) const
IsoParticleType * iso_multiplet_
Container for the isospin multiplet information.
Definition: particletype.h:637
double get_partial_width(const double m, const ParticleType &t_a, const ParticleType &t_b) const
Get the mass-dependent partial width of a resonance with mass m, decaying into two given daughter par...
double spectral_function_simple(double m) const
This one is the most simple form of the spectral function, using a Cauchy distribution (non-relativis...
double min_mass_kinematic() const
The minimum mass of the resonance that is kinematically allowed.
int isospin_
Isospin of the particle; filled automatically from pdgcode_.
Definition: particletype.h:632
A pointer-like interface to global references to ParticleType objects.
Definition: particletype.h:660
int antiparticle_sign() const
Definition: particletype.h:155
double width_
width of the particle
Definition: particletype.h:607
static ParticleTypePtrList & list_nucleons()
Definition: particletype.cc:73
bool is_deuteron() const
Definition: pdgcode.h:384
constexpr int n
Neutron.
bool is_meson() const
Definition: pdgcode.h:321
bool is_dprime() const
Definition: particletype.h:235
double min_mass_kinematic_
minimum kinematically allowed mass of the particle Mutable, because it is initialized at first call o...
Definition: particletype.h:618
bool has_antiparticle() const
Definition: pdgcode.h:393
DecayBranchList get_partial_widths_hadronic(const FourVector p, const ThreeVector x) const
Get the mass-dependent hadronic partial decay widths of a particle with mass m.
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...
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
bool is_Nstar1535() const
Definition: particletype.h:217
bool is_hadron() const
Definition: particletype.h:184
ParticleType(std::string n, double m, double w, Parity p, PdgCode id)
Creates a fully initialized ParticleType object.
bool is_rho() const
Definition: particletype.h:208
bool operator==(const ParticleTypePtr &rhs) const
Definition: particletype.h:679
PdgCode pdgcode() const
Definition: particletype.h:146
ParticleData contains the dynamic information of a certain particle.
Definition: particledata.h:52
double spectral_function_no_norm(double m) const
Full spectral function without normalization factor.
static ParticleTypePtrList & list_anti_Deltas()
Definition: particletype.cc:81
ParticleTypePtr(std::uint16_t i)
Constructs a pointer to the ParticleType object at offset i.
Definition: particletype.h:715
int baryon_number() const
Definition: pdgcode.h:308
Positive parity.
Definition: action.h:24
DecayBranchList get_partial_widths(const double m) const
Get all the mass-dependent partial decay widths of a particle with mass m.
bool is_hadron() const
Definition: pdgcode.h:297
const std::string & name() const
Definition: particletype.h:131