Version: SMASH-2.1
pdgcode.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2014-2020
4  * SMASH Team
5  *
6  * GNU General Public License (GPLv3 or later)
7  *
8  */
9 
10 #ifndef SRC_INCLUDE_SMASH_PDGCODE_H_
11 #define SRC_INCLUDE_SMASH_PDGCODE_H_
12 
13 #include <algorithm>
14 #include <array>
15 #include <cassert>
16 #include <cstdlib>
17 #include <iosfwd>
18 #include <sstream>
19 #include <stdexcept>
20 #include <string>
21 
22 #include <iostream>
23 
24 #include "pdgcode_constants.h"
25 
26 namespace smash {
27 
108 class PdgCode {
109  public:
114  struct InvalidPdgCode : public std::invalid_argument {
115  using std::invalid_argument::invalid_argument;
116  };
117 
118  /****************************************************************************
119  * *
120  * First, the constructors *
121  * *
122  ****************************************************************************/
123 
125  PdgCode() : dump_(0x0) {}
131  explicit PdgCode(const std::string& codestring) {
132  set_from_string(codestring);
133  }
134 
143  PdgCode(std::int32_t codenumber) : dump_(0x0) { // NOLINT(runtime/explicit)
144  digits_.antiparticle_ = false;
145  if (codenumber < 0) {
146  digits_.antiparticle_ = true;
147  codenumber = -codenumber;
148  }
149  set_fields(codenumber);
150  }
155  explicit PdgCode(const std::uint32_t abscode) : dump_(0x0) {
156  // use the first bit for the antiparticle_ boolean.
157  digits_.antiparticle_ = ((abscode & 0x80000000u) != 0);
158  set_fields(abscode);
159  }
160 
161  /****************************************************************************
162  * *
163  * test function and export functions *
164  * *
165  ****************************************************************************/
166 
180  inline int test_code() const {
181  int fail = 0;
182  if (digits_.n_ > 9) {
183  fail |= 1 << 6;
184  }
185  if (digits_.n_R_ > 9) {
186  fail |= 1 << 5;
187  }
188  if (digits_.n_L_ > 9) {
189  fail |= 1 << 4;
190  }
191  if (digits_.n_q1_ > 6) {
192  fail |= 1 << 3;
193  }
194  if (digits_.n_q2_ > 6) {
195  fail |= 1 << 2;
196  }
197  if (digits_.n_q3_ > 6) {
198  fail |= 1 << 1;
199  }
200  if (digits_.n_J_ > 15) {
201  fail |= 1;
202  }
203  return fail;
204  }
205 
214  void check() const {
215  // n_J must be odd for mesons and even for baryons (and cannot be zero)
216  if (is_hadron()) {
217  if (baryon_number() == 0) {
218  // mesons: special cases K0_L=0x130 and K0_S=0x310
219  if ((digits_.n_J_ % 2 == 0) && dump() != 0x130 && dump() != 0x310) {
220  throw InvalidPdgCode("Invalid PDG code " + string() +
221  " (meson with even n_J)");
222  }
223  } else {
224  if ((digits_.n_J_ % 2 != 0) || digits_.n_J_ == 0) {
225  throw InvalidPdgCode("Invalid PDG code " + string() +
226  " (baryon with odd n_J)");
227  }
228  }
229  } else {
230  if (digits_.n_J_ == 0 && dump() != 0x0) {
231  throw InvalidPdgCode("Invalid PDG code " + string() + " (n_J==0)");
232  }
233  }
234  /* The antiparticle flag only makes sense for particle types
235  * that have an antiparticle. */
236  if (digits_.antiparticle_ && !has_antiparticle()) {
237  throw InvalidPdgCode("Invalid PDG code " + string() +
238  " (cannot be negative)");
239  }
240  }
241 
243  inline std::uint32_t dump() const {
244  // this cuts the three unused bits.
245  return (dump_ & 0x8fffffff);
246  }
247 
249  inline std::int32_t code() const { return antiparticle_sign() * ucode(); }
250 
252  inline std::string string() const {
253  std::stringstream ss;
254  ss << get_decimal();
255  return ss.str();
256  }
257 
260  PdgCode result = *this;
261  result.digits_.antiparticle_ = !digits_.antiparticle_;
262  return result;
263  }
264 
269  static PdgCode from_decimal(const int pdgcode_decimal) {
270  // Nucleus and special codes with 2J+1 > 9
271  if (std::abs(pdgcode_decimal) > 1E7) {
272  return PdgCode(std::to_string(pdgcode_decimal));
273  }
274  int a = pdgcode_decimal;
275  int hex_pdg = 0, tmp = 1;
276  while (a) {
277  hex_pdg += (a % 10) * tmp;
278  tmp *= 16;
279  a = a / 10;
280  }
281  return PdgCode(hex_pdg);
282  }
283 
284  /****************************************************************************
285  * *
286  * accessors of various properties *
287  * *
288  ****************************************************************************/
289 
291  inline bool is_nucleus() const {
292  assert(digits_.is_nucleus_ == nucleus_.is_nucleus_);
293  return nucleus_.is_nucleus_;
294  }
295 
297  inline bool is_hadron() const {
298  return (digits_.n_q3_ != 0 && digits_.n_q2_ != 0 && !is_nucleus());
299  }
300 
302  inline bool is_lepton() const {
303  return (digits_.n_q1_ == 0 && digits_.n_q2_ == 0 && digits_.n_q3_ == 1 &&
304  !is_nucleus());
305  }
306 
308  inline int baryon_number() const {
309  if (is_nucleus()) {
310  return static_cast<int>(nucleus_.A_) * antiparticle_sign();
311  }
312  if (!is_hadron() || digits_.n_q1_ == 0) {
313  return 0;
314  }
315  return antiparticle_sign();
316  }
318  inline bool is_baryon() const { return is_hadron() && digits_.n_q1_ != 0; }
319 
321  inline bool is_meson() const { return is_hadron() && digits_.n_q1_ == 0; }
322 
324  inline bool is_nucleon() const {
325  const auto abs_code = std::abs(code());
326  return (abs_code == pdg::p || abs_code == pdg::n);
327  }
328 
330  inline bool is_proton() const {
331  const auto abs_code = std::abs(code());
332  return (abs_code == pdg::p);
333  }
334 
336  inline bool is_neutron() const {
337  const auto abs_code = std::abs(code());
338  return (abs_code == pdg::n);
339  }
340 
342  inline bool is_Nstar1535() const {
343  const auto abs_code = std::abs(code());
344  return (abs_code == pdg::N1535_p || abs_code == pdg::N1535_z);
345  }
346 
348  inline bool is_Delta() const {
349  const auto abs_code = std::abs(code());
350  return (abs_code == pdg::Delta_pp || abs_code == pdg::Delta_p ||
351  abs_code == pdg::Delta_z || abs_code == pdg::Delta_m);
352  }
353 
355  inline bool is_hyperon() const { return is_hadron() && digits_.n_q1_ == 3; }
356 
358  inline bool is_Omega() const {
359  return is_hyperon() && digits_.n_q2_ == 3 && digits_.n_q3_ == 3;
360  }
361 
363  inline bool is_Xi() const {
364  return is_hyperon() && digits_.n_q2_ == 3 && digits_.n_q3_ != 3;
365  }
366 
368  inline bool is_Lambda() const {
369  return is_hyperon() && digits_.n_q2_ == 1 && digits_.n_q3_ == 2;
370  }
371 
373  inline bool is_Sigma() const {
374  return is_hyperon() && digits_.n_q2_ != 3 && !is_Lambda();
375  }
376 
378  inline bool is_kaon() const {
379  const auto abs_code = std::abs(code());
380  return (abs_code == pdg::K_p) || (abs_code == pdg::K_z);
381  }
382 
384  inline bool is_pion() const {
385  const auto c = code();
386  return (c == pdg::pi_z) || (c == pdg::pi_p) || (c == pdg::pi_m);
387  }
388 
390  inline bool is_rho() const {
391  const auto c = code();
392  return (c == pdg::rho_z) || (c == pdg::rho_p) || (c == pdg::rho_m);
393  }
394 
396  inline bool is_deuteron() const {
397  const int dec = get_decimal();
398  return is_nucleus() && (dec == pdg::decimal_d || dec == pdg::decimal_antid);
399  }
400 
405  bool has_antiparticle() const {
406  if (is_nucleus()) {
407  return true;
408  }
409  if (is_hadron()) {
410  return (baryon_number() != 0) || (digits_.n_q2_ != digits_.n_q3_);
411  } else {
412  return digits_.n_q3_ == 1; // leptons!
413  }
414  }
415 
421  inline int isospin3() const {
422  /* net_quark_number(2) is the number of u quarks,
423  * net_quark_number(1) is the number of d quarks. */
424  return net_quark_number(2) - net_quark_number(1);
425  }
426 
434  inline double frac_strange() const {
435  /* The quarkonium state has 0 net strangeness
436  * but there are actually 2 strange quarks out of 2 total */
437  if (is_hadron() && digits_.n_q3_ == 3 && digits_.n_q2_ == 3) {
438  return 1.;
439  } else {
440  // For all other cases, there isn't both a strange and anti-strange
441  if (is_baryon()) {
442  return std::abs(strangeness()) / 3.;
443  } else if (is_meson()) {
444  return std::abs(strangeness()) / 2.;
445  } else {
446  /* If not baryon or meson, this should be 0, as AQM does not
447  * extend to non-hadrons */
448  return 0.;
449  }
450  }
451  }
452 
458  inline int strangeness() const { return -net_quark_number(3); }
459 
465  inline int charmness() const { return +net_quark_number(4); }
466 
472  inline int bottomness() const { return -net_quark_number(5); }
473 
482  int charge() const {
483  if (is_hadron() || is_nucleus()) {
484  // Q will accumulate 3*charge (please excuse the upper case. I
485  // want to distinguish this from q which might be interpreted as
486  // shorthand for "quark".)
487  int Q = 0;
488  /* This loops over d,u,s,c,b,t quarks (the latter can be safely ignored,
489  * but I don't think this will be a bottle neck. */
490  for (int i = 1; i < 7; i++) {
491  /* u,c,t quarks have charge = 2/3 e, while d,s,b quarks have -1/3 e.
492  * The antiparticle sign is already in net_quark_number. */
493  Q += (i % 2 == 0 ? 2 : -1) * net_quark_number(i);
494  }
495  return Q / 3;
496  }
497  /* non-hadron:
498  * Leptons: 11, 13, 15 are e, μ, τ and have a charge -1, while
499  * 12, 14, 16 are the neutrinos that have no charge. */
500  if (digits_.n_q3_ == 1) {
501  return -1 * (digits_.n_J_ % 2) * antiparticle_sign();
502  }
503  /* Bosons: 24 is the W+, all else is uncharged.
504  * we ignore the first digits so that this also finds strange gauge
505  * boson "resonances" (in particular, \f$\tilde \chi_1^+\f$ with PDG
506  * Code 1000024). */
507  if ((dump_ & 0x0000ffff) == 0x24) {
508  return antiparticle_sign();
509  }
510  // default (this includes all other Bosons) is 0.
511  return 0;
512  }
513 
521  inline unsigned int spin() const {
522  if (is_nucleus()) {
523  /* Currently the only nucleus I care about is deutron,
524  * which has spin one. */
525  return 2;
526  }
527 
528  if (is_hadron()) {
529  if (digits_.n_J_ == 0) {
530  return 0; // special cases: K0_L=0x130 & K0_S=0x310
531  } else {
532  return digits_.n_J_ - 1;
533  }
534  }
535  /* this assumes that we only have white particles (no single
536  * quarks): Electroweak fermions have 11-17, so the
537  * second-to-last-digit is the spin. The same for the Bosons: they
538  * have 21-29 and 2spin = 2 (this fails for the Higgs). */
539  return digits_.n_q3_;
540  }
542  inline unsigned int spin_degeneracy() const {
543  if (is_hadron() && digits_.n_J_ > 0) {
544  return digits_.n_J_;
545  }
546  return spin() + 1;
547  }
549  inline int antiparticle_sign() const {
550  return (digits_.antiparticle_ ? -1 : +1);
551  }
553  inline std::int32_t quarks() const {
554  if (!is_hadron() || is_nucleus()) {
555  return 0;
556  }
557  return chunks_.quarks_;
558  }
559 
569  std::array<int, 3> quark_content() const {
570  std::array<int, 3> result = {static_cast<int>(digits_.n_q1_),
571  static_cast<int>(digits_.n_q2_),
572  static_cast<int>(digits_.n_q3_)};
573  if (is_hadron()) {
574  // Antibaryons
575  if (digits_.n_q1_ != 0 && digits_.antiparticle_) {
576  for (size_t i = 0; i < 3; i++) {
577  result[i] = -result[i];
578  }
579  }
580  // Mesons
581  if (digits_.n_q1_ == 0) {
582  // Own antiparticle
583  if (digits_.n_q2_ == digits_.n_q3_) {
584  result[2] = -result[2];
585  } else {
586  // Like pi-
587  if (digits_.antiparticle_) {
588  result[1] = -result[1];
589  // Like pi+
590  } else {
591  result[2] = -result[2];
592  }
593  }
594  // add extra minus sign according to the pdg convention
595  if (digits_.n_q2_ != digits_.n_q3_ && digits_.n_q2_ % 2 == 1) {
596  for (int i = 1; i <= 2; i++) {
597  result[i] = -result[i];
598  }
599  }
600  }
601  } else {
602  result = {0, 0, 0};
603  }
604  return result;
605  }
606 
617  bool contains_enough_valence_quarks(int valence_quarks_required) const;
618 
619  /****************************************************************************
620  * *
621  * operations with more than one PDG Code *
622  * *
623  ****************************************************************************/
624 
629  inline bool operator<(const PdgCode rhs) const {
630  return dump_ < rhs.dump_;
631  /* the complex thing to do here is to calculate:
632  * code() < rhs.code()
633  * but for getting a total order that's overkill. The uint32_t value in
634  * dump_ works just fine. */
635  }
636 
638  inline bool operator==(const PdgCode rhs) const { return dump_ == rhs.dump_; }
639 
641  inline bool operator!=(const PdgCode rhs) const { return !(*this == rhs); }
642 
644  inline bool is_antiparticle_of(const PdgCode rhs) const {
645  return code() == -rhs.code();
646  }
647 
649  friend std::istream& operator>>(std::istream& is, PdgCode& code);
650 
656  static PdgCode invalid() { return PdgCode(0x0); }
657 
667  int32_t get_decimal() const {
668  if (is_nucleus()) {
669  // ±10LZZZAAAI
670  return antiparticle_sign() *
671  (nucleus_.I_ + 10 * nucleus_.A_ + 10000 * nucleus_.Z_ +
672  10000000 * nucleus_.n_Lambda_ + 1000000000);
673  }
674  int n_J_1 = 0;
675  int n_J_2 = digits_.n_J_;
676  if (n_J_2 > 9) {
677  n_J_1 = n_J_2 - 9;
678  n_J_2 = 9;
679  }
680  return antiparticle_sign() *
681  (n_J_2 + digits_.n_q3_ * 10 + digits_.n_q2_ * 100 +
682  digits_.n_q1_ * 1000 + digits_.n_L_ * 10000 +
683  digits_.n_R_ * 100000 + digits_.n_ * 1000000 + n_J_1 * 10000000);
684  }
685 
687  void deexcite() {
688  if (!is_nucleus()) {
689  chunks_.excitation_ = 0;
690  } else {
691  nucleus_.I_ = 0;
692  }
693  }
694 
705  int net_quark_number(const int quark) const;
706 
707  private:
713  union {
718  struct {
719 #if defined(LITTLE_ENDIAN_ARCHITECTURE) || defined(DOXYGEN)
721  std::uint32_t n_J_ : 4;
723  std::uint32_t n_q3_ : 4;
725  std::uint32_t n_q2_ : 4;
727  std::uint32_t n_q1_ : 4;
729  std::uint32_t n_L_ : 4;
731  std::uint32_t n_R_ : 4;
733  std::uint32_t n_ : 4, : 2;
735  bool is_nucleus_ : 1;
737  bool antiparticle_ : 1;
738 #else // reverse ordering
739  bool antiparticle_ : 1;
740  bool is_nucleus : 1, : 2;
741  std::uint32_t n_ : 4;
742  std::uint32_t n_R_ : 4;
743  std::uint32_t n_L_ : 4;
744  std::uint32_t n_q1_ : 4;
745  std::uint32_t n_q2_ : 4;
746  std::uint32_t n_q3_ : 4;
747  std::uint32_t n_J_ : 4;
748 #endif
754  std::uint32_t dump_;
759  struct {
760 #if defined(LITTLE_ENDIAN_ARCHITECTURE) || defined(DOXYGEN)
761  std::uint32_t : 4;
763  std::uint32_t quarks_ : 12;
765  std::uint32_t excitation_ : 12, : 4;
766 #else
767  std::uint32_t : 4, excitation_ : 12;
768  std::uint32_t quarks_ : 12, : 4;
769 #endif
772  struct {
773 #if defined(LITTLE_ENDIAN_ARCHITECTURE) || defined(DOXYGEN)
774  std::uint32_t n_Lambda_ : 6;
775  std::uint32_t Z_ : 10;
776  std::uint32_t A_ : 10;
777  std::uint32_t I_ : 4;
778  bool is_nucleus_ : 1;
779  bool antiparticle_ : 1;
780 #else // Reverse ordering
781  bool antiparticle_ : 1;
782  bool is_nucleus_ : 1;
783  std::uint32_t I_ : 4;
784  std::uint32_t A_ : 10;
785  std::uint32_t Z_ : 10;
786  std::uint32_t n_Lambda_ : 6;
787 #endif
789  };
790 
795  inline std::uint32_t ucode() const { return (dump_ & 0x0fffffff); }
796 
803  inline std::uint32_t get_digit_from_char(const char inp) const {
804  // Decimal digit
805  if (48 <= inp && inp <= 57) {
806  return inp - 48;
807  }
808  // Hexdecimal digit, uppercase
809  if (65 <= inp && inp <= 70) {
810  return inp - 65 + 10;
811  }
812  // Hexdecimal digit, lowercase
813  if (97 <= inp && inp <= 102) {
814  return inp - 97 + 10;
815  }
816  throw InvalidPdgCode("PdgCode: Invalid character " + std::string(&inp, 1) +
817  " found.\n");
818  }
819 
841  inline void set_from_string(const std::string& codestring) {
842  dump_ = 0;
843  // Implicit with the above: digits_.antiparticle_ = false;
844  digits_.n_ = digits_.n_R_ = digits_.n_L_ = digits_.n_q1_ = digits_.n_q2_ =
845  digits_.n_q3_ = digits_.n_J_ = digits_.is_nucleus_ = 0;
846  size_t length = codestring.size();
847  if (length < 1) {
848  throw InvalidPdgCode("Empty string does not contain PDG Code\n");
849  }
850  int c = 0;
851  /* Look at current character; if it is a + or minus sign, read it
852  * and advance to next char. */
853  if (codestring[c] == '-') {
854  digits_.antiparticle_ = true;
855  ++c;
856  } else if (codestring[c] == '+') {
857  digits_.antiparticle_ = false;
858  ++c;
859  }
860  // Save if the first character was a sign:
861  unsigned int sign = c;
862 
863  // Nucleus
864  if (length == 10 + sign) {
865  nucleus_.is_nucleus_ = true;
866  if (codestring[c] != '1' || codestring[c + 1] != '0') {
867  throw InvalidPdgCode("Pdg code of nucleus \"" + codestring +
868  "\" should start with 10\n");
869  }
870  c += 2;
871  // ±10LZZZAAAI is the standard for nuclei
872  std::array<int, 8> digits;
873  for (int i = 0; i < 8; i++) {
874  digits[i] = get_digit_from_char(codestring[c + i]);
875  }
876  nucleus_.n_Lambda_ = digits[0];
877  nucleus_.Z_ = 100 * digits[1] + 10 * digits[2] + digits[3];
878  nucleus_.A_ = 100 * digits[4] + 10 * digits[5] + digits[6];
879  nucleus_.I_ = digits[7];
880  return;
881  }
882 
883  // Codestring shouldn't be longer than 8 + sign, except for nuclei
884  if (length > 8 + sign) {
885  throw InvalidPdgCode("String \"" + codestring +
886  "\" too long for PDG Code\n");
887  }
888  /* Please note that in what follows, we actually need c++, not ++c.
889  * first digit is used for n_J if the last digit is not enough. */
890  if (length > 7 + sign) {
891  digits_.n_J_ += get_digit_from_char(codestring[c++]);
892  }
893  // Codestring has 7 digits? 7th from last goes in n_.
894  if (length > 6 + sign) {
895  digits_.n_ = get_digit_from_char(codestring[c++]);
896  }
897  // It has 6 or 7 digits? 6th from last is n_R_.
898  if (length > 5 + sign) {
899  digits_.n_R_ = get_digit_from_char(codestring[c++]);
900  }
901  // 5th from last is n_L_.
902  if (length > 4 + sign) {
903  digits_.n_L_ = get_digit_from_char(codestring[c++]);
904  }
905  // 4th from last is n_q1_.
906  if (length > 3 + sign) {
907  digits_.n_q1_ = get_digit_from_char(codestring[c++]);
908  if (digits_.n_q1_ > 6) {
909  throw InvalidPdgCode("Invalid PDG code " + codestring + " (n_q1>6)");
910  }
911  }
912  // 3rd from last is n_q2_.
913  if (length > 2 + sign) {
914  digits_.n_q2_ = get_digit_from_char(codestring[c++]);
915  if (digits_.n_q2_ > 6) {
916  throw InvalidPdgCode("Invalid PDG code " + codestring + " (n_q2>6)");
917  }
918  }
919  // Next to last is n_q3_.
920  if (length > 1 + sign) {
921  digits_.n_q3_ = get_digit_from_char(codestring[c++]);
922  if (digits_.n_q3_ > 6) {
923  throw InvalidPdgCode("Invalid PDG code " + codestring + " (n_q3>6)");
924  }
925  }
926  // Last digit is the spin degeneracy.
927  if (length > sign) {
928  digits_.n_J_ += get_digit_from_char(codestring[c++]);
929  } else {
930  throw InvalidPdgCode(
931  "String \"" + codestring +
932  "\" only consists of a sign, that is no valid PDG Code\n");
933  }
934  check();
935  }
936 
946  inline void set_fields(std::uint32_t abscode) {
947  /* "dump_ =" overwrites antiparticle_, but this needs to have been set
948  * already, so we carry it around the assignment. */
949  bool ap = digits_.antiparticle_;
950  dump_ = abscode & 0x0fffffff;
951  digits_.antiparticle_ = ap;
952  int test = test_code();
953  if (test > 0) {
954  throw InvalidPdgCode("Invalid digits " + std::to_string(test) +
955  " in PDG Code " + string());
956  }
957  check();
958  }
959 };
960 
961 static_assert(sizeof(PdgCode) == 4, "should fit into 32 bit integer");
962 
969 std::istream& operator>>(std::istream& is, PdgCode& code);
975 std::ostream& operator<<(std::ostream& is, const PdgCode& code);
976 
978 inline bool is_dilepton(const PdgCode pdg1, const PdgCode pdg2) {
979  const auto c1 = pdg1.code();
980  const auto c2 = pdg2.code();
981  const auto min = std::min(c1, c2);
982  const auto max = std::max(c1, c2);
983  return (max == 0x11 && min == -0x11) || (max == 0x13 && min == -0x13);
984 }
985 
990 inline bool has_lepton_pair(const PdgCode pdg1, const PdgCode pdg2,
991  const PdgCode pdg3) {
992  return is_dilepton(pdg1, pdg2) || is_dilepton(pdg1, pdg3) ||
993  is_dilepton(pdg2, pdg3);
994 }
995 
996 } // namespace smash
997 
998 #endif // SRC_INCLUDE_SMASH_PDGCODE_H_
PdgCode stores a Particle Data Group Particle Numbering Scheme particle type number.
Definition: pdgcode.h:108
std::uint32_t quarks_
The quark digits n_q{1,2,3}_.
Definition: pdgcode.h:763
bool is_Nstar1535() const
Definition: pdgcode.h:342
std::int32_t code() const
Definition: pdgcode.h:249
bool is_rho() const
Definition: pdgcode.h:390
int antiparticle_sign() const
Definition: pdgcode.h:549
bool operator!=(const PdgCode rhs) const
Definition: pdgcode.h:641
int baryon_number() const
Definition: pdgcode.h:308
bool is_meson() const
Definition: pdgcode.h:321
PdgCode(const std::uint32_t abscode)
receive an unsigned integer and process it into a PDG Code.
Definition: pdgcode.h:155
std::uint32_t n_q1_
first quark field. 0 for mesons.
Definition: pdgcode.h:727
bool is_Sigma() const
Definition: pdgcode.h:373
PdgCode(const std::string &codestring)
Initialize using a string The string is interpreted as a hexadecimal number, i.e.,...
Definition: pdgcode.h:131
int net_quark_number(const int quark) const
Returns the net number of quarks with given flavour number For public use, see strangeness(),...
Definition: pdgcode.cc:31
friend std::istream & operator>>(std::istream &is, PdgCode &code)
istream >> PdgCode assigns the PDG Code from an istream.
Definition: pdgcode.cc:14
int bottomness() const
Definition: pdgcode.h:472
std::array< int, 3 > quark_content() const
The return is always an array of three numbers, which are pdgcodes of quarks: 1 - d,...
Definition: pdgcode.h:569
std::uint32_t n_q3_
third quark field
Definition: pdgcode.h:723
unsigned int spin() const
Definition: pdgcode.h:521
bool is_pion() const
Definition: pdgcode.h:384
bool is_kaon() const
Definition: pdgcode.h:378
bool antiparticle_
first bit: stores the sign.
Definition: pdgcode.h:737
std::uint32_t dump() const
Dumps the bitfield into an unsigned integer.
Definition: pdgcode.h:243
std::uint32_t Z_
Definition: pdgcode.h:775
std::uint32_t n_
first field: "counter"
Definition: pdgcode.h:733
bool is_lepton() const
Definition: pdgcode.h:302
bool is_hyperon() const
Definition: pdgcode.h:355
std::uint32_t n_J_
spin quantum number .
Definition: pdgcode.h:721
bool is_nucleus() const
Definition: pdgcode.h:291
bool is_deuteron() const
Definition: pdgcode.h:396
bool is_proton() const
Definition: pdgcode.h:330
static PdgCode from_decimal(const int pdgcode_decimal)
Construct PDG code from decimal number.
Definition: pdgcode.h:269
bool is_nucleus_
Definition: pdgcode.h:778
bool is_antiparticle_of(const PdgCode rhs) const
Definition: pdgcode.h:644
std::uint32_t bool is_nucleus_
1 for nuclei, 0 for the rest
Definition: pdgcode.h:733
int charmness() const
Definition: pdgcode.h:465
int strangeness() const
Definition: pdgcode.h:458
struct smash::PdgCode::@0::@2 digits_
The single digits collection of the code.
int32_t get_decimal() const
Definition: pdgcode.h:667
bool is_baryon() const
Definition: pdgcode.h:318
void set_fields(std::uint32_t abscode)
Sets the bitfield from an unsigned integer.
Definition: pdgcode.h:946
int isospin3() const
Definition: pdgcode.h:421
void check() const
Do all sorts of validity checks.
Definition: pdgcode.h:214
bool is_nucleon() const
Definition: pdgcode.h:324
std::string string() const
Definition: pdgcode.h:252
int test_code() const
Checks the integer for invalid hex digits.
Definition: pdgcode.h:180
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 operator==(const PdgCode rhs) const
Definition: pdgcode.h:638
PdgCode()
Standard initializer.
Definition: pdgcode.h:125
static PdgCode invalid()
PdgCode 0x0 is guaranteed not to be valid by the PDG standard, but it passes all tests here,...
Definition: pdgcode.h:656
bool contains_enough_valence_quarks(int valence_quarks_required) const
Definition: pdgcode.cc:92
bool operator<(const PdgCode rhs) const
Sorts PDG Codes according to their numeric value.
Definition: pdgcode.h:629
PdgCode(std::int32_t codenumber)
Receive a signed integer and process it into a PDG Code.
Definition: pdgcode.h:143
bool is_Omega() const
Definition: pdgcode.h:358
std::uint32_t A_
Definition: pdgcode.h:776
bool is_neutron() const
Definition: pdgcode.h:336
void deexcite()
Remove all excitation, except spin. Sign and quark content remains.
Definition: pdgcode.h:687
std::uint32_t n_L_
"angular momentum"
Definition: pdgcode.h:729
void set_from_string(const std::string &codestring)
Set the PDG code from the given string.
Definition: pdgcode.h:841
std::uint32_t ucode() const
Definition: pdgcode.h:795
std::uint32_t n_R_
"radial excitation"
Definition: pdgcode.h:731
std::uint32_t dump_
The bitfield dumped into a single integer.
Definition: pdgcode.h:754
struct smash::PdgCode::@0::@4 nucleus_
Structure for the nuclei.
struct smash::PdgCode::@0::@3 chunks_
Chunk collection: here, the chunks with and are directly accessible.
bool is_Delta() const
Definition: pdgcode.h:348
std::uint32_t n_Lambda_
Definition: pdgcode.h:774
double frac_strange() const
Definition: pdgcode.h:434
bool has_antiparticle() const
Definition: pdgcode.h:405
bool is_Lambda() const
Definition: pdgcode.h:368
std::uint32_t get_digit_from_char(const char inp) const
Definition: pdgcode.h:803
bool is_Xi() const
Definition: pdgcode.h:363
std::int32_t quarks() const
Definition: pdgcode.h:553
std::uint32_t I_
Definition: pdgcode.h:777
std::uint32_t n_q2_
second quark field
Definition: pdgcode.h:725
unsigned int spin_degeneracy() const
Definition: pdgcode.h:542
std::uint32_t excitation_
The excitation digits n_, n_R_, n_L_.
Definition: pdgcode.h:765
int charge() const
The charge of the particle.
Definition: pdgcode.h:482
std::ostream & operator<<(std::ostream &out, const ActionPtr &action)
Convenience: dereferences the ActionPtr to Action.
Definition: action.h:529
constexpr int pi_p
π⁺.
constexpr int rho_p
ρ⁺.
constexpr int Delta_p
Δ⁺.
constexpr int rho_m
ρ⁻.
constexpr int Delta_pp
Δ⁺⁺.
constexpr int K_p
K⁺.
constexpr int K_z
K⁰.
constexpr int p
Proton.
constexpr int N1535_z
N(1535)⁰.
constexpr int pi_z
π⁰.
constexpr int n
Neutron.
constexpr int Delta_m
Δ⁻.
constexpr int Delta_z
Δ⁰.
constexpr int rho_z
ρ⁰.
constexpr int pi_m
π⁻.
constexpr int decimal_antid
Anti-deuteron in decimal digits.
constexpr int N1535_p
N(1535)⁺.
constexpr int decimal_d
Deuteron in decimal digits.
Definition: action.h:24
bool is_dilepton(const PdgCode pdg1, const PdgCode pdg2)
Definition: pdgcode.h:978
std::istream & operator>>(std::istream &is, PdgCode &code)
Sets the PDG code from the textual representation in the input stream.
Definition: pdgcode.cc:14
bool has_lepton_pair(const PdgCode pdg1, const PdgCode pdg2, const PdgCode pdg3)
Definition: pdgcode.h:990
thrown for invalid inputs
Definition: pdgcode.h:114