Loading [MathJax]/extensions/tex2jax.js
hej
is hosted by
Hepforge
,
IPPP Durham
HEJ
2.3.0
High energy resummation for hadron colliders
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
Functions
a
c
d
f
g
h
i
j
l
m
n
o
p
r
s
t
Variables
Typedefs
Enumerations
Enumerator
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
s
t
u
w
z
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
z
~
Functions
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
z
~
Variables
a
b
c
d
e
f
h
i
j
l
m
n
o
p
r
s
t
u
v
w
Typedefs
Related Functions
Files
File List
File Members
All
Macros
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
include
HEJ
YAMLreader.hh
Go to the documentation of this file.
1
11
#pragma once
12
13
#include <optional>
14
#include <string>
15
#include <utility>
16
#include <vector>
17
18
#include "yaml-cpp/yaml.h"
19
20
#include "fastjet/JetDefinition.hh"
21
22
#include "
HEJ/Config.hh
"
23
#include "
HEJ/Fraction.hh
"
24
#include "
HEJ/PDG_codes.hh
"
25
#include "
HEJ/exceptions.hh
"
26
#include "
HEJ/utility.hh
"
27
28
namespace
HEJ
{
29
struct
OutputFile;
31
35
Config
load_config
(std::string
const
& config_file);
36
38
42
Config
to_Config
(YAML::Node
const
& yaml);
43
45
65
template
<
typename
T,
typename
... YamlNames>
66
void
set_from_yaml
(
67
T & setting,
68
YAML::Node
const
& yaml, YamlNames
const
& ... names
69
);
70
72
82
template
<
typename
T,
typename
... YamlNames>
83
void
set_from_yaml_if_defined
(
84
T & setting,
85
YAML::Node
const
& yaml, YamlNames
const
& ... names
86
);
87
89
JetParameters
get_jet_parameters
(
90
YAML::Node
const
& node, std::string
const
& entry
91
);
92
94
HiggsCouplingSettings
get_Higgs_coupling
(
95
YAML::Node
const
& node, std::string
const
& entry
96
);
97
99
EWConstants
get_ew_parameters
(YAML::Node
const
& node);
100
102
ScaleConfig
to_ScaleConfig
(YAML::Node
const
& yaml);
103
105
RNGConfig
to_RNGConfig
(YAML::Node
const
& node, std::string
const
& entry);
106
108
NLOConfig
to_NLOConfig
(YAML::Node
const
& node, std::string
const
& entry);
109
111
121
void
assert_all_options_known
(
122
YAML::Node
const
& conf, YAML::Node
const
& supported
123
);
124
125
namespace
detail{
126
void
set_from_yaml
(fastjet::JetAlgorithm & setting, YAML::Node
const
& yaml);
127
void
set_from_yaml
(
EventTreatment
& setting, YAML::Node
const
& yaml);
128
void
set_from_yaml
(
ParticleID
& setting, YAML::Node
const
& yaml);
129
void
set_from_yaml
(
OutputFile
& setting, YAML::Node
const
& yaml);
130
void
set_from_yaml
(
WeightType
& setting, YAML::Node
const
& yaml);
131
132
inline
133
void
set_from_yaml
(YAML::Node & setting, YAML::Node
const
& yaml){
134
setting = yaml;
135
}
136
137
template
<
typename
Scalar>
138
void
set_from_yaml
(Scalar & setting, YAML::Node
const
& yaml){
139
assert(yaml);
140
if
(!yaml.IsScalar()){
141
throw
invalid_type
{
"value is not a scalar"
};
142
}
143
try
{
144
setting = yaml.as<Scalar>();
145
}
146
catch
(...){
147
throw
invalid_type
{
148
"value "
+ yaml.as<std::string>()
149
+
" cannot be converted to a "
+
type_string
(setting)
150
};
151
}
152
}
153
154
template
<
typename
T>
155
void
set_from_yaml
(std::optional<T> & setting, YAML::Node
const
& yaml){
156
T tmp{};
157
set_from_yaml
(tmp, yaml);
158
setting = tmp;
159
}
160
161
template
<
typename
T>
162
void
set_from_yaml
(std::vector<T> & setting, YAML::Node
const
& yaml){
163
assert(yaml);
164
// special case: treat a single value like a vector with one element
165
if
(yaml.IsScalar()){
166
setting.resize(1);
167
return
set_from_yaml
(setting.front(), yaml);
168
}
169
if
(yaml.IsSequence()){
170
setting.resize(yaml.size());
171
for
(
size_t
i = 0; i < setting.size(); ++i){
172
set_from_yaml
(setting[i], yaml[i]);
173
}
174
return
;
175
}
176
throw
invalid_type
{
""
};
177
}
178
179
template
<
typename
T,
typename
FirstName,
typename
... YamlNames>
180
void
set_from_yaml
(
181
T & setting,
182
YAML::Node
const
& yaml, FirstName
const
&
name
,
183
YamlNames && ... names
184
){
185
if
(!yaml[
name
])
throw
missing_option
{
""
};
186
set_from_yaml
(
187
setting,
188
yaml[
name
], std::forward<YamlNames>(names)...
189
);
190
}
191
192
template
<
typename
T>
193
void
set_from_yaml_if_defined
(T & setting, YAML::Node
const
& yaml){
194
return
set_from_yaml
(setting, yaml);
195
}
196
197
template
<
typename
T,
typename
FirstName,
typename
... YamlNames>
198
void
set_from_yaml_if_defined
(
199
T & setting,
200
YAML::Node
const
& yaml, FirstName
const
&
name
,
201
YamlNames && ... names
202
){
203
if
(!yaml[
name
])
return
;
204
set_from_yaml_if_defined
(
205
setting,
206
yaml[
name
], std::forward<YamlNames>(names)...
207
);
208
}
209
}
// namespace detail
210
211
template
<
typename
T,
typename
... YamlNames>
212
void
set_from_yaml
(
213
T & setting,
214
YAML::Node
const
& yaml, YamlNames
const
& ... names
215
){
216
try
{
217
detail::set_from_yaml
(setting, yaml, names...);
218
}
219
catch
(
invalid_type
const
& ex){
220
throw
invalid_type
{
221
"In option "
+
join
(
": "
, names...) +
": "
+ ex.what()
222
};
223
}
224
catch
(
missing_option
const
&){
225
throw
missing_option
{
226
"No entry for mandatory option "
+
join
(
": "
, names...)
227
};
228
}
229
catch
(std::invalid_argument
const
& ex){
230
throw
missing_option
{
231
"In option "
+
join
(
": "
, names...) +
":"
232
" invalid value "
+ ex.what()
233
};
234
}
235
}
236
237
template
<
typename
T,
typename
... YamlNames>
238
void
set_from_yaml_if_defined
(
239
T & setting,
240
YAML::Node
const
& yaml, YamlNames
const
& ... names
241
){
242
try
{
243
detail::set_from_yaml_if_defined
(setting, yaml, names...);
244
}
245
catch
(
invalid_type
const
& ex){
246
throw
invalid_type
{
247
"In option "
+
join
(
": "
, names...) +
": "
+ ex.what()
248
};
249
}
250
catch
(std::invalid_argument
const
& ex){
251
throw
missing_option
{
252
"In option "
+
join
(
": "
, names...) +
":"
253
" invalid value "
+ ex.what()
254
};
255
}
256
}
257
258
std::string
to_string
(YAML::Node
const
& yaml);
259
}
// namespace HEJ
260
261
namespace
YAML
{
262
263
template
<>
264
struct
convert<
HEJ
::OutputFile> {
265
static
Node
encode
(
HEJ::OutputFile
const
& outfile);
266
static
bool
decode
(Node
const
& node,
HEJ::OutputFile
&
out
);
267
};
268
269
template
<
class
Real>
270
struct
convert<
HEJ
::Fraction<Real>> {
271
static
Node
encode
(
HEJ::Fraction<Real>
const
& f) {
272
return
convert<Real>::encode(Real{f});
273
}
274
static
bool
decode
(Node
const
& node,
HEJ::Fraction<Real>
& f) {
275
Real r;
276
if
(!convert<Real>::decode(node, r))
return
false
;
277
f = r;
278
return
true
;
279
}
280
};
281
}
// namespace YAML
Config.hh
HEJ 2 configuration parameters.
Fraction.hh
Header file for fractions, i.e. floating point numbers between 0 and 1.
PDG_codes.hh
Contains the Particle IDs of all relevant SM particles.
HEJ::EWConstants
Collection of electro-weak constants.
Definition:
EWConstants.hh:24
HEJ::Fraction
Class for floating point numbers between 0 and 1.
Definition:
Fraction.hh:21
exceptions.hh
Custom exception classes.
HEJ::detail_HepMC::status_codes::out
@ out
Final outgoing.
Definition:
HepMCInterface_common.hh:24
HEJ::detail::set_from_yaml_if_defined
void set_from_yaml_if_defined(T &setting, YAML::Node const &yaml)
Definition:
YAMLreader.hh:193
HEJ::detail::set_from_yaml
void set_from_yaml(fastjet::JetAlgorithm &setting, YAML::Node const &yaml)
HEJ::event_type::name
std::string name(EventType type)
Event type names.
Definition:
event_types.hh:57
HEJ::pid::ParticleID
ParticleID
The possible particle identities. We use PDG IDs as standard.
Definition:
PDG_codes.hh:25
HEJ
Main HEJ 2 Namespace.
Definition:
mainpage.dox:1
HEJ::set_from_yaml_if_defined
void set_from_yaml_if_defined(T &setting, YAML::Node const &yaml, YamlNames const &... names)
Set option using the corresponding YAML entry, if present.
Definition:
YAMLreader.hh:238
HEJ::get_jet_parameters
JetParameters get_jet_parameters(YAML::Node const &node, std::string const &entry)
Extract jet parameters from YAML configuration.
HEJ::assert_all_options_known
void assert_all_options_known(YAML::Node const &conf, YAML::Node const &supported)
Check whether all options in configuration are supported.
HEJ::to_RNGConfig
RNGConfig to_RNGConfig(YAML::Node const &node, std::string const &entry)
Extract random number generator settings from YAML configuration.
HEJ::to_NLOConfig
NLOConfig to_NLOConfig(YAML::Node const &node, std::string const &entry)
Extract HEJNLO settings from YAML configuration.
HEJ::to_string
std::string to_string(Event const &ev)
HEJ::load_config
Config load_config(std::string const &config_file)
Load configuration from file.
HEJ::type_string
std::string type_string(T &&)
Return the name of the argument's type.
Definition:
utility.hh:53
HEJ::join
std::string join(std::string const &)
Definition:
utility.hh:22
HEJ::WeightType
WeightType
Possible setting for the event weight.
Definition:
Config.hh:86
HEJ::set_from_yaml
void set_from_yaml(T &setting, YAML::Node const &yaml, YamlNames const &... names)
Set option using the corresponding YAML entry.
Definition:
YAMLreader.hh:212
HEJ::to_Config
Config to_Config(YAML::Node const &yaml)
Extract configuration from YAML.
HEJ::get_Higgs_coupling
HiggsCouplingSettings get_Higgs_coupling(YAML::Node const &node, std::string const &entry)
Extract Higgs coupling settings from YAML configuration.
HEJ::to_ScaleConfig
ScaleConfig to_ScaleConfig(YAML::Node const &yaml)
Extract scale setting parameters from YAML configuration.
HEJ::get_ew_parameters
EWConstants get_ew_parameters(YAML::Node const &node)
Extract the EW parameters from YAML configuration.
HEJ::EventTreatment
EventTreatment
Definition:
Config.hh:75
YAML
Definition:
get_analysis.hh:15
HEJ::Config
Definition:
Config.hh:108
HEJ::HiggsCouplingSettings
Settings for Higgs boson coupling to gluons.
Definition:
HiggsCouplingSettings.hh:14
HEJ::JetParameters
Jet parameters.
Definition:
Config.hh:31
HEJ::NLOConfig
Settings for NLO truncation of HEJ resummation.
Definition:
Config.hh:63
HEJ::OutputFile
Output file specification.
Definition:
output_formats.hh:37
HEJ::RNGConfig
Settings for random number generator.
Definition:
Config.hh:47
HEJ::ScaleConfig
Settings for scale variation.
Definition:
Config.hh:37
HEJ::invalid_type
Exception indicating wrong option type.
Definition:
exceptions.hh:19
HEJ::missing_option
Exception indicating missing option setting.
Definition:
exceptions.hh:43
YAML::convert< HEJ::Fraction< Real > >::encode
static Node encode(HEJ::Fraction< Real > const &f)
Definition:
YAMLreader.hh:271
YAML::convert< HEJ::Fraction< Real > >::decode
static bool decode(Node const &node, HEJ::Fraction< Real > &f)
Definition:
YAMLreader.hh:274
YAML::convert< HEJ::OutputFile >::encode
static Node encode(HEJ::OutputFile const &outfile)
YAML::convert< HEJ::OutputFile >::decode
static bool decode(Node const &node, HEJ::OutputFile &out)
utility.hh
Contains various utilities.
Generated by
1.9.1