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

Alias-aware container / façade over several parameter blocks. More...

#include <BlockAccessor.h>

Inheritance diagram for BlockAccessor:
Collaboration diagram for BlockAccessor:

Public Types

using base_t = std::unordered_map< std::string, std::shared_ptr< Block > >
 Underlying associative container type.
 

Public Member Functions

bool has_param (const BlockName &blockName, LhaID pdgCode) const
 Checks whether a given parameter exists inside a named block.
 
void setValue (const BlockName &blockName, LhaID pdgCode, scalar_t value)
 Sets the value of a parameter inside an existing block.
 
scalar_t getValue (const BlockName &blockName, LhaID pdgCode) const
 Retrieves the current value of a parameter from a block.
 
std::shared_ptr< ParametergetParameter (const BlockName &blockName, LhaID id) const
 Retrieves the full Parameter object stored in a block.
 
void setParameter (const BlockName &blockName, LhaID id, std::shared_ptr< Parameter > source)
 Inserts or updates a full Parameter object in a block.
 
std::map< LhaID, scalar_tgetAllValues (BlockName blockName)
 Returns all current scalar values stored in a block.
 
std::unordered_set< BlockNameget_block_names () const
 Returns the set of all known block names.
 
void remove_item (const BlockName &block_name, LhaID id)
 Removes one parameter from a block.
 
bool contains (const BlockName &block_name) const
 Checks whether a block exists (alias-aware).
 
double get_scale (const BlockName &block_name) const
 Returns the scale attached to a given block.
 
bool has_scale (const BlockName &block_name) const
 Checks whether a given block has a scale attached.
 
std::unordered_map< std::string, std::shared_ptr< Block > > get_block_sources (const BlockName &block_name) const
 Returns the source blocks of a given block.
 
std::unordered_map< ParamId, std::shared_ptr< Parameter > > get_parameter_sources (const BlockName &block_name, LhaID id) const
 Returns the source parameters of a given parameter.
 
std::unordered_set< ParamIdget_all_source_parameters (const std::unordered_set< ParamId > &param_ids) const
 Recursively finds all leaf source parameters behind a set of parameters.
 
bool is_dependent_block (const BlockName &block_name) const
 Checks whether a block is implemented as a DependentBlock.
 
std::vector< std::string > get_source_block_names (const BlockName &block_name) const
 Returns the direct source block names of a block.
 
std::vector< std::string > get_dependent_block_names (const BlockName &block_name) const
 Returns the direct dependent block names observing a block.
 
std::vector< std::string > get_all_source_block_names (const BlockName &block_name) const
 Returns all transitive source block names of a block.
 
std::vector< std::string > get_all_dependent_block_names (const BlockName &block_name) const
 Returns all transitive dependent block names observing a block.
 
std::shared_ptr< Block > & at (const BlockName &block_name)
 Alias-aware mutable access to a block.
 
const std::shared_ptr< Block > & at (const BlockName &block_name) const
 Alias-aware const access to a block.
 
std::shared_ptr< BlockAccessoroperator[] (std::unordered_set< BlockName > block_names)
 Extracts a subset of blocks into a new accessor.
 
void emplace (const BlockName &name, std::shared_ptr< Block > blk)
 Inserts or replaces a block, updating alias metadata.
 
std::shared_ptr< BlockAccessordeep_clone_plain () const
 Deep-copy all stored blocks as independent plain blocks.
 
void detach_block (const BlockName &block_name)
 Detaches a dependent block from its upstream dependencies.
 
void reattach_block (const BlockName &block_name)
 Reattaches a previously detached dependent block to its saved sources.
 
void detach_parameter (const BlockName &block_name, LhaID id)
 Detaches a dependent parameter from its upstream dependencies.
 
void reattach_parameter (const BlockName &block_name, LhaID id)
 Reattaches a previously detached dependent parameter.
 
void erase_block (const BlockName &name)
 Erases a block and removes all associated aliases from metadata.
 
Convenience overloads (std::string / const char*)

Thin wrappers around the std::string_view / BlockName API.

These overloads exist purely for ergonomics so callers can pass std::string or C-strings directly. They forward to the corresponding std::string_view or BlockName implementations.

