Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
DecayMapper Class Reference

Mapper for decay names, dynamic ids and observable membership. More...

#include <decay_ids.hpp>

Inheritance diagram for DecayMapper:
Collaboration diagram for DecayMapper:

Public Types

using Base = GenericMapperWithExt< DecayTag, Decays, LhaID, std::hash< LhaID >, decays_mapping, decay_external_mapping >
 

Static Public Member Functions

static bool register_custom (std::string canonical, std::vector< std::string > aliases={}, std::optional< LhaID > ext=std::nullopt)=delete
 Disabled low-level decay registration.
 
static std::vector< Observablesget_observables (Decays d)
 Legacy static lookup of builtin observables for a builtin decay.
 
static std::vector< ObservableIdget_observable_ids (Decays d)
 Convert builtin observables of a builtin decay to dynamic ids.
 
static std::vector< ObservableIdget_observables (const DecayId &d)
 Dynamic lookup of observables attached to a decay id.
 
static std::vector< ObservableIdget_observables (std::string_view d)
 Dynamic lookup of observables attached to a decay resolved by name.
 
static bool has_observables (const DecayId &d)
 Test whether a decay has at least one observable.
 
static void require_observables (const DecayId &d)
 Throw if a decay has no observable.
 
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 Decays get_decay (Observables obs)
 Legacy static lookup of the builtin decay owning a builtin observable.
 
static const std::unordered_map< ObservableId, DecayId > & observable_to_decay ()
 Static cache mapping builtin observable ids to builtin decay ids.
 
static std::optional< DecayIdget_decay_id (const ObservableId &obs)
 Return the parent decay id of an observable id.
 
static std::optional< DecayIdget_decay_id (Observables obs)
 Return the parent decay id of a builtin observable enum.
 
static DecayId get_decay_id_or_throw (const ObservableId &obs)
 Throwing variant of get_decay_id().
 
- Static Public Member Functions inherited from GenericMapperWithExt< DecayTag, Decays, LhaID, std::hash< LhaID >, decays_mapping, decay_external_mapping >
static void init_builtins ()
 Explicitly initializes builtin entries.
 
static std::vector< std::string > get_str ()
 Returns the list of builtin string names from MapFn().
 
static std::vector< Decaysget_enum ()
 Returns the list of builtin enum values.
 
static std::vector< std::string > get_str_all ()
 Returns all known names (builtin + custom).
 
static Decays enum_elt_legacy (std::string_view s)
 Legacy enum lookup using only the static MapFn() table.
 
static IdOf< DecayTagid_of (std::string_view s)
 Resolves a string into an IdOf<Tag> via the registry.
 
static IdOf< DecayTagenum_elt (std::string_view s)
 Alias for id_of(), kept for compatibility.
 
static std::optional< IdOf< DecayTag > > from_external (const LhaID &k)
 Resolves an external key into an identifier.
 
static std::optional< LhaIDexternal_of (const IdOf< DecayTag > &id)
 Returns the external key associated with a given identifier.
 
static bool register_custom (std::string canonical, std::vector< std::string > aliases={}, std::optional< LhaID > ext=std::nullopt)
 Registers a custom entry with optional external key.
 
static bool set_external (const IdOf< DecayTag > &id, const LhaID &k)
 Sets or updates the external key of an existing identifier.
 
static std::vector< IdOf< DecayTag > > list_all ()
 Lists all distinct identifiers currently registered.
 
static std::string str (const IdOf< DecayTag > &id)
 Returns the string representation of an identifier.
 
static std::string str (Decays e)
 Returns the builtin string name of an enum value.
 
static IdOf< DecayTagto_id (Decays e)
 Converts an enum value to an IdOf<Tag>.
 
static std::optional< Decaysenum_of (const IdOf< DecayTag > &id)
 Attempts to recover the enum value associated with an identifier.
 

Detailed Description

Mapper for decay names, dynamic ids and observable membership.

DecayMapper resolves names to DecayId through the dynamic registry and provides both legacy static accessors and dynamic DecayId-based accessors.

@important For dynamic/user-facing code, prefer DecayId and ObservableId. Use Decays/Observables only when a builtin enum value is explicitly required.

Definition at line 79 of file decay_ids.hpp.

Member Typedef Documentation

◆ Base

Member Function Documentation

◆ get_decay()

static Decays DecayMapper::get_decay ( Observables  obs)
inlinestatic

Legacy static lookup of the builtin decay owning a builtin observable.

Parameters
obsBuiltin observable enum.
Returns
Builtin parent decay enum.
Exceptions
std::runtime_errorif obs is not mapped statically.

Definition at line 293 of file decay_ids.hpp.

◆ get_decay_id() [1/2]

static std::optional< DecayId > DecayMapper::get_decay_id ( const ObservableId obs)
inlinestatic

