Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
HyperisoBanner.h
Go to the documentation of this file.
1#ifndef HYPERISO_BANNER_H
2#define HYPERISO_BANNER_H
3
4#include <filesystem>
5#include <iomanip>
6#include <iostream>
7#include <optional>
8#include <sstream>
9#include <string>
10#include <vector>
11
12#include "Config.h"
13#include "config.hpp"
14#include "IPathsProvider.h"
15#include "MemoryManager.h"
16
17
18#ifndef HYPERISO_AUTHORS
19#define HYPERISO_AUTHORS "Theo Reymermier, Niels Fardeau and the Hyperiso contributors"
20#endif
21
30public:
31 static void print_startup(const std::string& lha_file, const HyperisoConfig& config)
32 {
33 auto* mm = MemoryManager::GetInstance();
34
35 const std::string assets_root = get_path(mm, APIPath::ASSETS_ROOT);
36 const std::string lha_path = resolve_lha_path(lha_file, assets_root);
37
38 std::cout << "\n";
39 print_rule('=');
40 std::cout << " H Y P E R I S O v" << project_version << "\n";
41 std::cout << " High-energy flavour observables and Wilson coefficient engine\n";
42 std::cout << " Authors: " << HYPERISO_AUTHORS << "\n";
43 print_rule('-');
44
45 print_section("Session");
46 print_kv("Model", model_name(config.model));
47 print_kv("LHA input", lha_path);
48 print_kv("Assets root", assets_root);
49
50 print_section("Read-only defaults");
51 print_kv("parameters", get_path(mm, APIPath::DEFAULT_PARAM_VALUES));
52 print_kv("observables", get_path(mm, APIPath::DEFAULT_OBS_VALUES));
53 print_kv("parameter correlations", get_path(mm, APIPath::DEFAULT_PARAM_CORR));
54 print_kv("observable correlations", get_path(mm, APIPath::DEFAULT_OBS_CORR));
55 print_kv("nuisances", get_path(mm, APIPath::DEFAULT_NUISANCES));
56
57 print_section("Input overrides / packaged templates");
58 print_kv("SM parameters", get_path(mm, APIPath::USER_SM_PARAMS));
59 print_kv("flavour parameters", get_path(mm, APIPath::USER_FLAVOR_PARAMS));
60 print_kv("decay parameters", get_path(mm, APIPath::USER_DECAY_PARAMS));
61 print_kv("observables", get_path(mm, APIPath::USER_OBS_VALUES));
62 print_kv("parameter correlations", get_path(mm, APIPath::USER_PARAM_CORR));
63 print_kv("observable correlations", get_path(mm, APIPath::USER_OBS_CORR));
64 print_kv("nuisances", get_path(mm, APIPath::USER_NUISANCES));
65
66 print_section("Writable runtime directories");
67 print_kv("spectrum cache", get_path(mm, APIPath::SPECTRUM_DIR));
68 print_kv("MARTY temp/cache", get_path(mm, APIPath::MARTY_TEMP_DIR));
69
70 if (uses_marty(config)) {
71 print_section("MARTY backend");
72 print_kv("model name", optional_string(config.mty_model_name));
73 print_kv("model file", optional_path(config.mty_model_path));
74 print_kv("template dir", get_path(mm, APIPath::TEMPLATE_DIR) + "/MARTY");
75 print_kv("mapping dir", get_path(mm, APIPath::PARAM_MAPPING_DIR));
76 print_kv("SM mapping", path_join(get_path(mm, APIPath::PARAM_MAPPING_DIR), "sm.json"));
77 print_kv("BSM mapping", optional_path(config.mty_bsm_mapping_path));
78 print_kv("Wilson CSV", marty_wilson_csv_path(mm, config));
79 }
80
81 print_rule('=');
82 std::cout << std::endl;
83 }
84
85private:
86 static constexpr int key_width = 24;
87 static constexpr int banner_width = 92;
88
89 static void print_rule(char c)
90 {
91 std::cout << std::string(banner_width, c) << "\n";
92 }
93
94 static void print_section(const std::string& name)
95 {
96 std::cout << "\n[" << name << "]\n";
97 }
98
99 static void print_kv(const std::string& key, const std::string& value)
100 {
101 std::cout << " " << std::left << std::setw(key_width) << key << " : " << value << "\n";
102 }
103
104 static std::string get_path(MemoryManager* mm, APIPath path)
105 {
106 try {
107 return mm->get_path(path).string();
108 } catch (const std::exception& e) {
109 return std::string("<unavailable: ") + e.what() + ">";
110 } catch (...) {
111 return "<unavailable>";
112 }
113 }
114
115 static std::string path_join(const std::string& lhs, const std::string& rhs)
116 {
117 if (lhs.empty()) {
118 return rhs;
119 }
120 return (std::filesystem::path(lhs) / rhs).string();
121 }
122
123 static std::string resolve_lha_path(const std::string& lha_file, const std::string& assets_root)
124 {
125 const std::filesystem::path input(lha_file);
126 if (input.is_absolute()) {
127 return input.string();
128 }
129 return (std::filesystem::path(assets_root) / input).string();
130 }
131
132 static std::string optional_string(const std::optional<std::string>& value)
133 {
134 return value.has_value() ? value.value() : std::string("<not set>");
135 }
136
137 static std::string optional_path(const std::optional<std::filesystem::path>& value)
138 {
139 return value.has_value() ? value.value().string() : std::string("<not set>");
140 }
141
142 static bool uses_marty(const HyperisoConfig& config)
143 {
144 return config.model == Model::MARTY
145 || config.mty_model_name.has_value()
146 || config.mty_model_path.has_value()
147 || config.mty_bsm_mapping_path.has_value();
148 }
149
150 static std::string model_name(Model model)
151 {
152 if (model == Model::SM) return "SM";
153 if (model == Model::THDM) return "THDM";
154 if (model == Model::SUSY) return "SUSY";
155 if (model == Model::MARTY) return "MARTY";
156
157 std::ostringstream oss;
158 oss << "Model(" << static_cast<int>(model) << ")";
159 return oss.str();
160 }
161
162 static std::string marty_wilson_csv_path(MemoryManager* mm, const HyperisoConfig& config)
163 {
164 const std::string model = config.mty_model_name.value_or("SM");
165 return (std::filesystem::path(get_path(mm, APIPath::MARTY_TEMP_DIR)) / (model + "_wilson.csv")).string();
166 }
167};
168
169#endif // HYPERISO_BANNER_H
Model
#define HYPERISO_AUTHORS
APIPath
Enumerates the filesystem paths exposed through the public API.
@ USER_OBS_VALUES
YAML/YML file containing user observable overrides.
@ DEFAULT_NUISANCES
JSON file containing default nuisance definitions.
@ USER_OBS_CORR
YAML/YML file containing user observable correlation overrides.
@ USER_NUISANCES
YAML/YML file containing user nuisance overrides.
@ TEMPLATE_DIR
Read-only directory containing generated-code templates.
@ DEFAULT_OBS_CORR
JSON file containing default observable correlations.
@ USER_PARAM_CORR
YAML/YML file containing user parameter correlation overrides.
@ DEFAULT_PARAM_VALUES
JSON file containing default parameter values.
@ USER_SM_PARAMS
YAML/YML file containing user SM parameter overrides.
@ DEFAULT_OBS_VALUES
JSON file containing default observable values.
@ MARTY_TEMP_DIR
Writable cache directory used for generated MARTY files.
@ PARAM_MAPPING_DIR
Read-only directory containing MARTY/Hyperiso parameter mappings.
@ SPECTRUM_DIR
Writable cache directory used for generated spectrum files.
@ USER_FLAVOR_PARAMS
YAML/YML file containing user flavor parameter overrides.
@ ASSETS_ROOT
Root directory for HyperISO read-only assets.
@ DEFAULT_PARAM_CORR
JSON file containing default parameter correlations.
@ USER_DECAY_PARAMS
YAML/YML file containing user decay parameter overrides.
Manages memory caching, parameter blocks, and LHA reader instances.
Pretty startup banner for Hyperiso sessions.
static void print_startup(const std::string &lha_file, const HyperisoConfig &config)
Singleton class responsible for initializing and managing memory, input files, and parameter blocks.
static MemoryManager * GetInstance()
Retrieves the singleton instance of MemoryManager.
fs::path get_path(APIPath path_name)
Retrieves a public API path from the runtime cache or path provider.
Configuration object controlling model, input flags and optional MARTY resources.
Definition Config.h:24
std::optional< fs::path > mty_bsm_mapping_path
Optional user-provided BSM mapping JSON.
Definition Config.h:47
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