Note
All semantics (alias resolution, exceptions, logging) are defined by the forwarded-to overloads. In particular:
  • at(...) will throw std::invalid_argument if the block cannot be resolved;
  • contains(...) returns false if the name/alias cannot be resolved;
  • erase_block(...) is a no-op if the name/alias cannot be resolved.
Warning
The std::string_view overloads do not own storage. These wrappers are safe because they create the string_view from arguments whose lifetime extends through the call.
void erase_block (const std::string &name)
 Erase by name/alias (std::string overload).
 
void erase_block (const char *name)
 Erase by name/alias (C-string overload).
 
bool contains (const std::string &name) const
 Alias-aware existence check (std::string overload).
 
bool contains (const char *name) const
 Alias-aware existence check (C-string overload).
 
std::shared_ptr< Block > & at (const std::string &name)
 Alias-aware block access (std::string overload).
 
const std::shared_ptr< Block > & at (const std::string &name) const
 Alias-aware block access (std::string overload, const).
 
std::shared_ptr< Block > & at (const char *name)
 Alias-aware block access (C-string overload).
 
const std::shared_ptr< Block > & at (const char *name) const
 Alias-aware block access (C-string overload, const).
 
void emplace (const std::string &name, std::shared_ptr< Block > blk)
 Insert/replace a block using a raw string name (converted to BlockName).
 
void emplace (const char *name, std::shared_ptr< Block > blk)
 Insert/replace a block using a C-string name (converted to BlockName).
 
bool has_param (const std::string &block, const LhaID &id) const
 Parameter existence check (std::string overload).
 
bool has_param (const char *block, const LhaID &id) const
 Parameter existence check (C-string overload).
 
scalar_t getValue (const std::string &block, const LhaID &id) const
 Value getter (std::string overload).
 
scalar_t getValue (const char *block, const LhaID &id) const
 Value getter (C-string overload).
 
void setValue (const std::string &block, const LhaID &id, scalar_t v)
 Value setter (std::string overload).
 
void setValue (const char *block, const LhaID &id, scalar_t v)
 Value setter (C-string overload).
 
void remove_item (const std::string &block, const LhaID &id)
 Remove parameter (std::string overload).
 
void remove_item (const char *block, const LhaID &id)
 Remove parameter (C-string overload).
 
bool has_scale (const std::string &block) const
 Scale existence check (std::string overload).
 
bool has_scale (const char *block) const
 Scale existence check (C-string overload).
 
double get_scale (const std::string &block) const
 Scale getter (std::string overload).
 
double get_scale (const char *block) const
 Scale getter (C-string overload).
 

Friends

std::shared_ptr< BlockAccessoroperator+ (std::shared_ptr< BlockAccessor > lhs, std::shared_ptr< BlockAccessor > rhs)
 Merges two block accessors with no conflict allowed.
 
std::shared_ptr< BlockAccessoroperator>> (std::shared_ptr< BlockAccessor > lhs, std::shared_ptr< BlockAccessor > rhs)
 Merges two accessors with priority given to lhs.
 
std::ostream & operator<< (std::ostream &, std::shared_ptr< BlockAccessor >)
 Stream output operator for BlockAccessor.
 

Detailed Description

Alias-aware container / façade over several parameter blocks.

A BlockAccessor stores blocks under canonical internal keys while exposing a more user-friendly interface based on BlockName aliases.

Main features:

  • check whether a block or parameter exists,
  • read/write scalar values,
  • read/write full Parameter objects,
  • retrieve all values from a block,
  • remove parameters with proper dependency cleanup,
  • inspect source blocks / source parameters,
  • recursively find leaf source parameters,
  • merge several accessors,
  • detach/reattach dependent blocks or dependent parameters.
Note
Although this class publicly inherits from std::unordered_map, direct manipulation of the base map may desynchronize alias metadata (alias_to_key_, key_to_name_). Prefer the dedicated API.

Definition at line 61 of file BlockAccessor.h.

Member Typedef Documentation

◆ base_t

using BlockAccessor::base_t = std::unordered_map<std::string, std::shared_ptr<Block> >

