Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
ObsWilsonHelper.cpp
Go to the documentation of this file.
1#include "ObsWilsonHelper.h"
2
4 state.clear();
5}
6
8 std::shared_ptr<IObsWilsonBuilder>& wil_builder,
9 std::shared_ptr<IWilsonFreezer<WGroupId>> iobs_wfreezer) {
10 config.groups = update_state(config, std::move(iobs_wfreezer));
11 if (config.groups.empty()) {
12 return;
13 }
14 for (auto group : config.groups) {
15 LOG_DEBUG("Building Wilson group", GroupMapper::str(group));
16 }
17 wil_builder->build(std::make_shared<WilsonBuildConfig>(config));
18}
19
20void ObsWilsonHelper::mark_built(WGroupId group, const WilsonBuildConfig& config, bool frozen) {
21 state[group] = GroupState{frozen, make_signature(config)};
22}
23
25 double matching_scale,
26 double hadronic_scale,
27 QCDOrder order,
28 bool frozen) {
29 WilsonBuildConfig config;
30 config.groups = {group};
31 config.matching_scale = matching_scale;
32 config.hadronic_scale = hadronic_scale;
33 config.order = order;
34 mark_built(group, config, frozen);
35}
36
37std::unordered_set<WGroupId> ObsWilsonHelper::get_all_groups(const std::unordered_set<WGroupId>& needed) const {
38 std::unordered_set<WGroupId> all_groups;
39 all_groups.reserve(state.size() + needed.size());
40
41 for (const auto& [group, _] : state) {
42 all_groups.emplace(group);
43 }
44 all_groups.insert(needed.begin(), needed.end());
45
46 return all_groups;
47}
48
49std::unordered_set<WGroupId> ObsWilsonHelper::update_state(const WilsonBuildConfig& config,
50 std::shared_ptr<IWilsonFreezer<WGroupId>> iobs_wfreezer) {
51 std::unordered_set<WGroupId> to_build;
52 const auto signature = make_signature(config);
53
54 for (auto group : get_all_groups(config.groups)) {
55 if (!config.groups.contains(group)) {
56 auto it = state.find(group);
57 if (it != state.end() && !it->second.frozen && iobs_wfreezer) {
58 iobs_wfreezer->freeze(group);
59 it->second.frozen = true;
60 }
61 continue;
62 }
63
64 auto it = state.find(group);
65 if (it == state.end()) {
66 to_build.emplace(group);
67 state[group] = GroupState{false, signature};
68 continue;
69 }
70
71 if (!it->second.signature.matches(config)) {
72 to_build.emplace(group);
73 it->second = GroupState{false, signature};
74 continue;
75 }
76
77 if (it->second.frozen) {
78 if (iobs_wfreezer) {
79 iobs_wfreezer->unfreeze(group);
80 }
81 it->second.frozen = false;
82 }
83 }
84
85 return to_build;
86}
87
88ObsWilsonHelper::BuildSignature ObsWilsonHelper::make_signature(const WilsonBuildConfig& config) {
89 return BuildSignature{config.matching_scale, config.hadronic_scale, config.order};
90}
QCDOrder
#define LOG_DEBUG(...)
Macro for logging debug messages.
Definition Logger.h:45
Per-manager helper that manages the Wilson group lifecycle for observable computations.
static std::string str(const WGroupId &gid, ScaleType s, WilsonBasis b=WilsonBasis::B_STANDARD)
Builds a composite block name using a WGroupId, scale and basis.
void clear()
Clear the per-helper build/freeze state.
void mark_built(WGroupId group, const WilsonBuildConfig &config, bool frozen=false)
Mark a Wilson group as already available in this helper state.
void build(WilsonBuildConfig config, std::shared_ptr< IObsWilsonBuilder > &wil_builder, std::shared_ptr< IWilsonFreezer< WGroupId > > iobs_wfreezer)
Build or update Wilson groups required by observables.
Returns an uppercase copy of the input string.
Configuration for building sets of Wilson coefficients.
Definition Configs.h:32
std::unordered_set< WGroupId > groups
Set of Wilson operator group identifiers to be included in the build.
Definition Configs.h:36
double hadronic_scale
Hadronic scale (in GeV) at which the Wilson coefficients are evaluated in the effective theory.
Definition Configs.h:48
QCDOrder order
Perturbative QCD order used for the evolution and matching of Wilson coefficients....
Definition Configs.h:54
double matching_scale
Matching scale (in GeV) at which the high-energy theory is matched to the effective theory.
Definition Configs.h:42