Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
ObsManager.h
Go to the documentation of this file.
1#ifndef OBSERVABLEMANAGER_H
2#define OBSERVABLEMANAGER_H
3
4#include <memory>
5#include <map>
6#include <unordered_set>
7#include <unordered_map>
8#include <optional>
9#include <any>
10
11#include "ParamID.h"
12#include "Observable.h"
13#include "Decays.h"
14#include "IObsParameterProxy.h"
15#include "ObsPortsConfig.h"
16
78
79using DecayThreadSnapshot = std::unordered_map<DecayId, size_t>;
80using DecayConfigSnapshot = std::unordered_map<DecayId, std::any>;
81
83public:
94 ObsManager(ObservablePortsConfig obs_port_conf, bool init_default_decays=true);
95
112 ObsManager add_obs(Observables id, QCDOrder order, bool add_deps=false);
113
123
145 ObsManager add_obs(ObservableId id, QCDOrder order, bool add_deps=false);
146
158 ObsManager add_obs(BinnedObservableId id, QCDOrder order, bool add_deps=false);
159
163 bool is_decay_binned(Decays decay) const;
164
168 bool is_decay_binned(DecayId decay) const;
169
173 bool is_observable_binned(Observables obs) const;
174
178 bool is_observable_binned(ObservableId obs) const;
179
189
199 std::vector<ObservableValue> evaluate(Observables id);
200
210 std::vector<ObservableValue> evaluate(ObservableId id);
211
222
233 std::map<ObservableId, std::vector<ObservableValue>> evaluate_all();
234
244 void add_custom_decay(DecayId id, std::shared_ptr<DecayParent> ptr);
245
256 void add_obs_dep(Observables id, ParamId param);
257
267 void add_obs_deps(Observables id, std::unordered_set<ParamId> params);
268
279 void add_obs_dep(ObservableId id, ParamId param);
280
290 void add_obs_deps(ObservableId id, std::unordered_set<ParamId> params);
291
303 std::unordered_set<ParamId> get_all_ops_deps(ObservableId id);
304
314
324
329 std::vector<BinnedObservableId> get_current_obss();
330
336 std::shared_ptr<Observable> get_obs(Observables id);
337
343 std::shared_ptr<Observable> get_obs(ObservableId id);
344
349 ObservablePortsConfig& get_ports() {return obs_port_conf;}
350
362 void select_decay(ObservableId id);
363
370 void reload_params();
371
379 void enable_obs();
380
390 void set_decay_config(Decays dec, std::any config);
391
401 ObsManager set_decay_threads(Decays dec, size_t n_threads);
402
407
411 void set_all_decay_threads(size_t n_threads);
412
416 void restore_decay_threads(const DecayThreadSnapshot& snapshot);
417
422
426 void restore_decay_configs(const DecayConfigSnapshot& snapshot);
427
431 std::vector<ObservableSelectionSnapshot> snapshot_observable_selection() const;
432
438 ObsManager set_bkstarll_threads(size_t n_threads);
439
445 ObsManager set_bkll_threads(size_t n_threads);
446
452 ObsManager set_bsphi_threads(size_t n_threads);
453
459 ObsManager set_lblll_threads(size_t n_threads);
460
461private:
463 std::unordered_map<DecayId, std::shared_ptr<DecayParent>> decays;
464
466 std::map<ObservableId, std::shared_ptr<Observable>> obss;
467
479 ObservableId ensure_present(Observables id, bool critical=true);
480
492 ObservableId ensure_present(ObservableId id, bool critical=true);
493
495 ObservablePortsConfig obs_port_conf;
496
499 std::optional<DecayId> active_decay;
500};
501
502#endif // OBSERVABLEMANAGER_H
Observables
Definition GeneralEnum.h:4
QCDOrder
Decays
Interface for read-only access to parameters used by observable computations.
std::unordered_map< DecayId, size_t > DecayThreadSnapshot
Definition ObsManager.h:79
std::unordered_map< DecayId, std::any > DecayConfigSnapshot
Definition ObsManager.h:80
High-level observable wrapper (user-facing) that connects experimental inputs to theory predictions.
bool is_decay_binned(Decays decay) const
Return whether this decay has at least one observable requiring q² bins.
ObsManager set_decay_threads(Decays dec, size_t n_threads)
Set the thread option for a decay that supports parallel cache filling.
std::map< ObservableId, std::vector< ObservableValue > > evaluate_all()
Evaluate all currently registered observables.
void restore_decay_configs(const DecayConfigSnapshot &snapshot)
Restore runtime decay configurations on matching decays.
void set_decay_config(Decays dec, std::any config)
Set a decay configuration object.
std::unordered_set< ParamId > get_all_ops_deps(ObservableId id)
Get the full allowed dependency set for a given observable.
std::vector< BinnedObservableId > get_current_obss()
Get the set of observable ids currently registered in the manager.
void add_custom_decay(DecayId id, std::shared_ptr< DecayParent > ptr)
Register a custom decay implementation.
void add_obs_deps(Observables id, std::unordered_set< ParamId > params)
Add a set of dependencies (parameters) to an observable (public enum).
ObsManager set_lblll_threads(size_t n_threads)
Set the thread option for the Lambda_b -> Lambda l+ l- decay.
void reload_params()
Reload cached parameters for all registered decays.
ObservablePortsConfig & get_ports()
Access manager ports (non-const reference).
Definition ObsManager.h:349
ObsManager remove_obs(Observables id)
Remove an observable (public enum) from the manager.
void set_all_decay_threads(size_t n_threads)
Set all thread-configurable decays to the same thread count.
void add_obs_dep(Observables id, ParamId param)
Add a single dependency (parameter) to an observable (public enum).
ObsManager set_bkstarll_threads(size_t n_threads)
Set the thread option for the B -> K* l+ l- decay.
std::vector< ObservableValue > evaluate(Observables id)
Evaluate a single observable (public enum).
void add_all_obs_deps(Observables id)
Attach all allowed dependencies to an observable (public enum).
void select_decay(ObservableId id)
Enable the decay needed by an observable and disable all others.
DecayThreadSnapshot snapshot_decay_threads() const
Snapshot thread settings for all decays with thread configuration support.
bool is_observable_binned(Observables obs) const
Return whether a specific observable requires q² bins.
DecayConfigSnapshot snapshot_decay_configs() const
Snapshot runtime decay configurations that expose one.
ObsManager set_bsphi_threads(size_t n_threads)
Set the thread option for the Bs -> phi l+ l- decay.
void enable_obs()
Enable all observables' decays sequentially.
void restore_decay_threads(const DecayThreadSnapshot &snapshot)
Restore a previous decay thread snapshot.
std::shared_ptr< Observable > get_obs(Observables id)
Retrieve an observable (public enum).
ObsManager add_obs(Observables id, QCDOrder order, bool add_deps=false)
Add an observable (public enum) to the manager.
ObsManager set_bkll_threads(size_t n_threads)
Set the thread option for the B -> K l+ l- decay.
std::vector< ObservableSelectionSnapshot > snapshot_observable_selection() const
Capture selected observables, bins, orders and dependencies.
Identifies an observable together with a numerical bin.
Dependency container (“ports”) for observable computations.
BinnedObservableId id
Definition ObsManager.h:73
std::unordered_set< ParamId > dependencies
Definition ObsManager.h:75
Container for a computed observable value, optionally binned.
Composite identifier for a single parameter.
Definition ParamID.h:57