Return the parent decay id of an observable id.

Resolution order:

  1. runtime graph (DecayGraph) for custom links,
  2. static cache built from builtin mappings.
Parameters
obsObservable identifier.
Returns
Parent decay id, if known.

Definition at line 333 of file decay_ids.hpp.

◆ get_decay_id() [2/2]

static std::optional< DecayId > DecayMapper::get_decay_id ( Observables  obs)
inlinestatic

Return the parent decay id of a builtin observable enum.

Definition at line 349 of file decay_ids.hpp.

◆ get_decay_id_or_throw()

static DecayId DecayMapper::get_decay_id_or_throw ( const ObservableId obs)
inlinestatic

Throwing variant of get_decay_id().

Parameters
obsObservable identifier.
Returns
Parent decay id.
Exceptions
std::runtime_errorif obs has no parent decay.

Definition at line 361 of file decay_ids.hpp.

◆ get_observable_ids()

static std::vector< ObservableId > DecayMapper::get_observable_ids ( Decays  d)
inlinestatic

Convert builtin observables of a builtin decay to dynamic ids.

Parameters
dBuiltin decay enum value.
Returns
Observable ids corresponding to the builtin observables.

Definition at line 139 of file decay_ids.hpp.

◆ get_observables() [1/3]

static std::vector< ObservableId > DecayMapper::get_observables ( const DecayId d)
inlinestatic

Dynamic lookup of observables attached to a decay id.

This merges:

  • runtime links stored in DecayGraph,
  • static builtin links if d corresponds to a builtin Decays enum.

Duplicates are removed while preserving insertion order.

Parameters
dDynamic decay identifier.
Returns
Observable ids attached to d.
Exceptions
std::runtime_errorif d has no observable.

Definition at line 165 of file decay_ids.hpp.

◆ get_observables() [2/3]

static std::vector< Observables > DecayMapper::get_observables ( Decays  d)
inlinestatic

Legacy static lookup of builtin observables for a builtin decay.

Parameters
dBuiltin decay enum value.
Returns
Builtin observable enum values attached to d.
Exceptions
std::out_of_rangeif d is not present in the static map.

Definition at line 129 of file decay_ids.hpp.

◆ get_observables() [3/3]

static std::vector< ObservableId > DecayMapper::get_observables ( std::string_view  d)
inlinestatic

Dynamic lookup of observables attached to a decay resolved by name.

Parameters
dDecay name or alias.
Returns
Observable ids attached to the resolved decay.

Definition at line 198 of file decay_ids.hpp.

◆ has_observables()

static bool DecayMapper::has_observables ( const DecayId d)
inlinestatic

Test whether a decay has at least one observable.

This checks both the runtime graph and the builtin static mapping.

Parameters
dDynamic decay identifier.
Returns
true if d has at least one observable.

Definition at line 210 of file decay_ids.hpp.

◆ observable_to_decay()

static const std::unordered_map< ObservableId, DecayId > & DecayMapper::observable_to_decay ( )
inlinestatic

Static cache mapping builtin observable ids to builtin decay ids.

Returns
Map built once from decay_observable_mapping().

Definition at line 307 of file decay_ids.hpp.

◆ register_custom()

static bool DecayMapper::register_custom ( std::string  canonical,
std::vector< std::string >  aliases = {},
std::optional< LhaID ext = std::nullopt 
)
staticdelete

Disabled low-level decay registration.

A decay without observables violates the public invariant of the dynamic mapper layer. Use register_custom_with_observables() to create a custom decay together with at least one custom observable.

◆ register_custom_with_observables()

static bool DecayMapper::register_custom_with_observables ( std::string  canonical,
std::vector< std::string >  aliases,
std::vector< CustomObservableSpec observables 
)
inlinestatic

Register a custom decay and its custom observables in one call.

This helper enforces the invariant that a custom decay must have at least one observable. It first registers the decay, then registers every custom observable under that decay through ObservableMapper::register_custom().

Parameters
canonicalCanonical decay name.
aliasesOptional decay aliases.
observablesCustom observable definitions to attach.
Returns
true if the decay was registered and observable registrations were attempted successfully; false if the decay registration is blocked by a builtin symbol.
Exceptions
std::invalid_argumentif observables is empty.
std::runtime_errorif one observable cannot be linked.
Note
Registration is not transactional because the underlying registry has no unregister operation. Avoid reusing canonical names on failure.

Definition at line 256 of file decay_ids.hpp.

◆ require_observables()

static void DecayMapper::require_observables ( const DecayId d)
inlinestatic

Throw if a decay has no observable.

Parameters
dDynamic decay identifier.
Exceptions
std::runtime_errorif d has no observable.

Definition at line 230 of file decay_ids.hpp.


The documentation for this class was generated from the following file: