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

#include <ObsManager.h>

Public Member Functions

 ObsManager (ObservablePortsConfig obs_port_conf, bool init_default_decays=true)
 Construct an observable manager with the required ports.
 
ObsManager add_obs (Observables id, QCDOrder order, bool add_deps=false)
 Add an observable (public enum) to the manager.
 
ObsManager remove_obs (Observables id)
 Remove an observable (public enum) from the manager.
 
ObsManager add_obs (ObservableId id, QCDOrder order, bool add_deps=false)
 Add an observable (internal ObservableId) to the manager.
 
ObsManager add_obs (BinnedObservableId id, QCDOrder order, bool add_deps=false)
 Add a binned observable to the manager, or add a bin to an existing observable.
 
bool is_decay_binned (Decays decay) const
 Return whether this decay has at least one observable requiring q² bins.
 
bool is_decay_binned (DecayId decay) const
 Return whether this decay has at least one observable requiring q² bins.
 
bool is_observable_binned (Observables obs) const
 Return whether a specific observable requires q² bins.
 
bool is_observable_binned (ObservableId obs) const
 Return whether a specific observable requires q² bins.
 
ObsManager remove_obs (ObservableId id)
 Remove an observable (internal ObservableId) from the manager.
 
std::vector< ObservableValueevaluate (Observables id)
 Evaluate a single observable (public enum).
 
std::vector< ObservableValueevaluate (ObservableId id)
 Evaluate a single observable (internal ObservableId).
 
ObservableValue evaluate (BinnedObservableId id)
 Evaluate a single observable (internal ObservableId).
 
std::map< ObservableId, std::vector< ObservableValue > > evaluate_all ()
 Evaluate all currently registered observables.
 
void add_custom_decay (DecayId id, std::shared_ptr< DecayParent > ptr)
 Register a custom decay implementation.
 
void add_obs_dep (Observables id, ParamId param)
 Add a single dependency (parameter) to an observable (public enum).
 
void add_obs_deps (Observables id, std::unordered_set< ParamId > params)
 Add a set of dependencies (parameters) to an observable (public enum).
 
void add_obs_dep (ObservableId id, ParamId param)
 Add a single dependency (parameter) to an observable (ObservableId).
 
void add_obs_deps (ObservableId id, std::unordered_set< ParamId > params)
 Add a set of dependencies (parameters) to an observable (ObservableId).
 
std::unordered_set< ParamIdget_all_ops_deps (ObservableId id)
 Get the full allowed dependency set for a given observable.
 
void add_all_obs_deps (Observables id)
 Attach all allowed dependencies to an observable (public enum).
 
void add_all_obs_deps (ObservableId id)
 Attach all allowed dependencies to an observable (ObservableId).
 
std::vector< BinnedObservableIdget_current_obss ()
 Get the set of observable ids currently registered in the manager.
 
std::shared_ptr< Observableget_obs (Observables id)
 Retrieve an observable (public enum).
 
std::shared_ptr< Observableget_obs (ObservableId id)
 Retrieve an observable (ObservableId).
 
ObservablePortsConfigget_ports ()
 Access manager ports (non-const reference).
 
void select_decay (ObservableId id)
 Enable the decay needed by an observable and disable all others.
 
void reload_params ()
 Reload cached parameters for all registered decays.
 
void enable_obs ()
 Enable all observables' decays sequentially.
 
void set_decay_config (Decays dec, std::any config)
 Set a decay configuration object.
 
ObsManager set_decay_threads (Decays dec, size_t n_threads)
 Set the thread option for a decay that supports parallel cache filling.
 
DecayThreadSnapshot snapshot_decay_threads () const
 Snapshot thread settings for all decays with thread configuration support.
 
void set_all_decay_threads (size_t n_threads)
 Set all thread-configurable decays to the same thread count.
 
void restore_decay_threads (const DecayThreadSnapshot &snapshot)
 Restore a previous decay thread snapshot.
 
DecayConfigSnapshot snapshot_decay_configs () const
 Snapshot runtime decay configurations that expose one.
 