Underlying associative container type.

Definition at line 65 of file BlockAccessor.h.

Member Function Documentation

◆ at() [1/6]

std::shared_ptr< Block > & BlockAccessor::at ( const BlockName block_name)

Alias-aware mutable access to a block.

Parameters
block_nameName or alias of the block.
Returns
Reference to the stored block shared pointer.
Exceptions
std::invalid_argumentif the block cannot be resolved.

Definition at line 517 of file BlockAccessor.cpp.

◆ at() [2/6]

const std::shared_ptr< Block > & BlockAccessor::at ( const BlockName block_name) const

Alias-aware const access to a block.

Parameters
block_nameName or alias of the block.
Returns
Const reference to the stored block shared pointer.
Exceptions
std::invalid_argumentif the block cannot be resolved.

Definition at line 524 of file BlockAccessor.cpp.

◆ at() [3/6]

std::shared_ptr< Block > & BlockAccessor::at ( const char *  name)
inline

Alias-aware block access (C-string overload).

Definition at line 534 of file BlockAccessor.h.

◆ at() [4/6]

const std::shared_ptr< Block > & BlockAccessor::at ( const char *  name) const
inline

Alias-aware block access (C-string overload, const).

Definition at line 536 of file BlockAccessor.h.

◆ at() [5/6]

std::shared_ptr< Block > & BlockAccessor::at ( const std::string &  name)
inline

Alias-aware block access (std::string overload).

Definition at line 530 of file BlockAccessor.h.

◆ at() [6/6]

const std::shared_ptr< Block > & BlockAccessor::at ( const std::string &  name) const
inline

Alias-aware block access (std::string overload, const).

Definition at line 532 of file BlockAccessor.h.

◆ contains() [1/3]

bool BlockAccessor::contains ( const BlockName block_name) const

Checks whether a block exists (alias-aware).

This method resolves aliases through the internal alias map instead of using the raw underlying map lookup.

Parameters
block_nameName (or aliases) of the block.
Returns
True if the block exists, false otherwise.

Definition at line 513 of file BlockAccessor.cpp.

◆ contains() [2/3]

bool BlockAccessor::contains ( const char *  name) const
inline

Alias-aware existence check (C-string overload).

Definition at line 527 of file BlockAccessor.h.

◆ contains() [3/3]

bool BlockAccessor::contains ( const std::string &  name) const
inline

Alias-aware existence check (std::string overload).

Definition at line 525 of file BlockAccessor.h.

◆ deep_clone_plain()

std::shared_ptr< BlockAccessor > BlockAccessor::deep_clone_plain ( ) const

Deep-copy all stored blocks as independent plain blocks.

The clone duplicates Parameter payloads and preserves block names/aliases and scales. It deliberately does not share observer/dependency links.

Definition at line 386 of file BlockAccessor.cpp.

◆ detach_block()

void BlockAccessor::detach_block ( const BlockName block_name)

Detaches a dependent block from its upstream dependencies.

This method resolves the block, checks that it is actually a DependentBlock, and then calls DependentBlock::detach().

Detaching keeps the current cached contents of the block but removes the active dependency links to source blocks until reattachment.

Parameters
block_nameName of the block to detach. If the resolved block is not a DependentBlock, do nothing.

Definition at line 398 of file BlockAccessor.cpp.

◆ detach_parameter()

void BlockAccessor::detach_parameter ( const BlockName block_name,
LhaID  id 
)

Detaches a dependent parameter from its upstream dependencies.

The target parameter is retrieved from the given block, dynamically cast to DependentParameter, and then DependentParameter::detach() is called.

Parameters
block_nameName of the block containing the parameter.
idLHA identifier of the parameter to detach. If the resolved parameter is not a DependentParameter, do nothing.

Definition at line 420 of file BlockAccessor.cpp.

◆ emplace() [1/3]

void BlockAccessor::emplace ( const BlockName name,
std::shared_ptr< Block blk 
)

Inserts or replaces a block, updating alias metadata.

The block is stored under a canonical internal key chosen from its aliases (or merged into an existing key if one alias is already known).

