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

High-level mapper for observable names, FLHA ids and parent decays. More...

#include <observable_ids.hpp>

Inheritance diagram for ObservableMapper:
Collaboration diagram for ObservableMapper:

Public Types

using Base = GenericMapperWithExt< ObservableTag, Observables, LhaID, std::hash< LhaID >, observable_mapping, observable_flha_mapping >
 

Static Public Member Functions

static Observables enum_elt_legacy (std::string_view s)
 Legacy builtin-only lookup from string to enum.
 
static Observables enum_elt (const LhaID &ext)
 Legacy builtin-only lookup from FLHA id to enum.
 
static std::optional< ObservableIdfrom_flha (const LhaID &ext)
 Resolve a FLHA id to a dynamic observable id.
 
static std::optional< LhaIDflha_of (const ObservableId &id)
 Return the FLHA id attached to an observable id, if any.
 
static std::optional< BinnedObservableIdfrom_binned_flha (const LhaID &ext)
 Decode a binned FLHA id into a binned observable id.
 
static std::optional< LhaIDbinned_flha_of (const BinnedObservableId &id)
 Encode a binned observable id into its FLHA representation.
 
static BinnedObservableId binned_from_flha (const LhaID &ext)
 Throwing variant of from_binned_flha().
 
static LhaID flha (const Observables &id)
 Return the FLHA id associated with a builtin enum value.
 
static bool register_custom (const std::string &canonical, std::vector< std::string > aliases, std::optional< LhaID > ext, const DecayId &parent_decay)
 Register a custom observable and attach it to a parent decay.
 
static bool register_custom (const std::string &canonical, std::vector< std::string > aliases, std::optional< LhaID > ext, Decays parent_decay_enum)
 Register a custom observable under a builtin parent decay.
 
static bool register_custom (const std::string &canonical, std::vector< std::string > aliases, std::optional< LhaID > ext, std::string_view parent_decay_str)
 Register a custom observable under a parent decay resolved by name.
 
static LhaID flha (const ObservableId &id)
 Return the FLHA id associated with an observable id.
 
static LhaID flha (const BinnedObservableId &id)
 Return the binned FLHA id associated with a binned observable id.
 
- Static Public Member Functions inherited from GenericMapperWithExt< ObservableTag, Observables, LhaID, std::hash< LhaID >, observable_mapping, observable_flha_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< Observablesget_enum ()
 Returns the list of builtin enum values.
 
static std::vector< std::string > get_str_all ()
 Returns all known names (builtin + custom).
 
static Observables enum_elt_legacy (std::string_view s)
 Legacy enum lookup using only the static MapFn() table.
 
static IdOf< ObservableTagid_of (std::string_view s)
 Resolves a string into an IdOf<Tag> via the registry.
 
static IdOf< ObservableTagenum_elt (std::string_view s)
 Alias for id_of(), kept for compatibility.
 
static std::optional< IdOf< ObservableTag > > from_external (const LhaID &k)
 Resolves an external key into an identifier.
 
static std::optional< LhaIDexternal_of (const IdOf< ObservableTag > &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< ObservableTag > &id, const LhaID &k)
 Sets or updates the external key of an existing identifier.
 
static std::vector< IdOf< ObservableTag > > list_all ()
 Lists all distinct identifiers currently registered.
 
static std::string str (const IdOf< ObservableTag > &id)
 Returns the string representation of an identifier.
 
static std::string str (Observables e)
 Returns the builtin string name of an enum value.
 
static IdOf< ObservableTagto_id (Observables e)
 Converts an enum value to an IdOf<Tag>.
 
static std::optional< Observablesenum_of (const IdOf< ObservableTag > &id)
 Attempts to recover the enum value associated with an identifier.
 

Detailed Description

High-level mapper for observable names, FLHA ids and parent decays.

ObservableMapper combines:

@important A custom observable must always be registered with a parent decay. This is enforced by the public register_custom() overloads below.

Definition at line 50 of file observable_ids.hpp.

Member Typedef Documentation

◆ Base

Member Function Documentation

◆ binned_flha_of()

std::optional< LhaID > ObservableMapper::binned_flha_of ( const BinnedObservableId id)
static

Encode a binned observable id into its FLHA representation.

Parameters
idBinned observable identifier.
Returns
Encoded FLHA id, or nullopt if the observable has no FLHA id.

Definition at line 85 of file observable_ids.cpp.

◆ binned_from_flha()

BinnedObservableId ObservableMapper::binned_from_flha ( const LhaID ext)
static

Throwing variant of from_binned_flha().

Parameters
extBinned FLHA identifier.
Returns
Decoded binned observable id.
Exceptions
std::runtime_errorif ext cannot be decoded.

Definition at line 93 of file observable_ids.cpp.