void restore_decay_configs (const DecayConfigSnapshot &snapshot)
 Restore runtime decay configurations on matching decays.
 
std::vector< ObservableSelectionSnapshotsnapshot_observable_selection () const
 Capture selected observables, bins, orders and dependencies.
 
ObsManager set_bkstarll_threads (size_t n_threads)
 Set the thread option for the B -> K* l+ l- decay.
 
ObsManager set_bkll_threads (size_t n_threads)
 Set the thread option for the B -> K l+ l- decay.
 
ObsManager set_bsphi_threads (size_t n_threads)
 Set the thread option for the Bs -> phi l+ l- decay.
 
ObsManager set_lblll_threads (size_t n_threads)
 Set the thread option for the Lambda_b -> Lambda l+ l- decay.
 

Detailed Description

Definition at line 82 of file ObsManager.h.

Constructor & Destructor Documentation

◆ ObsManager()

ObsManager::ObsManager ( ObservablePortsConfig  obs_port_conf,
bool  init_default_decays = true 
)

Construct an observable manager with the required ports.

If init_default_decays is true, the manager registers the library default decays (B, K, D, mixing, ...). Their default matching/hadronic scales are derived from SM parameters accessed through ObservablePortsConfig::iobspp_sm.

Parameters
obs_port_confPorts used by decays/observables (Wilson builder, parameter proxies, QCD proxy, freezer, ...).
init_default_decaysWhether to register built-in decays at construction.

Definition at line 4 of file ObsManager.cpp.

Member Function Documentation

◆ add_all_obs_deps() [1/2]

void ObsManager::add_all_obs_deps ( ObservableId  id)

Attach all allowed dependencies to an observable (ObservableId).

Equivalent to calling DependenciesHelper::get_allowed_parameters and adding the returned set to the observable.

Parameters
idObservable internal id.

Definition at line 289 of file ObsManager.cpp.

◆ add_all_obs_deps() [2/2]

void ObsManager::add_all_obs_deps ( Observables  id)

Attach all allowed dependencies to an observable (public enum).

Equivalent to calling DependenciesHelper::get_allowed_parameters and adding the returned set to the observable.

Parameters
idObservable public enum.

Definition at line 283 of file ObsManager.cpp.

◆ add_custom_decay()

void ObsManager::add_custom_decay ( DecayId  id,
std::shared_ptr< DecayParent ptr 
)

Register a custom decay implementation.

The decay is rebound to the manager Wilson builder (ports), so it can build Wilson groups consistently with the rest of the system.

Parameters
idDecay identifier.
ptrShared pointer to the decay implementation.

Definition at line 238 of file ObsManager.cpp.

◆ add_obs() [1/3]

ObsManager ObsManager::add_obs ( BinnedObservableId  id,
QCDOrder  order,
bool  add_deps = false 
)

Add a binned observable to the manager, or add a bin to an existing observable.

The parent decay is resolved from id.s through DecayMapper::get_decay_id, which keeps the binned path compatible with dynamic/custom observable ids.

Parameters
idObservable internal id with bin information.
orderRequested QCD order for the underlying decay. May be downgraded by the decay.
add_depsIf true, attaches all allowed parameter dependencies to the observable.
Returns
A copy of the manager (builder-like chaining). Note: this returns by value.

Definition at line 104 of file ObsManager.cpp.

◆ add_obs() [2/3]

ObsManager ObsManager::add_obs ( ObservableId  id,
QCDOrder  order,
bool  add_deps = false 
)

Add an observable (internal ObservableId) to the manager.

Steps:

  1. Logs the addition.
  2. Resolves the parent decay directly from id with DecayMapper::get_decay_id.
  3. Finds the registered DecayParent instance by DecayId.
  4. Sets the decay QCD order (via DecayParent::set_order).
  5. Creates and stores an Observable bound to that decay.
  6. Optionally attaches dependencies.

