Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
DecayParent.cpp
Go to the documentation of this file.
1#include "DecayParent.h"
2#include <iostream>
3#include <algorithm>
4
6 if (order > max_order) {
7 LOG_WARN("QCD order for decay cannot be higher than", OrderMapper::str(max_order));
8 return max_order;
9 }
10 return order;
11}
12
13DecayParent::DecayParent(DecayId id, double matching_scale, double hadronic_scale, QCDOrder order, ObservablePortsConfig& ports) :
14 ports(ports), use_marty(ports.iobs_use_marty), p(ports.iobspp_sm), iobs_qcdp(ports.iobs_qcdp), iobs_wfreezer(ports.iobs_wfreezer), w_helper(ports.iobs_whelper) {
16 this->id = id;
17 this->w_config.matching_scale = matching_scale;
18 this->w_config.hadronic_scale = hadronic_scale;
19 this->w_config.order = check_max_order(order);
20}
21
22void DecayParent::bind_wilson_builder(std::shared_ptr<IObsWilsonBuilder> &wilson_builder) {
23 this->w_builder = wilson_builder;
24}
25
27 if (this->enabled) {
29 return;
30 }
31 if (!w_helper) {
32 w_helper = std::make_shared<ObsWilsonHelper>();
33 }
34 w_helper->build(this->w_config, this->w_builder, iobs_wfreezer);
35 this->w_proxy = this->w_builder->get_proxy();
36 this->w_proxy->set_basis(WilsonBasis::B_STANDARD);
38 this->enabled = true;
39}
40
42 this->enabled = false;
43}
44
46 if (use_marty->get() && new_order > QCDOrder::LO) {
47 LOG_WARN("Using MARTY defaults all calculations to LO in QCD.");
48 new_order = QCDOrder::LO;
49 }
50
51 QCDOrder effective_order = check_max_order(new_order);
52 if (this->w_config.order == effective_order) {
53 return;
54 }
55
56 if (this->enabled) {
58 "Changing QCD order for enabled decay",
59 DecayMapper::str(this->id),
60 "from",
62 "to",
63 OrderMapper::str(effective_order),
64 ": cached parameters are invalidated."
65 );
66 disable();
67 }
68
69 this->w_config.order = effective_order;
70}
71
72void DecayParent::set_n_threads(size_t n_threads) {
74 "Thread configuration is not implemented for decay",
75 DecayMapper::str(this->id),
76 ". Requested",
77 n_threads,
78 "threads."
79 );
80}
81
83 return 1;
84}
85
87 return false;
88}
89
90void DecayParent::set_bins(std::vector<std::pair<double, double>> new_bins) {
91 for (auto& [qmin, qmax] : new_bins)
92 if (qmin > qmax)
93 LOG_WARN("Found inverted bin [", qmin, ",", qmax, "].");
94
95 this->bins = new_bins;
96}
97
98void DecayParent::add_bin(std::pair<double, double> new_bin) {
99 if (new_bin.first > new_bin.second)
100 LOG_WARN("Found inverted bin [", new_bin.first, ",", new_bin.second, "].");
101
102 if (!this->bins.has_value()) {
103 this->bins = std::vector<std::pair<double, double>>{};
104 }
105
106 auto& current_bins = this->bins.value();
107 if (std::find(current_bins.begin(), current_bins.end(), new_bin) == current_bins.end()) {
108 current_bins.emplace_back(new_bin);
109 }
110}
111
112std::optional<std::vector<std::pair<double, double>>> DecayParent::get_bins() {
113 return this->bins;
114}
Base class for observable/decay computation modules.
QCDOrder
#define LOG_WARN(...)
Macro for logging warning messages.
Definition Logger.h:40
DecayId id
Unique decay identifier.
bool enabled
Whether the decay is enabled (i.e. Wilson groups built and parameters loaded).
virtual void load_params()=0
Load and cache parameters needed by this decay.
WilsonBuildConfig w_config
Wilson build configuration used when enabling this decay (scales, order, groups).
std::shared_ptr< IWilsonFreezer< WGroupId > > iobs_wfreezer
Freezer to freeze/unfreeze Wilson blocks when they are not needed by active decays.
ObservablePortsConfig & ports
Reference to the ports/configuration wiring this decay to the framework.
Definition DecayParent.h:93
virtual void set_n_threads(size_t n_threads)
Set the number of worker threads used by decays that support parallel cache filling.
std::optional< std::vector< std::pair< double, double > > > bins
Optional q^2 bins.
std::shared_ptr< IObsCoreAPI< bool > > use_marty
Port exposing whether the MARTY backend is active.
void add_bin(std::pair< double, double > new_bin)
Adds a bin to the observables related to this decay.
void enable()
Enable the decay module (build Wilson groups and load parameters).
QCDOrder max_order
Maximum QCD order supported by this decay module (default: LO).
Definition DecayParent.h:90
void set_bins(std::vector< std::pair< double, double > > new_bins)
Set the binning for the observables related to this decay.
virtual size_t get_n_threads() const
Return the currently configured worker-thread count.
void disable()
Disable the decay module.
void bind_wilson_builder(std::shared_ptr< IObsWilsonBuilder > &wilson_builder)
Bind a Wilson builder to this decay.
void set_order(QCDOrder new_order)
Set the QCD order for this decay (one-shot policy).
DecayParent(DecayId custom_id, double matching_scale, double hadronic_scale, QCDOrder order, ObservablePortsConfig &ports)
Construct a decay module and bind it to the observable ports.
virtual bool supports_thread_config() const
Whether this decay supports runtime thread configuration.
std::shared_ptr< IObsWilsonProxy > w_proxy
Wilson proxy used at compute-time to query coefficients (matching/run).
Definition DecayParent.h:99
std::shared_ptr< ObsWilsonHelper > w_helper
Per-manager Wilson lifecycle helper.
std::optional< std::vector< std::pair< double, double > > > get_bins()
Returns the current binning of the decay.
QCDOrder check_max_order(QCDOrder order) const
Clamp a requested QCD order to this decay's supported maximum.
std::shared_ptr< IObsWilsonBuilder > w_builder
Wilson builder used to build/add Wilson groups for this decay.
Definition DecayParent.h:96
static std::string str(const IdOf< QCDOrderTag > &id)
Returns the string representation associated with an identifier.
static std::string str(const IdOf< DecayTag > &id)
Returns the string representation of an identifier.
Dependency container (“ports”) for observable computations.
std::shared_ptr< IObsWilsonBuilder > iobswb
Builder used to (re)build Wilson coefficient groups on demand.
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