Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
DecayParent.h
Go to the documentation of this file.
1#ifndef DECAYPARENT_H
2#define DECAYPARENT_H
3
4#include <map>
5#include <string>
6#include <chrono>
7#include <any>
8#include <type_traits>
9
10#include "Include.h"
11#include "WilsonInterface.h"
12#include "ObsWilsonBuilder.h"
13#include "ObsWilsonProxy.h"
14#include "ObsWilsonHelper.h"
15#include "Math.h"
16#include "Configs.h"
17#include "DefaultConfig.h"
18#include "ObservableValue.h"
19#include "ObsParameterProxy.h"
20#include "ObsPortsConfig.h"
21
22using std::chrono::high_resolution_clock;
23using std::chrono::duration;
24
88protected:
91
94
96 std::shared_ptr<IObsWilsonBuilder> w_builder;
97
99 std::shared_ptr<IObsWilsonProxy> w_proxy;
100
102 std::shared_ptr<IObsCoreAPI<bool>> use_marty;
103
105 std::shared_ptr<IObsParameterProxy<ParamId, DataType, std::string, LhaID>> p;
106
108 std::shared_ptr<IObsQCDProxy> iobs_qcdp;
109
111 std::shared_ptr<IWilsonFreezer<WGroupId>> iobs_wfreezer;
112
114 std::shared_ptr<ObsWilsonHelper> w_helper;
115
118
120 bool enabled {false};
121
123 bool binned {false};
124
127
129 std::optional<std::vector<std::pair<double, double>>> bins;
130
140 QCDOrder check_max_order(QCDOrder order) const;
141
142public:
143 virtual ~DecayParent() = default;
144
157 DecayParent(DecayId custom_id, double matching_scale, double hadronic_scale, QCDOrder order, ObservablePortsConfig& ports);
158
167 void bind_wilson_builder(std::shared_ptr<IObsWilsonBuilder>& wilson_builder);
168
182 void enable();
183
190 void disable();
191
203 void set_order(QCDOrder new_order);
204
213 virtual void load_params() = 0;
214
223 virtual std::vector<ObservableValue> compute_observable(Observables obs) = 0;
224
231 virtual std::vector<ObservableValue> compute_observable(ObservableId obs) = 0;
232
243 virtual void set_config(std::any cfg) = 0;
244
253 virtual std::any get_config() const { return {}; }
254
264 virtual void set_n_threads(size_t n_threads);
265
271 virtual size_t get_n_threads() const;
272
276 virtual bool supports_thread_config() const;
277
283 void set_bins(std::vector<std::pair<double, double>> new_bins);
284
290 void add_bin(std::pair<double, double> new_bin);
291
295 std::optional<std::vector<std::pair<double, double>>> get_bins();
296
300 DecayId get_id() { return id; };
301
305 QCDOrder get_order() const { return w_config.order; }
306
315 bool is_enabled() const { return enabled; }
316
324 bool is_binned() const { return binned; }
325
332 virtual bool is_observable_binned(ObservableId) const { return binned; }
333
335 virtual bool is_observable_binned(Observables obs) const {
337 }
338};
339
362template<typename T>
364public:
374 DecayParentConfigurable(DecayId id, double matching_scale, double hadronic_scale,
376 : DecayParent(id, matching_scale, hadronic_scale, order, ports)
377 {}
378
391 void set_config(std::any cfg) final override {
392 if (auto p = std::any_cast<T>(&cfg)) { set_config_spe(*p); return; }
393 if (auto p = std::any_cast<std::add_const_t<T>>(&cfg)) { set_config_spe(*p); return; }
394 throw std::bad_any_cast{};
395 }
396
402 virtual void set_config_spe(T config) = 0;
403};
404
412template<>
414public:
415 DecayParentConfigurable(DecayId id, double matching_scale, double hadronic_scale,
417 : DecayParent(id, matching_scale, hadronic_scale, order, ports)
418 {}
419
421 void set_config(std::any) final override {
422
423 }
424};
425
426#endif // DECAYPARENT_H
Configuration structures used to control Wilson coefficient computations, strong coupling evaluations...
Observables
Definition GeneralEnum.h:4
QCDOrder
Read-only proxy to access parameters needed by observable computations.
Observable-side builder for Wilson coefficient services.
Per-manager helper that manages the Wilson group lifecycle for observable computations.
Observable-facing proxy to query Wilson coefficients.
Typed configuration adapter for DecayParent using std::any.
void set_config(std::any cfg) final override
Type-erased config setter (final).
DecayParentConfigurable(DecayId id, double matching_scale, double hadronic_scale, QCDOrder order, ObservablePortsConfig &ports)
Construct a configurable decay module.
virtual void set_config_spe(T config)=0
Strongly-typed configuration setter to implement in derived classes.
Abstract base class for a decay/observable module.
Definition DecayParent.h:87
DecayId id
Unique decay identifier.
bool enabled
Whether the decay is enabled (i.e. Wilson groups built and parameters loaded).
virtual std::any get_config() const
Return the current decay configuration when the decay has one.
virtual void load_params()=0
Load and cache parameters needed by this decay.
bool binned
Whether this decay requires q² bins before its observables can be computed.
WilsonBuildConfig w_config
Wilson build configuration used when enabling this decay (scales, order, groups).
virtual std::vector< ObservableValue > compute_observable(Observables obs)=0
Compute an observable given a public observable enum.
QCDOrder get_order() const
Return the currently configured QCD order for this decay.
std::shared_ptr< IWilsonFreezer< WGroupId > > iobs_wfreezer
Freezer to freeze/unfreeze Wilson blocks when they are not needed by active decays.
virtual void set_config(std::any cfg)=0
Set a configuration blob for this decay.
ObservablePortsConfig & ports
Reference to the ports/configuration wiring this decay to the framework.
Definition DecayParent.h:93
bool is_enabled() const
Return whether the decay has already been enabled.
virtual void set_n_threads(size_t n_threads)
Set the number of worker threads used by decays that support parallel cache filling.
std::optional< std::vector< std::pair< double, double > > > bins
Optional q^2 bins.
std::shared_ptr< IObsCoreAPI< bool > > use_marty
Port exposing whether the MARTY backend is active.
std::shared_ptr< IObsParameterProxy< ParamId, DataType, std::string, LhaID > > p
Parameter proxy for SM-like quantities used by the decay (may be SM/BSM depending on wiring).
void add_bin(std::pair< double, double > new_bin)
Adds a bin to the observables related to this decay.
void enable()
Enable the decay module (build Wilson groups and load parameters).
QCDOrder max_order
Maximum QCD order supported by this decay module (default: LO).
Definition DecayParent.h:90
void set_bins(std::vector< std::pair< double, double > > new_bins)
Set the binning for the observables related to this decay.
virtual size_t get_n_threads() const
Return the currently configured worker-thread count.
void disable()
Disable the decay module.
void bind_wilson_builder(std::shared_ptr< IObsWilsonBuilder > &wilson_builder)
Bind a Wilson builder to this decay.
virtual std::vector< ObservableValue > compute_observable(ObservableId obs)=0
Compute an observable given an internal observable identifier.
virtual bool is_observable_binned(ObservableId) const
Return whether one observable of this decay requires q² bins.
void set_order(QCDOrder new_order)
Set the QCD order for this decay (one-shot policy).
bool is_binned() const
Return whether this decay has at least one observable requiring q² bins.
virtual ~DecayParent()=default
virtual bool supports_thread_config() const
Whether this decay supports runtime thread configuration.
std::shared_ptr< IObsWilsonProxy > w_proxy
Wilson proxy used at compute-time to query coefficients (matching/run).
Definition DecayParent.h:99
std::shared_ptr< IObsQCDProxy > iobs_qcdp
QCD proxy (alpha_s, running masses, constants...).
std::shared_ptr< ObsWilsonHelper > w_helper
Per-manager Wilson lifecycle helper.
DecayId get_id()
Return the decay identifier.
std::optional< std::vector< std::pair< double, double > > > get_bins()
Returns the current binning of the decay.
QCDOrder check_max_order(QCDOrder order) const
Clamp a requested QCD order to this decay's supported maximum.
virtual bool is_observable_binned(Observables obs) const
Convenience overload for public observable enum ids.
std::shared_ptr< IObsWilsonBuilder > w_builder
Wilson builder used to build/add Wilson groups for this decay.
Definition DecayParent.h:96
static IdOf< ObservableTag > to_id(Observables e)
Converts an enum value to an IdOf<Tag>.
double T(double x)
Wilson coefficient T(x).
DecayParentConfigurable(DecayId id, double matching_scale, double hadronic_scale, QCDOrder order, ObservablePortsConfig &ports)
void set_config(std::any) final override
No-op configuration setter for default config.
Dependency container (“ports”) for observable computations.
Configuration for building sets of Wilson coefficients.
Definition Configs.h:32
QCDOrder order
Perturbative QCD order used for the evolution and matching of Wilson coefficients....
Definition Configs.h:54