This overload does not require id to be convertible back to the static Observables enum. It therefore supports runtime/custom observables as long as the mapper layer knows their parent decay and that decay has been registered in the manager.

Parameters
idObservable internal id.
orderRequested QCD order for the underlying decay. May be downgraded by the decay.
add_depsIf true, attaches all allowed parameter dependencies to the observable.
Returns
A copy of the manager (builder-like chaining). Note: this returns by value.

Definition at line 31 of file ObsManager.cpp.

◆ add_obs() [3/3]

ObsManager ObsManager::add_obs ( Observables  id,
QCDOrder  order,
bool  add_deps = false 
)

Add an observable (public enum) to the manager.

Internally maps to an ObservableId, finds its decay, sets the decay order, and registers an Observable instance bound to that decay.

If add_deps is true, the observable is populated with its full allowed dependency set from DependenciesHelper.

Parameters
idObservable public enum.
orderRequested QCD order for the underlying decay. May be downgraded by the decay.
add_depsIf true, attaches all allowed parameter dependencies to the observable.
Returns
A copy of the manager (builder-like chaining). Note: this returns by value.
See also
add_obs(ObservableId, QCDOrder, bool)

Definition at line 67 of file ObsManager.cpp.

◆ add_obs_dep() [1/2]

void ObsManager::add_obs_dep ( ObservableId  id,
ParamId  param 
)

Add a single dependency (parameter) to an observable (ObservableId).

Builtin observables are validated against DependenciesHelper. Runtime observables accept this dependency directly because the generated helper cannot know plugin/lambda observables in advance.

Parameters
idObservable internal id.
paramParameter identifier to add.

Definition at line 250 of file ObsManager.cpp.

◆ add_obs_dep() [2/2]

void ObsManager::add_obs_dep ( Observables  id,
ParamId  param 
)

Add a single dependency (parameter) to an observable (public enum).

Builtin observables are validated against DependenciesHelper. Runtime observables do not live in that generated table, so their dependencies are accepted as user-declared metadata.

Parameters
idObservable public enum.
paramParameter identifier to add.

Definition at line 244 of file ObsManager.cpp.

◆ add_obs_deps() [1/2]

void ObsManager::add_obs_deps ( ObservableId  id,
std::unordered_set< ParamId params 
)

Add a set of dependencies (parameters) to an observable (ObservableId).

Builtin observables are validated against the allowed dependency set. Runtime observables accept the provided set directly.

Parameters
idObservable internal id.
paramsSet of parameters to add.

Definition at line 268 of file ObsManager.cpp.

◆ add_obs_deps() [2/2]

void ObsManager::add_obs_deps ( Observables  id,
std::unordered_set< ParamId params 
)

Add a set of dependencies (parameters) to an observable (public enum).

Builtin observables are validated against the generated allowed dependency set. Runtime observables accept the provided set directly.

Parameters
idObservable public enum.
paramsSet of parameters to add.

Definition at line 262 of file ObsManager.cpp.

◆ enable_obs()

void ObsManager::enable_obs ( )

Enable all observables' decays sequentially.

This is a convenience method to (re)initialize decays for all currently registered observables.

Each decay is enabled at most once, even when several observables map to it.

Definition at line 406 of file ObsManager.cpp.

◆ evaluate() [1/3]

ObservableValue ObsManager::evaluate ( BinnedObservableId  id)

Evaluate a single observable (internal ObservableId).

This selects (enables) the observable's decay and disables others (see select_decay), then runs Observable::compute.

Parameters
idObservable internal id with bin information.
Returns
Computed value with bin and id information inside ObservableValue.

Definition at line 211 of file ObsManager.cpp.

◆ evaluate() [2/3]

std::vector< ObservableValue > ObsManager::evaluate ( ObservableId  id)

Evaluate a single observable (internal ObservableId).

This selects (enables) the observable's decay and disables others (see select_decay), then runs Observable::compute.

Parameters
idObservable internal id.
Returns
Vector of computed values. May contain multiple entries for binned observables.

Definition at line 201 of file ObsManager.cpp.

