Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
CorrelationProvider.cpp
Go to the documentation of this file.
2
4 const ParamId& pid_2,
5 CorrelationType type) {
6 return get_correlation(pid_1, pid_2, type);
7}
8
10 const ExperimentObs& oid_2,
11 CorrelationType type) {
12 return get_correlation(oid_1, oid_2, type);
13}
14
15double CorrelationProvider::operator()(const std::string& experiment,
16 const Observables& oid_1,
17 const Observables& oid_2,
18 CorrelationType type) {
19 ObservableId obs_id_1 = ObservableMapper::to_id(oid_1);
20 ObservableId obs_id_2 = ObservableMapper::to_id(oid_2);
21 return (*this)(experiment, obs_id_1, obs_id_2, type);
22}
23
24double CorrelationProvider::operator()(const std::string& experiment,
25 const ObservableId& oid_1,
26 const ObservableId& oid_2,
27 CorrelationType type) {
28 BinnedObservableId oid_1_b{oid_1, {0., 0.}};
29 BinnedObservableId oid_2_b{oid_2, {0., 0.}};
30 return (*this)(experiment, oid_1_b, oid_2_b, type);
31}
32
33double CorrelationProvider::operator()(const std::string& experiment,
34 const BinnedObservableId& oid_1,
35 const BinnedObservableId& oid_2,
36 CorrelationType type) {
37 return get_correlation(experiment, oid_1, oid_2, type);
38}
39
40double CorrelationProvider::operator()(const std::string& exp_1,
41 const BinnedObservableId& oid_1,
42 const std::string& exp_2,
43 const BinnedObservableId& oid_2,
44 CorrelationType type) {
45 return get_correlation(exp_1, oid_1, exp_2, oid_2, type);
46}
47
49 const ParamId& pid_2,
50 CorrelationType type) {
51 return get_correlation(pid_1, pid_2, type) != 0.0;
52}
53
55 const ExperimentObs& oid_2,
56 CorrelationType type) {
57 return get_correlation(oid_1, oid_2, type) != 0.0;
58}
59
60bool CorrelationProvider::exists(const std::string& experiment,
61 const Observables& oid_1,
62 const Observables& oid_2,
63 CorrelationType type) {
64 return (*this)(experiment, oid_1, oid_2, type) != 0.0;
65}
66
67bool CorrelationProvider::exists(const std::string& experiment,
68 const ObservableId& oid_1,
69 const ObservableId& oid_2,
70 CorrelationType type) {
71 return (*this)(experiment, oid_1, oid_2, type) != 0.0;
72}
73
74bool CorrelationProvider::exists(const std::string& experiment,
75 const BinnedObservableId& oid_1,
76 const BinnedObservableId& oid_2,
77 CorrelationType type) {
78 return (*this)(experiment, oid_1, oid_2, type) != 0.0;
79}
80
81bool CorrelationProvider::exists(const std::string& exp_1,
82 const BinnedObservableId& oid_1,
83 const std::string& exp_2,
84 const BinnedObservableId& oid_2,
85 CorrelationType type) {
86 return (*this)(exp_1, oid_1, exp_2, oid_2, type) != 0.0;
87}
88
89template <typename T>
90inline double CorrelationProvider::get_correlation(const T& id_1,
91 const T& id_2,
92 CorrelationType type) const {
93 if (id_1 == id_2) {
94 return 1.0;
95 }
96
98
99 switch (type) {
101 return correlation_repo.get_correlation(id_1, id_2).first;
103 return correlation_repo.get_correlation(id_1, id_2).second;
105 return correlation_repo.get_combined_correlation(id_1, id_2);
106 default:
107 LOG_ERROR("CorrelationProvider", "Unknown correlation type requested.");
108 return 0.0;
109 }
110}
111
112double CorrelationProvider::get_correlation(const std::string& experiment,
113 const BinnedObservableId& id_1,
114 const BinnedObservableId& id_2,
115 CorrelationType type) const {
116 if (id_1 == id_2) {
117 return 1.0;
118 }
119
121
122 switch (type) {
124 return correlation_repo.get_correlation(experiment, id_1, id_2).first;
126 return correlation_repo.get_correlation(experiment, id_1, id_2).second;
128 auto corr = correlation_repo.get_correlation(experiment, id_1, id_2);
129 return std::hypot(corr.first, corr.second);
130 }
131 default:
132 LOG_ERROR("CorrelationProvider", "Unknown correlation type requested.");
133 return 0.0;
134 }
135}
136
137double CorrelationProvider::get_correlation(const std::string& exp_1,
138 const BinnedObservableId& id_1,
139 const std::string& exp_2,
140 const BinnedObservableId& id_2,
141 CorrelationType type) const {
142 if (exp_1 == exp_2 && id_1 == id_2) {
143 return 1.0;
144 }
145
147
148 switch (type) {
150 return correlation_repo.get_correlation(exp_1, id_1, exp_2, id_2).first;
152 return correlation_repo.get_correlation(exp_1, id_1, exp_2, id_2).second;
154 auto corr = correlation_repo.get_correlation(exp_1, id_1, exp_2, id_2);
155 return std::hypot(corr.first, corr.second);
156 }
157 default:
158 LOG_ERROR("CorrelationProvider", "Unknown correlation type requested.");
159 return 0.0;
160 }
161}
High-level access to parameter and experiment-scoped observable correlations.
Observables
Definition GeneralEnum.h:4
#define LOG_ERROR(type,...)
Macro for logging error messages and terminating the application.
Definition Logger.h:41
double operator()(const ParamId &pid_1, const ParamId &pid_2, CorrelationType type)
Retrieves a correlation between two parameters.
bool exists(const ParamId &pid_1, const ParamId &pid_2, CorrelationType type)
Checks if a correlation between two parameters is non-zero.
CorrelationType
Type of correlation component requested.
Manages correlations between parameters and experiment-scoped observables.
double get_combined_correlation(T p1, T p2) const
Computes the combined correlation (quadratic sum) between two entities of the same type.
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>.
static MemoryManager * GetInstance()
Retrieves the singleton instance of MemoryManager.
const CorrelationRepository & get_correlation_repository()
Retrieves the current correlation repository.
double T(double x)
Wilson coefficient T(x).
Identifies an observable together with a numerical bin.
Composite identifier for a single parameter.
Definition ParamID.h:57