flexiblesusy is hosted by Hepforge, IPPP Durham
FlexibleSUSY
decay.cpp
Go to the documentation of this file.
1// ====================================================================
2// This file is part of FlexibleSUSY.
3//
4// FlexibleSUSY is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published
6// by the Free Software Foundation, either version 3 of the License,
7// or (at your option) any later version.
8//
9// FlexibleSUSY is distributed in the hope that it will be useful, but
10// WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with FlexibleSUSY. If not, see
16// <http://www.gnu.org/licenses/>.
17// ====================================================================
18
19#include "decay.hpp"
20#include "error.hpp"
21#include "wrappers.hpp"
22
23#include <boost/functional/hash.hpp>
24
25#include <algorithm>
26#include <sstream>
27
28#include "string_utils.hpp"
29
30namespace flexiblesusy {
31
32namespace {
33
34template <class Container>
35std::size_t hash_pid_list(int pid_in, Container pids_out)
36{
37 Container sorted(pids_out);
38 std::sort(sorted.begin(), sorted.end());
39
40 boost::hash<int> hash_pid;
41 auto seed = hash_pid(pid_in);
42 boost::hash_range(seed, sorted.begin(), sorted.end());
43
44 return seed;
45}
46
47} // anonymous namespace
48
49std::size_t hash_decay(const Decay& decay)
50{
51 int pid_in = decay.get_initial_particle_id();
52 const auto& pids_out = decay.get_final_state_particle_ids();
53 return hash_pid_list(pid_in, pids_out);
54}
55
56Decays_list::Decays_list(int initial_pdg_)
57 : initial_pdg(initial_pdg_)
58{
59}
60
62{
63 decays.clear();
64 total_width = 0.;
65}
66
68 std::initializer_list<int> product_pdgs) const
69{
70 const Decay decay(initial_pdg, product_pdgs, 0., std::string());
71 const auto decay_hash = hash_decay(decay);
72
73 const auto pos = decays.find(decay_hash);
74
75 if (pos == std::end(decays)) {
76 std::ostringstream msg;
77 msg << "Decay of particle " << initial_pdg
78 << " into particles {"
79 << concat(product_pdgs.begin(), product_pdgs.end(), ", ")
80 << "} not found\n";
81
82 throw OutOfBoundsError(msg.str());
83 }
84
85 return pos->second;
86}
87
91std::vector<Decay> sort_decays_list(const Decays_list& decays_list) {
92 std::vector<Decay> decays_list_as_vector;
93 decays_list_as_vector.reserve(decays_list.size());
94 for (const auto& el : decays_list) {
95 decays_list_as_vector.push_back(el.second);
96 }
97
99 decays_list_as_vector.begin(),
100 decays_list_as_vector.end(),
101 [](const auto& d1, const auto& d2) {
102 return d1.get_width() > d2.get_width();
103 }
104 );
105
106 return decays_list_as_vector;
107}
108
109std::string strip_field_namespace(std::string const& s) {
110 std::string result = s.substr(s.find_last_of(':')+1);
111 if (s.find("bar") != std::string::npos) {
112 result.pop_back();
113 return "bar" + result;
114 } else if (s.find("conj") != std::string::npos) {
115 result.pop_back();
116 return "conj" + result;
117 } else {
118 return result;
119 }
120}
121
122double hVV_4body(double *q2, size_t /* dim */, void *params)
123{
124 struct hVV_4body_params * fp = static_cast<struct hVV_4body_params*>(params);
125 const double mHOS = fp->mHOS;
126 if (q2[1] > Sqr(mHOS - std::sqrt(q2[0]))) return 0.;
127 const double mVOS = fp->mVOS;
128 const double GammaV = fp->GammaV;
129 const double kl = KallenLambda(1., q2[0]/Sqr(mHOS), q2[1]/Sqr(mHOS));
130 return
131 mVOS*GammaV/(Sqr(q2[0] - Sqr(mVOS)) + Sqr(mVOS*GammaV))
132 * mVOS*GammaV/(Sqr(q2[1] - Sqr(mVOS)) + Sqr(mVOS*GammaV))
133 * std::sqrt(kl)*(kl + 12.*q2[0]*q2[1]/Power4(mHOS));
134}
135
136} // namespace flexiblesusy
int get_initial_particle_id() const
Definition: decay.hpp:54
const std::vector< int > & get_final_state_particle_ids() const
Definition: decay.hpp:55
const Decay & get_decay(std::initializer_list< int > products) const
Definition: decay.cpp:67
std::size_t size() const noexcept
Definition: decay.hpp:95
Out of bounds access.
Definition: error.hpp:208
std::size_t hash_pid_list(int pid_in, Container pids_out)
Definition: decay.cpp:35
std::string strip_field_namespace(std::string const &s)
Definition: decay.cpp:109
double * end(GSL_vector &v)
iterator to end of GSL_vector
Definition: gsl_vector.cpp:254
double hVV_4body(double *q2, size_t, void *params)
Definition: decay.cpp:122
constexpr std::complex< T > Sqr(const std::complex< T > &a) noexcept
Definition: wrappers.hpp:631
std::vector< Decay > sort_decays_list(const Decays_list &decays_list)
sort decays w.r.t. their width
Definition: decay.cpp:91
T KallenLambda(T x, T y, T z) noexcept
Definition: wrappers.hpp:835
constexpr Base Power4(Base b) noexcept
Definition: wrappers.hpp:493
std::string concat(const std::vector< std::string > &strings)
concatenate strings
std::size_t hash_decay(const Decay &decay)
Definition: decay.cpp:49