◆ evaluate() [3/3]

std::vector< ObservableValue > ObsManager::evaluate ( Observables  id)

Evaluate a single observable (public enum).

This selects (enables) the observable's decay and disables others (see select_decay), then runs Observable::compute.

Parameters
idObservable public enum.
Returns
Vector of computed values. May contain multiple entries for binned observables.

Definition at line 206 of file ObsManager.cpp.

◆ evaluate_all()

std::map< ObservableId, std::vector< ObservableValue > > ObsManager::evaluate_all ( )

Evaluate all currently registered observables.

Iterates over obss and calls Observable::compute for each. Note: this does not call select_decay beforehand, so if multiple observables belong to different decays, each compute() will enable its decay on demand (depending on decay implementation).

Returns
Map from ObservableId to computed values.

Definition at line 229 of file ObsManager.cpp.

◆ get_all_ops_deps()

std::unordered_set< ParamId > ObsManager::get_all_ops_deps ( ObservableId  id)

Get the full allowed dependency set for a given observable.

This first returns the dependency set attached to the observable instance. If none is attached, it falls back to the generated DependenciesHelper map for builtin observables. Runtime observables without declared dependencies therefore safely return an empty set instead of throwing.

Parameters
idObservable internal id.
Returns
Set of allowed dependencies.

Definition at line 301 of file ObsManager.cpp.

◆ get_current_obss()

std::vector< BinnedObservableId > ObsManager::get_current_obss ( )

Get the set of observable ids currently registered in the manager.

Returns
Set of ObservableId keys from obss.

Definition at line 318 of file ObsManager.cpp.

◆ get_obs() [1/2]

std::shared_ptr< Observable > ObsManager::get_obs ( ObservableId  id)

Retrieve an observable (ObservableId).

Parameters
idObservable internal id.
Returns
Shared pointer to the stored observable.

Definition at line 339 of file ObsManager.cpp.

◆ get_obs() [2/2]

std::shared_ptr< Observable > ObsManager::get_obs ( Observables  id)

Retrieve an observable (public enum).

Parameters
idObservable public enum.
Returns
Shared pointer to the stored observable.

Definition at line 334 of file ObsManager.cpp.

◆ get_ports()

ObservablePortsConfig & ObsManager::get_ports ( )
inline

Access manager ports (non-const reference).

Returns
Reference to the stored ports configuration.

Definition at line 349 of file ObsManager.h.

◆ is_decay_binned() [1/2]

bool ObsManager::is_decay_binned ( DecayId  decay) const

Return whether this decay has at least one observable requiring q² bins.

Definition at line 76 of file ObsManager.cpp.

◆ is_decay_binned() [2/2]

bool ObsManager::is_decay_binned ( Decays  decay) const

Return whether this decay has at least one observable requiring q² bins.

Definition at line 72 of file ObsManager.cpp.

◆ is_observable_binned() [1/2]

bool ObsManager::is_observable_binned ( ObservableId  obs) const

Return whether a specific observable requires q² bins.

Definition at line 88 of file ObsManager.cpp.

◆ is_observable_binned() [2/2]

bool ObsManager::is_observable_binned ( Observables  obs) const

Return whether a specific observable requires q² bins.

Definition at line 84 of file ObsManager.cpp.

◆ reload_params()

void ObsManager::reload_params ( )

Reload cached parameters for all registered decays.

Calls DecayParent::load_params on each decay instance. Useful after changing global inputs or parameter modes.

Definition at line 398 of file ObsManager.cpp.

◆ remove_obs() [1/2]

ObsManager ObsManager::remove_obs ( ObservableId  id)

Remove an observable (internal ObservableId) from the manager.

If the observable is not present, a warning may be logged (non-critical path).

Parameters
idObservable internal id.
Returns
A copy of the manager (builder-like chaining). Note: this returns by value.

Definition at line 174 of file ObsManager.cpp.

◆ remove_obs() [2/2]

ObsManager ObsManager::remove_obs ( Observables  id)

