|
Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
|
Parameter whose value is computed from other parameters and cached lazily. More...
#include <DependentParameter.h>


Public Member Functions | |
| DependentParameter (ParamId pid, std::unordered_map< ParamId, std::shared_ptr< Parameter > > sources, DepParamUpdateFunc recalculateFunc) | |
| Constructs a dependent parameter from its id, sources, and recomputation rule. | |
| bool | dependsOn (const ParamId &pid) |
| Checks whether this parameter depends on a given source parameter. | |
| void | init () |
| Initializes observer registration on all source parameters. | |
| void | update () override |
| Marks the parameter as dirty and propagates the update downstream. | |
| void | freeze () override |
| Freezes the dependent parameter. | |
| void | unfreeze () override |
| Unfreezes the dependent parameter. | |
| void | clear_above () override |
| Detaches this parameter from all upstream source parameters. | |
| void | clear_below () override |
| Clears this parameter and all downstream dependent parameters. | |
| std::unordered_map< ParamId, std::shared_ptr< Parameter > > | get_source_parameters () const override |
| Returns the source parameters this dependent parameter currently uses. | |
| scalar_t | get_val () const override |
| Returns the current cached value, recomputing it on demand if needed. | |
| void | mark_dirty () |
| Marks the cached value as dirty. | |
| void | ensure_up_to_date () |
| Recomputes the parameter if its cached value is stale. | |
| void | rebind (std::unordered_map< ParamId, std::shared_ptr< Parameter > > new_sources, DepParamUpdateFunc new_lambda) |
| Replaces the dependency set and recomputation rule at runtime. | |
| void | detach () |
| Temporarily detaches all dependencies while keeping the current cached value. | |
| void | reattach () |
| Restores previously detached dependencies and recomputation rule. | |
| ~DependentParameter () | |
| Destructor. | |
Public Member Functions inherited from Parameter | |
| Parameter () | |
| Default constructor. | |
| Parameter (ParamId id, scalar_t mean, scalar_t std_stat, scalar_t std_syst) | |
| Constructs a parameter from its identifier, value, and uncertainties. | |
| Parameter (const Parameter &other) | |
| Copy constructor that copies only scalar payload/metadata. | |
| void | set_mode (ParameterMode mode) |
| Sets the parameter mode. | |
| void | set_std (scalar_t stat, scalar_t syst) |
| Sets the statistical and systematic uncertainties. | |
| void | set_scale (double scale) |
| Sets the parameter scale metadata. | |
| void | set_bin (std::pair< double, double > bin) |
| Sets the binning metadata of the parameter. | |
| void | set_id (ParamId id) |
| Replaces the identifier of the parameter. | |
| void | set_expected (scalar_t val) |
| Sets the expected value and notifies dependents. | |
| void | set_expected_silent (scalar_t val) |
| Sets the expected value without notifying observers. | |
| scalar_t | get_combined_std () const |
| Returns the combined standard deviation. | |
| std::pair< scalar_t, scalar_t > | get_std () const |
| Returns statistical and systematic uncertainties separately. | |
| double | get_scale () |
| Returns the parameter scale metadata. | |
| std::pair< double, double > | get_bin () |
| Returns the parameter bin metadata. | |
| ParamId | get_id () const |
| Returns the identifier of the parameter. | |
| void | set_owner (ParameterType type) |
| Changes the owner ParameterType part of the identifier. | |
| void | set_shift (scalar_t shift) |
| Sets the additive shift of the parameter. | |
| void | addObserver (std::shared_ptr< Parameter > observer) |
| Adds an observer parameter. | |
| void | removeObserver (std::shared_ptr< Parameter > observer) |
| Removes an observer parameter. | |
| void | notifyObservers () |
| Notifies downstream parameter observers and then the owner block. | |
| void | notifyParamObserversOnly () |
| Notifies only parameter observers. | |
| void | set_owner_block (std::weak_ptr< Block > owner) |
| Sets the owning block of this parameter. | |
| std::weak_ptr< Block > | get_owner_block () const |
| Returns the owning block of this parameter. | |
| void | overwrite_payload_from (const Parameter &other) |
| Overwrites the numerical/configuration payload from another parameter. | |
| Parameter & | operator= (const Parameter &other) |
| Assignment operator. | |
| Parameter & | operator+= (const Parameter &other) |
| Adds another parameter payload to this one. | |
| Parameter & | operator*= (const scalar_t &scale) |
| Multiplies the parameter by a scalar factor. | |
| virtual | ~Parameter ()=default |
| Virtual destructor. | |
Additional Inherited Members | |
Protected Attributes inherited from Parameter | |
| ParamId | id |
| Unique identifier for the parameter. | |
| scalar_t | expected |
| Expected value of the parameter. | |
| scalar_t | deviation_stat |
| Statistical standard deviation. | |
| scalar_t | deviation_syst |
| Systematic standard deviation. | |
| scalar_t | shift |
| Additive shift applied when the parameter is SHIFTABLE. | |
| ParameterMode | mode |
| Current operating mode. | |
| std::vector< std::shared_ptr< Parameter > > | observers |
| Observers notified when this parameter changes. | |
| std::weak_ptr< Block > | owner_block |
| Owning Block (if any) that this parameter belongs to. | |
| std::optional< double > | scale |
| Optional renormalization scale associated with the parameter. | |
| std::optional< std::pair< double, double > > | binning |
| Optional energy bin [low, high] associated with the parameter. | |
Parameter whose value is computed from other parameters and cached lazily.
A DependentParameter stores:
Lifecycle:
std::shared_ptr,Freezing:
update_at_unfreeze,Detach / reattach:
expected value directly after ensure_up_to_date(). It does not apply mode/shift logic from the base class. Definition at line 80 of file DependentParameter.h.
|
explicit |
Constructs a dependent parameter from its id, sources, and recomputation rule.
The base Parameter is initialized with:
The constructor stores:
The parameter is initially marked dirty.
std::shared_ptr.| pid | Identifier of the dependent parameter. |
| sources | Source parameters keyed by ParamId. |
| recalculateFunc | Callback used to recompute this parameter. |
Definition at line 4 of file DependentParameter.cpp.
| DependentParameter::~DependentParameter | ( | ) |
Destructor.
If the parameter is still initialized and can lock its self-reference, it unregisters itself from all currently active source parameters.
This prevents stale observer pointers from remaining in source parameters.
Definition at line 180 of file DependentParameter.cpp.
|
overridevirtual |
Detaches this parameter from all upstream source parameters.
If the parameter has been initialized, this removes this dependent parameter from each source observer list.
This does not clear local downstream observers.
Reimplemented from Parameter.
Definition at line 24 of file DependentParameter.cpp.
|
overridevirtual |
Clears this parameter and all downstream dependent parameters.
Current behavior:
owner_block->erase_local(id.code),clear_below() on downstream observers.id.code, consistent with block storage being keyed by LhaID inside a block. Reimplemented from Parameter.
Definition at line 32 of file DependentParameter.cpp.
| bool DependentParameter::dependsOn | ( | const ParamId & | pid | ) |
Checks whether this parameter depends on a given source parameter.
| pid | Identifier of the candidate source parameter. |
pid is present in the current source map. Definition at line 19 of file DependentParameter.cpp.
| void DependentParameter::detach | ( | ) |
Temporarily detaches all dependencies while keeping the current cached value.
Current behavior:
This is useful when one wants to “freeze” the dependency graph structure while preserving the last computed numeric value.
Definition at line 138 of file DependentParameter.cpp.
| void DependentParameter::ensure_up_to_date | ( | ) |
Recomputes the parameter if its cached value is stale.
Behavior:
src->get_val(),Definition at line 80 of file DependentParameter.cpp.
|
overridevirtual |
Freezes the dependent parameter.
While frozen:
Reimplemented from Parameter.
Definition at line 99 of file DependentParameter.cpp.
|
inlineoverridevirtual |
Returns the source parameters this dependent parameter currently uses.
Reimplemented from Parameter.
Definition at line 190 of file DependentParameter.h.
|
overridevirtual |
Returns the current cached value, recomputing it on demand if needed.
This method:
expected value directly.ParameterMode::SHIFTABLE / shift. It returns expected only.Reimplemented from Parameter.
Definition at line 75 of file DependentParameter.cpp.
| void DependentParameter::init | ( | ) |
Initializes observer registration on all source parameters.
This method:
std::shared_ptr, because it uses shared_from_this(). Definition at line 46 of file DependentParameter.cpp.
| void DependentParameter::mark_dirty | ( | ) |
Marks the cached value as dirty.
This only sets the internal dirty flag to true. No notification is emitted here.
Definition at line 56 of file DependentParameter.cpp.
| void DependentParameter::reattach | ( | ) |
Restores previously detached dependencies and recomputation rule.
Current behavior:
After reattachment, the value will be recomputed lazily on the next access.
Definition at line 158 of file DependentParameter.cpp.
| void DependentParameter::rebind | ( | std::unordered_map< ParamId, std::shared_ptr< Parameter > > | new_sources, |
| DepParamUpdateFunc | new_lambda | ||
| ) |
Replaces the dependency set and recomputation rule at runtime.
This method:
| new_sources | New source parameter map. |
| new_lambda | New recomputation lambda. |
Definition at line 111 of file DependentParameter.cpp.
|
overridevirtual |
Unfreezes the dependent parameter.
If an update was requested while frozen, this method triggers one call to update() after unfreezing.
Reimplemented from Parameter.
Definition at line 103 of file DependentParameter.cpp.
|
overridevirtual |
Marks the parameter as dirty and propagates the update downstream.
Current behavior:
update_at_unfreeze = true,dirty = true,Actual recomputation is deferred to ensure_up_to_date().
Reimplemented from Parameter.
Definition at line 60 of file DependentParameter.cpp.