Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
SourcesView.h
Go to the documentation of this file.
1#ifndef SOURCES_VIEW_H
2#define SOURCES_VIEW_H
3
4#include <unordered_map>
5#include <memory>
6#include <sstream>
7#include <string>
8#include <string_view>
9#include <stdexcept>
10#include <vector>
11#include <utility>
12
13#include "Block.h"
14#include "Parameters.h"
15
16
26std::string join(const std::vector<std::string>& v);
27
36std::string to_string(const LhaID& id);
37
48std::string to_string(const ParamId& id);
49
71class BlockSrc {
72public:
80 explicit BlockSrc(const std::unordered_map<std::string, std::shared_ptr<Block>>& m,
81 std::string ctx = {});
82
89 bool has_block(std::string_view name) const;
90
102 const std::shared_ptr<Block>& block(std::string_view name) const;
103
116 std::shared_ptr<Parameter> get_param(std::string_view blk, const LhaID& code) const;
117
127 std::shared_ptr<Parameter> get_param(std::string_view blk, int code) const;
128
138 std::shared_ptr<Parameter> get_param(std::string_view blk, std::pair<int,int> code) const;
139
155 scalar_t get_val(std::string_view blk, std::initializer_list<long> code) const;
156
172 scalar_t get_val(std::string_view blk,
173 std::initializer_list<std::size_t> code) const;
174
190 scalar_t get_val(std::string_view blk, std::initializer_list<int> code) const;
191
199 scalar_t get_val(std::string_view blk, const LhaID& code) const;
200
208 scalar_t get_val(std::string_view blk, int code) const;
209
217 scalar_t get_val(std::string_view blk, std::pair<int,int> code) const;
218
227 const std::unordered_map<std::string, std::shared_ptr<Block>>& raw() const;
228
229private:
230 const std::unordered_map<std::string, std::shared_ptr<Block>>* m_;
231 std::string ctx_;
232};
233
249class ParamSrc {
250public:
257 explicit ParamSrc(const std::unordered_map<ParamId, std::shared_ptr<Parameter>>& m,
258 std::string ctx = {});
259
261 ParamSrc() = default;
262
269 bool has(const ParamId& id) const;
270
282 const std::shared_ptr<Parameter>& require(const ParamId& id) const;
283
292 std::shared_ptr<Parameter> get_param(const ParamId& id) const;
293
300 scalar_t get_val(const ParamId& id) const;
301
312 scalar_t get_val(ParameterType t, std::string_view block, std::initializer_list<long> code) const;
313
317 scalar_t get_val(ParameterType t, std::string_view block, const LhaID& code) const;
318
322 scalar_t get_val(ParameterType t, std::string_view block, int code) const;
323
327 scalar_t get_val(ParameterType t, std::string_view block, std::pair<int,int> code) const;
328
334 const std::unordered_map<ParamId, std::shared_ptr<Parameter>>& raw() const;
335
336private:
337 const std::unordered_map<ParamId, std::shared_ptr<Parameter>>* m_;
338 std::string ctx_;
339};
340
348BlockSrc as_block_src(const std::unordered_map<std::string, std::shared_ptr<Block>>& m, std::string ctx = {});
349
357ParamSrc as_param_src(const std::unordered_map<ParamId, std::shared_ptr<Parameter>>& m, std::string ctx = {});
358
359#endif
Defines classes used to store parameters and to build derived/dependent parameter blocks.
ParameterType
Model-dependent parameter repository and initialization strategies.
std::string to_string(const LhaID &id)
Convenience stringification for LhaID.
Definition SourceView.cpp:9
std::string join(const std::vector< std::string > &v)
Joins a list of strings with ", ".
Definition SourceView.cpp:3
BlockSrc as_block_src(const std::unordered_map< std::string, std::shared_ptr< Block > > &m, std::string ctx={})
Helper function to build a BlockSrc view from a block map.
ParamSrc as_param_src(const std::unordered_map< ParamId, std::shared_ptr< Parameter > > &m, std::string ctx={})
Helper function to build a ParamSrc view from a parameter map.
Lightweight view over a set of source blocks.
Definition SourcesView.h:71
const std::unordered_map< std::string, std::shared_ptr< Block > > & raw() const
Returns the underlying map reference.
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.
const std::shared_ptr< Block > & block(std::string_view name) const
Returns a reference to a block by name.
std::shared_ptr< Parameter > get_param(std::string_view blk, const LhaID &code) const
Retrieves a parameter from a given block by LhaID.
bool has_block(std::string_view name) const
Checks whether a block with a given name is present.
Lightweight view over a set of source parameters keyed by ParamId.
const std::shared_ptr< Parameter > & require(const ParamId &id) const
Returns a parameter reference or throws if missing.
ParamSrc()=default
Default constructor: creates an empty, unbound view.
std::shared_ptr< Parameter > get_param(const ParamId &id) const
Convenience wrapper for require().
const std::unordered_map< ParamId, std::shared_ptr< Parameter > > & raw() const
Access to the underlying parameter map.
scalar_t get_val(const ParamId &id) const
Retrieves the current value of a parameter.
bool has(const ParamId &id) const
Checks whether a parameter with the given ID exists.
Represents an identifier of a LHA element, possibly containing several sub-ids.
Definition LhaID.h:56
Composite identifier for a single parameter.
Definition ParamID.h:57