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

Represents a single parameter with value, uncertainties, and dependency links. More...

#include <Parameter.h>

Inheritance diagram for Parameter:
Collaboration diagram for Parameter:

Public Member Functions

 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.
 
virtual scalar_t get_val () const
 Returns the current value 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_tget_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.
 
virtual void update ()
 Hook called when an upstream dependency changes.
 
virtual void freeze ()
 Hook to freeze the parameter.
 
virtual void unfreeze ()
 Hook to unfreeze the parameter.
 
virtual void clear_above ()
 Hook to clear upstream dependencies.
 
virtual void clear_below ()
 Recursively clears downstream dependencies below this parameter.
 
virtual std::unordered_map< ParamId, std::shared_ptr< Parameter > > get_source_parameters () const
 Returns the source parameters this parameter depends on.
 
void set_owner_block (std::weak_ptr< Block > owner)
 Sets the owning block of this parameter.
 
std::weak_ptr< Blockget_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.
 
Parameteroperator= (const Parameter &other)
 Assignment operator.
 
Parameteroperator+= (const Parameter &other)
 Adds another parameter payload to this one.
 
Parameteroperator*= (const scalar_t &scale)
 Multiplies the parameter by a scalar factor.
 
virtual ~Parameter ()=default
 Virtual destructor.
 

Protected Attributes

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< Blockowner_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.
 

Friends

std::ostream & operator<< (std::ostream &os, const Parameter &p)
 Stream output operator for a parameter.
 

Detailed Description

Represents a single parameter with value, uncertainties, and dependency links.

This is the fundamental data container for model, flavor, observable, and Wilson parameters.

A Parameter stores:

  • its identifier (ParamId),
  • its expected value,
  • statistical and systematic standard deviations,
  • an optional additive shift,
  • optional metadata (scale, bin),
  • a list of observer parameters,
  • and optionally the block that owns it.

Notification model:

  • when the parameter changes, it can notify downstream parameter observers,
  • if attached to a block, it can also trigger block-level observer propagation through the owning block.

Read model:

  • get_val() first ensures that the owning block (if any) is up to date, so accessing a parameter transparently triggers lazy recomputation of dependent blocks when needed.
See also
Block
ParameterMode

Definition at line 78 of file Parameter.h.

Constructor & Destructor Documentation

◆ Parameter() [1/3]

Parameter::Parameter ( )
inline

Default constructor.

Creates a neutral parameter:

  • id = (SM, "NullBlock", 0)
  • expected = 0
  • zero uncertainties
  • zero shift
  • mode = FIXED

Definition at line 102 of file Parameter.h.

◆ Parameter() [2/3]

Parameter::Parameter ( ParamId  id,
scalar_t  mean,
scalar_t  std_stat,
scalar_t  std_syst 
)

Constructs a parameter from its identifier, value, and uncertainties.

The shift is initialized to zero and the mode to ParameterMode::FIXED.

Parameters
idUnique identifier of the parameter.
meanCentral value.
std_statStatistical uncertainty.
std_systSystematic uncertainty.

Definition at line 6 of file Parameter.cpp.

◆ Parameter() [3/3]

Parameter::Parameter ( const Parameter other)

Copy constructor that copies only scalar payload/metadata.

Observer links and owning block are intentionally not copied so deep clones can be rebound to their new local blocks safely.

Definition at line 10 of file Parameter.cpp.

◆ ~Parameter()

virtual Parameter::~Parameter ( )
virtualdefault

Virtual destructor.

Member Function Documentation

◆ addObserver()

void Parameter::addObserver ( std::shared_ptr< Parameter observer)

Adds an observer parameter.

Observers are stored uniquely by pointer identity.

Parameters
observerDownstream observer parameter.

Definition at line 89 of file Parameter.cpp.

◆ clear_above()

virtual void Parameter::clear_above ( )
inlinevirtual

Hook to clear upstream dependencies.

Base implementation does nothing. Derived classes may override this to detach from source parameters.

Reimplemented in DependentParameter.

Definition at line 336 of file Parameter.h.

◆ clear_below()

void Parameter::clear_below ( )
virtual

Recursively clears downstream dependencies below this parameter.

Current behavior:

  • takes ownership of the current observer list,
  • clears the local observer list,
  • calls clear_above() on this parameter,
  • recursively calls clear_below() on each former observer.

This is used to tear down or invalidate a parameter dependency subtree.

Reimplemented in DependentParameter.

Definition at line 95 of file Parameter.cpp.

◆ freeze()

virtual void Parameter::freeze ( )
inlinevirtual

Hook to freeze the parameter.

Base implementation does nothing. Derived classes may override this if they support explicit freezing.

Reimplemented in DependentParameter.

Definition at line 321 of file Parameter.h.

◆ get_bin()

std::pair< double, double > Parameter::get_bin ( )