After insertion, Block::bind_self() is called on the stored block so it can later retrieve a valid weak self reference.

Parameters
nameLogical block name (possibly with several aliases).
blkBlock instance to store.

Definition at line 361 of file BlockAccessor.cpp.

◆ emplace() [2/3]

void BlockAccessor::emplace ( const char *  name,
std::shared_ptr< Block blk 
)
inline

Insert/replace a block using a C-string name (converted to BlockName).

Definition at line 541 of file BlockAccessor.h.

◆ emplace() [3/3]

void BlockAccessor::emplace ( const std::string &  name,
std::shared_ptr< Block blk 
)
inline

Insert/replace a block using a raw string name (converted to BlockName).

Definition at line 539 of file BlockAccessor.h.

◆ erase_block() [1/3]

void BlockAccessor::erase_block ( const BlockName name)

Erases a block and removes all associated aliases from metadata.

If the name cannot be resolved, this is a no-op.

Parameters
nameBlock name or alias.

Definition at line 594 of file BlockAccessor.cpp.

◆ erase_block() [2/3]

void BlockAccessor::erase_block ( const char *  name)
inline

Erase by name/alias (C-string overload).

Definition at line 522 of file BlockAccessor.h.

◆ erase_block() [3/3]

void BlockAccessor::erase_block ( const std::string &  name)
inline

Erase by name/alias (std::string overload).

Definition at line 520 of file BlockAccessor.h.

◆ get_all_dependent_block_names()

std::vector< std::string > BlockAccessor::get_all_dependent_block_names ( const BlockName block_name) const

Returns all transitive dependent block names observing a block.

Starting from block_name, this recursively follows block observers in the downstream direction. The returned list contains each dependent block name at most once.

Parameters
block_nameName or alias of the block to inspect.
Returns
Sorted list of all downstream/dependent block names.
Exceptions
std::invalid_argumentif block_name cannot be resolved.

Definition at line 353 of file BlockAccessor.cpp.

◆ get_all_source_block_names()

std::vector< std::string > BlockAccessor::get_all_source_block_names ( const BlockName block_name) const

Returns all transitive source block names of a block.

Starting from block_name, this recursively follows source-block links through every reachable DependentBlock. The returned list contains each upstream block name at most once.

Parameters
block_nameName or alias of the block to inspect.
Returns
Sorted list of all upstream/source block names.
Exceptions
std::invalid_argumentif block_name cannot be resolved.

Definition at line 346 of file BlockAccessor.cpp.

◆ get_all_source_parameters()

std::unordered_set< ParamId > BlockAccessor::get_all_source_parameters ( const std::unordered_set< ParamId > &  param_ids) const

Recursively finds all leaf source parameters behind a set of parameters.

Starting from each input ParamId, this method recursively explores:

A parameter is considered a leaf if:

  • it cannot be resolved in this accessor, or
  • it has no parameter/block sources.
Parameters
param_idsInitial set of parameters to inspect.
Returns
Set of leaf/root source parameters.

Definition at line 187 of file BlockAccessor.cpp.

◆ get_block_names()

std::unordered_set< BlockName > BlockAccessor::get_block_names ( ) const

Returns the set of all known block names.

This returns the values stored in the alias metadata table key_to_name_, not the raw keys of the underlying unordered_map.

Returns
Set of block names with aliases preserved.

Definition at line 48 of file BlockAccessor.cpp.

◆ get_block_sources()

std::unordered_map< std::string, std::shared_ptr< Block > > BlockAccessor::get_block_sources ( const BlockName block_name) const

Returns the source blocks of a given block.

For plain Block objects, this is usually an empty map. For DependentBlock objects, this returns the actual dependency map.

Parameters
block_nameName of the block.
Returns
Map of source block names to source block pointers.
Exceptions
Ifthe block does not exist.

Definition at line 177 of file BlockAccessor.cpp.

◆ get_dependent_block_names()

std::vector< std::string > BlockAccessor::get_dependent_block_names ( const BlockName block_name) const

Returns the direct dependent block names observing a block.

This method follows the block-observer graph in the downstream direction. It returns the blocks that are directly notified when block_name changes. In practice, these are the direct dependent blocks built on top of the inspected block.

