27 hi.
init(
"lha/testInput.flha", config);
37 auto bin = obs_p->get_bin();
38 LOG_INFO(
"A_FB(B > K mu mu) = [", bin.first,
",", bin.second,
"] =", obs_p->get_val());
45 auto bin2 = obs_p2->get_bin();
46 LOG_INFO(
"A_FB(B > K mu mu) = [", bin2.first,
",", bin2.second,
"] =", obs_p2->get_val());
51 std::unordered_map<ParameterType, std::vector<std::string>> src = {{
ParameterType::SM, {
"SMINPUTS",
"MASS"}}};
53 auto func = [] (
const BlockSrc& src, std::shared_ptr<DependentBlock> dep_block) {
61 LOG_INFO(
"Before: m_W =", sm(
"MASS", 24),
", x_t =", wil(
"WPARAM", 1));
63 LOG_INFO(
"After: m_W =", sm(
"MASS", 24),
", x_t =", wil(
"WPARAM", 1));
65 std::shared_ptr<DBNode> node = std::make_shared<DBNode>();
69 std::cout <<
"writing to file.." << std::endl;
81 auto src = std::make_shared<Block>();
82 src->blockname =
"SRC";
85 auto x = std::make_shared<Parameter>(x_id, 1.0, 0.0, 0.0);
86 src->store(
LhaID(1), x);
88 std::unordered_map<std::string, std::shared_ptr<Block>> blk_sources;
89 blk_sources.emplace(
"SRC", src);
92 [](
const BlockSrc& srcs, std::shared_ptr<DependentBlock> self) {
93 auto s = srcs.
block(
"SRC");
94 double xv = s->retrieve(
LhaID(1))->get_val();
96 if (!self->contains(
LhaID(1))) {
98 auto a = std::make_shared<Parameter>(a_id, xv + 10.0, 0.0, 0.0);
99 self->store(
LhaID(1), a);
101 self->retrieve(
LhaID(1))->set_expected(xv + 10.0);
106 auto dblk = std::make_shared<DependentBlock>(blk_sources, blk_recalc);
107 dblk->blockname =
"DBLK";
114 std::unordered_map<ParamId, std::shared_ptr<Parameter>> psources;
115 psources.emplace(a_id, dblk->retrieve(
LhaID(1)));
118 [a_id](
const ParamSrc& srcs, std::shared_ptr<DependentParameter> self) {
119 double av = srcs.
get_val(a_id);
120 self->set_expected(2.0 * av + 1.0);
124 auto y = std::make_shared<DependentParameter>(y_id, psources, y_recalc);
128 auto out = std::make_shared<Block>();
129 out->blockname =
"OUT";
130 out->store(
LhaID(1), y);
132 double y0 = out->retrieve(
LhaID(1))->get_val();
133 std::cout <<
"y0 = " << y0 <<
" (expect 23)\n";
135 src->assign(
LhaID(1), 2.0);
137 double a1 = dblk->retrieve(
LhaID(1))->get_val();
138 std::cout <<
"a after x=2 => " << a1 <<
" (expect 12)\n";
139 double y1 = out->retrieve(
LhaID(1))->get_val();
140 std::cout <<
"y1 = " << y1 <<
" (expect 25)\n";
142 if (std::abs(y0 - 23.0) > 1e-9) {
143 std::cerr <<
"[FAIL] y0 != 23\n";
146 if (std::abs(y1 - 25.0) > 1e-9) {
147 std::cerr <<
"[FAIL] y1 != 25 -> cascade broken (block->param)\n";
151 std::cout <<
"[OK] DependentBlock + DependentParameter cascade works.\n";
154 catch (
const std::exception& e) {
155 std::cerr <<
"Exception: " << e.what() <<
"\n";
Concrete implementation of IBlockProvider for HyperISO parameter blocks.
std::function< void(const BlockSrc &, std::shared_ptr< DependentBlock >)> DepUpdateFunc
Function type used to recompute a DependentBlock from its sources.
@ HAS_WILSON_INPUT
User provided Wilson coefficient input.
std::function< void(const ParamSrc &, std::shared_ptr< DependentParameter >)> DepParamUpdateFunc
Function signature used to recompute a DependentParameter.
Export the current HyperIso parameter database to JSON, YAML or LHA.
High-level helpers for initializing and monitoring the Hyperiso framework.
Lightweight JSON parser/serializer for DBNode trees.
Parser for LHA / FLHA-style files into LhaBlock structures and DBNode trees.
#define LOG_INFO(...)
Macro for logging informational messages.
Write parameter blocks from a BlockAccessor into a DBNode.
High-level access to parameter values and uncertainties.
High-level access to QCD quantities like α_s and running quark masses.
Lightweight YAML parser/serializer for DBNode trees.
Block identifier with alias support.
Block provider bound to HyperISO Parameters / ParameterType.
void log_all_blocks(ParameterType type) override
Logs all blocks for a given ParameterType.
Lightweight view over a set of source blocks.
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.
Concrete implementation of IDependency using DependentBlockManager.
void add_block_dependency(const BlockName &name, const std::unordered_map< ParameterType, std::vector< std::string > > &source_names, ParameterType dest, DepUpdateFunc recalculateFunc) override
Adds a dependent block using DependentBlockManager.
void write(const std::string &dest, std::shared_ptr< BlockAccessor > src=nullptr) override
Export all blocks from an accessor or from the current database.
High-level interface to initialize and monitor the main framework configuration.
void init(const std::string &lhaFile, HyperisoConfig config)
Initializes Hyperiso using a LHA file and a full Config object.
void switch_lha(const std::string &lhaFile, HyperisoConfig config)
Switches the LHA file and applies a new configuration.
JSON implementation of the IParser interface.
void writeToFile(const std::string &filename, const std::shared_ptr< DBNode > &root) const override
Serializes a DBNode tree to a JSON file.
Parser for LHA/FLHA files, producing blocks and a DBNode representation.
void writeToFile(const std::string &filename, const std::shared_ptr< DBNode > &root) const
Serializes a DBNode structure back to an LHA-like file.
void setLevel(LogLevel level)
Sets the logging level.
static Logger * getInstance()
Retrieves the singleton instance of the Logger.
std::shared_ptr< BlockAccessor > extract_block_accessor()
Extracts all blocks from the cached input.
static MemoryManager * GetInstance()
Retrieves the singleton instance of MemoryManager.
Writer class to populate a DbNode from a BlockAccessor.
void write(std::shared_ptr< DBNode > dest, std::shared_ptr< BlockAccessor > src) override
Write node parameters from a BlockAccessor into the given destination node.
Lightweight view over a set of source parameters keyed by ParamId.
Provides access to parameter values, errors, and existence checks.
std::shared_ptr< Parameter > get_parameter(const ParamId &pid) const
Retrieves the actual Parameter object corresponding to the given ParamId.
Concrete mutator that directly sets the value of parameters.
void mutate(const ParamId &pid, scalar_t value) override
Sets the value of a parameter.
Represents a single parameter with value, uncertainties, and dependency links.
Provides strong coupling constant and MS-bar mass values at various energy scales.
YAML implementation of the IParser interface.
void writeToFile(const std::string &filename, const std::shared_ptr< DBNode > &root) const override
Writes a DBNode hierarchy to a YAML file.
Configuration object controlling model, input flags and optional MARTY resources.
std::map< ExternalFlag, bool > flags
External flags describing the nature of the inputs.
Model model
Current model.
Represents an identifier of a LHA element, possibly containing several sub-ids.
Configuration for computing a particle mass at a given scale.
Composite identifier for a single parameter.