Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
WilsonGroup.cpp
Go to the documentation of this file.
1#include "WilsonGroup.h"
2
3#include <algorithm>
4
6 for (auto& [_, coeff]: *this) {
7 coeff->set_owned(true);
8 coeff->set_storage_block(this->get_matching_storage_block());
9 coeff->set_contribution_type(this->wilson_type);
10 }
11}
12
14 : std::map<std::string, std::shared_ptr<WilsonCoefficient>> (), adapters(other.adapters)
15{
16 for (const auto& [key, ptr] : other) {
17 if (ptr) {
18 (*this)[key] = ptr->clone();
19 } else {
20 (*this)[key] = nullptr;
21 }
22 }
25 id = other.id;
26 member_ids = other.member_ids;
27 sources = other.sources;
28 block_name = other.block_name;
29}
30
31CoefficientGroup::CoefficientGroup(std::map<std::string, std::shared_ptr<WilsonCoefficient>>& coeffs, WilsonGroupAdapterConfig adapters) : CoefficientGroup(adapters) {
32 this->insert(coeffs.begin(), coeffs.end());
33
34 QCDOrder max_order = QCDOrder::NNLO;
35
36 this->init(max_order == QCDOrder::NONE ? QCDOrder::LO : max_order);
37}
38
40 this->claim_coefficients();
41 for (int order = 1; order <= (int)max_order; order++) {
42 for (auto& coeff : *this) {
43 auto func_wrapper = [&coeff, order](const ParamSrc& src,
44 std::shared_ptr<DependentParameter> dep_param) {
45 auto func = coeff.second->get_func((QCDOrder)order);
46 if (!func) {
47 dep_param->set_expected(0.);
48 return;
49 }
50 dep_param->set_expected(func(src));
51 };
52 adapters.iblock_c->compose_parameter(ParamId{coeff.second->get_storage_block(), coeff.second->get_lhaid((QCDOrder)order)}, coeff.second->get_sources((QCDOrder)order), func_wrapper);
53 }
54 }
55 this->current_order = max_order;
56}
57
59 block_name = name;
60}
61
63 if (std::find(member_ids.begin(), member_ids.end(), id) == member_ids.end()) {
64 member_ids.emplace_back(std::move(id));
65 }
66}
67complex_t CoefficientGroup::get_matching_coefficient(std::string coeff, std::string order, ContributionType cont_type) const {
68 auto it = this->find(coeff);
69 if (it == this->end()) {
70 throw std::out_of_range("Coefficient '" + coeff + "' not found in group '" + GroupMapper::str(this->id) + "'");
71 }
72 return it->second->get_matching_value(order, cont_type, adapters.wilson_proxy);
73}
74
75complex_t CoefficientGroup::get_running_coefficient(std::string coeff, std::string order, ContributionType cont_type, WilsonBasis basis) const {
76 auto it = this->find(coeff);
77 if (it == this->end()) {
78 throw std::out_of_range("Coefficient '" + coeff + "' not found in group '" + GroupMapper::str(this->id) + "'");
79 }
80 auto& c = it->second;
81
82 if (!(*adapters.wilson_proxy).exist(GroupMapper::str(this->id, ScaleType::HADRONIC, basis),
83 c->id(OrderMapper::enum_elt(order), cont_type))) {
84 return complex_t(0.,0.);
85 }
86
88 GroupMapper::str(this->id, ScaleType::HADRONIC, basis),
89 c->id(OrderMapper::enum_elt(order), cont_type)
90 ));
91}
92
96
97std::ostream& operator<<(std::ostream& os, const CoefficientGroup& coeffs) {
98 for(auto& [name, coeff] : coeffs) {
99 os << name << " --------------------------------" << std::endl;
100 os << "LO at mu_W: " << coeffs.get_matching_coefficient(name, "LO", ContributionType::TOTAL) << std::endl;
101 os << "LO at mu_h: " << coeffs.get_running_coefficient(name, "LO", ContributionType::TOTAL) << std::endl;
102 os << "NLO at mu_W: " << coeffs.get_matching_coefficient(name, "NLO", ContributionType::TOTAL) << std::endl;
103 os << "NLO at mu_h: " << coeffs.get_running_coefficient(name, "NLO", ContributionType::TOTAL) << std::endl;
104 os << "NNLO at mu_W: " << coeffs.get_matching_coefficient(name, "NNLO", ContributionType::TOTAL) << std::endl;
105 os << "NNLO at mu_h: " << coeffs.get_running_coefficient(name, "NNLO", ContributionType::TOTAL) << std::endl;
106 }
107 return os;
108}
109
110std::ostream& operator<<(std::ostream& os, std::shared_ptr<CoefficientGroup>& coeffs) {
111 return os << *coeffs;
112}
QCDOrder
WilsonBasis
ContributionType
std::complex< double > complex_t
Convenience alias for std::complex<double>.
Definition Utils.h:35
std::ostream & operator<<(std::ostream &os, const CoefficientGroup &coeffs)
Streams all coefficients and standard values (LO/NLO/NNLO at matching + hadronic scales).
Domain container grouping related Wilson coefficients with matching and running access.
Polymorphic container of WilsonCoefficient objects representing a coefficient group.
CoefficientGroup(WilsonGroupAdapterConfig adapters)
Constructs an empty group with adapter configuration.
void init(QCDOrder order)
Registers dependent parameters for matching coefficients up to a maximum order.
std::vector< WCoefId > member_ids
Dynamic coefficient ids belonging to this group.
std::string get_matching_storage_block() const
Returns the current matching storage block name.
WilsonGroupAdapterConfig adapters
Adapter configuration bundle (proxies, composers, core APIs, MARTY hooks).
complex_t get_matching_coefficient(std::string coeff, std::string order, ContributionType cont_type) const
Reads a coefficient at the matching scale (mu_W).
void claim_coefficients()
Claims coefficient objects as owned by this group and sets their storage/type.
void set_matching_storage_block(std::string)
Sets the matching storage block name (used by claim_coefficients()).
void add_member_id(WCoefId id)
Add one dynamic coefficient id to the membership list if absent.
WGroupId id
Identifier of this group (used by GroupMapper to build block names).
ContributionType wilson_type
Contribution type for this group (default SM).
std::string block_name
Block name for matching-scale storage.
std::map< WilsonBasis, std::map< QCDOrder, CoefficientGroupSources > > sources
Running-block source specification, keyed by (basis -> order).
complex_t get_running_coefficient(std::string coeff, std::string order, ContributionType cont_type, WilsonBasis basis=WilsonBasis::B_STANDARD) const
Reads a coefficient at the hadronic scale (mu_h) in a given basis.
QCDOrder get_order()
Returns the maximum initialized QCD order for this group.
QCDOrder current_order
Max initialized order (default LO).
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.
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.
Abstract base class representing a Wilson coefficient and its matching information.
Definition Wilson.h:153
virtual std::shared_ptr< WilsonCoefficient > clone() const =0
Virtual clone for polymorphic copy.
Hash specialization for SymbolId<Tag>.
Definition BlockName.h:353
Composite identifier for a single parameter.
Definition ParamID.h:57
Dependency injection bundle for CoefficientGroup.
std::shared_ptr< IBlockComposer > iblock_c
Composer used to register dependent parameters / dependent blocks.
std::shared_ptr< IParameterProxy< std::string, LhaID > > wilson_proxy
Proxy used to read/write Wilson coefficients from Parameters (WILSON scope).