Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
CorrelationRepo.cpp
Go to the documentation of this file.
1#include "CorrelationRepo.h"
2
3std::pair<double, double> CorrelationRepository::get_correlation(ParamId id1, ParamId id2) const {
4 auto key = std::make_pair(id1, id2);
5 return parameter_correlations->at(key);
6}
7
8std::pair<double, double> CorrelationRepository::get_correlation(
9 const ExperimentObs& id1,
10 const ExperimentObs& id2) const {
11
12 auto key = std::make_pair(id1, id2);
13 return observable_correlations->at(key);
14}
15
17 const std::string& experiment,
18 Observables id1,
19 Observables id2) const {
20
23
24 return get_correlation(experiment, obs_id1, obs_id2);
25}
26
28 const std::string& experiment,
29 ObservableId id1,
30 ObservableId id2) const {
31
32 BinnedObservableId id1_b{id1, {0., 0.}};
33 BinnedObservableId id2_b{id2, {0., 0.}};
34
35 return get_correlation(experiment, id1_b, id2_b);
36}
37
39 const std::string& experiment,
40 const BinnedObservableId& id1,
41 const BinnedObservableId& id2) const {
42
43 return get_correlation(ExperimentObs{experiment, id1},
44 ExperimentObs{experiment, id2});
45}
46
48 const std::string& exp1,
49 const BinnedObservableId& id1,
50 const std::string& exp2,
51 const BinnedObservableId& id2) const {
52
53 return get_correlation(ExperimentObs{exp1, id1},
54 ExperimentObs{exp2, id2});
55}
56
58 std::shared_ptr<CorrelationMatrixPair<ParamId>> correlation_matrices) {
59 parameter_correlations = correlation_matrices;
60}
61
63 std::shared_ptr<CorrelationMatrixPair<ExperimentObs>> correlation_matrices) {
64 observable_correlations = correlation_matrices;
65}
66
68 std::shared_ptr<CorrelationMatrixPair<ParamId>> correlation_matrices) {
69
70 for (const auto &corr : correlation_matrices->stat) {
71 parameter_correlations->stat.insert_or_assign(corr.first, corr.second);
72 }
73
74 for (const auto &corr : correlation_matrices->syst) {
75 parameter_correlations->syst.insert_or_assign(corr.first, corr.second);
76 }
77}
78
80 std::shared_ptr<CorrelationMatrixPair<ExperimentObs>> correlation_matrices) {
81
82 for (const auto &corr : correlation_matrices->stat) {
83 observable_correlations->stat.insert_or_assign(corr.first, corr.second);
84 }
85
86 for (const auto &corr : correlation_matrices->syst) {
87 observable_correlations->syst.insert_or_assign(corr.first, corr.second);
88 }
89}
90
92 LOG_INFO("------- Parameter correlations (off-diagonal) -------");
93 LOG_INFO(parameter_correlations);
94 LOG_INFO("------- Observable correlations by experiment (off-diagonal) -------");
95 LOG_INFO(observable_correlations);
96}
97
98template<typename U>
99std::ostream &operator<<(std::ostream &os, const CorrelationMatrixPair<U>& cmp) {
100 for (const std::pair<std::pair<U, U>, double>& corr : cmp.stat) {
101 auto corr_vals = cmp.at(corr.first);
102 os << "\t(" << corr.first.first << ", " << corr.first.second << "): "
103 << corr_vals.first << " (stat) + "
104 << corr_vals.second << " (syst)\n";
105 }
106 return os;
107}
std::ostream & operator<<(std::ostream &os, const CorrelationMatrixPair< U > &cmp)
Observables
Definition GeneralEnum.h:4
#define LOG_INFO(...)
Macro for logging informational messages.
Definition Logger.h:39
void set_correlation_matrix(std::shared_ptr< CorrelationMatrixPair< ParamId > > correlation_matrices)
Sets (replaces) the correlation matrix for parameters.
void print_content() const
Prints the current content of parameter and observable correlations.
void merge_correlation_matrix(std::shared_ptr< CorrelationMatrixPair< ParamId > > correlation_matrix)
Merges a new correlation matrix into the existing parameter correlations.
std::pair< double, double > get_correlation(ParamId p1, ParamId p2) const
Retrieves the correlation between two parameters.
static IdOf< ObservableTag > to_id(Observables e)
Converts an enum value to an IdOf<Tag>.
Identifies an observable together with a numerical bin.
Stores a pair of correlation matrices (statistical and systematic) for a given key type.
std::pair< double, double > at(const std::pair< T, T > &key) const
Retrieves the correlation values for a given pair.
SparseMatrix< T > stat
Statistical correlation matrix.
Composite identifier for a single parameter.
Definition ParamID.h:57