flexiblesusy is hosted by Hepforge, IPPP Durham
FlexibleSUSY
flexibledecay_settings.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
20#include "error.hpp"
21#include "string_format.hpp"
22
23#include <cmath>
24#include <iostream>
25#include <string>
26
27namespace flexiblesusy {
28
29namespace {
30const std::array<std::string, FlexibleDecay_settings::NUMBER_OF_OPTIONS> descriptions = {
31 "calculate particle decays",
32 "minimum BR to print",
33 "include higher order corrections in decays",
34 "use Thomson alpha(0) instead of alpha(m) in decays to γγ and γZ",
35 "off-shell decays into VV pair",
36 "print EFFHIGGSCOUPLINGS block"
37};
38
39bool is_integer(double value)
40{
41 double intpart;
42 return std::modf(value, &intpart) == 0.0;
43}
44
45void assert_bool(double value, const char* quantity)
46{
47 if (value != 0.0 && value != 1.0) {
48 throw SetupError(std::string(quantity) + " must either 0 or 1");
49 }
50}
51
52void assert_integer(double value, const char* quantity)
53{
54 if (!is_integer(value)) {
55 throw SetupError(std::string(quantity) + " must be an integer");
56 }
57}
58
59void assert_ge(double value, double lower_bound, const char* quantity)
60{
61 if (value < lower_bound) {
62 throw SetupError(std::string(quantity) +
63 " must be greater than or equal to " +
64 flexiblesusy::to_string(lower_bound));
65 }
66}
67
68void assert_le(double value, double upper_bound, const char* quantity)
69{
70 if (value > upper_bound) {
71 throw SetupError(std::string(quantity) +
72 " must be lower than or equal to " +
73 flexiblesusy::to_string(upper_bound));
74 }
75}
76
77} // anonymous namespace
78
86{
87 reset();
88}
89
91{
92 return values.at(o);
93}
94
96{
97 Settings_t s(&values[0]);
98 return s;
99}
100
102{
103 return descriptions.at(o);
104}
105
107{
108 switch (o) {
109 case calculate_decays: // 0 [bool]
110 assert_bool(value, descriptions.at(o).c_str());
111 break;
112 case min_br_to_print: // 1 [double >= 0 and <= 1]
113 assert_ge(value, 0, descriptions.at(o).c_str());
114 assert_le(value, 1, descriptions.at(o).c_str());
115 break;
116 case include_higher_order_corrections: // 2 [int >= 0 and <= 4]
117 assert_integer(value, descriptions.at(o).c_str());
118 assert_ge(value, 0, descriptions.at(o).c_str());
119 assert_le(value, 4, descriptions.at(o).c_str());
120 break;
122 assert_bool(value, descriptions.at(o).c_str());
123 break;
124 case offshell_VV_decays: // 4 [int >= 0 and <= 2]
125 assert_integer(value, descriptions.at(o).c_str());
126 assert_ge(value, 0, descriptions.at(o).c_str());
127 assert_le(value, 2, descriptions.at(o).c_str());
128 break;
129 case print_effc_block: // 1 [bool]
130 assert_bool(value, descriptions.at(o).c_str());
131 default:
132 break;
133 }
134
135 values.at(o) = value;
136}
137
139{
140 std::copy(s.data(), s.data() + s.size(), values.begin());
141}
142
152{
159}
160bool is_integer(double value)
161{
162 double intpart;
163 return std::modf(value, &intpart) == 0.0;
164}
165
166}
@ include_higher_order_corrections
[2] include higher order corrections in decays
@ calculate_decays
[0] calculate particle decays
std::string get_description(Settings) const
get description of spectrum generator setting
Eigen::Array< double, NUMBER_OF_OPTIONS, 1 > Settings_t
void reset()
resets all settings to their defaults
std::array< double, NUMBER_OF_OPTIONS > values
spectrum generator settings
Settings_t get() const
get all spectrum generator settings
void set(Settings, double)
set value of spectrum generator setting
Spectrum generator was not setup correctly.
Definition: error.hpp:46
const std::array< std::string, FlexibleDecay_settings::NUMBER_OF_OPTIONS > descriptions
void assert_le(double value, double upper_bound, const char *quantity)
void assert_ge(double value, double lower_bound, const char *quantity)
bool is_integer(double value)
std::string to_string(char a)