Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
CorrelationRepository Class Reference

Manages correlations between parameters and experiment-scoped observables. More...

#include <CorrelationRepo.h>

Public Member Functions

std::pair< double, double > get_correlation (ParamId p1, ParamId p2) const
 Retrieves the correlation between two parameters.
 
std::pair< double, double > get_correlation (const ExperimentObs &o1, const ExperimentObs &o2) const
 Retrieves the correlation between two experiment-scoped observables.
 
std::pair< double, double > get_correlation (const std::string &experiment, Observables o1, Observables o2) const
 Retrieves the correlation between two observables given as enum, within the same experiment.
 
std::pair< double, double > get_correlation (const std::string &experiment, ObservableId o1, ObservableId o2) const
 Retrieves the correlation between two observables given as IDs, within the same experiment.
 
std::pair< double, double > get_correlation (const std::string &experiment, const BinnedObservableId &o1, const BinnedObservableId &o2) const
 Retrieves the correlation between two binned observables, within the same experiment.
 
std::pair< double, double > get_correlation (const std::string &exp1, const BinnedObservableId &o1, const std::string &exp2, const BinnedObservableId &o2) const
 Retrieves the correlation between two binned observables coming from possibly different experiments.
 
template<typename T >
double get_combined_correlation (T p1, T p2) const
 Computes the combined correlation (quadratic sum) between two entities of the same type.
 
void set_correlation_matrix (std::shared_ptr< CorrelationMatrixPair< ParamId > > correlation_matrices)
 Sets (replaces) the correlation matrix for parameters.
 
void set_correlation_matrix (std::shared_ptr< CorrelationMatrixPair< ExperimentObs > > correlation_matrix)
 Sets (replaces) the correlation matrix for experiment-scoped observables.
 
void merge_correlation_matrix (std::shared_ptr< CorrelationMatrixPair< ParamId > > correlation_matrix)
 Merges a new correlation matrix into the existing parameter correlations.
 
void merge_correlation_matrix (std::shared_ptr< CorrelationMatrixPair< ExperimentObs > > correlation_matrix)
 Merges a new correlation matrix into the existing observable correlations.
 
void print_content () const
 Prints the current content of parameter and observable correlations.
 

Detailed Description

Manages correlations between parameters and experiment-scoped observables.

This class acts as a central repository of correlation information. It stores:

  • Parameter-level correlations: CorrelationMatrixPair<ParamId>
  • Observable-level correlations: CorrelationMatrixPair<ExperimentObs>

Observable correlations are indexed by ExperimentObs, i.e. by the pair (experiment, observable). This makes it possible to store different correlation values for the same observable pair across different experiments.

Typical usage:

  • Call set_correlation_matrix(...) once to install initial matrices.
  • Optionally call merge_correlation_matrix(...) to overlay new entries (overwriting any existing ones with the same key).
  • Query correlations via get_correlation(...) and get_combined_correlation(...).

Note: The repository expects its internal shared_ptr members to be set before any get_correlation calls are made.

Definition at line 112 of file CorrelationRepo.h.

Member Function Documentation

◆ get_combined_correlation()

template<typename T >
double CorrelationRepository::get_combined_correlation ( T  p1,
T  p2 
) const
inline

Computes the combined correlation (quadratic sum) between two entities of the same type.

The combined correlation is defined as:

sqrt( rho_stat^2 + rho_syst^2 )

which is simply std::hypot(rho_stat, rho_syst).

This helper is intended for homogeneous key types, such as:

Template Parameters
TEntity type.
Parameters
p1First entity.
p2Second entity.
Returns
The combined correlation.

Definition at line 236 of file CorrelationRepo.h.

◆ get_correlation() [1/6]

std::pair< double, double > CorrelationRepository::get_correlation ( const ExperimentObs o1,
const ExperimentObs o2 
) const

Retrieves the correlation between two experiment-scoped observables.

This is the most explicit observable overload. Each observable is represented by an ExperimentObs, which combines:

Parameters
o1First experiment-scoped observable.
o2Second experiment-scoped observable.
Returns
A pair (rho_stat, rho_syst).
Precondition
observable_correlations must be non-null and properly initialized.

Definition at line 8 of file CorrelationRepo.cpp.

◆ get_correlation() [2/6]

std::pair< double, double > CorrelationRepository::get_correlation ( const std::string &  exp1,
const BinnedObservableId o1,
const std::string &  exp2,
const BinnedObservableId o2 
) const

Retrieves the correlation between two binned observables coming from possibly different experiments.

This overload is useful when one wants to explicitly query the entry corresponding to:

  • (exp1, o1)
  • (exp2, o2)
Parameters
exp1Experiment name associated with the first observable.
o1First binned observable ID.
exp2Experiment name associated with the second observable.
o2Second binned observable ID.
Returns
A pair (rho_stat, rho_syst).
Precondition
observable_correlations must be non-null and properly initialized.

