Version: SMASH-1.5
tabulation.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2018
3  * SMASH Team
4  *
5  * GNU General Public License (GPLv3 or later)
6  */
7 
8 #ifndef SRC_INCLUDE_TABULATION_H_
9 #define SRC_INCLUDE_TABULATION_H_
10 
11 #include <functional>
12 #include <map>
13 #include <memory>
14 #include <vector>
15 
16 #include "forwarddeclarations.h"
17 #include "integrate.h"
18 #include "kinematics.h"
19 #include "particletype.h"
20 
21 namespace smash {
22 
24 enum class Extrapolation {
25  Zero = 0,
26  Const = 1,
27  Linear = 2,
28 };
29 
33 class Tabulation {
34  public:
44  Tabulation(double x_min, double range, int num,
45  std::function<double(double)> f);
46 
56  double get_value_step(double x) const;
57 
72  double get_value_linear(
73  double x, Extrapolation extrapolation = Extrapolation::Linear) const;
74 
75  protected:
77  std::vector<double> values_;
78 
80  const double x_min_;
81 
83  const double x_max_;
84 
86  const double inv_dx_;
87 };
88 
103 inline double spec_func_integrand_1res(double resonance_mass, double sqrts,
104  double stable_mass,
105  const ParticleType& type) {
106  if (sqrts <= stable_mass + resonance_mass) {
107  return 0.;
108  }
109 
110  /* Integrand is the spectral function weighted by the CM momentum of the
111  * final state. */
112  return type.spectral_function(resonance_mass) *
113  pCM(sqrts, stable_mass, resonance_mass);
114 }
115 
132 inline double spec_func_integrand_2res(double sqrts, double res_mass_1,
133  double res_mass_2,
134  const ParticleType& t1,
135  const ParticleType& t2) {
136  if (sqrts <= res_mass_1 + res_mass_2) {
137  return 0.;
138  }
139 
140  /* Integrand is the product of the spectral function weighted by the
141  * CM momentum of the final state. */
142  return t1.spectral_function(res_mass_1) * t2.spectral_function(res_mass_2) *
143  pCM(sqrts, res_mass_1, res_mass_2);
144 }
145 
156 inline std::unique_ptr<Tabulation> spectral_integral_semistable(
157  Integrator& integrate, const ParticleType& resonance,
158  const ParticleType& stable, double range) {
159  const double m_min = resonance.min_mass_kinematic();
160  const double m_stable = stable.mass();
161  return make_unique<Tabulation>(
162  m_min + m_stable, range, 100, [&](double srts) {
163  return integrate(m_min, srts - m_stable, [&](double m) {
164  return spec_func_integrand_1res(m, srts, m_stable, resonance);
165  });
166  });
167 }
168 
178 inline std::unique_ptr<Tabulation> spectral_integral_unstable(
180  const ParticleType& res2, double range) {
181  const double m1_min = res1.min_mass_kinematic();
182  const double m2_min = res2.min_mass_kinematic();
183  return make_unique<Tabulation>(m1_min + m2_min, range, 100, [&](double srts) {
184  const double m1_max = srts - m2_min;
185  const double m2_max = srts - m1_min;
186  return integrate2d(
187  m1_min, m1_max, m2_min, m2_max, [&](double m1, double m2) {
188  return spec_func_integrand_2res(srts, m1, m2, res1, res2);
189  });
190  });
191 }
192 
193 } // namespace smash
194 
195 #endif // SRC_INCLUDE_TABULATION_H_
static Integrator2dCuhre integrate2d(1E7)
double spec_func_integrand_1res(double resonance_mass, double sqrts, double stable_mass, const ParticleType &type)
Spectral function integrand for GSL integration, with one resonance in the final state (the second pa...
Definition: tabulation.h:103
double mass() const
Definition: particletype.h:134
double get_value_linear(double x, Extrapolation extrapolation=Extrapolation::Linear) const
Look up a value from the tabulation using linear interpolation.
Definition: tabulation.cc:35
double spec_func_integrand_2res(double sqrts, double res_mass_1, double res_mass_2, const ParticleType &t1, const ParticleType &t2)
Spectral function integrand for GSL integration, with two resonances in the final state...
Definition: tabulation.h:132
double spectral_function(double m) const
Full spectral function of the resonance (relativistic Breit-Wigner distribution with mass-dependent ...
A C++ interface for numerical integration in two dimensions with the Cuba Cuhre integration function...
Definition: integrate.h:406
std::unique_ptr< Tabulation > spectral_integral_unstable(Integrator2dCuhre &integrate2d, const ParticleType &res1, const ParticleType &res2, double range)
Create a table for the spectral integral of two resonances.
Definition: tabulation.h:178
std::unique_ptr< Tabulation > spectral_integral_semistable(Integrator &integrate, const ParticleType &resonance, const ParticleType &stable, double range)
Create a table for the spectral integral of a resonance and a stable particle.
Definition: tabulation.h:156
Extrapolation
The kind of extrapolation used by the tabulation.
Definition: tabulation.h:24
Tabulation(double x_min, double range, int num, std::function< double(double)> f)
Construct a new tabulation object.
Definition: tabulation.cc:12
A class for storing a one-dimensional lookup table of floating-point values.
Definition: tabulation.h:33
const double x_min_
lower bound for tabulation
Definition: tabulation.h:80
Particle type contains the static properties of a particle species.
Definition: particletype.h:87
const double x_max_
upper bound for tabulation
Definition: tabulation.h:83
double get_value_step(double x) const
Look up a value from the tabulation (without any interpolation, simply using the closest tabulated va...
Definition: tabulation.cc:22
A C++ interface for numerical integration in one dimension with the GSL CQUAD integration functions...
Definition: integrate.h:106
double min_mass_kinematic() const
The minimum mass of the resonance that is kinematically allowed.
T pCM(const T sqrts, const T mass_a, const T mass_b) noexcept
Definition: kinematics.h:79
const double inv_dx_
inverse step size 1/dx
Definition: tabulation.h:86
std::vector< double > values_
vector for storing tabulated values
Definition: tabulation.h:77
Definition: action.h:24
static Integrator integrate
Definition: decaytype.cc:147