Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
ParamBlockWriter.cpp
Go to the documentation of this file.
1#include "ParamBlockWriter.h"
2
3static BlockName lhaid_to_key(const LhaID& id)
4{
5 std::ostringstream oss;
6 oss << id;
7 return BlockName(oss.str());
8}
9
10void ParamBlockWriter::write(std::shared_ptr<DBNode> dest, std::shared_ptr<BlockAccessor> src) {
11
12 if (!dest) {
13 LOG_ERROR("ParamBlockWriter", "dest is null");
14 return;
15 }
16 if (!src) {
17 LOG_ERROR("ParamBlockWriter", "src is null");
18 return;
19 }
20
21 for (const auto& bk : src->get_block_names()) {
22
23 if (!src->contains(bk)) {
24 LOG_WARN("ParamBlockWriter", "Block not found in accessor:", bk);
25 continue;
26 }
27
28 auto blk = src->at(bk);
29 if (!blk) {
30 LOG_WARN("ParamBlockWriter", "Null block pointer for:", bk);
31 continue;
32 }
33
34 std::map<BlockName, DBNode::Value> groupData;
35
36 if (blk->has_scale()) {
37 groupData[BlockName("scale")] = blk->get_scale();
38 }
39
40 for (const auto& [id, p] : blk->getItems()) {
41 if (!p) continue;
42
43 auto node = std::make_shared<DBNode>();
44
45 const scalar_t value = p->get_val();
46 node->set(value.real(), "central_value");
47 if (value.imag() != 0.0) {
48 node->set(value.imag(), "imaginary_value");
49 }
50
51 {
52 auto [stat, syst] = p->get_std();
53 node->set(static_cast<double>(stat), "stat_error");
54 node->set(static_cast<double>(syst), "syst_error");
55 }
56
57 {
58 double sc = p->get_scale();
59 if (sc != -1.0) {
60 node->set(sc, "scale");
61 }
62 }
63
64 {
65 auto bin = p->get_bin();
66 if (!(bin.first == -1.0 && bin.second == -1.0)) {
67 node->set(bin.first, "bin_low");
68 node->set(bin.second, "bin_high");
69 }
70 }
71
72 groupData[lhaid_to_key(id)] = node;
73 }
74
75 dest->setGroup({bk}, groupData);
76 }
77}
#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
Write parameter blocks from a BlockAccessor into a DBNode.
Block identifier with alias support.
Definition BlockName.h:59
void write(std::shared_ptr< DBNode > dest, std::shared_ptr< BlockAccessor > src) override
Write node parameters from a BlockAccessor into the given destination node.
Represents an identifier of a LHA element, possibly containing several sub-ids.
Definition LhaID.h:56