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

Lightweight view over a set of source blocks. More...

#include <SourcesView.h>

Public Member Functions

 BlockSrc (const std::unordered_map< std::string, std::shared_ptr< Block > > &m, std::string ctx={})
 Constructs a BlockSrc view from an existing map.
 
bool has_block (std::string_view name) const
 Checks whether a block with a given name is present.
 
const std::shared_ptr< Block > & block (std::string_view name) const
 Returns a reference to a block by name.
 
std::shared_ptr< Parameterget_param (std::string_view blk, const LhaID &code) const
 Retrieves a parameter from a given block by LhaID.
 
std::shared_ptr< Parameterget_param (std::string_view blk, int code) const
 Helper: get parameter using an integer code.
 
std::shared_ptr< Parameterget_param (std::string_view blk, std::pair< int, int > code) const
 Helper: get parameter using a pair of integers.
 
scalar_t get_val (std::string_view blk, std::initializer_list< long > code) const
 Retrieves the value of a parameter given as an initializer_list.
 
scalar_t get_val (std::string_view blk, std::initializer_list< std::size_t > code) const
 Retrieves the value of a parameter given as an initializer_list.
 
scalar_t get_val (std::string_view blk, std::initializer_list< int > code) const
 Retrieves the value of a parameter given as an initializer_list.
 
scalar_t get_val (std::string_view blk, const LhaID &code) const
 Retrieves the value of a parameter identified by an LhaID.
 
scalar_t get_val (std::string_view blk, int code) const
 Helper: get value from an integer code.
 
scalar_t get_val (std::string_view blk, std::pair< int, int > code) const
 Helper: get value from a pair of integers.
 
const std::unordered_map< std::string, std::shared_ptr< Block > > & raw () const
 Returns the underlying map reference.
 

Detailed Description

Lightweight view over a set of source blocks.

This class is a non-owning wrapper around a std::unordered_map<std::string, std::shared_ptr<Block>>.

It provides:

  • checked access to a block by name, with good error messages
  • checked access to parameters in those blocks
  • convenient get_val helpers from various ID forms

It is typically used inside dependent-block update lambdas:

void recalc(const BlockSrc& src, std::shared_ptr<DependentBlock> self) {
double alpha = src.get_val("SMINPUTS", 1);
...
}
Lightweight view over a set of source blocks.
Definition SourcesView.h:71
scalar_t get_val(std::string_view blk, std::initializer_list< long > code) const
Retrieves the value of a parameter given as an initializer_list.

Definition at line 71 of file SourcesView.h.

Constructor & Destructor Documentation

◆ BlockSrc()

BlockSrc::BlockSrc ( const std::unordered_map< std::string, std::shared_ptr< Block > > &  m,
std::string  ctx = {} 
)
explicit

Constructs a BlockSrc view from an existing map.

Parameters
mMap of block-name to Block pointers (not owned).
ctxOptional textual context added to error messages (e.g. name of the DependentBlock being updated).

Definition at line 19 of file SourceView.cpp.

Member Function Documentation

◆ block()

const std::shared_ptr< Block > & BlockSrc::block ( std::string_view  name) const

Returns a reference to a block by name.

If the block is missing, throws std::invalid_argument with a message mentioning the context (if provided) and the list of available blocks.

Parameters
nameName of the block (case-sensitive as stored in the map).
Returns
Const reference to shared_ptr<Block>.
Exceptions
std::invalid_argumentif the block is not found.

Definition at line 27 of file SourceView.cpp.

◆ get_param() [1/3]

std::shared_ptr< Parameter > BlockSrc::get_param ( std::string_view  blk,
const LhaID code 
) const

Retrieves a parameter from a given block by LhaID.

If the block or parameter is missing, throws std::invalid_argument with a detailed message including available IDs.

Parameters
blkName of the block.
codeLhaID of the parameter.
Returns
Shared pointer to the Parameter.
Exceptions
std::invalid_argumentif the block or parameter is not found.

Definition at line 42 of file SourceView.cpp.

◆ get_param() [2/3]

