Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
main_custom.cpp
Go to the documentation of this file.
1#include <iostream>
2#include "WilsonBuilder.h"
3#include "WilsonManager.h"
4#include "GroupDefinition.h"
5#include "CustomWilson.h"
6#include "CustomWilsonGroup.h"
7
8int main(int argc, char** argv) {
9
10 auto hyp = HyperisoMaster();
11 HyperisoConfig config_hyp;
12
13 config_hyp.model = Model::SM;
14 config_hyp.mty_model_name = "ZPrime";
15 config_hyp.mty_model_path = argc > 2 ? argv[2] : "Assets/input_files/marty_model/ZPrime.h";
16 hyp.init(argc > 1 ? argv[1] : "Assets/lha/camilia.flha", config_hyp);
17
18 GroupMapper::register_custom("NP_DEMO", {"np-demo"});
19 const WGroupId GID = GroupMapper::id_of("NP_DEMO");
20
23 const auto CNP1 = WCoefMapper::id_of("C_NP1");
24 const auto CNP2 = WCoefMapper::id_of("C_NP2");
25 WCoefMapper::set_external(CNP1, {9001, 1});
26 WCoefMapper::set_external(CNP2, {9001, 2});
27
29 def.id = GID;
30
31 def.sources[WilsonBasis::B_STANDARD][QCDOrder::LO].sources = {
33 };
34
35 def.sources[WilsonBasis::B_STANDARD][QCDOrder::LO].func =
36 [=](const std::unordered_map<QCDOrder, std::unordered_map<WCoefId, scalar_t>>& match,
37 const BlockSrc& /*src*/) -> std::unordered_map<WCoefId, scalar_t>
38 {
39 const auto& C_LO = match.at(QCDOrder::LO);
40
41 const auto it1 = C_LO.find(CNP1);
42 const auto it2 = C_LO.find(CNP2);
43 scalar_t C1W = (it1==C_LO.end()) ? scalar_t{} : it1->second;
44 scalar_t C2W = (it2==C_LO.end()) ? scalar_t{} : it2->second;
45
46 // [ 0.85 0.10 ]
47 // [ 0.05 0.90 ]
48 scalar_t C1H = scalar_t(0.85)*C1W + scalar_t(0.10)*C2W;
49 scalar_t C2H = scalar_t(0.05)*C1W + scalar_t(0.90)*C2W;
50
51 return {
52 { CNP1, C1H },
53 { CNP2, C2H }
54 };
55 };
56
57 def.setup[Model::SM].push_back([=](const BuildContext& ctx, CoefficientGroup& grp){
58 const auto blk = GroupMapper::str(ctx.group_id, ScaleType::MATCHING);
59
60 auto w1 = std::make_shared<CustomWilson>(LhaID(9001,1,0,(int)ctx.contrib), blk, ctx.contrib);
61 w1->set_name("C_NP1");
62 w1->set_contribution_type(ctx.contrib);
63 w1->set_order_info(QCDOrder::LO, /*sources*/{},
64 [](const ParamSrc&){ return scalar_t(1.234); },
65 LhaID(9001,1,0,(int)ctx.contrib));
66
67 auto w2 = std::make_shared<CustomWilson>(LhaID(9001,2,0,(int)ctx.contrib), blk, ctx.contrib);
68 w2->set_name("C_NP2");
69 w2->set_contribution_type(ctx.contrib);
70 w2->set_order_info(QCDOrder::LO, /*sources*/{},
71 [](const ParamSrc&){ return scalar_t(0.5); },
72 LhaID(9001,2,0,(int)ctx.contrib));
73
74 grp.insert({ w1->get_name(), w1 });
75 grp.insert({ w2->get_name(), w2 });
76 });
77
79
81 cfg.groups = { GID };
82 cfg.matching_scale = 80.0; // mu_W
83 cfg.hadronic_scale = 4.8; // mu_h
84 cfg.order = QCDOrder::LO;
85
86 auto builder = std::make_shared<WilsonBuilder>(cfg);
87 auto cm = builder->get_coefficient_manager();
88
89 const std::string gname = GroupMapper::str(GID);
90 auto CNP1_M = cm->getMatchingCoefficient(gname, "C_NP1", "LO", ContributionType::SM);
91 auto CNP2_M = cm->getMatchingCoefficient(gname, "C_NP2", "LO", ContributionType::SM);
92 auto CNP1_R = cm->getRunCoefficient(gname, "C_NP1", "LO", ContributionType::SM, WilsonBasis::B_STANDARD);
93 auto CNP2_R = cm->getRunCoefficient(gname, "C_NP2", "LO", ContributionType::SM, WilsonBasis::B_STANDARD);
94
95 std::cout << "C_NP1 LO @ mu_W = " << CNP1_M << "\n";
96 std::cout << "C_NP2 LO @ mu_W = " << CNP2_M << "\n";
97 std::cout << "C_NP1 LO @ mu_h = " << CNP1_R << "\n";
98 std::cout << "C_NP2 LO @ mu_h = " << CNP2_R << "\n";
99
100 return 0;
101}
User-assembled CoefficientGroup with explicit coefficients and running rules.
User-definable WilsonCoefficient with explicit per-order matching definitions.
Declarative registry describing Wilson coefficient groups, their sources, and setup hooks.
constexpr const char * MATCHING_BLOCK_PLACEHOLDER
Placeholder string used in GroupDefinition sources to refer to the matching block.
High-level orchestration of Wilson coefficient groups (matching + running/hadronic).
Lightweight view over a set of source blocks.
Definition SourcesView.h:71
Polymorphic container of WilsonCoefficient objects representing a coefficient group.
static bool register_custom(std::string canonical, std::vector< std::string > aliases={}, std::optional< std::pair< int, int > > ext=std::nullopt)
Registers a custom entry with optional external key.
static bool set_external(const IdOf< WCoefTag > &id, const std::pair< int, int > &k)
Sets or updates the external key of an existing identifier.
static IdOf< WGroupTag > id_of(std::string_view s)
Resolves a string into an IdOf<Tag> via the registry.
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 bool register_custom(std::string canonical, std::vector< std::string > aliases={}, std::optional< std::string > ext=std::nullopt)
Registers a custom Wilson group with optional external label.
High-level interface to initialize and monitor the main framework configuration.
Lightweight view over a set of source parameters keyed by ParamId.
Returns an uppercase copy of the input string.
void register_custom(const GroupDefinition &def)
Registers a custom group definition at runtime.
Build-time context passed to group setup hooks.
WGroupId group_id
Identifier of the group being built.
ContributionType contrib
Contribution type used for this build (SM/BSM/TOTAL, etc.).
Declarative description of a Wilson coefficient group.
WGroupId id
Identifier for this group.
Configuration object controlling model, input flags and optional MARTY resources.
Definition Config.h:24
std::optional< fs::path > mty_model_path
Path to the MARTY model file, if needed.
Definition Config.h:35
std::optional< std::string > mty_model_name
MARTY model class name, if needed.
Definition Config.h:34
Model model
Current model.
Definition Config.h:33
Represents an identifier of a LHA element, possibly containing several sub-ids.
Definition LhaID.h:56
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