Returns the parameter bin metadata.

If no bin has been assigned, returns (-1.0, -1.0).

Returns
Bin interval, or sentinel pair if undefined.

Definition at line 68 of file Parameter.cpp.

◆ get_combined_std()

scalar_t Parameter::get_combined_std ( ) const

Returns the combined standard deviation.

The combined uncertainty is computed as:

\[
\sqrt{\sigma_{\mathrm{stat}}^2 + \sigma_{\mathrm{syst}}^2}
\]

Returns
Combined uncertainty.

Definition at line 55 of file Parameter.cpp.

◆ get_id()

ParamId Parameter::get_id ( ) const

Returns the identifier of the parameter.

Returns
Parameter id.

Definition at line 72 of file Parameter.cpp.

◆ get_owner_block()

std::weak_ptr< Block > Parameter::get_owner_block ( ) const

Returns the owning block of this parameter.

Returns
Weak pointer to the owning block.

Definition at line 112 of file Parameter.cpp.

◆ get_scale()

double Parameter::get_scale ( )

Returns the parameter scale metadata.

If no scale has been assigned, returns -1.0.

Returns
Scale value, or -1.0 if undefined.

Definition at line 64 of file Parameter.cpp.

◆ get_source_parameters()

std::unordered_map< ParamId, std::shared_ptr< Parameter > > Parameter::get_source_parameters ( ) const
virtual

Returns the source parameters this parameter depends on.

A plain Parameter has no explicit upstream parameter sources, so the default implementation returns an empty map.

Derived classes such as computed/dependent parameters should override this.

Returns
Map of source ParamId -> Parameter.

Reimplemented in DependentParameter.

Definition at line 106 of file Parameter.cpp.

◆ get_std()

std::pair< scalar_t, scalar_t > Parameter::get_std ( ) const

Returns statistical and systematic uncertainties separately.

Returns
Pair (stat, syst).

Definition at line 60 of file Parameter.cpp.

◆ get_val()

scalar_t Parameter::get_val ( ) const
virtual

Returns the current value of the parameter.

Behavior:

Returns
Current parameter value.

Reimplemented in DependentParameter.

Definition at line 34 of file Parameter.cpp.

◆ notifyObservers()

void Parameter::notifyObservers ( )

Notifies downstream parameter observers and then the owner block.

Current behavior:

This is the standard propagation entry point after a value-changing operation.

Definition at line 146 of file Parameter.cpp.

◆ notifyParamObserversOnly()

void Parameter::notifyParamObserversOnly ( )

Notifies only parameter observers.

This method:

  • calls update() on each non-null observer parameter,
  • removes null observer entries,
  • does not notify the owning block.

This is useful when propagating parameter-level dirtiness without re-triggering block-level cascades multiple times.

Definition at line 137 of file Parameter.cpp.

◆ operator*=()

Parameter & Parameter::operator*= ( const scalar_t scale)

Multiplies the parameter by a scalar factor.

Update rules:

  • expected value is scaled by factor,
  • uncertainties are scaled by abs(factor),
  • shift is scaled by factor.

Metadata and observer relationships are unchanged.

Parameters
scaleMultiplicative factor.
Returns
Reference to this parameter.

Definition at line 177 of file Parameter.cpp.

◆ operator+=()

Parameter & Parameter::operator+= ( const Parameter other)

Adds another parameter payload to this one.

Update rules:

  • expected values are summed,
  • statistical/systematic uncertainties are combined in quadrature,
  • shifts are summed.

Identifier, mode, metadata, and observer relationships are unchanged.

Parameters
otherParameter to add.
Returns
Reference to this parameter.

Definition at line 169 of file Parameter.cpp.

◆ operator=()

Parameter & Parameter::operator= ( const Parameter other)

Assignment operator.

Copies:

  • identifier
  • expected value
  • uncertainties
  • mode
  • shift
  • scale
  • binning

Does not copy:

  • observer list
  • owning block
Parameters
otherSource parameter.
Returns
Reference to this parameter.

Definition at line 115 of file Parameter.cpp.

◆ overwrite_payload_from()

void Parameter::overwrite_payload_from ( const Parameter other)

Overwrites the numerical/configuration payload from another parameter.

Copied fields:

  • expected value
  • statistical uncertainty
  • systematic uncertainty
  • shift
  • mode
  • scale
  • binning

Preserved fields:

  • identifier
  • observers
  • owning block
Parameters
otherSource parameter payload.

Definition at line 127 of file Parameter.cpp.

◆ removeObserver()

void Parameter::removeObserver ( std::shared_ptr< Parameter observer)

Removes an observer parameter.

Removal is performed by pointer identity.

Parameters
observerObserver to remove.

Definition at line 153 of file Parameter.cpp.

◆ set_bin()

void Parameter::set_bin ( std::pair< double, double >  bin)

