Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
WilsonParamComposer.cpp
Go to the documentation of this file.
2
3#include <algorithm>
4#include <vector>
5
7 const std::string &block_name,
8 const std::unordered_map<ParameterType, std::vector<std::string>> &source_names,
9 const DepUpdateFunc &update_func) {
10 CompositeParamAdapter().add_block_dependency(block_name, source_names, ParameterType::WILSON, update_func);
11 composed_blocks.emplace(block_name);
12}
13
15 const std::unordered_set<ParamId>& source_pids,
16 const DepParamUpdateFunc& update_func)
17{
18 ParamId typed_pid = {ParameterType::WILSON, pid.block, pid.code};
19 std::unordered_set<ParamId> typed_sources;
20 for (auto& src_pid : source_pids) {
21 if (!src_pid.type.has_value()){
22 typed_sources.emplace(ParamId{ParameterType::WILSON, src_pid.block, src_pid.code});
23 } else {
24 typed_sources.emplace(ParamId{src_pid.type.value(), src_pid.block, src_pid.code});
25 }
26 }
27 CompositeParamAdapter().add_param_dependency(typed_pid, typed_sources, update_func);
28 composed_blocks.emplace(pid.block);
29}
30
31void WilsonParamComposer::remove_block(const std::string &block_name) {
33 composed_blocks.erase(block_name);
34}
35
36void WilsonParamComposer::update(const std::string &block_name) {
38}
39
41 // The dependency graph is global in Core::Parameters, while this registry is
42 // manager/composer-local. Remove downstream blocks before their sources so
43 // no lazy DependentBlock keeps a stale pointer to a source block erased from
44 // the global repository.
45 std::vector<std::string> blocks(composed_blocks.begin(), composed_blocks.end());
46
47 auto removal_rank = [](const std::string& name) {
48 // Final hadronic Wilson blocks depend on the intermediate running
49 // blocks, which depend on matching/helper blocks. Remove in that order.
50 if (name.find("_B_SCALE_") != std::string::npos &&
51 name.find("__") == std::string::npos) {
52 return 0;
53 }
54 if (name.find("__") != std::string::npos) {
55 return 1;
56 }
57 if (name.find("_EW_SCALE") != std::string::npos) {
58 return 2;
59 }
60 return 3;
61 };
62
63 std::sort(blocks.begin(), blocks.end(), [&](const std::string& a, const std::string& b) {
64 const int ra = removal_rank(a);
65 const int rb = removal_rank(b);
66 if (ra != rb) return ra < rb;
67 return a < b;
68 });
69
70 for (const auto& block_name : blocks) {
72 }
73 composed_blocks.clear();
74}
std::function< void(const BlockSrc &, std::shared_ptr< DependentBlock >)> DepUpdateFunc
Function type used to recompute a DependentBlock from its sources.
Definition Block.h:56
std::function< void(const ParamSrc &, std::shared_ptr< DependentParameter >)> DepParamUpdateFunc
Function signature used to recompute a DependentParameter.
ParameterType
Block composer specialized for the Wilson parameter scope.
Concrete implementation of IDependency using DependentBlockManager.
void remove_dependency(const BlockName &name, ParameterType src) override
Removes a dependent block using DependentBlockManager.
void add_param_dependency(const ParamId &pid, const std::unordered_set< ParamId > &source_pids, DepParamUpdateFunc recalculateFunc) override
Adds a dependent parameter using DependentBlockManager.
void update_dependency(const BlockName &name, ParameterType src) override
Manually triggers an update on a dependent block 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.
std::unordered_set< std::string > composed_blocks
Registry of blocks composed through this composer instance.
void compose_parameter(const ParamId &, const std::unordered_set< ParamId > &, const DepParamUpdateFunc &) override
Creates a dependent parameter in the Wilson scope.
void compose_block(const std::string &block_name, const std::unordered_map< ParameterType, std::vector< std::string > > &source_names, const DepUpdateFunc &update_func) override
Creates a dependent block in the Wilson scope.
void remove_all_composed_blocks() override
Removes all dependent blocks composed via this composer.
void remove_block(const std::string &) override
Removes a dependent block from the Wilson scope and from the registry.
void update(const std::string &block_name) override
Triggers an update on a dependent block in the Wilson scope.
Composite identifier for a single parameter.
Definition ParamID.h:57
std::optional< ParameterType > type
Optional high-level parameter category.
Definition ParamID.h:65
BlockName block
Name of the block where the parameter is stored.
Definition ParamID.h:73
LhaID code
Index or multi-index of the parameter inside the block.
Definition ParamID.h:82