Parameters
block_nameName or alias of the block to inspect.
Returns
Sorted list of direct downstream/dependent block names.
Exceptions
std::invalid_argumentif block_name cannot be resolved.

Definition at line 336 of file BlockAccessor.cpp.

◆ get_parameter_sources()

std::unordered_map< ParamId, std::shared_ptr< Parameter > > BlockAccessor::get_parameter_sources ( const BlockName block_name,
LhaID  id 
) const

Returns the source parameters of a given parameter.

For plain Parameter objects, this is usually an empty map. For DependentParameter objects, this returns the actual source parameters.

Parameters
block_nameName of the block containing the parameter.
idLHA identifier of the parameter.
Returns
Map of source ParamId to Parameter pointer.
Exceptions
Ifthe block or parameter does not exist.

Definition at line 182 of file BlockAccessor.cpp.

◆ get_scale() [1/3]

double BlockAccessor::get_scale ( const BlockName block_name) const

Returns the scale attached to a given block.

Delegates to Block::get_scale() after resolving the block.

Parameters
block_nameName of the block.
Returns
Block scale.
Exceptions
Ifthe block does not exist or if the block has no scale set.

Definition at line 98 of file BlockAccessor.cpp.

◆ get_scale() [2/3]

double BlockAccessor::get_scale ( const char *  block) const
inline

Scale getter (C-string overload).

Definition at line 571 of file BlockAccessor.h.

◆ get_scale() [3/3]

double BlockAccessor::get_scale ( const std::string &  block) const
inline

Scale getter (std::string overload).

Definition at line 569 of file BlockAccessor.h.

◆ get_source_block_names()

std::vector< std::string > BlockAccessor::get_source_block_names ( const BlockName block_name) const

Returns the direct source block names of a block.

For a plain Block this returns an empty vector. For a DependentBlock this returns the direct upstream blocks currently used by its active dependency graph, converted to display names.

Parameters
block_nameName or alias of the block to inspect.
Returns
Sorted list of direct source block names.
Exceptions
std::invalid_argumentif block_name cannot be resolved.

Definition at line 326 of file BlockAccessor.cpp.

◆ getAllValues()

std::map< LhaID, scalar_t > BlockAccessor::getAllValues ( BlockName  blockName)

Returns all current scalar values stored in a block.

Each stored parameter is converted to its current scalar value through Parameter::get_val().

Parameters
blockNameName of the block.
Returns
Ordered map of LhaID -> scalar_t.
Exceptions
std::invalid_argumentif the block does not exist.

Definition at line 36 of file BlockAccessor.cpp.

◆ getParameter()

std::shared_ptr< Parameter > BlockAccessor::getParameter ( const BlockName blockName,
LhaID  id 
) const

Retrieves the full Parameter object stored in a block.

Parameters
blockNameName of the block.
idLHA identifier of the parameter.
Returns
Shared pointer to the stored parameter.
Exceptions
std::invalid_argumentif the block cannot be resolved. If the block exists but the parameter does not, the underlying Block::retrieve() may log and/or throw.

Definition at line 7 of file BlockAccessor.cpp.

◆ getValue() [1/3]

scalar_t BlockAccessor::getValue ( const BlockName blockName,
LhaID  pdgCode 
) const

Retrieves the current value of a parameter from a block.

This is equivalent to:

at(blockName)->retrieve(pdgCode)->get_val();
std::shared_ptr< Block > & at(const BlockName &block_name)
Alias-aware mutable access to a block.
Parameters
blockNameName of the block.
pdgCodeLHA identifier of the parameter.
Returns
Current parameter value.
Exceptions
std::invalid_argumentif the block cannot be resolved. If the block exists but the parameter does not, the underlying Block::retrieve() may log and/or throw.

Definition at line 3 of file BlockAccessor.cpp.

◆ getValue() [2/3]

scalar_t BlockAccessor::getValue ( const char *  block,
const LhaID id 
) const
inline

Value getter (C-string overload).

Definition at line 551 of file BlockAccessor.h.

◆ getValue() [3/3]

