Version: SMASH-1.5
pdgcode.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2014-2018
4  * SMASH Team
5  *
6  * GNU General Public License (GPLv3 or later)
7  *
8  */
9 
10 #ifndef SRC_INCLUDE_PDGCODE_H_
11 #define SRC_INCLUDE_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_Nstar1535() const {
331  const auto abs_code = std::abs(code());
332  return (abs_code == pdg::N1535_p || abs_code == pdg::N1535_z);
333  }
334 
336  inline bool is_Delta() const {
337  const auto abs_code = std::abs(code());
338  return (abs_code == pdg::Delta_pp || abs_code == pdg::Delta_p ||
339  abs_code == pdg::Delta_z || abs_code == pdg::Delta_m);
340  }
341 
343  inline bool is_hyperon() const { return is_hadron() && digits_.n_q1_ == 3; }
344 
346  inline bool is_Omega() const {
347  return is_hyperon() && digits_.n_q2_ == 3 && digits_.n_q3_ == 3;
348  }
349 
351  inline bool is_Xi() const {
352  return is_hyperon() && digits_.n_q2_ == 3 && digits_.n_q3_ != 3;
353  }
354 
356  inline bool is_Lambda() const {
357  return is_hyperon() && digits_.n_q2_ == 1 && digits_.n_q3_ == 2;
358  }
359 
361  inline bool is_Sigma() const {
362  return is_hyperon() && digits_.n_q2_ != 3 && !is_Lambda();
363  }
364 
366  inline bool is_kaon() const {
367  const auto abs_code = std::abs(code());
368  return (abs_code == pdg::K_p) || (abs_code == pdg::K_z);
369  }
370 
372  inline bool is_pion() const {
373  const auto c = code();
374  return (c == pdg::pi_z) || (c == pdg::pi_p) || (c == pdg::pi_m);
375  }
376 
378  inline bool is_rho() const {
379  const auto c = code();
380  return (c == pdg::rho_z) || (c == pdg::rho_p) || (c == pdg::rho_m);
381  }
382 
384  inline bool is_deuteron() const {
385  const int dec = get_decimal();
386  return is_nucleus() && (dec == pdg::decimal_d || dec == pdg::decimal_antid);
387  }
388 
393  bool has_antiparticle() const {
394  if (is_nucleus()) {
395  return true;
396  }
397  if (is_hadron()) {
398  return (baryon_number() != 0) || (digits_.n_q2_ != digits_.n_q3_);
399  } else {
400  return digits_.n_q3_ == 1; // leptons!
401  }
402  }
403 
409  inline int isospin3() const {
410  /* net_quark_number(2) is the number of u quarks,
411  * net_quark_number(1) is the number of d quarks. */
412  return net_quark_number(2) - net_quark_number(1);
413  }
414 
422  inline double frac_strange() const {
423  /* The quarkonium state has 0 net strangeness
424  * but there are actually 2 strange quarks out of 2 total */
425  if (is_hadron() && digits_.n_q3_ == 3 && digits_.n_q2_ == 3) {
426  return 1.;
427  } else {
428  // For all other cases, there isn't both a strange and anti-strange
429  if (is_baryon()) {
430  return abs(strangeness()) / 3.;
431  } else if (is_meson()) {
432  return abs(strangeness()) / 2.;
433  } else {
434  /* If not baryon or meson, this should be 0, as AQM does not
435  * extend to non-hadrons */
436  return 0.;
437  }
438  }
439  }
440 
446  inline int strangeness() const { return -net_quark_number(3); }
447 
453  inline int charmness() const { return +net_quark_number(4); }
454 
460  inline int bottomness() const { return -net_quark_number(5); }
461 
470  int charge() const {
471  if (is_hadron() || is_nucleus()) {
472  // Q will accumulate 3*charge (please excuse the upper case. I
473  // want to distinguish this from q which might be interpreted as
474  // shorthand for "quark".)
475  int Q = 0;
476  /* This loops over d,u,s,c,b,t quarks (the latter can be safely ignored,
477  * but I don't think this will be a bottle neck. */
478  for (int i = 1; i < 7; i++) {
479  /* u,c,t quarks have charge = 2/3 e, while d,s,b quarks have -1/3 e.
480  * The antiparticle sign is already in net_quark_number. */
481  Q += (i % 2 == 0 ? 2 : -1) * net_quark_number(i);
482  }
483  return Q / 3;
484  }
485  /* non-hadron:
486  * Leptons: 11, 13, 15 are e, μ, τ and have a charge -1, while
487  * 12, 14, 16 are the neutrinos that have no charge. */
488  if (digits_.n_q3_ == 1) {
489  return -1 * (digits_.n_J_ % 2) * antiparticle_sign();
490  }
491  /* Bosons: 24 is the W+, all else is uncharged.
492  * we ignore the first digits so that this also finds strange gauge
493  * boson "resonances" (in particular, \f$\tilde \chi_1^+\f$ with PDG
494  * Code 1000024). */
495  if ((dump_ & 0x0000ffff) == 0x24) {
496  return antiparticle_sign();
497  }
498  // default (this includes all other Bosons) is 0.
499  return 0;
500  }
501 
509  inline unsigned int spin() const {
510  if (is_nucleus()) {
511  /* Currently the only nucleus I care about is deutron,
512  * which has spin one. */
513  return 2;
514  }
515 
516  if (is_hadron()) {
517  if (digits_.n_J_ == 0) {
518  return 0; // special cases: K0_L=0x130 & K0_S=0x310
519  } else {
520  return digits_.n_J_ - 1;
521  }
522  }
523  /* this assumes that we only have white particles (no single
524  * quarks): Electroweak fermions have 11-17, so the
525  * second-to-last-digit is the spin. The same for the Bosons: they
526  * have 21-29 and 2spin = 2 (this fails for the Higgs). */
527  return digits_.n_q3_;
528  }
530  inline unsigned int spin_degeneracy() const {
531  if (is_hadron() && digits_.n_J_ > 0) {
532  return digits_.n_J_;
533  }
534  return spin() + 1;
535  }
537  inline int antiparticle_sign() const {
538  return (digits_.antiparticle_ ? -1 : +1);
539  }
541  inline std::int32_t quarks() const {
542  if (!is_hadron() || is_nucleus()) {
543  return 0;
544  }
545  return chunks_.quarks_;
546  }
547 
557  std::array<int, 3> quark_content() const {
558  std::array<int, 3> result = {static_cast<int>(digits_.n_q1_),
559  static_cast<int>(digits_.n_q2_),
560  static_cast<int>(digits_.n_q3_)};
561  if (is_hadron()) {
562  // Antibaryons
563  if (digits_.n_q1_ != 0 && digits_.antiparticle_) {
564  for (size_t i = 0; i < 3; i++) {
565  result[i] = -result[i];
566  }
567  }
568  // Mesons
569  if (digits_.n_q1_ == 0) {
570  // Own antiparticle
571  if (digits_.n_q2_ == digits_.n_q3_) {
572  result[2] = -result[2];
573  } else {
574  // Like pi-
575  if (digits_.antiparticle_) {
576  result[1] = -result[1];
577  // Like pi+
578  } else {
579  result[2] = -result[2];
580  }
581  }
582  // add extra minus sign according to the pdg convention
583  if (digits_.n_q2_ != digits_.n_q3_ && digits_.n_q2_ % 2 == 1) {
584  for (int i = 1; i <= 2; i++) {
585  result[i] = -result[i];
586  }
587  }
588  }
589  } else {
590  result = {0, 0, 0};
591  }
592  return result;
593  }
594 
605  bool contains_enough_valence_quarks(int valence_quarks_required) const;
606 
607  /****************************************************************************
608  * *
609  * operations with more than one PDG Code *
610  * *
611  ****************************************************************************/
612 
617  inline bool operator<(const PdgCode rhs) const {
618  return dump_ < rhs.dump_;
619  /* the complex thing to do here is to calculate:
620  * code() < rhs.code()
621  * but for getting a total order that's overkill. The uint32_t value in
622  * dump_ works just fine. */
623  }
624 
626  inline bool operator==(const PdgCode rhs) const { return dump_ == rhs.dump_; }
627 
629  inline bool operator!=(const PdgCode rhs) const { return !(*this == rhs); }
630 
632  inline bool is_antiparticle_of(const PdgCode rhs) const {
633  return code() == -rhs.code();
634  }
635 
637  friend std::istream& operator>>(std::istream& is, PdgCode& code);
638 
644  static PdgCode invalid() { return PdgCode(0x0); }
645 
655  int get_decimal() const {
656  if (is_nucleus()) {
657  // ±10LZZZAAAI
658  return antiparticle_sign() *
659  (nucleus_.I_ + 10 * nucleus_.A_ + 10000 * nucleus_.Z_ +
660  10000000 * nucleus_.n_Lambda_ + 1000000000);
661  }
662  int n_J_1 = 0;
663  int n_J_2 = digits_.n_J_;
664  if (n_J_2 > 9) {
665  n_J_1 = n_J_2 - 9;
666  n_J_2 = 9;
667  }
668  return antiparticle_sign() *
669  (n_J_2 + digits_.n_q3_ * 10 + digits_.n_q2_ * 100 +
670  digits_.n_q1_ * 1000 + digits_.n_L_ * 10000 +
671  digits_.n_R_ * 100000 + digits_.n_ * 1000000 + n_J_1 * 10000000);
672  }
673 
675  void deexcite() {
676  if (!is_nucleus()) {
677  chunks_.excitation_ = 0;
678  } else {
679  nucleus_.I_ = 0;
680  }
681  }
682 
693  int net_quark_number(const int quark) const;
694 
695  private:
696 /* amend this line with something that identifies your compiler if its
697  * bit field order is like in the gnu c compiler for 64 bit
698  * architectures (if you are unsure, try one and check the pdgcode
699  * test). */
700 #if defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__)) || \
701  defined(DOXYGEN)
702 #define SMASH_BITFIELD_ORDER_ 1
703 /* put your compiler here if the bit field order is reversed w.r.t. gnu
704  * c compiler for 64 bit. */
705 #elif defined(__OTHER_COMPILER__)
706 #define SMASH_BITFIELD_ORDER_ 2
707 #else
708 #error "Please determine the correct bit-field order for your target/compiler"
709 #endif
710 
715  union {
720  struct {
721 #if SMASH_BITFIELD_ORDER_ == 1
722  std::uint32_t n_J_ : 4;
725  std::uint32_t n_q3_ : 4;
727  std::uint32_t n_q2_ : 4;
729  std::uint32_t n_q1_ : 4;
731  std::uint32_t n_L_ : 4;
733  std::uint32_t n_R_ : 4;
735  std::uint32_t n_ : 4, : 2;
737  bool is_nucleus_ : 1;
739  bool antiparticle_ : 1;
740 #else // reverse ordering
741  bool antiparticle_ : 1;
742  bool is_nucleus : 1, : 2;
743  std::uint32_t n_ : 4;
744  std::uint32_t n_R_ : 4;
745  std::uint32_t n_L_ : 4;
746  std::uint32_t n_q1_ : 4;
747  std::uint32_t n_q2_ : 4;
748  std::uint32_t n_q3_ : 4;
749  std::uint32_t n_J_ : 4;
750 #endif
751  } digits_;
756  std::uint32_t dump_;
761  struct {
762 #if SMASH_BITFIELD_ORDER_ == 1
763  std::uint32_t : 4;
765  std::uint32_t quarks_ : 12;
767  std::uint32_t excitation_ : 12, : 4;
768 #else
769  std::uint32_t : 4, excitation_ : 12;
770  std::uint32_t quarks_ : 12, : 4;
771 #endif
772  } chunks_;
774  struct {
775 #if SMASH_BITFIELD_ORDER_ == 1
776  std::uint32_t n_Lambda_ : 6;
777  std::uint32_t Z_ : 10;
778  std::uint32_t A_ : 10;
779  std::uint32_t I_ : 4;
780  bool is_nucleus_ : 1;
781  bool antiparticle_ : 1;
782 #else // Reverse ordering
783  bool antiparticle_ : 1;
784  bool is_nucleus_ : 1;
785  std::uint32_t I_ : 4;
786  std::uint32_t A_ : 10;
787  std::uint32_t Z_ : 10;
788  std::uint32_t n_Lambda_ : 6;
789 #endif
790  } nucleus_;
791  };
792 
797  inline std::uint32_t ucode() const { return (dump_ & 0x0fffffff); }
798 
805  inline std::uint32_t get_digit_from_char(const char inp) const {
806  // Decimal digit
807  if (48 <= inp && inp <= 57) {
808  return inp - 48;
809  }
810  // Hexdecimal digit, uppercase
811  if (65 <= inp && inp <= 70) {
812  return inp - 65 + 10;
813  }
814  // Hexdecimal digit, lowercase
815  if (97 <= inp && inp <= 102) {
816  return inp - 97 + 10;
817  }
818  throw InvalidPdgCode("PdgCode: Invalid character " + std::string(&inp, 1) +
819  " found.\n");
820  }
821 
843  inline void set_from_string(const std::string& codestring) {
844  dump_ = 0;
845  // Implicit with the above: digits_.antiparticle_ = false;
846  digits_.n_ = digits_.n_R_ = digits_.n_L_ = digits_.n_q1_ = digits_.n_q2_ =
847  digits_.n_q3_ = digits_.n_J_ = digits_.is_nucleus_ = 0;
848  size_t length = codestring.size();
849  if (length < 1) {
850  throw InvalidPdgCode("Empty string does not contain PDG Code\n");
851  }
852  int c = 0;
853  /* Look at current character; if it is a + or minus sign, read it
854  * and advance to next char. */
855  if (codestring[c] == '-') {
856  digits_.antiparticle_ = true;
857  ++c;
858  } else if (codestring[c] == '+') {
859  digits_.antiparticle_ = false;
860  ++c;
861  }
862  // Save if the first character was a sign:
863  unsigned int sign = c;
864 
865  // Nucleus
866  if (length == 10 + sign) {
867  nucleus_.is_nucleus_ = true;
868  if (codestring[c] != '1' || codestring[c + 1] != '0') {
869  throw InvalidPdgCode("Pdg code of nucleus \"" + codestring +
870  "\" should start with 10\n");
871  }
872  c += 2;
873  // ±10LZZZAAAI is the standard for nuclei
874  std::array<int, 8> digits;
875  for (int i = 0; i < 8; i++) {
876  digits[i] = get_digit_from_char(codestring[c + i]);
877  }
878  nucleus_.n_Lambda_ = digits[0];
879  nucleus_.Z_ = 100 * digits[1] + 10 * digits[2] + digits[3];
880  nucleus_.A_ = 100 * digits[4] + 10 * digits[5] + digits[6];
881  nucleus_.I_ = digits[7];
882  return;
883  }
884 
885  // Codestring shouldn't be longer than 8 + sign, except for nuclei
886  if (length > 8 + sign) {
887  throw InvalidPdgCode("String \"" + codestring +
888  "\" too long for PDG Code\n");
889  }
890  /* Please note that in what follows, we actually need c++, not ++c.
891  * first digit is used for n_J if the last digit is not enough. */
892  if (length > 7 + sign) {
893  digits_.n_J_ += get_digit_from_char(codestring[c++]);
894  }
895  // Codestring has 7 digits? 7th from last goes in n_.
896  if (length > 6 + sign) {
897  digits_.n_ = get_digit_from_char(codestring[c++]);
898  }
899  // It has 6 or 7 digits? 6th from last is n_R_.
900  if (length > 5 + sign) {
901  digits_.n_R_ = get_digit_from_char(codestring[c++]);
902  }
903  // 5th from last is n_L_.
904  if (length > 4 + sign) {
905  digits_.n_L_ = get_digit_from_char(codestring[c++]);
906  }
907  // 4th from last is n_q1_.
908  if (length > 3 + sign) {
909  digits_.n_q1_ = get_digit_from_char(codestring[c++]);
910  if (digits_.n_q1_ > 6) {
911  throw InvalidPdgCode("Invalid PDG code " + codestring + " (n_q1>6)");
912  }
913  }
914  // 3rd from last is n_q2_.
915  if (length > 2 + sign) {
916  digits_.n_q2_ = get_digit_from_char(codestring[c++]);
917  if (digits_.n_q2_ > 6) {
918  throw InvalidPdgCode("Invalid PDG code " + codestring + " (n_q2>6)");
919  }
920  }
921  // Next to last is n_q3_.
922  if (length > 1 + sign) {
923  digits_.n_q3_ = get_digit_from_char(codestring[c++]);
924  if (digits_.n_q3_ > 6) {
925  throw InvalidPdgCode("Invalid PDG code " + codestring + " (n_q3>6)");
926  }
927  }
928  // Last digit is the spin degeneracy.
929  if (length > sign) {
930  digits_.n_J_ += get_digit_from_char(codestring[c++]);
931  } else {
932  throw InvalidPdgCode(
933  "String \"" + codestring +
934  "\" only consists of a sign, that is no valid PDG Code\n");
935  }
936  check();
937  }
938 
948  inline void set_fields(std::uint32_t abscode) {
949  /* "dump_ =" overwrites antiparticle_, but this needs to have been set
950  * already, so we carry it around the assignment. */
951  bool ap = digits_.antiparticle_;
952  dump_ = abscode & 0x0fffffff;
953  digits_.antiparticle_ = ap;
954  int test = test_code();
955  if (test > 0) {
956  throw InvalidPdgCode("Invalid digits " + std::to_string(test) +
957  " in PDG Code " + string());
958  }
959  check();
960  }
961 };
962 
963 static_assert(sizeof(PdgCode) == 4, "should fit into 32 bit integer");
964 
971 std::istream& operator>>(std::istream& is, PdgCode& code);
977 std::ostream& operator<<(std::ostream& is, const PdgCode& code);
978 
980 inline bool is_dilepton(const PdgCode pdg1, const PdgCode pdg2) {
981  const auto c1 = pdg1.code();
982  const auto c2 = pdg2.code();
983  const auto min = std::min(c1, c2);
984  const auto max = std::max(c1, c2);
985  return (max == 0x11 && min == -0x11) || (max == 0x13 && min == -0x13);
986 }
987 
992 inline bool has_lepton_pair(const PdgCode pdg1, const PdgCode pdg2,
993  const PdgCode pdg3) {
994  return is_dilepton(pdg1, pdg2) || is_dilepton(pdg1, pdg3) ||
995  is_dilepton(pdg2, pdg3);
996 }
997 
998 } // namespace smash
999 
1000 #endif // SRC_INCLUDE_PDGCODE_H_
static PdgCode from_decimal(const int pdgcode_decimal)
Construct PDG code from decimal number.
Definition: pdgcode.h:269
unsigned int spin() const
Definition: pdgcode.h:509
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:557
bool is_Omega() const
Definition: pdgcode.h:346
bool is_Delta() const
Definition: pdgcode.h:336
std::uint32_t n_q3_
third quark field
Definition: pdgcode.h:725
int net_quark_number(const int quark) const
Returns the net number of quarks with given flavour number For public use, see strangeness(), charmness(), bottomness() and isospin3().
Definition: pdgcode.cc:31
int antiparticle_sign() const
Definition: pdgcode.h:537
bool is_Nstar1535() const
Definition: pdgcode.h:330
bool is_lepton() const
Definition: pdgcode.h:302
PdgCode get_antiparticle() const
Construct the antiparticle to a given PDG code.
Definition: pdgcode.h:259
int get_decimal() const
Definition: pdgcode.h:655
unsigned int spin_degeneracy() const
Definition: pdgcode.h:530
constexpr int K_p
K⁺.
std::uint32_t dump() const
Dumps the bitfield into an unsigned integer.
Definition: pdgcode.h:243
std::uint32_t excitation_
The excitation digits n_, n_R_, n_L_.
Definition: pdgcode.h:767
bool is_dilepton(const PdgCode pdg1, const PdgCode pdg2)
Definition: pdgcode.h:980
PdgCode(std::int32_t codenumber)
Receive a signed integer and process it into a PDG Code.
Definition: pdgcode.h:143
bool is_kaon() const
Definition: pdgcode.h:366
std::uint32_t n_J_
spin quantum number .
Definition: pdgcode.h:723
bool is_nucleon() const
Definition: pdgcode.h:324
constexpr int Delta_m
Δ⁻.
bool has_lepton_pair(const PdgCode pdg1, const PdgCode pdg2, const PdgCode pdg3)
Definition: pdgcode.h:992
std::uint32_t Z_
Definition: pdgcode.h:777
constexpr int rho_z
ρ⁰.
bool operator<(const PdgCode rhs) const
Sorts PDG Codes according to their numeric value.
Definition: pdgcode.h:617
struct smash::PdgCode::@0::@4 nucleus_
Structure for the nuclei.
std::string string() const
Definition: pdgcode.h:252
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_R_
"radial excitation"
Definition: pdgcode.h:733
void set_fields(std::uint32_t abscode)
Sets the bitfield from an unsigned integer.
Definition: pdgcode.h:948
int charge() const
The charge of the particle.
Definition: pdgcode.h:470
bool is_nucleus() const
Definition: pdgcode.h:291
bool is_Sigma() const
Definition: pdgcode.h:361
struct smash::PdgCode::@0::@3 chunks_
Chunk collection: here, the chunks with and are directly accessible.
bool is_pion() const
Definition: pdgcode.h:372
constexpr int Delta_z
Δ⁰.
std::uint32_t n_L_
"angular momentum"
Definition: pdgcode.h:731
thrown for invalid inputs
Definition: pdgcode.h:114
constexpr int N1535_p
N(1535)⁺.
constexpr int pi_z
π⁰.
std::uint32_t n_q2_
second quark field
Definition: pdgcode.h:727
constexpr int Delta_p
Δ⁺.
bool is_hyperon() const
Definition: pdgcode.h:343
struct smash::PdgCode::@0::@2 digits_
The single digits collection of the code.
std::uint32_t ucode() const
Definition: pdgcode.h:797
bool is_rho() const
Definition: pdgcode.h:378
constexpr int K_z
K⁰.
void deexcite()
Remove all excitation, except spin. Sign and quark content remains.
Definition: pdgcode.h:675
constexpr int decimal_d
Deuteron in decimal digits.
constexpr int rho_p
ρ⁺.
constexpr int Delta_pp
Δ⁺⁺.
std::uint32_t n_q1_
first quark field. 0 for mesons.
Definition: pdgcode.h:729
constexpr int N1535_z
N(1535)⁰.
int isospin3() const
Definition: pdgcode.h:409
int strangeness() const
Definition: pdgcode.h:446
constexpr int decimal_antid
Anti-deuteron in decimal digits.
std::uint32_t n_
first field: "counter"
Definition: pdgcode.h:735
std::uint32_t I_
Definition: pdgcode.h:779
int bottomness() const
Definition: pdgcode.h:460
std::istream & operator>>(std::istream &is, PdgCode &code)
Sets the PDG code from the textual representation in the input stream.
Definition: pdgcode.cc:14
PdgCode stores a Particle Data Group Particle Numbering Scheme particle type number.
Definition: pdgcode.h:108
PdgCode(const std::string &codestring)
Initialize using a string The string is interpreted as a hexadecimal number, i.e., 211 is interpreted as 0x211 = .
Definition: pdgcode.h:131
std::uint32_t bool is_nucleus_
1 for nuclei, 0 for the rest
Definition: pdgcode.h:735
friend std::istream & operator>>(std::istream &is, PdgCode &code)
istream >> PdgCode assigns the PDG Code from an istream.
Definition: pdgcode.cc:14
void set_from_string(const std::string &codestring)
Set the PDG code from the given string.
Definition: pdgcode.h:843
bool is_Xi() const
Definition: pdgcode.h:351
std::uint32_t get_digit_from_char(const char inp) const
Definition: pdgcode.h:805
constexpr int pi_p
π⁺.
bool operator!=(const PdgCode rhs) const
Definition: pdgcode.h:629
bool is_baryon() const
Definition: pdgcode.h:318
std::uint32_t A_
Definition: pdgcode.h:778
std::uint32_t n_Lambda_
Definition: pdgcode.h:776
constexpr int rho_m
ρ⁻.
std::uint32_t quarks_
The quark digits n_q{1,2,3}_.
Definition: pdgcode.h:765
bool is_antiparticle_of(const PdgCode rhs) const
Definition: pdgcode.h:632
int test_code() const
Checks the integer for invalid hex digits.
Definition: pdgcode.h:180
constexpr int p
Proton.
std::uint32_t dump_
The bitfield dumped into a single integer.
Definition: pdgcode.h:756
int charmness() const
Definition: pdgcode.h:453
std::int32_t quarks() const
Definition: pdgcode.h:541
void check() const
Do all sorts of validity checks.
Definition: pdgcode.h:214
constexpr int pi_m
π⁻.
bool is_Lambda() const
Definition: pdgcode.h:356
double frac_strange() const
Definition: pdgcode.h:422
bool contains_enough_valence_quarks(int valence_quarks_required) const
Definition: pdgcode.cc:92
bool is_deuteron() const
Definition: pdgcode.h:384
constexpr int n
Neutron.
bool is_meson() const
Definition: pdgcode.h:321
bool operator==(const PdgCode rhs) const
Definition: pdgcode.h:626
bool has_antiparticle() const
Definition: pdgcode.h:393
std::ostream & operator<<(std::ostream &out, const ActionPtr &action)
Convenience: dereferences the ActionPtr to Action.
Definition: action.h:457
bool antiparticle_
first bit: stores the sign.
Definition: pdgcode.h:739
static PdgCode invalid()
PdgCode 0x0 is guaranteed not to be valid by the PDG standard, but it passes all tests here...
Definition: pdgcode.h:644
bool is_nucleus_
Definition: pdgcode.h:780
int baryon_number() const
Definition: pdgcode.h:308
std::int32_t code() const
Definition: pdgcode.h:249
Definition: action.h:24
PdgCode()
Standard initializer.
Definition: pdgcode.h:125
bool is_hadron() const
Definition: pdgcode.h:297