Sets the binning metadata of the parameter.

Parameters
binBin interval as (low, high).

Definition at line 30 of file Parameter.cpp.

◆ set_expected()

void Parameter::set_expected ( scalar_t  val)

Sets the expected value and notifies dependents.

This updates the central value, then calls notifyObservers().

Parameters
valNew expected value.

Definition at line 41 of file Parameter.cpp.

◆ set_expected_silent()

void Parameter::set_expected_silent ( scalar_t  val)

Sets the expected value without notifying observers.

This is intended for internal/batched updates where propagation is handled separately.

Warning
This can leave dependents stale until notifications are manually triggered.
Parameters
valNew expected value.

Definition at line 47 of file Parameter.cpp.

◆ set_id()

void Parameter::set_id ( ParamId  id)

Replaces the identifier of the parameter.

Parameters
idNew identifier.

Definition at line 51 of file Parameter.cpp.

◆ set_mode()

void Parameter::set_mode ( ParameterMode  mode)

Sets the parameter mode.

This does not trigger notifications by itself.

Parameters
modeNew mode to assign.

Definition at line 15 of file Parameter.cpp.

◆ set_owner()

void Parameter::set_owner ( ParameterType  type)

Changes the owner ParameterType part of the identifier.

This is typically used when re-tagging a parameter as SM, BSM, WILSON, etc.

Parameters
typeNew owner type.

Definition at line 77 of file Parameter.cpp.

◆ set_owner_block()

void Parameter::set_owner_block ( std::weak_ptr< Block owner)

Sets the owning block of this parameter.

Parameters
ownerWeak pointer to the owning block.

Definition at line 110 of file Parameter.cpp.

◆ set_scale()

void Parameter::set_scale ( double  scale)

Sets the parameter scale metadata.

This is purely metadata storage; no notification is emitted.

Parameters
scaleScale value.

Definition at line 26 of file Parameter.cpp.

◆ set_shift()

void Parameter::set_shift ( scalar_t  shift)

Sets the additive shift of the parameter.

This is only allowed if the parameter is in ParameterMode::SHIFTABLE mode.

Parameters
shiftNew shift value.
Exceptions
std::runtime_errorif called while the parameter is FIXED.

Definition at line 81 of file Parameter.cpp.

◆ set_std()

void Parameter::set_std ( scalar_t  stat,
scalar_t  syst 
)

Sets the statistical and systematic uncertainties.

Parameters
statStatistical standard deviation.
systSystematic standard deviation.

Definition at line 21 of file Parameter.cpp.

◆ unfreeze()

virtual void Parameter::unfreeze ( )
inlinevirtual

Hook to unfreeze the parameter.

Base implementation does nothing.

Reimplemented in DependentParameter.

Definition at line 328 of file Parameter.h.

◆ update()

virtual void Parameter::update ( )
inlinevirtual

Hook called when an upstream dependency changes.

Base implementation does nothing. Derived classes may override this to recompute internal state.

Reimplemented in DependentParameter.

Definition at line 313 of file Parameter.h.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const Parameter p 
)
friend

Stream output operator for a parameter.

Prints a compact human-readable representation including block/code, optional binning, central value, and uncertainties.

Parameters
osOutput stream.
pParameter to print.
Returns
Output stream.

Definition at line 159 of file Parameter.cpp.

Member Data Documentation

◆ binning

std::optional<std::pair<double, double> > Parameter::binning
protected

Optional energy bin [low, high] associated with the parameter.

Definition at line 89 of file Parameter.h.

◆ deviation_stat

scalar_t Parameter::deviation_stat
protected

Statistical standard deviation.

Definition at line 82 of file Parameter.h.

◆ deviation_syst

scalar_t Parameter::deviation_syst
protected

Systematic standard deviation.

Definition at line 83 of file Parameter.h.

◆ expected

scalar_t Parameter::expected
protected

Expected value of the parameter.

Definition at line 81 of file Parameter.h.

◆ id

ParamId Parameter::id
protected

Unique identifier for the parameter.

Definition at line 80 of file Parameter.h.

◆ mode

ParameterMode Parameter::mode
protected

Current operating mode.

Definition at line 85 of file Parameter.h.

◆ observers

std::vector<std::shared_ptr<Parameter> > Parameter::observers
protected

Observers notified when this parameter changes.

Definition at line 86 of file Parameter.h.

◆ owner_block

std::weak_ptr<Block> Parameter::owner_block
protected

Owning Block (if any) that this parameter belongs to.

Definition at line 87 of file Parameter.h.

◆ scale

std::optional<double> Parameter::scale
protected

Optional renormalization scale associated with the parameter.

Definition at line 88 of file Parameter.h.

◆ shift

scalar_t Parameter::shift
protected

Additive shift applied when the parameter is SHIFTABLE.

Definition at line 84 of file Parameter.h.


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