9 auto append_unique = [&hooks](
const std::vector<SetupHook>& src) {
10 for (
const auto& hook : src) {
12 const bool already_present = target && std::any_of(
13 hooks.begin(), hooks.end(),
15 const auto* existing_target = existing.target<void(*)(const BuildContext&, CoefficientGroup&)>();
16 return existing_target && (*existing_target == *target);
18 if (!already_present) {
19 hooks.push_back(hook);
26 append_unique(it->second);
30 if (
auto it =
setup.find(model); it !=
setup.end()) {
31 append_unique(it->second);
38 static std::unordered_map<WGroupId, GroupDefinition> kCustomDefs;
43 kCustomDefs[def.
id] = def;
46 return kCustomDefs.find(
id) != kCustomDefs.end();
49 auto it = kCustomDefs.find(
id);
50 if (it == kCustomDefs.end())
throw std::runtime_error(
"Unknown custom WGroupId");
70 throw std::runtime_error(
"Unknown built-in WGroup");
Declarative registry describing Wilson coefficient groups, their sources, and setup hooks.
Polymorphic container of WilsonCoefficient objects representing a coefficient group.
static std::optional< WGroup > enum_of(const IdOf< WGroupTag > &id)
Attempts to recover the enum value associated with an identifier.
Returns an uppercase copy of the input string.
Registry/factory of built-in and custom GroupDefinition objects.
const GroupDefinition & CC_bu()
bool has_custom(WGroupId id)
Checks if a custom group definition is registered.
const GroupDefinition & BPrime()
const GroupDefinition & B()
Built-in group definition accessors.
const GroupDefinition & CC_bc()
const GroupDefinition & BScalar()
const GroupDefinition & CC_cs()
const GroupDefinition & CC_cd()
const GroupDefinition & K()
const GroupDefinition & get_custom(WGroupId id)
Retrieves a previously registered custom group definition.
const GroupDefinition & CC_du()
void register_custom(const GroupDefinition &def)
Registers a custom group definition at runtime.
const GroupDefinition & MesonMixing()
const GroupDefinition & get(WGroupId g)
Returns the definition for a given group id.
const GroupDefinition & CC_su()
Build-time context passed to group setup hooks.
Declarative description of a Wilson coefficient group.
WGroupId id
Identifier for this group.
std::unordered_map< Model, std::vector< SetupHook > > setup
Model-specific setup hooks to run during group construction.
std::vector< SetupHook > hooks_for(Model model) const
Returns hooks applicable to model, including common hooks and the explicit Marty -> SM compatibility ...
std::function< void(const BuildContext &, CoefficientGroup &)> SetupHook
Setup hook signature.
std::vector< SetupHook > common_setup
Setup hooks to run for every model/backend during group construction.