13 bool block_in_blocks) {
15 auto src = np->provide_db_as_node();
17 for (
auto &list_item : src->getGroup({
"correlations"})) {
18 emplace_correlation(dest, std::get<std::shared_ptr<DBNode>>(list_item.second));
25 std::shared_ptr<DBNode> leaf) {
27 auto parse_pid = [leaf](
size_t i) {
28 DBNode::Value id_value = leaf->get(
"id_" + std::to_string(i));
31 if (std::holds_alternative<int>(id_value)) {
32 id =
LhaID{std::get<int>(id_value)};
34 id =
LhaID{std::get<BlockName>(id_value)};
37 auto block = std::get<BlockName>(leaf->get(
"block_" + std::to_string(i)));
41 if (!leaf->contains(
"block_1") || !leaf->contains(
"block_2")
42 || !leaf->contains(
"id_1") || !leaf->contains(
"id_2")
43 || !leaf->contains(
"stat_correlation")) {
45 "DBNode doesn't have all necessary keys for parameter correlation.");
52 auto stat_value = std::get<double>(leaf->get(
"stat_correlation"));
53 auto syst_value = leaf->contains(
"syst_correlation")
54 ? std::get<double>(leaf->get(
"syst_correlation"))
57 corr_matrices->emplace(std::make_pair(pid_1, pid_2), stat_value, syst_value);
64 bool block_in_blocks) {
67 auto src = np->provide_db_as_node();
69 if (!src->contains(
"correlations")) {
71 "DBNode doesn't contain 'correlations' for observable correlations.");
83 for (
auto &exp_item : src->getGroup({
"correlations"})) {
84 const std::string experiment = exp_item.first;
86 for (
auto &list_item : src->getGroup({
"correlations", experiment})) {
87 auto leaf = std::get<std::shared_ptr<DBNode>>(list_item.second);
89 if (!leaf->contains(
"id_1") || !leaf->contains(
"id_2")
90 || !leaf->contains(
"stat_correlation")) {
92 "DBNode doesn't have all necessary keys for observable correlation.");
101 auto stat_value = std::get<double>(leaf->get(
"stat_correlation"));
102 auto syst_value = leaf->contains(
"syst_correlation")
103 ? std::get<double>(leaf->get(
"syst_correlation"))
Experiment-scoped observable identifiers.
#define LOG_ERROR(type,...)
Macro for logging error messages and terminating the application.
Loader class to populate CorrelationMatrixPair from a file.
void load(std::shared_ptr< CorrelationMatrixPair< T > > dest, fs::path src_file, bool block_in_blocks=false) override
Loads correlation matrices from a source file into a destination CorrelationMatrixPair.
static std::shared_ptr< IDBNodeProvider > createDBNodeProvider(fs::path src_path)
Creates an IDBNodeProvider for a given file path.
std::variant< BlockName, int, double, bool, std::shared_ptr< DBNode >, std::vector< std::shared_ptr< DBNode > > > Value
Variant type used to store values in the tree.
static ParameterType GetType(BlockName block, LhaID id)
Determines the ParameterType of a given (block, LhaID) pair.
Identifies an observable together with a numerical bin.
static BinnedObservableId from_flha(LhaID const &id)
Reconstructs a binned observable identifier from an FLHA encoding.
Stores a pair of correlation matrices (statistical and systematic) for a given key type.
Represents an identifier of a LHA element, possibly containing several sub-ids.
Composite identifier for a single parameter.