Version: SMASH-3.1
kinematics.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2018,2020-2021
3  * SMASH Team
4  *
5  * GNU General Public License (GPLv3 or later)
6  */
7 
8 #ifndef SRC_INCLUDE_SMASH_KINEMATICS_H_
9 #define SRC_INCLUDE_SMASH_KINEMATICS_H_
10 
11 #include <array>
12 #include <cassert>
13 #include <sstream>
14 
15 #include "constants.h"
16 
17 namespace smash {
18 
26 inline double center_of_velocity_v(double s, double ma, double mb) {
27  const double m_sum = ma + mb;
28  const double m_dif = ma - mb;
29  return std::sqrt((s - m_sum * m_sum) / (s - m_dif * m_dif));
30 }
31 
39 inline double fixed_target_projectile_v(double s, double ma, double mb) {
40  const double inv_gamma = 2 * ma * mb / (s - ma * ma - mb * mb);
41  return std::sqrt(1.0 - inv_gamma * inv_gamma);
42 }
43 
51 template <typename T>
52 T pCM_sqr_from_s(const T s, const T mass_a, const T mass_b) noexcept {
53  const auto mass_a_sqr = mass_a * mass_a;
54  const auto x = s + mass_a_sqr - mass_b * mass_b;
55  return x * x * (T(0.25) / s) - mass_a_sqr;
56 }
57 
65 template <typename T>
66 T pCM_from_s(const T s, const T mass_a, const T mass_b) noexcept {
67  const auto psqr = pCM_sqr_from_s(s, mass_a, mass_b);
68  return psqr > T(0.) ? std::sqrt(psqr) : T(0.);
69 }
70 
78 template <typename T>
79 T pCM(const T sqrts, const T mass_a, const T mass_b) noexcept {
80  return pCM_from_s(sqrts * sqrts, mass_a, mass_b);
81 }
82 
90 template <typename T>
91 T pCM_sqr(const T sqrts, const T mass_a, const T mass_b) noexcept {
92  return pCM_sqr_from_s(sqrts * sqrts, mass_a, mass_b);
93 }
94 
108 template <typename T>
109 std::array<T, 2> get_t_range(const T sqrts, const T m1, const T m2, const T m3,
110  const T m4) {
111  const T p_i = pCM(sqrts, m1, m2); // initial-state CM momentum
112  const T p_f = pCM(sqrts, m3, m4); // final-state CM momentum
113  const T sqrt_t0 = (m1 * m1 - m2 * m2 - m3 * m3 + m4 * m4) / (2. * sqrts);
114  const T t0 = sqrt_t0 * sqrt_t0;
115  const T t_min = t0 - (p_i - p_f) * (p_i - p_f);
116  const T t_max = t0 - (p_i + p_f) * (p_i + p_f);
117  assert(t_min >= t_max);
118  return {t_min, t_max};
119 }
120 
127 static inline void check_energy(double mandelstam_s, double m_sum) {
128  if (mandelstam_s < m_sum * m_sum) {
129  std::stringstream err;
130  err << "plab_from_s: s too small: " << mandelstam_s << " < "
131  << m_sum * m_sum;
132  throw std::runtime_error(err.str());
133  }
134 }
135 
142 static inline void check_radicand(double mandelstam_s, double radicand) {
143  if (radicand < 0) {
144  std::stringstream err;
145  err << "plab_from_s: negative radicand: " << mandelstam_s;
146  throw std::runtime_error(err.str());
147  }
148 }
149 
157 inline double plab_from_s(double mandelstam_s, double mass) {
158  const double radicand = mandelstam_s * (mandelstam_s - 4 * mass * mass);
159 #ifndef NDEBUG
160  const double m_sum = 2 * mass;
161  check_energy(mandelstam_s, m_sum);
162  check_radicand(mandelstam_s, radicand);
163 #endif
164  return std::sqrt(radicand) / (2 * mass);
165 }
166 
173 inline double plab_from_s(double mandelstam_s) {
174  return plab_from_s(mandelstam_s, nucleon_mass);
175 }
176 
185 inline double plab_from_s(double mandelstam_s, double m_projectile,
186  double m_target) {
187  const double m_sum = m_projectile + m_target;
188  const double m_diff = m_projectile - m_target;
189  const double radicand =
190  (mandelstam_s - m_sum * m_sum) * (mandelstam_s - m_diff * m_diff);
191 /* This is equivalent to:
192  * const double radicand
193  * = (mandelstam_s - m_a_sq - m_b_sq) * (mandelstam_s - m_a_sq - m_b_sq)
194  * - 4 * m_a_sq * m_b_sq; */
195 #ifndef NDEBUG
196  check_energy(mandelstam_s, m_sum);
197  check_radicand(mandelstam_s, radicand);
198 #endif
199  return std::sqrt(radicand) / (2 * m_target);
200 }
201 
211 inline double s_from_Etot(double e_tot, double m_P, double m_T) {
212  return m_P * m_P + m_T * m_T + 2 * m_T * e_tot;
213 }
224 inline double s_from_Etot(double e_tot_p, double e_tot_t, double m_p,
225  double m_t) {
226  double pz_p = std::sqrt(e_tot_p * e_tot_p - m_p * m_p);
227  double pz_t = std::sqrt(e_tot_t * e_tot_t - m_t * m_t);
228  return std::pow(e_tot_p + e_tot_t, 2) - std::pow(pz_p - pz_t, 2);
229 }
239 inline double s_from_Ekin(double e_kin, double m_P, double m_T) {
240  return s_from_Etot(e_kin + m_P, m_P, m_T);
241 }
252 inline double s_from_Ekin(double e_kin_p, double e_kin_t, double m_p,
253  double m_t) {
254  return s_from_Etot(e_kin_p + m_t, e_kin_t + m_t, m_p, m_t);
255 }
265 inline double s_from_plab(double plab, double m_P, double m_T) {
266  return m_P * m_P + m_T * m_T + 2 * m_T * std::sqrt(m_P * m_P + plab * plab);
267 }
278 inline double s_from_plab(double plab_p, double plab_t, double m_p,
279  double m_t) {
280  return s_from_Etot(std::sqrt(m_p * m_p + plab_p * plab_p),
281  std::sqrt(m_t * m_t + plab_t * plab_t), plab_p, plab_t);
282 }
283 
284 } // namespace smash
285 
286 #endif // SRC_INCLUDE_SMASH_KINEMATICS_H_
Collection of useful constants that are known at compile time.
Definition: action.h:24
double plab_from_s(double mandelstam_s, double mass)
Convert Mandelstam-s to p_lab in a fixed-target collision.
Definition: kinematics.h:157
T pCM(const T sqrts, const T mass_a, const T mass_b) noexcept
Definition: kinematics.h:79
T pCM_sqr(const T sqrts, const T mass_a, const T mass_b) noexcept
Definition: kinematics.h:91
double fixed_target_projectile_v(double s, double ma, double mb)
Definition: kinematics.h:39
double s_from_Ekin(double e_kin, double m_P, double m_T)
Convert E_kin to Mandelstam-s for a fixed-target setup, with a projectile of mass m_P and a kinetic e...
Definition: kinematics.h:239
T pCM_sqr_from_s(const T s, const T mass_a, const T mass_b) noexcept
Definition: kinematics.h:52
static void check_radicand(double mandelstam_s, double radicand)
Helper function for plab_from_s.
Definition: kinematics.h:142
std::array< T, 2 > get_t_range(const T sqrts, const T m1, const T m2, const T m3, const T m4)
Get the range of Mandelstam-t values allowed in a particular 2->2 process, see PDG 2014 booklet,...
Definition: kinematics.h:109
static void check_energy(double mandelstam_s, double m_sum)
Helper function for plab_from_s.
Definition: kinematics.h:127
constexpr double nucleon_mass
Nucleon mass in GeV.
Definition: constants.h:58
double center_of_velocity_v(double s, double ma, double mb)
Definition: kinematics.h:26
T pCM_from_s(const T s, const T mass_a, const T mass_b) noexcept
Definition: kinematics.h:66
double s_from_Etot(double e_tot, double m_P, double m_T)
Convert E_tot to Mandelstam-s for a fixed-target setup, with a projectile of mass m_P and a total ene...
Definition: kinematics.h:211
double s_from_plab(double plab, double m_P, double m_T)
Convert p_lab to Mandelstam-s for a fixed-target setup, with a projectile of mass m_P and momentum pl...
Definition: kinematics.h:265