8#include <unordered_map>
9#include <unordered_set>
67 std::optional<LhaID>
flha = std::nullopt;
90 std::string canonical_,
110 std::string canonical_,
220 LOG_ERROR(
"ValueError",
"Lambda observable", obs.canonical,
"has no compute function.");
246 auto it = computers_.find(obs);
247 if (it == computers_.end()) {
251 return it->second(*
this, obs);
258 runtime_config_ = std::move(cfg);
260 config_.
configure(*
this, runtime_config_);
276 LOG_ERROR(
"LogicError",
"Wilson proxy is not available before LambdaDecay is enabled.");
284 LOG_ERROR(
"LogicError",
"Wilson proxy is not available before LambdaDecay is enabled.");
306 std::any runtime_config_;
307 std::unordered_map<ObservableId, LambdaObservableComputer> computers_;
311 std::string canonical_,
317 std::vector<ObservableValue> values;
318 auto bins = ctx.current_bins();
319 if (!bins.has_value() || bins->empty()) {
320 values.emplace_back(
id, fn(ctx, {0.0, 0.0}, id));
324 values.reserve(bins->size());
325 for (
const auto& bin : *bins) {
326 values.emplace_back(
id, fn(ctx, bin,
id), bin);
High-level configuration helpers for user-defined Wilson groups and coefficients.
Base class for observable/decay computation modules.
std::function< void(LambdaDecay &, const std::any &)> LambdaDecayConfigureHook
Optional hook called from LambdaDecay::set_config().
std::function< std::vector< ObservableValue >(LambdaDecay &, ObservableId)> LambdaObservableComputer
User function used to compute a runtime/custom observable.
std::function< void(LambdaDecay &)> LambdaDecayLoadHook
Optional hook called when the lambda decay is enabled/reloaded.
#define LOG_ERROR(type,...)
Macro for logging error messages and terminating the application.
Abstract base class for a decay/observable module.
DecayId id
Unique decay identifier.
WilsonBuildConfig w_config
Wilson build configuration used when enabling this decay (scales, order, groups).
ObservablePortsConfig & ports
Reference to the ports/configuration wiring this decay to the framework.
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).
QCDOrder max_order
Maximum QCD order supported by this decay module (default: LO).
std::shared_ptr< IObsWilsonProxy > w_proxy
Wilson proxy used at compute-time to query coefficients (matching/run).
std::shared_ptr< IObsQCDProxy > iobs_qcdp
QCD proxy (alpha_s, running masses, constants...).
std::optional< std::vector< std::pair< double, double > > > get_bins()
Returns the current binning of the decay.
static IdOf< ObservableTag > to_id(Observables e)
Converts an enum value to an IdOf<Tag>.
static IdOf< ObservableTag > id_of(std::string_view s)
Resolves a string into an IdOf<Tag> via the registry.
static std::string str(const IdOf< DecayTag > &id)
Returns the string representation of an identifier.
DecayParent implementation backed by user-provided lambdas.
ObservablePortsConfig & observable_ports()
Access all observable ports for advanced use.
bool has_user_config() const
True if set_config() has received a payload.
LambdaDecay(DecayId id, LambdaDecayConfig config, ObservablePortsConfig &ports)
Construct a lambda-backed decay from a dynamic id and config.
IObsWilsonProxy & W()
Access the Wilson proxy after enable().
void set_config(std::any cfg) override
Store and optionally handle a type-erased user config.
std::vector< ObservableValue > compute_observable(Observables obs) override
Compute a builtin observable by converting it to ObservableId.
IObsQCDProxy & QCD()
Access the QCD proxy used by decays.
std::optional< std::vector< std::pair< double, double > > > current_bins()
Return the current optional bin list.
IObsParameterProxy< ParamId, DataType, std::string, LhaID > & SM()
Access the SM/BSM parameter proxy used by decays.
std::vector< ObservableValue > compute_observable(ObservableId obs) override
Compute a runtime/custom observable by dispatching to its lambda.
const std::any & user_config() const
Access the last std::any payload passed to set_config().
void load_params() override
Run the user-defined loading/cache hook, if any.
const LambdaDecayConfig & config() const
Access the immutable LambdaDecayConfig.
std::shared_ptr< IObsWilsonProxy > wilson_proxy()
Access the Wilson proxy as a shared pointer after enable().
IObsParameterProxy< ParamId, DataType, std::string, LhaID > & FLAVOR()
Access the FLAVOR parameter proxy from the ports configuration.
Non-templated façade over the project mapper families.
Hash specialization for SymbolId<Tag>.
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.
double matching_scale
Matching scale used by the decay's Wilson build config.
QCDOrder max_order
Maximum QCD order supported by this custom decay.
QCDOrder order
Requested QCD order for the decay.
bool propagate_custom_wilson_dependencies
Propagate custom-Wilson matching dependencies to every observable.
std::vector< std::string > aliases
Optional alternative decay names accepted by DecayMapper::id_of().
LambdaDecayConfigureHook configure
Optional type-erased configuration hook called by LambdaDecay::set_config().
LambdaDecayLoadHook load_params
Optional cache/loading hook called by LambdaDecay::load_params().
double hadronic_scale
Hadronic scale used by the decay's Wilson build config.
std::unordered_set< WGroupId > wilson_groups
Builtin or already-registered Wilson groups needed by the decay.
std::string canonical
Canonical decay name, for example "MY_DECAY".
Registration and compute function for one runtime/custom observable.
std::unordered_set< ParamId > dependencies
Optional dependency list used by scans/profilers/likelihood tooling.
LambdaObservableConfig(std::string canonical_, LambdaObservableComputer compute_)
Construct a custom observable from a vector-valued compute lambda.
LambdaObservableConfig()=default
static LambdaObservableConfig binned_scalar(std::string canonical_, std::function< double(LambdaDecay &, std::pair< double, double >, ObservableId)> compute_)
Convenience factory for a scalar binned observable.
std::string canonical
Canonical observable name, for example "BR_MY_DECAY".
static LambdaObservableConfig scalar(std::string canonical_, std::function< double(LambdaDecay &, ObservableId)> compute_)
Convenience factory for a scalar, unbinned observable.
std::optional< LhaID > flha
Optional FLHA id used for experimental values / binned encodings.
LambdaObservableComputer compute
User-provided observable computation.
std::vector< std::string > aliases
Optional alternative names accepted by ObservableMapper::id_of().
Dependency container (“ports”) for observable computations.
std::shared_ptr< IObsParameterProxy< ParamId, DataType, std::string, LhaID > > iobspp_flav
Parameter proxy for flavor-specific parameters.
Container for a computed observable value, optionally binned.
std::unordered_set< WGroupId > groups
Set of Wilson operator group identifiers to be included in the build.