◆ enum_elt()

Observables ObservableMapper::enum_elt ( const LhaID ext)
static

Legacy builtin-only lookup from FLHA id to enum.

This first resolves the FLHA id to an ObservableId, then attempts to recover the corresponding builtin enum. Custom observables with a FLHA id can be resolved through from_flha() but cannot necessarily be converted to Observables.

Parameters
extFLHA identifier.
Returns
Matching builtin enum value.
Exceptions
std::out_of_rangeif ext is unknown or points to a custom id.

Definition at line 47 of file observable_ids.cpp.

◆ enum_elt_legacy()

Observables ObservableMapper::enum_elt_legacy ( std::string_view  s)
static

Legacy builtin-only lookup from string to enum.

This function deliberately ignores custom observables because a custom observable cannot be represented by the static Observables enum. Use id_of() for all dynamic/user-facing lookup.

Parameters
sBuiltin observable name or alias present in observable_mapping().
Returns
Matching builtin enum value.
Exceptions
std::out_of_rangeif s is not a builtin observable.

Definition at line 35 of file observable_ids.cpp.

◆ flha() [1/3]

LhaID ObservableMapper::flha ( const BinnedObservableId id)
static

Return the binned FLHA id associated with a binned observable id.

Parameters
idBinned observable id.
Returns
Binned FLHA id.
Exceptions
std::runtime_errorif encoding fails.

Definition at line 163 of file observable_ids.cpp.

◆ flha() [2/3]

LhaID ObservableMapper::flha ( const ObservableId id)
static

Return the FLHA id associated with an observable id.

Parameters
idObservable id.
Returns
FLHA id.
Exceptions
std::runtime_errorif id has no FLHA id.

Definition at line 155 of file observable_ids.cpp.

◆ flha() [3/3]

LhaID ObservableMapper::flha ( const Observables id)
static

Return the FLHA id associated with a builtin enum value.

Parameters
idBuiltin observable enum.
Returns
FLHA id from observable_flha_mapping().
Exceptions
std::out_of_rangeif id has no static FLHA entry.

Definition at line 101 of file observable_ids.cpp.

◆ flha_of()

std::optional< LhaID > ObservableMapper::flha_of ( const ObservableId id)
static

Return the FLHA id attached to an observable id, if any.

Parameters
idObservable identifier.
Returns
FLHA id if id has one.

Definition at line 73 of file observable_ids.cpp.

◆ from_binned_flha()

std::optional< BinnedObservableId > ObservableMapper::from_binned_flha ( const LhaID ext)
static

Decode a binned FLHA id into a binned observable id.

Binned FLHA ids are normal observable FLHA ids where six integer fields encoding the two bin boundaries are inserted after the first two fields.

Parameters
extBinned FLHA identifier.
Returns
Decoded binned observable id, or nullopt if decoding fails.

Definition at line 77 of file observable_ids.cpp.

◆ from_flha()

std::optional< ObservableId > ObservableMapper::from_flha ( const LhaID ext)
static

Resolve a FLHA id to a dynamic observable id.

The canonical v1.0.2 polarization pattern is 92ij. For input compatibility, the unambiguous v1.0.0–v1.0.1 polarization identifiers 92015 and 921423 are accepted and translated to 9212 and 9221, respectively. Output always uses the canonical identifiers.

Parameters
extFLHA identifier.
Returns
Observable id if the FLHA id is known.

Definition at line 61 of file observable_ids.cpp.

◆ register_custom() [1/3]

bool ObservableMapper::register_custom ( const std::string &  canonical,
std::vector< std::string >  aliases,
std::optional< LhaID ext,
const DecayId parent_decay 
)
static

Register a custom observable and attach it to a parent decay.

Parameters
canonicalCanonical observable name.
aliasesCase-insensitive aliases for lookup.
extOptional FLHA id.
parent_decayParent decay id. It must already be registered, either as builtin or custom.
Returns
true on success, false if registration is blocked by a builtin.
Exceptions
std::runtime_errorif parent_decay is unknown.
std::runtime_errorif the observable is already linked to another decay.

Definition at line 105 of file observable_ids.cpp.

◆ register_custom() [2/3]

bool ObservableMapper::register_custom ( const std::string &  canonical,
std::vector< std::string >  aliases,
std::optional< LhaID ext,
Decays  parent_decay_enum 
)
static

Register a custom observable under a builtin parent decay.

Definition at line 129 of file observable_ids.cpp.

◆ register_custom() [3/3]

bool ObservableMapper::register_custom ( const std::string &  canonical,
std::vector< std::string >  aliases,
std::optional< LhaID ext,
std::string_view  parent_decay_str 
)
static

Register a custom observable under a parent decay resolved by name.

Definition at line 142 of file observable_ids.cpp.


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