Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
JsonParamMappingAdapter.cpp
Go to the documentation of this file.
2#include "Logger.h"
3
4std::unordered_map<std::string, InterpretedParam>
5JsonParamMappingAdapter::loadFromFile(const std::string& filePath) const {
6 std::unordered_map<std::string, InterpretedParam> out;
7
8 if (!parser_) {
9 throw std::runtime_error("JsonParamMappingAdapter: parser is null");
10 }
11
12 auto root = parser_->readFromFile(filePath);
13 if (!root) {
14 throw std::runtime_error("JsonParamMappingAdapter: root DBNode is null");
15 }
16
17 auto keys = root->get_keys();
18 for (const auto& paramName : keys) {
19 try {
20 const auto blockV = root->get(paramName, "block");
21 const auto codeV = root->get(paramName, "pdgCode");
22
23 const std::string block = asString(blockV);
24 const std::string code = asString(codeV);
25
26 LhaID lh = LhaID(code);
27
28 out[static_cast<std::string>(paramName)] = InterpretedParam{ block, lh };
29 } catch (const std::exception& e) {
30 LOG_ERROR("JSON mapping", std::string("Key '") + static_cast<std::string>(paramName) + "': " + e.what());
31 }
32 }
33 return out;
34}
Adapter to load parameter mappings from a JSON/YAML-like DBNode tree.
#define LOG_ERROR(type,...)
Macro for logging error messages and terminating the application.
Definition Logger.h:41
std::unordered_map< std::string, InterpretedParam > loadFromFile(const std::string &filePath) const override
Loads parameter mappings from a file.
Identifies a single interpreted parameter from an LHA block.
Represents an identifier of a LHA element, possibly containing several sub-ids.
Definition LhaID.h:56