scalar_t BlockAccessor::getValue ( const std::string &  block,
const LhaID id 
) const
inline

Value getter (std::string overload).

Definition at line 549 of file BlockAccessor.h.

◆ has_param() [1/3]

bool BlockAccessor::has_param ( const BlockName blockName,
LhaID  pdgCode 
) const

Checks whether a given parameter exists inside a named block.

This method first resolves the block name through the alias system, then delegates to Block::contains(id).

Parameters
blockNameName (or alias set) of the block.
pdgCodeLHA identifier of the parameter inside the block.
Returns
True if the block exists and contains the parameter, false otherwise.

Definition at line 11 of file BlockAccessor.cpp.

◆ has_param() [2/3]

bool BlockAccessor::has_param ( const char *  block,
const LhaID id 
) const
inline

Parameter existence check (C-string overload).

Definition at line 546 of file BlockAccessor.h.

◆ has_param() [3/3]

bool BlockAccessor::has_param ( const std::string &  block,
const LhaID id 
) const
inline

Parameter existence check (std::string overload).

Definition at line 544 of file BlockAccessor.h.

◆ has_scale() [1/3]

bool BlockAccessor::has_scale ( const BlockName block_name) const

Checks whether a given block has a scale attached.

Parameters
block_nameName of the block.
Returns
True if the block exists and has a scale, false otherwise.
Exceptions
Ifthe block does not exist.

Definition at line 106 of file BlockAccessor.cpp.

◆ has_scale() [2/3]

bool BlockAccessor::has_scale ( const char *  block) const
inline

Scale existence check (C-string overload).

Definition at line 566 of file BlockAccessor.h.

◆ has_scale() [3/3]

bool BlockAccessor::has_scale ( const std::string &  block) const
inline

Scale existence check (std::string overload).

Definition at line 564 of file BlockAccessor.h.

◆ is_dependent_block()

bool BlockAccessor::is_dependent_block ( const BlockName block_name) const

Checks whether a block is implemented as a DependentBlock.

This method only inspects the block object itself. It does not force a recomputation and it does not infer dependency status from the presence of observers. A block is considered dependent exactly when the stored block can be dynamically cast to DependentBlock.

Parameters
block_nameName or alias of the block to inspect.
Returns
True if the resolved block is a DependentBlock, false otherwise.
Exceptions
std::invalid_argumentif block_name cannot be resolved.

Definition at line 322 of file BlockAccessor.cpp.

◆ operator[]()

std::shared_ptr< BlockAccessor > BlockAccessor::operator[] ( std::unordered_set< BlockName block_names)

Extracts a subset of blocks into a new accessor.

This operation performs a shallow copy of block shared pointers: the returned accessor points to the same underlying Block objects.

Parameters
block_namesSet of block names to extract.
Returns
New accessor containing the requested subset.
Exceptions
Ifone requested block does not exist.

Definition at line 65 of file BlockAccessor.cpp.

◆ reattach_block()

void BlockAccessor::reattach_block ( const BlockName block_name)

Reattaches a previously detached dependent block to its saved sources.

This method resolves the block, checks that it is a DependentBlock, and then calls DependentBlock::reattach().

Parameters
block_nameName of the block to reattach. If the resolved block is not a DependentBlock, do nothing.

Definition at line 409 of file BlockAccessor.cpp.

◆ reattach_parameter()

void BlockAccessor::reattach_parameter ( const BlockName block_name,
LhaID  id 
)

Reattaches a previously detached dependent parameter.

The target parameter is retrieved from the given block, dynamically cast to DependentParameter, and then DependentParameter::reattach() is called.

Parameters
block_nameName of the block containing the parameter.
idLHA identifier of the parameter to reattach. If the resolved parameter is not a DependentParameter, do nothing.

Definition at line 431 of file BlockAccessor.cpp.

◆ remove_item() [1/3]

void BlockAccessor::remove_item ( const BlockName block_name,
LhaID  id 
)

Removes one parameter from a block.

Delegates to Block::remove(id) which performs proper dependency cleanup.

Behavior of this overload:

  • if the block exists, the parameter is removed,
  • if the block does not exist, a warning is logged and nothing happens.