std::shared_ptr< Parameter > BlockSrc::get_param ( std::string_view  blk,
int  code 
) const

Helper: get parameter using an integer code.

Constructs LhaID(code) and forwards to the main overload.

Parameters
blkName of the block.
codeInteger PDG-like code.
Returns
Shared pointer to the Parameter.

Definition at line 47 of file SourceView.cpp.

◆ get_param() [3/3]

std::shared_ptr< Parameter > BlockSrc::get_param ( std::string_view  blk,
std::pair< int, int >  code 
) const

Helper: get parameter using a pair of integers.

Constructs an LhaID(code.first, code.second) and forwards.

Parameters
blkName of the block.
codePair of indices.
Returns
Shared pointer to the Parameter.

Definition at line 50 of file SourceView.cpp.

◆ get_val() [1/6]

scalar_t BlockSrc::get_val ( std::string_view  blk,
const LhaID code 
) const

Retrieves the value of a parameter identified by an LhaID.

Parameters
blkName of the block.
codeLhaID of the parameter.
Returns
The current parameter value, including any imaginary component.

Definition at line 73 of file SourceView.cpp.

◆ get_val() [2/6]

scalar_t BlockSrc::get_val ( std::string_view  blk,
int  code 
) const

Helper: get value from an integer code.

Parameters
blkName of the block.
codeInteger PDG-like code.
Returns
The current parameter value, including any imaginary component.

Definition at line 77 of file SourceView.cpp.

◆ get_val() [3/6]

scalar_t BlockSrc::get_val ( std::string_view  blk,
std::initializer_list< int >  code 
) const

Retrieves the value of a parameter given as an initializer_list.

Example:

auto v = src.get_val("MASS", {25}); // H mass
auto v2 = src.get_val("YU", {3,3}); // Yukawa entry
Parameters
blkName of the block.
codeList of positive integer components used to build an LhaID.
Returns
The current parameter value (scalar_t).
Exceptions
std::invalid_argumentif the block or parameter is missing.

Definition at line 66 of file SourceView.cpp.

◆ get_val() [4/6]

scalar_t BlockSrc::get_val ( std::string_view  blk,
std::initializer_list< long >  code 
) const

Retrieves the value of a parameter given as an initializer_list.

Example:

auto v = src.get_val("MASS", {25}); // H mass
auto v2 = src.get_val("YU", {3,3}); // Yukawa entry
Parameters
blkName of the block.
codeList of integer components used to build an LhaID.
Returns
The current parameter value (scalar_t).
Exceptions
std::invalid_argumentif the block or parameter is missing.

Definition at line 54 of file SourceView.cpp.

◆ get_val() [5/6]

scalar_t BlockSrc::get_val ( std::string_view  blk,
std::initializer_list< std::size_t >  code 
) const

Retrieves the value of a parameter given as an initializer_list.

Example:

auto v = src.get_val("MASS", {25}); // H mass
auto v2 = src.get_val("YU", {3,3}); // Yukawa entry
Parameters
blkName of the block.
codeList of positive integer components used to build an LhaID.
Returns
The current parameter value (scalar_t).
Exceptions
std::invalid_argumentif the block or parameter is missing.

Definition at line 58 of file SourceView.cpp.

◆ get_val() [6/6]

scalar_t BlockSrc::get_val ( std::string_view  blk,
std::pair< int, int >  code 
) const

Helper: get value from a pair of integers.

Parameters
blkName of the block.
codePair of indices.
Returns
The current parameter value, including any imaginary component.

Definition at line 81 of file SourceView.cpp.

◆ has_block()

bool BlockSrc::has_block ( std::string_view  name) const

Checks whether a block with a given name is present.

Parameters
nameName of the block.
Returns
True if the underlying map contains this block.

Definition at line 23 of file SourceView.cpp.

◆ raw()

const std::unordered_map< std::string, std::shared_ptr< Block > > & BlockSrc::raw ( ) const

Returns the underlying map reference.

This is useful if the caller needs to iterate or inspect the raw collection of blocks.

Returns
Const reference to the underlying map.

Definition at line 85 of file SourceView.cpp.


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