Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1#include "Logger.h"
2#include <iostream>
3#include <cassert>
5#include "HyperisoMaster.h"
6
7//TODO : .count doesn't work on vector
8// Utility function for displaying results
9template<typename T, typename U>
10void assert_equal(const T& result, const U& expected, const std::string& test_name) {
11 if (result == expected) {
12 std::cout << "[PASS] " << test_name << "\n";
13 } else {
14 std::cerr << "[FAIL] " << test_name << ": got " << result << ", expected " << expected << "\n";
15 }
16}
17
19 using enum Observables;
20 using enum QCDOrder;
21 using enum UncertaintyType;
22
23 // Add single observable
24 interface.add_observable(BR_BS_MUMU, NLO, true);
25 // assert_equal(interface.get_current_observables().count(ObservableMapper::to_id(BR_BS_MUMU)), 1u, "add_observable");
26
27 // Add multiple observables (map version)
28 interface.add_observables({
29 {R_D, LO},
30 {R_DSTAR, LO}
31 }, true);
32 // assert_equal(interface.get_current_observables().count(ObservableMapper::to_id(R_D)), 1u, "add_observables (map) - R_D");
33 // assert_equal(interface.get_current_observables().count(ObservableMapper::to_id(R_DSTAR)), 1u, "add_observables (map) - R_DSTAR");
34
35 // Add decay observables
38 // assert_equal(interface.get_current_observables().count(ObservableMapper::to_id(obs)), 1u, "add_observables (decay)");
39 }
40
41 // Add observable parameters
42 // interface.add_observable_parameter(R_DSTAR, ParamId(ParameterType::FLAVOR, "FMASS", 423));
43 // interface.add_observable_parameters(R_D, {ParamId(ParameterType::FLAVOR, "FMASS", 421), ParamId(ParameterType::FLAVOR, "FMASS", 521)});
44
45 // Compute observable
46 auto val = interface.compute_observable(R_DSTAR);
47 for (auto elem : val) {
48 std::cout << "compute_observable: " << elem.value << "\n";
49 }
50
51 // // Compute uncertainty
52 // auto unc = interface.compute_uncertainty(R_DSTAR);
53 // std::cout << "compute_uncertainty: " << unc << "\n";
54
55 // // Leading uncertainties
56 // auto leading_uncs = interface.compute_leading_uncertainties(BR_BS_MUMU, 2);
57 // std::cout << "compute_leading_uncertainties size: " << leading_uncs.size() << "\n";
58
59 // // All uncertainties
60 // auto all_uncs = interface.compute_all_uncertainties();
61 // std::cout << "compute_all_uncertainties size: " << all_uncs.size() << "\n";
62
63 // // Chi2
64 // double chi2 = interface.compute_chi2();
65 // std::cout << "compute_chi2: " << chi2 << "\n";
66
67 // Remove single observable
69 // assert_equal(interface.get_current_observables().count(ObservableMapper::to_id(BR_BS_MUMU)), 0u, "remove_observable");
70
71 // Remove multiple observables (set)
72 interface.remove_observables({R_D, R_DSTAR});
73 // assert_equal(interface.get_current_observables().count(ObservableMapper::to_id(R_D)), 0u, "remove_observables (set) - R_D");
74
75 // Remove decay observables
78 // assert_equal(interface.get_current_observables().count(ObservableMapper::to_id(obs)), 0u, "remove_observables (decay)");
79 }
80
81 // Experimental values and uncertainties
82 interface.add_observable(R_DSTAR, LO); // Add back for exp tests
83 scalar_t exp_val = interface.get_exp_value(R_DSTAR);
84 scalar_t stat = interface.get_exp_uncertainty(R_DSTAR, STAT);
85 scalar_t syst = interface.get_exp_uncertainty(R_DSTAR, SYST);
86 std::cout << "get_exp_value: " << exp_val << ", stat: " << stat << ", syst: " << syst << "\n";
87
88 // compute_all
89 auto estimates = interface.compute_all();
90 std::cout << "compute_all size: " << estimates.size() << "\n";
91
92 // // get_all_exp
93 // auto all_exp = interface.get_all_exp();
94 // std::cout << "get_all_exp size: " << all_exp.size() << "\n";
95}
96
97
98int main() {
100 HyperisoMaster hyperiso;
101 HyperisoConfig config;
102 config.model = Model::SM;
103 hyperiso.init("default/lha/testInput.flha", config);
104 LOG_INFO("HyperisoMaster initialized");
105
106 auto interface = ObservableInterface();
107
108 test_interface(interface);
109}
void test_interface(ObservableInterface &interface)
Definition main.cpp:18
void assert_equal(const T &result, const U &expected, const std::string &test_name)
Definition main.cpp:10
int main()
Definition main.cpp:98
Observables
Definition GeneralEnum.h:4
QCDOrder
UncertaintyType
High-level helpers for initializing and monitoring the Hyperiso framework.
#define LOG_INFO(...)
Macro for logging informational messages.
Definition Logger.h:39
High-level, user-facing entry point to compute flavor observables.
static std::vector< Observables > get_observables(Decays d)
Legacy static lookup of builtin observables for a builtin decay.
High-level interface to initialize and monitor the main framework configuration.
void init(const std::string &lhaFile, HyperisoConfig config)
Initializes Hyperiso using a LHA file and a full Config object.
void setLevel(LogLevel level)
Sets the logging level.
Definition Logger.cpp:38
static Logger * getInstance()
Retrieves the singleton instance of the Logger.
Definition Logger.cpp:5
void add_observables(std::map< Observables, QCDOrder > obss, bool add_dependencies=false)
Add multiple observables at once (enum map).
scalar_t get_exp_uncertainty(Observables id, UncertaintyType u_type=UncertaintyType::COMBINED)
Get experimental uncertainty for an observable (enum API).
void remove_observable(Observables id)
Remove an observable from the manager (enum API).
std::vector< ObservableValue > compute_observable(Observables obs) const
Compute a theory prediction for an observable (enum API).
std::map< ObservableId, std::vector< ObservableValue > > compute_all()
Compute all currently registered observables.
ObservableInterface & add_observable(Observables obs, QCDOrder order, bool add_dependencies=false)
Add an observable to the manager (enum API).
scalar_t get_exp_value(Observables id)
Get experimental central value for an observable (enum API).
void remove_observables(std::unordered_set< Observables > ids)
Remove several observables (enum set).
double T(double x)
Wilson coefficient T(x).
Configuration object controlling model, input flags and optional MARTY resources.
Definition Config.h:24
Model model
Current model.
Definition Config.h:33