Parameters
block_nameName of the block.
idLHA identifier of the parameter to remove.

Definition at line 56 of file BlockAccessor.cpp.

◆ remove_item() [2/3]

void BlockAccessor::remove_item ( const char *  block,
const LhaID id 
)
inline

Remove parameter (C-string overload).

Definition at line 561 of file BlockAccessor.h.

◆ remove_item() [3/3]

void BlockAccessor::remove_item ( const std::string &  block,
const LhaID id 
)
inline

Remove parameter (std::string overload).

Definition at line 559 of file BlockAccessor.h.

◆ setParameter()

void BlockAccessor::setParameter ( const BlockName blockName,
LhaID  id,
std::shared_ptr< Parameter source 
)

Inserts or updates a full Parameter object in a block.

Delegates to Block::store_or_assign(id, source) on the resolved block.

Parameters
blockNameName of the block.
idLHA identifier of the parameter.
sourceShared pointer to the source parameter object.
Exceptions
std::invalid_argumentif the block does not exist.

Definition at line 28 of file BlockAccessor.cpp.

◆ setValue() [1/3]

void BlockAccessor::setValue ( const BlockName blockName,
LhaID  pdgCode,
scalar_t  value 
)

Sets the value of a parameter inside an existing block.

Behavior:

  • if the block exists and the parameter already exists, delegates to Block::assign(id, value),
  • if the block exists but the parameter does not, creates a new Parameter with zero uncertainties and stores it,
  • if the block does not exist, throws std::invalid_argument.
Parameters
blockNameName of the target block.
pdgCodeLHA identifier of the parameter.
valueNew scalar value.

Definition at line 16 of file BlockAccessor.cpp.

◆ setValue() [2/3]

void BlockAccessor::setValue ( const char *  block,
const LhaID id,
scalar_t  v 
)
inline

Value setter (C-string overload).

Definition at line 556 of file BlockAccessor.h.

◆ setValue() [3/3]

void BlockAccessor::setValue ( const std::string &  block,
const LhaID id,
scalar_t  v 
)
inline

Value setter (std::string overload).

Definition at line 554 of file BlockAccessor.h.

Friends And Related Symbol Documentation

◆ operator+

std::shared_ptr< BlockAccessor > operator+ ( std::shared_ptr< BlockAccessor lhs,
std::shared_ptr< BlockAccessor rhs 
)
friend

Merges two block accessors with no conflict allowed.

All blocks from lhs and rhs are deep-copied into a new accessor using the Block(std::shared_ptr<Block>) constructor.

If both accessors contain a block with the same resolved name, this is considered an error.

Parameters
lhsLeft-hand accessor.
rhsRight-hand accessor.
Returns
New accessor containing all blocks from both operands.
Exceptions
Vialogging/error handling if overlapping block names are found.

Definition at line 82 of file BlockAccessor.cpp.

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
std::shared_ptr< BlockAccessor ba 
)
friend

Stream output operator for BlockAccessor.

Prints all block names and their parameter values using BlockAccessor::getAllValues:

id: value
...
Block MASS:
...
const Prototype SMINPUTS
const Prototype MASS
Definition Block.h:73
Parameters
osOutput stream.
baShared pointer to the BlockAccessor to print.
Returns
The output stream.

Definition at line 165 of file BlockAccessor.cpp.

◆ operator>>

std::shared_ptr< BlockAccessor > operator>> ( std::shared_ptr< BlockAccessor lhs,
std::shared_ptr< BlockAccessor rhs 
)
friend

Merges two accessors with priority given to lhs.

Semantics:

  • all rhs blocks are copied first,
  • lhs blocks are then merged on top,
  • if a block exists only in lhs, it is copied entirely,
  • if a parameter exists in both lhs and rhs:
    • lhs central value is kept,
    • if lhs uncertainties are non-zero, lhs is kept unchanged,
    • if lhs has zero stat+syst uncertainties, rhs uncertainties are copied into a copy of lhs.
Parameters
lhsPriority accessor.
rhsSecondary accessor.
Returns
New merged accessor.

Definition at line 110 of file BlockAccessor.cpp.


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