Definition at line 47 of file CorrelationRepo.cpp.

◆ get_correlation() [3/6]

std::pair< double, double > CorrelationRepository::get_correlation ( const std::string &  experiment,
const BinnedObservableId o1,
const BinnedObservableId o2 
) const

Retrieves the correlation between two binned observables, within the same experiment.

Parameters
experimentExperiment name used to scope both observables.
o1First binned observable ID.
o2Second binned observable ID.
Returns
A pair (rho_stat, rho_syst).
Precondition
observable_correlations must be non-null and properly initialized.

Definition at line 38 of file CorrelationRepo.cpp.

◆ get_correlation() [4/6]

std::pair< double, double > CorrelationRepository::get_correlation ( const std::string &  experiment,
ObservableId  o1,
ObservableId  o2 
) const

Retrieves the correlation between two observables given as IDs, within the same experiment.

This overload wraps each ObservableId into a default BinnedObservableId using a dummy bin range {0., 0.}, then delegates to the (experiment, BinnedObservableId, BinnedObservableId) overload.

Parameters
experimentExperiment name used to scope both observables.
o1First observable ID.
o2Second observable ID.
Returns
A pair (rho_stat, rho_syst).
Precondition
observable_correlations must be non-null and properly initialized.

Definition at line 27 of file CorrelationRepo.cpp.

◆ get_correlation() [5/6]

std::pair< double, double > CorrelationRepository::get_correlation ( const std::string &  experiment,
Observables  o1,
Observables  o2 
) const

Retrieves the correlation between two observables given as enum, within the same experiment.

This overload converts the enum values to ObservableId using ObservableMapper::to_id, then delegates to the corresponding (experiment, ObservableId, ObservableId) overload.

Parameters
experimentExperiment name used to scope both observables.
o1First observable (enum).
o2Second observable (enum).
Returns
A pair (rho_stat, rho_syst).

Definition at line 16 of file CorrelationRepo.cpp.

◆ get_correlation() [6/6]

std::pair< double, double > CorrelationRepository::get_correlation ( ParamId  p1,
ParamId  p2 
) const

Retrieves the correlation between two parameters.

Parameters
p1First parameter ID.
p2Second parameter ID.
Returns
A pair (rho_stat, rho_syst) with statistical and systematic correlation respectively.
Precondition
parameter_correlations must be non-null and properly initialized.

Definition at line 3 of file CorrelationRepo.cpp.

◆ merge_correlation_matrix() [1/2]

void CorrelationRepository::merge_correlation_matrix ( std::shared_ptr< CorrelationMatrixPair< ExperimentObs > >  correlation_matrix)

Merges a new correlation matrix into the existing observable correlations.

Same semantics as the parameter version, but applied to observable_correlations, whose keys are ExperimentObs.

Parameters
correlation_matrixShared pointer to the new observable correlation matrix.
Precondition
observable_correlations must be non-null.

Definition at line 79 of file CorrelationRepo.cpp.

◆ merge_correlation_matrix() [2/2]

void CorrelationRepository::merge_correlation_matrix ( std::shared_ptr< CorrelationMatrixPair< ParamId > >  correlation_matrix)

Merges a new correlation matrix into the existing parameter correlations.

For each entry in correlation_matrix->stat and correlation_matrix->syst, any existing entry in parameter_correlations with the same key is overwritten via insert_or_assign.

Parameters
correlation_matrixShared pointer to the new parameter correlation matrix.
Precondition
parameter_correlations must be non-null.

Definition at line 67 of file CorrelationRepo.cpp.

◆ print_content()

void CorrelationRepository::print_content ( ) const

Prints the current content of parameter and observable correlations.

Uses the LOGGER macros to print:

  • all stored parameter correlations
  • all stored observable correlations

in a diagnostic-friendly format (using the overloaded operator<< on CorrelationMatrixPair).

Definition at line 91 of file CorrelationRepo.cpp.

◆ set_correlation_matrix() [1/2]

void CorrelationRepository::set_correlation_matrix ( std::shared_ptr< CorrelationMatrixPair< ExperimentObs > >  correlation_matrix)

Sets (replaces) the correlation matrix for experiment-scoped observables.

Parameters
correlation_matrixShared pointer to the observable correlation matrices keyed by ExperimentObs.

Definition at line 62 of file CorrelationRepo.cpp.

◆ set_correlation_matrix() [2/2]

void CorrelationRepository::set_correlation_matrix ( std::shared_ptr< CorrelationMatrixPair< ParamId > >  correlation_matrices)

Sets (replaces) the correlation matrix for parameters.

Parameters
correlation_matricesShared pointer to the parameter correlation matrices.

Definition at line 57 of file CorrelationRepo.cpp.


The documentation for this class was generated from the following files: