Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
CustomWilsonLambda.h
Go to the documentation of this file.
1#ifndef CUSTOM_WILSON_LAMBDA_H
2#define CUSTOM_WILSON_LAMBDA_H
3
4#include <map>
5#include <memory>
6#include <string>
7#include <unordered_map>
8#include <unordered_set>
9#include <utility>
10#include <vector>
11
12#include "CustomWilson.h"
13#include "CustomWilsonGroup.h"
14#include "WilsonBlockNames.h"
15
53
55 std::map<QCDOrder, MatchingInfo> matching;
56
58 explicit CustomWilsonCoefficientConfig(WCoefId id) : id(std::move(id)) {}
59
70 QCDOrder order,
71 std::unordered_set<ParamId> sources,
72 std::function<scalar_t(const ParamSrc&)> compute,
74 ) {
75 matching[order] = MatchingInfo(
76 std::move(sources),
77 std::move(compute),
78 WCoefMapper::flha_full(id, order, contribution)
79 );
80 return *this;
81 }
82};
83
102
104 std::string display_name;
105
107 double matching_scale {81.0};
108
110 double hadronic_scale {4.8};
111
114
117
119 std::vector<CustomWilsonCoefficientConfig> coefficients;
120
122 std::unordered_map<WilsonBasis, std::map<QCDOrder, CoefficientGroupSources>> running;
123
126
129
134 coefficients.emplace_back(std::move(coef));
135 return *this;
136 }
137
146 WilsonBasis basis,
148 std::unordered_map<ParameterType, std::vector<std::string>> sources,
149 std::function<std::unordered_map<WCoefId, scalar_t>(
150 const std::unordered_map<QCDOrder, std::unordered_map<WCoefId, scalar_t>>&,
151 const BlockSrc&
152 )> compute
153 ) {
155 s.sources = std::move(sources);
156 s.func = std::move(compute);
157 running[basis][order] = std::move(s);
158 return *this;
159 }
160};
161
168inline std::unordered_map<WCoefId, scalar_t> custom_identity_running(
169 const std::unordered_map<QCDOrder, std::unordered_map<WCoefId, scalar_t>>& matching,
170 const BlockSrc&
171) {
172 if (auto it = matching.find(QCDOrder::NNLO); it != matching.end()) return it->second;
173 if (auto it = matching.find(QCDOrder::NLO); it != matching.end()) return it->second;
174 if (auto it = matching.find(QCDOrder::LO); it != matching.end()) return it->second;
175 return {};
176}
177
185inline std::shared_ptr<CustomCoefficientGroup> make_custom_wilson_group(
186 const CustomWilsonGroupConfig& cfg,
188) {
189 const std::string name = cfg.display_name.empty() ? GroupMapper::str(cfg.group) : cfg.display_name;
190 auto group = std::make_shared<CustomCoefficientGroup>(adapters, cfg.group, name, cfg.contribution);
191 group->set_matching_storage_block(WilsonBlockNames::matching(cfg.group));
192 group->set_wilson_type(cfg.contribution);
193
194 for (const auto& coef_cfg : cfg.coefficients) {
195 auto coef = std::make_shared<CustomWilson>(
196 coef_cfg.id,
198 cfg.contribution
199 );
200
201 for (auto order : {QCDOrder::LO, QCDOrder::NLO, QCDOrder::NNLO}) {
202 auto it = coef_cfg.matching.find(order);
203 if (it != coef_cfg.matching.end()) {
204 coef->set_order_info(order, it->second.sources, it->second.compute, it->second.lhaid);
205 } else {
206 coef->set_order_info(
207 order,
208 {},
209 [](const ParamSrc&) { return 0.0; },
210 WCoefMapper::flha_full(coef_cfg.id, order, cfg.contribution)
211 );
212 }
213 }
214
215 group->add_coefficient(coef_cfg.id, coef);
216 }
217
218 if (!cfg.running.empty()) {
219 for (const auto& [basis, per_order] : cfg.running) {
220 group->add_sources(basis, per_order);
221 }
222 } else if (cfg.install_identity_running_if_empty) {
223 std::map<QCDOrder, CoefficientGroupSources> per_order;
224 for (auto order : {QCDOrder::LO, QCDOrder::NLO, QCDOrder::NNLO}) {
227 s.func = &custom_identity_running;
228 per_order[order] = std::move(s);
229 }
230 group->add_sources(WilsonBasis::B_STANDARD, per_order);
231 }
232
233 return group;
234}
235
236#endif // CUSTOM_WILSON_LAMBDA_H
User-assembled CoefficientGroup with explicit coefficients and running rules.
std::shared_ptr< CustomCoefficientGroup > make_custom_wilson_group(const CustomWilsonGroupConfig &cfg, WilsonGroupAdapterConfig adapters)
Build a CustomCoefficientGroup from a lambda config.
std::unordered_map< WCoefId, scalar_t > custom_identity_running(const std::unordered_map< QCDOrder, std::unordered_map< WCoefId, scalar_t > > &matching, const BlockSrc &)
Identity running rule used as a safe default for custom groups.
User-definable WilsonCoefficient with explicit per-order matching definitions.
QCDOrder
WilsonBasis
ParameterType
ContributionType
Centralizes canonical SLHA/LHA block naming conventions for Wilson blocks.
Lightweight view over a set of source blocks.
Definition SourcesView.h:71
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.
Lightweight view over a set of source parameters keyed by ParamId.
static LhaID flha_full(WCoef e, QCDOrder q, ContributionType c)
Hash specialization for SymbolId<Tag>.
Definition BlockName.h:353
Source specification and aggregation function for a coefficient group block.
Definition WilsonGroup.h:68
Configuration of one user-defined Wilson coefficient.
std::map< QCDOrder, MatchingInfo > matching
Per-order matching rules.
WCoefId id
Dynamic coefficient id. It must be known by WCoefMapper and have an FLHA base key.
CustomWilsonCoefficientConfig & set_matching(QCDOrder order, std::unordered_set< ParamId > sources, std::function< scalar_t(const ParamSrc &)> compute, ContributionType contribution=ContributionType::SM)
Attach a matching lambda to a QCD order.
Configuration of a user-defined Wilson group built from lambdas.
bool install_identity_running_if_empty
If true, install identity running for B_STANDARD when no running rules were provided.
CustomWilsonGroupConfig(WGroupId group)
std::string display_name
Optional display name used by CustomCoefficientGroup; the mapper name remains authoritative.
double hadronic_scale
Hadronic/running scale used when the group is added to the manager.
CustomWilsonGroupConfig()=default
ContributionType contribution
Contribution slot computed by the custom matching lambdas.
WGroupId group
Dynamic group id. Register it with GroupMapper before use if it is custom.
QCDOrder order
Highest QCD order to initialize.
double matching_scale
Matching scale used when the group is added to the manager.
std::vector< CustomWilsonCoefficientConfig > coefficients
Coefficients belonging to the group.
std::unordered_map< WilsonBasis, std::map< QCDOrder, CoefficientGroupSources > > running
Running rules keyed by basis and QCD order.
CustomWilsonGroupConfig & add_coefficient(CustomWilsonCoefficientConfig coef)
Add a coefficient config to the group.
CustomWilsonGroupConfig & set_running(WilsonBasis basis, QCDOrder order, std::unordered_map< ParameterType, std::vector< std::string > > sources, std::function< std::unordered_map< WCoefId, scalar_t >(const std::unordered_map< QCDOrder, std::unordered_map< WCoefId, scalar_t > > &, const BlockSrc &)> compute)
Attach a running lambda for a basis/order pair.
Matching metadata for a Wilson coefficient at a specific QCD order.
Definition Wilson.h:62
static std::string matching(WGroupId gid)
Returns the canonical matching block name for a Wilson group.
Dependency injection bundle for CoefficientGroup.