5 std::shared_ptr<WilsonBuilder> builder_ptr = std::make_shared<WilsonBuilder>(config);
6 std::shared_ptr<IObsWilsonBuilder> builder = std::make_shared<ObsWilsonBuilder>(builder_ptr);
7 std::shared_ptr<ObsWilsonHelper> wilson_helper = std::make_shared<ObsWilsonHelper>();
10 std::shared_ptr<IObsParameterProxy<ParamId, DataType, std::string, LhaID>> iobspp_sm = std::make_shared<ObsParameterProxy>();
12 std::shared_ptr<IObsParameterProxy<ParamId, DataType, std::string, LhaID>> iobspp_flav = std::make_shared<ObsParameterProxy>(
ParameterType::FLAVOR);
13 std::shared_ptr<IObsQCDProxy> iobs_qcdp = std::make_shared<ObsQCDProxy>();
16 std::shared_ptr<IObsCoreAPI<bool>> iobs_use_marty = std::make_shared<ObsUseMarty>();
18 std::shared_ptr<IWilsonFreezer<WGroupId>> iobs_wfreezer = std::make_shared<WilsonFreezer>(builder);
20 ports = std::make_shared<ObservablePortsConfig>(builder, iobspp_sm, iobspp_flav, iobs_qcdp, iobs_use_marty, iobs_wfreezer, wilson_helper);
22 manager = std::make_shared<ObsManager>(*ports);
26 manager->add_custom_decay(
id, ptr);
31 LOG_ERROR(
"ValueError",
"Cannot register lambda decay", config.
canonical,
"without observables.");
34 std::vector<CustomObservableSpec> specs;
50 "was not newly registered. Reusing an existing mapper entry if it exists."
55 this->ports->iobswb->add_custom_group(custom_group);
56 this->ports->iobs_whelper->mark_built(
58 custom_group.matching_scale,
59 custom_group.hadronic_scale,
65 auto decay = std::make_shared<LambdaDecay>(decay_id, config, *this->ports);
66 this->manager->add_custom_decay(decay_id, decay);
71 this->manager->add_obs(obs_id, config.
order,
false);
72 if (!obs.dependencies.empty()) {
73 this->manager->add_obs_deps(obs_id, obs.dependencies);
83 this->ports->iobswb->add_matching_patch(patch);
92 manager->add_obs(obs, order, add_dependencies);
97 manager->add_obs(obs, order, add_dependencies);
103 bool add_dependencies)
105 manager->add_obs(obs, order, add_dependencies);
110 bool add_dependencies)
112 for (
auto &[k, v] : obss) {
118 for (
auto &[k, v] : obss) {
126 bool add_dependencies,
127 std::pair<double, double> bin)
130 if (manager->is_observable_binned(obs)) {
140 bool add_dependencies,
141 std::pair<double, double> bin)
144 if (manager->is_observable_binned(obs)) {
153 return manager->is_decay_binned(decay);
157 return manager->is_decay_binned(decay);
161 return manager->is_observable_binned(obs);
165 return manager->is_observable_binned(obs);
169 manager->add_obs_dep(obs, pid);
173 manager->add_obs_dep(obs, pid);
177 manager->add_obs_deps(obs, pids);
181 manager->add_obs_deps(obs, pids);
185 return manager->evaluate(obs);
189 return manager->evaluate(obs);
193 return manager->evaluate(obs);
197 manager->remove_obs(
id);
201 manager->remove_obs(
id);
218 return manager->get_obs(
id)->get_exp_val({0,0},
"DEFAULT");
222 return manager->get_obs(
id)->get_exp_val({0,0},
"DEFAULT");
226 return manager->get_obs(
id.s)->get_exp_val(
id.p,
"DEFAULT");
230 return manager->get_obs(
id.obs.s)->get_exp_val(
id.obs.p,
id.experiment);
234 return manager->get_obs(
id)->get_exp_uncertainty({0,0},
"DEFAULT", u_type);
238 return manager->get_obs(
id)->get_exp_uncertainty({0,0},
"DEFAULT", u_type);
242 return manager->get_obs(
id.s)->get_exp_uncertainty(
id.p,
"DEFAULT", u_type);
246 return manager->get_obs(
id.obs.s)->get_exp_uncertainty(
id.obs.p,
id.experiment, u_type);
250 return manager->get_current_obss();
254 auto worker = std::make_shared<ObservableInterface>();
255 auto selection = manager->snapshot_observable_selection();
257 for (
const auto& item : selection) {
259 worker->add_observable(item.id, item.order,
false);
261 worker->add_observable(item.id.s, item.order,
false);
264 if (!item.dependencies.empty()) {
265 worker->add_observable_parameters(item.id.s, item.dependencies);
273 return manager->snapshot_decay_threads();
277 manager->set_all_decay_threads(n_threads);
281 manager->restore_decay_threads(snapshot);
285 return manager->evaluate_all();
298 return manager->get_all_ops_deps(
id);
306 manager->reload_params();
310 manager->enable_obs();
313 manager->set_decay_config(dec, config);
#define LOG_ERROR(type,...)
Macro for logging error messages and terminating the application.
#define LOG_WARN(...)
Macro for logging warning messages.
std::unordered_map< DecayId, size_t > DecayThreadSnapshot
High-level, user-facing entry point to compute flavor observables.
static bool register_custom_with_observables(std::string canonical, std::vector< std::string > aliases, std::vector< CustomObservableSpec > observables)
Register a custom decay and its custom observables in one call.
static std::vector< Observables > get_observables(Decays d)
Legacy static lookup of builtin observables for a builtin decay.
static IdOf< ObservableTag > to_id(Observables e)
Converts an enum value to an IdOf<Tag>.
static IdOf< DecayTag > id_of(std::string_view s)
Resolves a string into an IdOf<Tag> via the registry.
void add_observables(std::map< Observables, QCDOrder > obss, bool add_dependencies=false)
Add multiple observables at once (enum map).
std::vector< BinnedObservableId > get_current_observables()
Return the set of currently registered observables.
void set_bkstarll_threads(size_t n_threads)
Set the thread option for the bkstarll decay.
ObservableInterface()
Construct a ready-to-use observable interface.
bool is_observable_binned(Observables obs) const
Return whether a specific observable requires q² bins.
void add_observable_parameter(Observables obs, ParamId pid)
Manually add a single parameter dependence to an observable (enum API).
void set_all_decay_threads(size_t n_threads)
Set every thread-configurable decay to the same value.
std::shared_ptr< ObservableInterface > clone_for_worker() const
Build a fresh ObservableInterface with the same selected builtin observables.
void set_bkll_threads(size_t n_threads)
Set the thread option for the bkll decay.
double get_param(const std::string &block, LhaID code, ParameterType type)
Read an input parameter in a given parameter space.
DecayThreadSnapshot snapshot_decay_threads() const
Snapshot thread settings for thread-configurable decays.
void set_param(const std::string &block, LhaID code, double value, ParameterType type)
Set an input parameter in a given parameter space.
scalar_t get_exp_uncertainty(Observables id, UncertaintyType u_type=UncertaintyType::COMBINED)
Get experimental uncertainty for an observable (enum API).
void remove_observable(Observables id)
Remove an observable from the manager (enum API).
void set_decay_config(Decays dec, std::any config)
Set configuration for a given decay.
void set_decay_threads(Decays dec, size_t n_threads)
Set the thread option for any decay that supports it.
void add_custom_decay(DecayId id, std::shared_ptr< DecayParent > ptr)
Register a custom decay implementation.
std::vector< ObservableValue > compute_observable(Observables obs) const
Compute a theory prediction for an observable (enum API).
void enable_obs()
Force enabling/re-enabling currently registered observables.
void restore_decay_threads(const DecayThreadSnapshot &snapshot)
Restore a previous decay-thread snapshot.
std::map< ObservableId, std::vector< ObservableValue > > compute_all()
Compute all currently registered observables.
ObservablePortsConfig & get_ports()
Access the underlying ports configuration (advanced use).
ObservableInterface & add_observable(Observables obs, QCDOrder order, bool add_dependencies=false)
Add an observable to the manager (enum API).
ObservableInterface & addMatchingPatch(const WilsonMatchingPatch &patch)
Camel-case alias for add_matching_patch.
ObservableInterface & add_lambda_decay(LambdaDecayConfig config, bool add_observables=true)
Register a complete custom decay backed by user lambdas.
void add_observable_parameters(Observables obs, std::unordered_set< ParamId > pids)
Manually add multiple parameter dependences to an observable (enum API).
void set_bsphi_threads(size_t n_threads)
Set the thread option for the bsphi decay.
ObservableInterface & add_matching_patch(const WilsonMatchingPatch &patch)
Add an additive Wilson matching patch through the observable layer.
bool is_decay_binned(Decays decay) const
Return whether this decay has at least one observable requiring q² bins.
std::unordered_set< ParamId > get_all_ops_deps(ObservableId id)
Retrieve the full allow-list of parameter dependences for an observable (id API).
void 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.
scalar_t get_exp_value(Observables id)
Get experimental central value for an observable (enum API).
void remove_observables(std::unordered_set< Observables > ids)
Remove several observables (enum set).
static std::shared_ptr< Parameters > GetInstance(ParameterType id=ParameterType::SM)
Returns the singleton-like repository for a given parameter type.
Identifies an observable together with a numerical bin.
Small value object used to register a custom decay with observables.
std::string canonical
Canonical observable name.
Full runtime definition of a custom decay and its observables.
std::vector< CustomWilsonGroupConfig > custom_wilson_groups
Custom Wilson groups to install before this decay is evaluated.
std::vector< LambdaObservableConfig > observables
Custom observables owned by this decay. Must not be empty.
QCDOrder order
Requested QCD order for the decay.
std::vector< std::string > aliases
Optional alternative decay names accepted by DecayMapper::id_of().
std::string canonical
Canonical decay name, for example "MY_DECAY".
Represents an identifier of a LHA element, possibly containing several sub-ids.
Dependency container (“ports”) for observable computations.
Container for a computed observable value, optionally binned.
Composite identifier for a single parameter.
Configuration for building sets of Wilson coefficients.