Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
Wilson.cpp
Go to the documentation of this file.
1#include "Wilson.h"
2
3WilsonCoefficient::WilsonCoefficient(const std::string& name, const std::string& storage_block) : coeffName(name), storage_block(storage_block) {
4 if (ends_with(coeffName, "_THDM") || ends_with(coeffName, "_SUSY")) {
6 }
7
8
9 for (auto order : {QCDOrder::LO, QCDOrder::NLO, QCDOrder::NNLO}) {
10 matching_info[order] = MatchingInfo(this->id(order, type));
11 }
12 }
13
14WilsonCoefficient::WilsonCoefficient(const LhaID &name, const std::string& storage_block, ContributionType ct) : coeffName(name.to_string()), storage_block(storage_block) {
15 type = ct;
16
17
18 for (auto order : {QCDOrder::LO, QCDOrder::NLO, QCDOrder::NNLO}) {
19 auto parts = name.get_parts();
20 int order_int = order == QCDOrder::LO ? 0 : order == QCDOrder::NLO ? 1 : 2;
21 int ct_int = ct == ContributionType::SM ? 0 : ct == ContributionType::BSM ? 1 : 2;
22 LhaID full(parts[0], parts[1], order_int, ct_int);
23 matching_info[order] = MatchingInfo(full);
24 }
25}
26
28 return this->matching_info[order].compute;
29}
30
31
32std::unordered_set<ParamId> WilsonCoefficient::get_sources(QCDOrder order) {
33 return this->matching_info[order].sources;
34}
35
36
38 std::unordered_set<ParamId> extra_sources,
39 std::function<scalar_t(const ParamSrc&)> patch) {
40 if (!patch) {
41 LOG_ERROR("ValueError", "Cannot add an empty Wilson matching patch to", this->get_name());
42 }
43
44 auto& info = this->matching_info[order];
45 auto base_compute = info.compute;
46
47 info.sources.insert(extra_sources.begin(), extra_sources.end());
48 info.compute = [base_compute, patch = std::move(patch)](const ParamSrc& src) -> scalar_t {
49 scalar_t base = 0.0;
50 if (base_compute) {
51 base = base_compute(src);
52 }
53 return base + patch(src);
54 };
55}
56
58 return this->matching_info[order].lhaid;
59}
60
62 std::pair<int,int> base_id = WCoefMapper::flha_base(WCoefMapper::id_of(this->get_base_name()));
63 int cont = type == ContributionType::SM ? 0 : type == ContributionType::BSM ? 1 : 2;
64 int ord = order == QCDOrder::LO ? 0 : order == QCDOrder::NLO ? 1 : 2;
65 return LhaID(base_id.first, base_id.second, ord, cont);
66}
67
69 std::string name = this->coeffName;
70
71 if (ends_with(name, "_THDM")) {
72 name = name.substr(0, name.size() - 5);
73 } else if (ends_with(name, "_SUSY")) {
74 name = name.substr(0, name.size() - 5);
75 }
76
77 return name;
78}
79
81{
82 if (this->is_owned && owned) {
83 return;
84 }
85
86 this->is_owned = owned;
87}
88
89void WilsonCoefficient::set_storage_block(std::string block_name) {
90 this->storage_block = block_name;
91}
92
96
100
102 return this->coeffName == other.coeffName
103 && this->type == other.type
104 && this->is_owned == other.is_owned;
105}
106
107complex_t WilsonCoefficient::get_matching_value(std::string order, ContributionType cont_type, std::shared_ptr<IParameterProxy<std::string, LhaID>> wilson_p) const {
108 if (!(*wilson_p).exist(storage_block, this->id(OrderMapper::enum_elt(order), cont_type))) {
109 return complex_t(0.,0.);
110 }
111 return complex_t((*wilson_p)(storage_block, this->id(OrderMapper::enum_elt(order), cont_type)));
112}
QCDOrder
ContributionType
#define LOG_ERROR(type,...)
Macro for logging error messages and terminating the application.
Definition Logger.h:41
std::string to_string(const LhaID &id)
Convenience stringification for LhaID.
Definition SourceView.cpp:9
bool ends_with(const std::string &str, const std::string &suffix)
Tests whether a string ends with a given suffix.
Definition Utils.cpp:3
std::complex< double > complex_t
Convenience alias for std::complex<double>.
Definition Utils.h:35
Domain objects representing Wilson coefficients and their matching metadata.
static IdOf< WCoefTag > enum_elt(std::string_view s)
Alias for id_of(), kept for compatibility.
static IdOf< WCoefTag > id_of(std::string_view s)
Resolves a string into an IdOf<Tag> via the registry.
Abstract interface for reading parameters and basic metadata.
static QCDOrder enum_elt(std::string_view s)
Legacy lookup: converts a string into a QCDOrder enum. Performs a case-insensitive search over the bu...
Lightweight view over a set of source parameters keyed by ParamId.
static std::pair< int, int > flha_base(WCoef e)
Returns the base FLHA pair (a,b) for a given WCoef.
static LhaID flha_full(WCoef e, QCDOrder q, ContributionType c)
Abstract base class representing a Wilson coefficient and its matching information.
Definition Wilson.h:153
std::string get_name() const
Returns the current full name (may include suffixes).
Definition Wilson.h:272
std::string get_base_name() const
Returns the base name of the coefficient without BSM suffixes.
Definition Wilson.cpp:68
std::unordered_set< ParamId > get_sources(QCDOrder order)
Returns the source ParamIds required at a given QCD order.
Definition Wilson.cpp:32
void add_matching_patch(QCDOrder order, std::unordered_set< ParamId > extra_sources, std::function< scalar_t(const ParamSrc &)> patch)
Add an extra additive term to the matching function of one QCD order.
Definition Wilson.cpp:37
void set_contribution_type(ContributionType type)
Sets the contribution type (SM/BSM/…).
Definition Wilson.cpp:93
bool is_owned
Ownership flag (used by higher-level logic to track "produced" coefficients).
Definition Wilson.h:317
LhaID get_lhaid_from_name(QCDOrder order)
Computes the LhaID directly from the coefficient base name and mapping conventions.
Definition Wilson.cpp:61
std::function< scalar_t(const ParamSrc &)> get_func(QCDOrder order)
Returns the compute function for a given QCD order.
Definition Wilson.cpp:27
void set_storage_block(std::string block_name)
Sets the storage block where the coefficient value is stored.
Definition Wilson.cpp:89
LhaID id(QCDOrder order, ContributionType typ) const
Returns the LHA id for a given order and contribution type.
Definition Wilson.cpp:97
WilsonCoefficient()=default
bool operator==(const WilsonCoefficient &other) const
Equality compares name, contribution type, and ownership flag.
Definition Wilson.cpp:101
std::string coeffName
Domain name of the coefficient (may include suffixes like _THDM/_SUSY).
Definition Wilson.h:311
complex_t get_matching_value(std::string order, ContributionType cont_type, std::shared_ptr< IParameterProxy< std::string, LhaID > > wilson_p) const
Reads the coefficient value from the storage backend for a given order/type.
Definition Wilson.cpp:107
std::map< QCDOrder, MatchingInfo > matching_info
Matching metadata indexed by QCD order.
Definition Wilson.h:330
void set_owned(bool owned)
Sets the ownership flag.
Definition Wilson.cpp:80
ContributionType type
Contribution type for this coefficient (SM by default, inferred in constructors).
Definition Wilson.h:314
std::string storage_block
Block name where this coefficient is stored in the Parameters system.
Definition Wilson.h:320
LhaID get_lhaid(QCDOrder order)
Returns the storage LhaID associated with a given QCD order.
Definition Wilson.cpp:57
Represents an identifier of a LHA element, possibly containing several sub-ids.
Definition LhaID.h:56
Matching metadata for a Wilson coefficient at a specific QCD order.
Definition Wilson.h:62