Remove an observable (public enum) from the manager.

If the observable is not present, a warning may be logged (non-critical path).

Parameters
idObservable public enum.
Returns
A copy of the manager (builder-like chaining). Note: this returns by value.

Definition at line 99 of file ObsManager.cpp.

◆ restore_decay_configs()

void ObsManager::restore_decay_configs ( const DecayConfigSnapshot snapshot)

Restore runtime decay configurations on matching decays.

Definition at line 479 of file ObsManager.cpp.

◆ restore_decay_threads()

void ObsManager::restore_decay_threads ( const DecayThreadSnapshot snapshot)

Restore a previous decay thread snapshot.

Definition at line 455 of file ObsManager.cpp.

◆ select_decay()

void ObsManager::select_decay ( ObservableId  id)

Enable the decay needed by an observable and disable all others.

This is used by evaluate to avoid keeping multiple decays enabled at once (which can matter if decays build Wilson groups lazily and cache parameters).

The decay is selected through DecayMapper::get_decay_id rather than through a static enum conversion, so this also works for registered custom observables.

Parameters
idObservable internal id used to determine the corresponding decay.

Definition at line 343 of file ObsManager.cpp.

◆ set_all_decay_threads()

void ObsManager::set_all_decay_threads ( size_t  n_threads)

Set all thread-configurable decays to the same thread count.

Definition at line 447 of file ObsManager.cpp.

◆ set_bkll_threads()

ObsManager ObsManager::set_bkll_threads ( size_t  n_threads)

Set the thread option for the B -> K l+ l- decay.

Parameters
n_threadsNumber of threads.

Definition at line 523 of file ObsManager.cpp.

◆ set_bkstarll_threads()

ObsManager ObsManager::set_bkstarll_threads ( size_t  n_threads)

Set the thread option for the B -> K* l+ l- decay.

Parameters
n_threadsNumber of threads.

Definition at line 519 of file ObsManager.cpp.

◆ set_bsphi_threads()

ObsManager ObsManager::set_bsphi_threads ( size_t  n_threads)

Set the thread option for the Bs -> phi l+ l- decay.

Parameters
n_threadsNumber of threads.

Definition at line 527 of file ObsManager.cpp.

◆ set_decay_config()

void ObsManager::set_decay_config ( Decays  dec,
std::any  config 
)

Set a decay configuration object.

This forwards a type-erased configuration payload to the corresponding decay via DecayParent::set_config. The decay decides how to interpret the payload.

Parameters
decDecay enum.
configType-erased configuration object (std::any).

Definition at line 379 of file ObsManager.cpp.

◆ set_decay_threads()

ObsManager ObsManager::set_decay_threads ( Decays  dec,
size_t  n_threads 
)

Set the thread option for a decay that supports parallel cache filling.

Passing 0 delegates to std::thread::hardware_concurrency for supported decays. Unsupported decays keep their default behavior and emit a warning.

Parameters
decDecay enum.
n_threadsNumber of threads.

Definition at line 430 of file ObsManager.cpp.

◆ set_lblll_threads()

ObsManager ObsManager::set_lblll_threads ( size_t  n_threads)

Set the thread option for the Lambda_b -> Lambda l+ l- decay.

Parameters
n_threadsNumber of threads.

Definition at line 531 of file ObsManager.cpp.

◆ snapshot_decay_configs()

DecayConfigSnapshot ObsManager::snapshot_decay_configs ( ) const

Snapshot runtime decay configurations that expose one.

Definition at line 464 of file ObsManager.cpp.

◆ snapshot_decay_threads()

DecayThreadSnapshot ObsManager::snapshot_decay_threads ( ) const

Snapshot thread settings for all decays with thread configuration support.

Definition at line 437 of file ObsManager.cpp.

◆ snapshot_observable_selection()

std::vector< ObservableSelectionSnapshot > ObsManager::snapshot_observable_selection ( ) const

Capture selected observables, bins, orders and dependencies.

Definition at line 488 of file ObsManager.cpp.


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