Version: SMASH-2.2
particletype.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2014-2022
4  * SMASH Team
5  *
6  * GNU General Public License (GPLv3 or later)
7  *
8  */
9 
10 #include "smash/particletype.h"
11 
12 #include <assert.h>
13 #include <algorithm>
14 #include <map>
15 #include <vector>
16 
17 #include "smash/constants.h"
18 #include "smash/cxx14compat.h"
19 #include "smash/decaymodes.h"
20 #include "smash/distributions.h"
21 #include "smash/formfactors.h"
22 #include "smash/inputfunctions.h"
23 #include "smash/integrate.h"
24 #include "smash/iomanipulators.h"
25 #include "smash/isoparticletype.h"
26 #include "smash/logging.h"
28 #include "smash/stringfunctions.h"
29 
30 namespace smash {
31 static constexpr int LParticleType = LogArea::ParticleType::id;
32 static constexpr int LResonances = LogArea::Resonances::id;
33 
34 namespace {
36 const ParticleTypeList *all_particle_types = nullptr;
38 ParticleTypePtrList nucleons_list;
40 ParticleTypePtrList anti_nucs_list;
42 ParticleTypePtrList deltas_list;
44 ParticleTypePtrList anti_deltas_list;
46 ParticleTypePtrList baryon_resonances_list;
48 ParticleTypePtrList light_nuclei_list;
49 } // unnamed namespace
50 
51 const ParticleTypeList &ParticleType::list_all() {
52  assert(all_particle_types);
53  return *all_particle_types;
54 }
55 
56 // For performance reasonce one might want to inline this function.
58  // Calculate the offset via pointer subtraction:
59  const auto offset = this - std::addressof(list_all()[0]);
60  // Since we're using uint16_t for storing the index better be safe than sorry:
61  // The offset must fit into the data type. If this ever fails we got a lot
62  // more particle types than initially expected and you have to increase the
63  // ParticleTypePtr storage to uint32_t.
64  assert(offset >= 0 && offset < 0xffff);
65  // After the assertion above the down-cast to uint16_t is safe:
66  return ParticleTypePtr(static_cast<uint16_t>(offset));
67 }
68 
69 ParticleTypePtrList &ParticleType::list_nucleons() { return nucleons_list; }
70 
71 ParticleTypePtrList &ParticleType::list_anti_nucleons() {
72  return anti_nucs_list;
73 }
74 
75 ParticleTypePtrList &ParticleType::list_Deltas() { return deltas_list; }
76 
77 ParticleTypePtrList &ParticleType::list_anti_Deltas() {
78  return anti_deltas_list;
79 }
80 
81 ParticleTypePtrList &ParticleType::list_baryon_resonances() {
83 }
84 
85 ParticleTypePtrList &ParticleType::list_light_nuclei() {
86  return light_nuclei_list;
87 }
88 
90  const auto found = std::lower_bound(
92  [](const ParticleType &l, const PdgCode &r) { return l.pdgcode() < r; });
93  if (found == all_particle_types->end() || found->pdgcode() != pdgcode) {
94  return {}; // The default constructor creates an invalid pointer.
95  }
96  return &*found;
97 }
98 
100  const auto found = ParticleType::try_find(pdgcode);
101  if (!found) {
102  throw PdgNotFoundFailure("PDG code " + pdgcode.string() + " not found!");
103  }
104  return *found;
105 }
106 
108  const auto found = ParticleType::try_find(pdgcode);
109  return found;
110 }
111 
112 bool ParticleType::exists(const std::string &name) {
113  const auto found =
114  std::find_if(all_particle_types->begin(), all_particle_types->end(),
115  [&](const ParticleType &p) { return p.name() == name; });
116  if (found == all_particle_types->end()) {
117  return false;
118  }
119  return true;
120 }
121 
122 ParticleType::ParticleType(std::string n, double m, double w, Parity p,
123  PdgCode id)
124  : name_(n),
125  mass_(m),
126  width_(w),
127  parity_(p),
128  pdgcode_(id),
129  min_mass_kinematic_(-1.),
130  min_mass_spectral_(-1.),
131  charge_(pdgcode_.charge()),
132  isospin_(-1),
133  I3_(pdgcode_.isospin3()) {}
134 
143 static std::string antiname(const std::string &name, PdgCode code) {
144  std::string basename, charge;
145 
146  if (name.find("⁺⁺") != std::string::npos) {
147  basename = name.substr(0, name.length() - sizeof("⁺⁺") + 1);
148  charge = "⁻⁻";
149  } else if (name.find("⁺") != std::string::npos) {
150  basename = name.substr(0, name.length() - sizeof("⁺") + 1);
151  charge = "⁻";
152  } else if (name.find("⁻⁻") != std::string::npos) {
153  basename = name.substr(0, name.length() - sizeof("⁻⁻") + 1);
154  charge = "⁺⁺";
155  } else if (name.find("⁻") != std::string::npos) {
156  basename = name.substr(0, name.length() - sizeof("⁻") + 1);
157  charge = "⁺";
158  } else if (name.find("⁰") != std::string::npos) {
159  basename = name.substr(0, name.length() - sizeof("⁰") + 1);
160  charge = "⁰";
161  } else {
162  basename = name;
163  charge = "";
164  }
165 
166  // baryons & strange mesons: insert a bar
167  if (code.baryon_number() != 0 || code.strangeness() != 0) {
168  constexpr char bar[] = "\u0305";
169  basename.insert(utf8::sequence_length(basename.begin()), bar);
170  }
171 
172  return basename + charge;
173 }
174 
182 static std::string chargestr(int charge) {
183  switch (charge) {
184  case 2:
185  return "⁺⁺";
186  case 1:
187  return "⁺";
188  case 0:
189  return "⁰";
190  case -1:
191  return "⁻";
192  case -2:
193  return "⁻⁻";
194  default:
195  throw std::runtime_error("Invalid charge " + std::to_string(charge));
196  }
197 }
198 
199 void ParticleType::create_type_list(const std::string &input) { // {{{
200  static ParticleTypeList type_list;
201  type_list.clear(); // in case LoadFailure was thrown and caught and we should
202  // try again
203  for (const Line &line : line_parser(input)) {
204  std::istringstream lineinput(line.text);
205  std::string name;
206  double mass, width;
207  std::string parity_string;
208  std::vector<std::string> pdgcode_strings;
209  // We expect at most 4 PDG codes per multiplet.
210  pdgcode_strings.reserve(4);
211  lineinput >> name >> mass >> width >> parity_string;
212  Parity parity;
213  bool fail = false;
214  if (parity_string == "+") {
216  } else if (parity_string == "-") {
218  } else {
219  fail = true;
220  }
221  if (lineinput.fail() || fail) {
223  "While loading the ParticleType data:\nFailed to convert the input "
224  "string to the expected data types.",
225  line));
226  }
227  // read additional PDG codes (if present)
228  while (!lineinput.eof()) {
229  pdgcode_strings.push_back("");
230  lineinput >> pdgcode_strings.back();
231  if (lineinput.fail()) {
233  "While loading the ParticleType data:\nFailed to convert the input "
234  "string to the expected data types.",
235  line));
236  }
237  }
238  if (pdgcode_strings.size() < 1) {
240  "While loading the ParticleType data:\nFailed to convert the input "
241  "string due to missing PDG code.",
242  line));
243  }
244  std::vector<PdgCode> pdgcode;
245  pdgcode.resize(pdgcode_strings.size());
246  std::transform(pdgcode_strings.begin(), pdgcode_strings.end(),
247  pdgcode.begin(),
248  [](const std::string &s) { return PdgCode(s); });
249  ensure_all_read(lineinput, line);
250 
251  /* Check if nucleon, kaon, and delta masses are
252  * the same as hardcoded ones, if present */
254  throw std::runtime_error(
255  "Nucleon mass in input file different from 0.938");
256  }
257  if (pdgcode[0].is_kaon() && !almost_equal(mass, kaon_mass)) {
258  throw std::runtime_error("Kaon mass in input file different from 0.494");
259  }
260  if (pdgcode[0].is_Delta() && !almost_equal(mass, delta_mass)) {
261  throw std::runtime_error("Delta mass in input file different from 1.232");
262  }
264  throw std::runtime_error("d mass in input file different from 1.8756");
265  }
266 
267  // add all states to type list
268  for (size_t i = 0; i < pdgcode.size(); i++) {
269  std::string full_name = name;
270  if (pdgcode.size() > 1) {
271  // for multiplets: add charge string to name
272  full_name += chargestr(pdgcode[i].charge());
273  }
274  type_list.emplace_back(full_name, mass, width, parity, pdgcode[i]);
275  logg[LParticleType].debug()
276  << "Setting particle type: " << type_list.back();
277  if (pdgcode[i].has_antiparticle()) {
278  /* add corresponding antiparticle */
279  PdgCode anti = pdgcode[i].get_antiparticle();
280  // For bosons the parity does not change, for fermions it gets inverted.
281  const auto anti_parity = (anti.spin() % 2 == 0) ? parity : -parity;
282  full_name = antiname(full_name, pdgcode[i]);
283  type_list.emplace_back(full_name, mass, width, anti_parity, anti);
284  logg[LParticleType].debug()
285  << "Setting antiparticle type: " << type_list.back();
286  }
287  }
288  }
289  type_list.shrink_to_fit();
290 
291  /* Sort the type list by PDG code. */
292  std::sort(type_list.begin(), type_list.end());
293 
294  /* Look for duplicates. */
295  PdgCode prev_pdg = 0;
296  for (const auto &t : type_list) {
297  if (t.pdgcode() == prev_pdg) {
298  throw ParticleType::LoadFailure("Duplicate PdgCode in particles.txt: " +
299  t.pdgcode().string());
300  }
301  prev_pdg = t.pdgcode();
302  }
303 
304  if (all_particle_types != nullptr) {
305  throw std::runtime_error("Error: Type list was already built!");
306  }
307  all_particle_types = &type_list; // note that type_list is a function-local
308  // static and thus will live on until after
309  // main().
310 
311  // create all isospin multiplets
312  for (const auto &t : type_list) {
314  }
315  // link the multiplets to the types
316  for (auto &t : type_list) {
317  t.iso_multiplet_ = IsoParticleType::find(t);
318  }
319 
320  // Create nucleons/anti-nucleons list
321  if (IsoParticleType::exists("N")) {
322  for (const auto &state : IsoParticleType::find("N").get_states()) {
323  nucleons_list.push_back(state);
324  anti_nucs_list.push_back(state->get_antiparticle());
325  }
326  }
327 
328  // Create deltas list
329  if (IsoParticleType::exists("Δ")) {
330  for (const auto &state : IsoParticleType::find("Δ").get_states()) {
331  deltas_list.push_back(state);
332  anti_deltas_list.push_back(state->get_antiparticle());
333  }
334  }
335 
336  // Create baryon resonances list
337  for (const ParticleType &type_resonance : ParticleType::list_all()) {
338  /* Only loop over baryon resonances. */
339  if (type_resonance.is_stable() ||
340  type_resonance.pdgcode().baryon_number() != 1) {
341  continue;
342  }
343  baryon_resonances_list.push_back(&type_resonance);
344  baryon_resonances_list.push_back(type_resonance.get_antiparticle());
345  }
346 
347  for (const ParticleType &type : ParticleType::list_all()) {
348  if (type.is_nucleus()) {
349  light_nuclei_list.push_back(&type);
350  }
351  }
352 } /*}}}*/
353 
355  if (unlikely(min_mass_kinematic_ < 0.)) {
356  /* If the particle is stable, min. mass is just the mass. */
358  /* Otherwise, find the lowest mass value needed in any decay mode */
359  if (!is_stable()) {
360  for (const auto &mode : decay_modes().decay_mode_list()) {
361  min_mass_kinematic_ = std::min(min_mass_kinematic_, mode->threshold());
362  }
363  }
364  }
365  return min_mass_kinematic_;
366 }
367 
369  if (unlikely(min_mass_spectral_ < 0.)) {
370  /* If the particle is stable or it has a non-zero spectral function value at
371  * the minimum mass that is allowed by kinematics, min_mass_spectral is just
372  * the min_mass_kinetic. */
374  /* Otherwise, find the lowest mass value where spectral function has a
375  * non-zero value by bisection.*/
376  if (!is_stable() &&
378  // find a right bound that has non-zero spectral function for bisection
379  const double m_step = 0.01;
380  double right_bound_bis;
381  for (unsigned int i = 0;; i++) {
382  right_bound_bis = min_mass_kinematic() + m_step * i;
383  if (this->spectral_function(right_bound_bis) > really_small) {
384  break;
385  }
386  }
387  // bisection
388  const double precision = 1E-6;
389  double left_bound_bis = right_bound_bis - m_step;
390  while (right_bound_bis - left_bound_bis > precision) {
391  const double mid = (left_bound_bis + right_bound_bis) / 2.0;
392  if (this->spectral_function(mid) > really_small) {
393  right_bound_bis = mid;
394  } else {
395  left_bound_bis = mid;
396  }
397  }
398  min_mass_spectral_ = right_bound_bis;
399  }
400  }
401  return min_mass_spectral_;
402 }
403 
405  if (isospin_ < 0) {
408  : 0;
409  }
410  return isospin_;
411 }
412 
413 double ParticleType::partial_width(const double m,
414  const DecayBranch *mode) const {
415  if (m < mode->threshold()) {
416  return 0.;
417  }
418  double partial_width_at_pole = width_at_pole() * mode->weight();
419  return mode->type().width(mass(), partial_width_at_pole, m);
420 }
421 
423  const auto offset = this - std::addressof(list_all()[0]);
424  const auto &modes = (*DecayModes::all_decay_modes)[offset];
425  assert(is_stable() || !modes.is_empty());
426  return modes;
427 }
428 
429 double ParticleType::total_width(const double m) const {
430  double w = 0.;
431  if (is_stable()) {
432  return w;
433  }
434  /* Loop over decay modes and sum up all partial widths. */
435  const auto &modes = decay_modes().decay_mode_list();
436  for (unsigned int i = 0; i < modes.size(); i++) {
437  w = w + partial_width(m, modes[i].get());
438  }
439  if (w < width_cutoff) {
440  return 0.;
441  }
442  return w;
443 }
444 
446  for (const ParticleType &ptype : ParticleType::list_all()) {
447  if (!ptype.is_stable() && ptype.decay_modes().is_empty()) {
448  throw std::runtime_error("Unstable particle " + ptype.name() +
449  " has no decay chanels!");
450  }
451  }
452 }
453 
455  WhichDecaymodes wh) const {
456  switch (wh) {
457  case WhichDecaymodes::All: {
458  return true;
459  }
461  return !t.is_dilepton_decay();
462  }
464  return t.is_dilepton_decay();
465  }
466  default:
467  throw std::runtime_error(
468  "Problem in selecting decaymodes in wanted_decaymode()");
469  }
470 }
471 
473  const ThreeVector x,
474  WhichDecaymodes wh) const {
475  const auto &decay_mode_list = decay_modes().decay_mode_list();
476  /* Determine whether the decay is affected by the potentials. If it's
477  * affected, read the values of the potentials at the position of the
478  * particle */
479  FourVector UB = FourVector();
480  FourVector UI3 = FourVector();
481  if (UB_lat_pointer != nullptr) {
482  UB_lat_pointer->value_at(x, UB);
483  }
484  if (UI3_lat_pointer != nullptr) {
485  UI3_lat_pointer->value_at(x, UI3);
486  }
487  /* Loop over decay modes and calculate all partial widths. */
488  DecayBranchList partial;
489  partial.reserve(decay_mode_list.size());
490  for (unsigned int i = 0; i < decay_mode_list.size(); i++) {
491  /* Calculate the sqare root s of the final state particles. */
492  const auto FinalTypes = decay_mode_list[i]->type().particle_types();
493  double scale_B = 0.0;
494  double scale_I3 = 0.0;
495  if (pot_pointer != nullptr) {
496  scale_B += pot_pointer->force_scale(*this).first;
497  scale_I3 += pot_pointer->force_scale(*this).second * isospin3_rel();
498  for (const auto &finaltype : FinalTypes) {
499  scale_B -= pot_pointer->force_scale(*finaltype).first;
500  scale_I3 -= pot_pointer->force_scale(*finaltype).second *
501  finaltype->isospin3_rel();
502  }
503  }
504  double sqrt_s = (p + UB * scale_B + UI3 * scale_I3).abs();
505 
506  const double w = partial_width(sqrt_s, decay_mode_list[i].get());
507  if (w > 0.) {
508  if (wanted_decaymode(decay_mode_list[i]->type(), wh)) {
509  partial.push_back(
510  make_unique<DecayBranch>(decay_mode_list[i]->type(), w));
511  }
512  }
513  }
514  return partial;
515 }
516 
517 double ParticleType::get_partial_width(const double m,
518  const ParticleTypePtrList dlist) const {
519  /* Get all decay modes. */
520  const auto &decaymodes = decay_modes().decay_mode_list();
521 
522  /* Find the right one(s) and add up corresponding widths. */
523  double w = 0.;
524  for (const auto &mode : decaymodes) {
525  double partial_width_at_pole = width_at_pole() * mode->weight();
526  if (mode->type().has_particles(dlist)) {
527  w += mode->type().width(mass(), partial_width_at_pole, m);
528  }
529  }
530  return w;
531 }
532 
534  const ParticleData &p_a,
535  const ParticleData &p_b) const {
536  /* Get all decay modes. */
537  const auto &decaymodes = decay_modes().decay_mode_list();
538 
539  /* Find the right one(s) and add up corresponding widths. */
540  double w = 0.;
541  for (const auto &mode : decaymodes) {
542  double partial_width_at_pole = width_at_pole() * mode->weight();
543  const ParticleTypePtrList l = {&p_a.type(), &p_b.type()};
544  if (mode->type().has_particles(l)) {
545  w += mode->type().in_width(mass(), partial_width_at_pole, m,
546  p_a.effective_mass(), p_b.effective_mass());
547  }
548  }
549  return w;
550 }
551 
552 double ParticleType::spectral_function(double m) const {
553  if (norm_factor_ < 0.) {
554  /* Initialize the normalization factor
555  * by integrating over the unnormalized spectral function. */
556  static /*thread_local (see #3075)*/ Integrator integrate;
557  const double width = width_at_pole();
558  const double m_pole = mass();
559  // We transform the integral using m = m_min + width_pole * tan(x), to
560  // make it definite and to avoid numerical issues.
561  const double x_min = std::atan((min_mass_kinematic() - m_pole) / width);
562  norm_factor_ = 1. / integrate(x_min, M_PI / 2., [&](double x) {
563  const double tanx = std::tan(x);
564  const double m_x = m_pole + width * tanx;
565  const double jacobian = width * (1.0 + tanx * tanx);
566  return spectral_function_no_norm(m_x) * jacobian;
567  });
568  }
570 }
571 
573  /* The spectral function is a relativistic Breit-Wigner function
574  * with mass-dependent width. Here: without normalization factor. */
575  const double resonance_width = total_width(m);
576  if (resonance_width < ParticleType::width_cutoff) {
577  return 0.;
578  }
579  return breit_wigner(m, mass(), resonance_width);
580 }
581 
583  /* The spectral function is a relativistic Breit-Wigner function.
584  * This variant is using a constant width (evaluated at the pole mass). */
585  const double resonance_width = width_at_pole();
586  if (resonance_width < ParticleType::width_cutoff) {
587  return 0.;
588  }
589  return breit_wigner(m, mass(), resonance_width);
590 }
591 
593  return breit_wigner_nonrel(m, mass(), width_at_pole());
594 }
595 
596 /* Resonance mass sampling for 2-particle final state */
597 double ParticleType::sample_resonance_mass(const double mass_stable,
598  const double cms_energy,
599  int L) const {
600  /* largest possible mass: Use 'nextafter' to make sure it is not above the
601  * physical limit by numerical error. */
602  const double max_mass = std::nextafter(cms_energy - mass_stable, 0.);
603 
604  // smallest possible mass to find non-zero spectral function contributions
605  const double min_mass = this->min_mass_spectral();
606 
607  // largest possible cm momentum (from smallest mass)
608  const double pcm_max = pCM(cms_energy, mass_stable, min_mass);
609  const double blw_max = pcm_max * blatt_weisskopf_sqr(pcm_max, L);
610  /* The maximum of the spectral-function ratio 'usually' happens at the
611  * largest mass. However, this is not always the case, therefore we need
612  * and additional fudge factor (determined automatically). Additionally,
613  * a heuristic knowledge is used that usually such mass exist that
614  * spectral_function(m) > spectral_function_simple(m). */
615  const double sf_ratio_max =
616  std::max(1., this->spectral_function(max_mass) /
617  this->spectral_function_simple(max_mass));
618 
619  double mass_res, val;
620  // outer loop: repeat if maximum is too small
621  do {
622  const double q_max = sf_ratio_max * this->max_factor1_;
623  const double max = blw_max * q_max; // maximum value for rejection sampling
624  // inner loop: rejection sampling
625  do {
626  // sample mass from a simple Breit-Wigner (aka Cauchy) distribution
627  mass_res = random::cauchy(this->mass(), this->width_at_pole() / 2.,
628  this->min_mass_spectral(), max_mass);
629  // determine cm momentum for this case
630  const double pcm = pCM(cms_energy, mass_stable, mass_res);
631  const double blw = pcm * blatt_weisskopf_sqr(pcm, L);
632  // determine ratio of full to simple spectral function
633  const double q = this->spectral_function(mass_res) /
634  this->spectral_function_simple(mass_res);
635  val = q * blw;
636  } while (val < random::uniform(0., max));
637 
638  // check that we are using the proper maximum value
639  if (val > max) {
640  logg[LResonances].debug(
641  "maximum is being increased in sample_resonance_mass: ",
642  this->max_factor1_, " ", val / max, " ", this->pdgcode(), " ",
643  mass_stable, " ", cms_energy, " ", mass_res);
644  this->max_factor1_ *= val / max;
645  } else {
646  break; // maximum ok, exit loop
647  }
648  } while (true);
649 
650  return mass_res;
651 }
652 
653 /* Resonance mass sampling for 2-particle final state with two resonances. */
654 std::pair<double, double> ParticleType::sample_resonance_masses(
655  const ParticleType &t2, const double cms_energy, int L) const {
656  const ParticleType &t1 = *this;
657  /* Sample resonance mass from the distribution
658  * used for calculating the cross section. */
659  const double max_mass_1 =
660  std::nextafter(cms_energy - t2.min_mass_spectral(), 0.);
661  const double max_mass_2 =
662  std::nextafter(cms_energy - t1.min_mass_spectral(), 0.);
663  // largest possible cm momentum (from smallest mass)
664  const double pcm_max =
665  pCM(cms_energy, t1.min_mass_spectral(), t2.min_mass_spectral());
666  const double blw_max = pcm_max * blatt_weisskopf_sqr(pcm_max, L);
667 
668  double mass_1, mass_2, val;
669  // outer loop: repeat if maximum is too small
670  do {
671  // maximum value for rejection sampling (determined automatically)
672  const double max = blw_max * t1.max_factor2_;
673  // inner loop: rejection sampling
674  do {
675  // sample mass from a simple Breit-Wigner (aka Cauchy) distribution
676  mass_1 = random::cauchy(t1.mass(), t1.width_at_pole() / 2.,
677  t1.min_mass_spectral(), max_mass_1);
678  mass_2 = random::cauchy(t2.mass(), t2.width_at_pole() / 2.,
679  t2.min_mass_spectral(), max_mass_2);
680  // determine cm momentum for this case
681  const double pcm = pCM(cms_energy, mass_1, mass_2);
682  const double blw = pcm * blatt_weisskopf_sqr(pcm, L);
683  // determine ratios of full to simple spectral function
684  const double q1 =
685  t1.spectral_function(mass_1) / t1.spectral_function_simple(mass_1);
686  const double q2 =
687  t2.spectral_function(mass_2) / t2.spectral_function_simple(mass_2);
688  val = q1 * q2 * blw;
689  } while (val < random::uniform(0., max));
690 
691  if (val > max) {
692  logg[LResonances].debug(
693  "maximum is being increased in sample_resonance_masses: ",
694  t1.max_factor2_, " ", val / max, " ", t1.pdgcode(), " ", t2.pdgcode(),
695  " ", cms_energy, " ", mass_1, " ", mass_2);
696  t1.max_factor2_ *= val / max;
697  } else {
698  break; // maximum ok, exit loop
699  }
700  } while (true);
701 
702  return {mass_1, mass_2};
703 }
704 
706  if (is_stable()) {
707  std::stringstream err;
708  err << "Particle " << *this << " is stable, so it makes no"
709  << " sense to print its spectral function, etc.";
710  throw std::runtime_error(err.str());
711  }
712 
713  double rightmost_pole = 0.0;
714  const auto &decaymodes = decay_modes().decay_mode_list();
715  for (const auto &mode : decaymodes) {
716  double pole_mass_sum = 0.0;
717  for (const ParticleTypePtr p : mode->type().particle_types()) {
718  pole_mass_sum += p->mass();
719  }
720  if (pole_mass_sum > rightmost_pole) {
721  rightmost_pole = pole_mass_sum;
722  }
723  }
724 
725  std::cout << "# mass m[GeV], width w(m) [GeV],"
726  << " spectral function(m^2)*m [GeV^-1] of " << *this << std::endl;
727  constexpr double m_step = 0.02;
728  const double m_min = min_mass_spectral();
729  // An empirical value used to stop the printout. Assumes that spectral
730  // function decays at high mass, which is true for all known resonances.
731  constexpr double spectral_function_threshold = 8.e-3;
732  std::cout << std::fixed << std::setprecision(5);
733  for (unsigned int i = 0;; i++) {
734  const double m = m_min + m_step * i;
735  const double w = total_width(m), sf = spectral_function(m);
736  if (m > rightmost_pole * 2 && sf < spectral_function_threshold) {
737  break;
738  }
739  std::cout << m << " " << w << " " << sf << std::endl;
740  }
741 }
742 
743 std::ostream &operator<<(std::ostream &out, const ParticleType &type) {
744  const PdgCode &pdg = type.pdgcode();
745  return out << type.name() << std::setfill(' ') << std::right
746  << "[ mass:" << field<6> << type.mass()
747  << ", width:" << field<6> << type.width_at_pole()
748  << ", PDG:" << field<6> << pdg
749  << ", charge:" << field<3> << pdg.charge()
750  << ", spin:" << field<2> << pdg.spin() << "/2 ]";
751 }
752 
753 } // namespace smash
DecayBranch is a derivative of ProcessBranch, which is used to represent decay channels.
const DecayType & type() const
The DecayModes class is used to store and update information about decay branches (i....
Definition: decaymodes.h:29
const DecayBranchList & decay_mode_list() const
Definition: decaymodes.h:63
DecayType is the abstract base class for all decay types.
Definition: decaytype.h:23
virtual bool is_dilepton_decay() const
Definition: decaytype.h:83
virtual double width(double m0, double G0, double m) const =0
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
Definition: fourvector.h:33
A C++ interface for numerical integration in one dimension with the GSL CQUAD integration functions.
Definition: integrate.h:106
static bool exists(const std::string &name)
Returns whether the ParticleType with the given pdgcode exists.
static const IsoParticleType & find(const std::string &name)
Returns the IsoParticleType object for the given name.
int isospin() const
Returns twice the total isospin of the multiplet.
static void create_multiplet(const ParticleType &type)
Add a new multiplet to the global list of IsoParticleTypes, which contains type.
ParticleData contains the dynamic information of a certain particle.
Definition: particledata.h:58
const ParticleType & type() const
Get the type of the particle.
Definition: particledata.h:128
double effective_mass() const
Get the particle's effective mass.
Definition: particledata.cc:21
A pointer-like interface to global references to ParticleType objects.
Definition: particletype.h:671
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:636
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:648
const DecayModes & decay_modes() const
double spectral_function(double m) const
Full spectral function of the resonance (relativistic Breit-Wigner distribution with mass-dependent ...
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...
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
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:653
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:629
int32_t charge() const
The charge of the particle.
Definition: particletype.h:188
double spectral_function_no_norm(double m) const
Full spectral function without normalization factor.
static ParticleTypePtrList & list_nucleons()
Definition: particletype.cc:69
static ParticleTypePtrList & list_anti_nucleons()
Definition: particletype.cc:71
static const ParticleTypeList & list_all()
Definition: particletype.cc:51
bool is_stable() const
Definition: particletype.h:242
int isospin_
Isospin of the particle; filled automatically from pdgcode_.
Definition: particletype.h:643
double isospin3_rel() const
Definition: particletype.h:179
bool is_Delta() const
Definition: particletype.h:221
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 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:622
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_deuteron() const
Definition: particletype.h:248
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 .
double norm_factor_
This normalization factor ensures that the spectral function is normalized to unity,...
Definition: particletype.h:639
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
double max_factor1_
Maximum factor for single-res mass sampling, cf. sample_resonance_mass.
Definition: particletype.h:651
double spectral_function_const_width(double m) const
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.
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:616
PdgCode stores a Particle Data Group Particle Numbering Scheme particle type number.
Definition: pdgcode.h:108
int baryon_number() const
Definition: pdgcode.h:308
unsigned int spin() const
Definition: pdgcode.h:529
int strangeness() const
Definition: pdgcode.h:464
std::string string() const
Definition: pdgcode.h:252
PdgCode get_antiparticle() const
Construct the antiparticle to a given PDG code.
Definition: pdgcode.h:259
bool is_hadron() const
Definition: pdgcode.h:297
int charge() const
The charge of the particle.
Definition: pdgcode.h:488
static std::pair< double, int > force_scale(const ParticleType &data)
Evaluates the scaling factor of the forces acting on the particles.
Definition: potentials.cc:318
double weight() const
The ThreeVector class represents a physical three-vector with the components .
Definition: threevector.h:31
Collection of useful constants that are known at compile time.
std::ostream & operator<<(std::ostream &out, const ActionPtr &action)
Convenience: dereferences the ActionPtr to Action.
Definition: action.h:532
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > logg
An array that stores all pre-configured Logger objects.
Definition: logging.cc:39
#define unlikely(x)
Tell the branch predictor that this expression is likely false.
Definition: macros.h:16
ParticleTypePtrList deltas_list
Global pointer to the Particle Type list of deltas.
Definition: particletype.cc:42
ParticleTypePtrList baryon_resonances_list
Global pointer to the Particle Type list of baryon resonances.
Definition: particletype.cc:46
const ParticleTypeList * all_particle_types
Global pointer to the Particle Type list.
Definition: particletype.cc:36
ParticleTypePtrList anti_deltas_list
Global pointer to the Particle Type list of anti-deltas.
Definition: particletype.cc:44
ParticleTypePtrList light_nuclei_list
Global pointer to the Particle Type list of light nuclei.
Definition: particletype.cc:48
ParticleTypePtrList anti_nucs_list
Global pointer to the Particle Type list of anti-nucleons.
Definition: particletype.cc:40
ParticleTypePtrList nucleons_list
Global pointer to the Particle Type list of nucleons.
Definition: particletype.cc:38
constexpr int p
Proton.
constexpr int n
Neutron.
T uniform(T min, T max)
Definition: random.h:88
T cauchy(T pole, T width, T min, T max)
Draws a random number from a Cauchy distribution (sometimes also called Lorentz or non-relativistic B...
Definition: random.h:307
std::iterator_traits< octet_iterator >::difference_type sequence_length(octet_iterator lead_it)
Given an iterator to the beginning of a UTF-8 sequence, return the length of the next UTF-8 code poin...
Definition: action.h:24
constexpr double delta_mass
Delta mass in GeV.
Definition: constants.h:92
T pCM(const T sqrts, const T mass_a, const T mass_b) noexcept
Definition: kinematics.h:79
void ensure_all_read(std::istream &input, const Line &line)
Makes sure that nothing is left to read from this line.
static Integrator integrate
Definition: decaytype.cc:144
double breit_wigner(double m, double pole, double width)
Returns a relativistic Breit-Wigner distribution.
static std::string antiname(const std::string &name, PdgCode code)
Construct an antiparticle name-string from the given name-string for the particle and its PDG code.
build_vector_< Line > line_parser(const std::string &input)
Helper function for parsing particles.txt and decaymodes.txt.
Parity
Represent the parity of a particle type.
Definition: particletype.h:24
@ Neg
Negative parity.
@ Pos
Positive parity.
constexpr double deuteron_mass
Deuteron mass in GeV.
Definition: constants.h:98
constexpr double nucleon_mass
Nucleon mass in GeV.
Definition: constants.h:58
double blatt_weisskopf_sqr(const double p_ab, const int L)
Definition: formfactors.h:33
static constexpr int LResonances
Potentials * pot_pointer
Pointer to a Potential class.
constexpr double really_small
Numerical error tolerance.
Definition: constants.h:37
std::string build_error_string(std::string message, const Line &line)
Builds a meaningful error message.
constexpr double kaon_mass
Kaon mass in GeV.
Definition: constants.h:72
RectangularLattice< FourVector > * UB_lat_pointer
Pointer to the skyrme potential on the lattice.
double breit_wigner_nonrel(double m, double pole, double width)
Returns a non-relativistic Breit-Wigner distribution, which is essentially a Cauchy distribution with...
static std::string chargestr(int charge)
Construct a charge string, given the charge as integer.
bool almost_equal(const N x, const N y)
Checks two numbers for relative approximate equality.
Definition: numerics.h:42
RectangularLattice< FourVector > * UI3_lat_pointer
Pointer to the symmmetry potential on the lattice.
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.
static constexpr int LParticleType
Line consists of a line number and the contents of that line.