Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
ParameterProvider.cpp
Go to the documentation of this file.
1#include "ParameterProvider.h"
2
4 if (this->p_type.has_value()) {
5 LOG_WARN("LogicError", "This ParameterProvider already has a type.");
6 }
7
8 return this->get_value(pid, d_type);
9}
10
11scalar_t ParameterProvider::operator()(const std::string &block, const LhaID &id, DataType d_type) const {
12 if (!this->p_type.has_value()) {
13 LOG_ERROR("LogicError", "Please specify a parameter type for the ParameterProvider.");
14 }
15
16 ParamId pid {this->p_type.value(), block, id};
17 return this->get_value(pid, d_type);
18}
19
20bool ParameterProvider::exists(const ParamId &pid) const {
21 return Parameters::GetInstance(pid.type.value())->exist(pid.block, pid.code);
22}
23
24bool ParameterProvider::exists(const std::string &block, const LhaID &id) const {
25 return Parameters::GetInstance(this->p_type.value())->exist(block, id);
26}
27
29 if (!p_type.has_value()) {
30 LOG_ERROR("LogicError", "ParameterProvider has no type.");
31 }
32
33 return p_type.value();
34}
35
36double ParameterProvider::get_scale(const std::string& block) const {
37 if (!p_type.has_value()) {
38 LOG_ERROR("LogicError", "ParameterProvider has no type.");
39 }
40
41 return Parameters::GetInstance(this->p_type.value())->get_block_scale(block);
42
43}
44
45std::shared_ptr<Parameter> ParameterProvider::get_parameter(const ParamId &pid) const {
46 return (*Parameters::GetInstance(pid.type.value())).get_parameter(pid.block, pid.code);
47}
48
49scalar_t ParameterProvider::get_value(const ParamId& pid, DataType d_type) const {
50 switch (d_type) {
51 case DataType::VALUE:
52 return (*Parameters::GetInstance(pid.type.value()))(pid.block, pid.code);
53 break;
55 return get_parameter(pid)->get_std().first;
56 break;
58 return get_parameter(pid)->get_std().second;
59 break;
61 return get_parameter(pid)->get_combined_std();
62 break;
63 default:
64 LOG_ERROR("LogicError", "ParameterProvider does not support this data type.");
65 }
66}
ParameterType
DataType
#define LOG_ERROR(type,...)
Macro for logging error messages and terminating the application.
Definition Logger.h:41
#define LOG_WARN(...)
Macro for logging warning messages.
Definition Logger.h:40
High-level access to parameter values and uncertainties.
double get_scale(const std::string &block) const
Checks if a parameter identified by block name and LHA ID exists.
std::shared_ptr< Parameter > get_parameter(const ParamId &pid) const
Retrieves the actual Parameter object corresponding to the given ParamId.
scalar_t operator()(const ParamId &pid, DataType d_type=DataType::VALUE) const
Retrieves a parameter value based on ParamId and requested data type.
ParameterType get_type() const
Retrieves the renormalization scale associated with a given block.
bool exists(const ParamId &pid) const
Checks if a parameter identified by ParamId exists.
static std::shared_ptr< Parameters > GetInstance(ParameterType id=ParameterType::SM)
Returns the singleton-like repository for a given parameter type.
Represents an identifier of a LHA element, possibly containing several sub-ids.
Definition LhaID.h:56
Composite identifier for a single parameter.
Definition ParamID.h:57
std::optional< ParameterType > type
Optional high-level parameter category.
Definition ParamID.h:65
BlockName block
Name of the block where the parameter is stored.
Definition ParamID.h:73
LhaID code
Index or multi-index of the parameter inside the block.
Definition ParamID.h:82