9#include <unordered_map>
11namespace fs = std::filesystem;
16 std::optional<fs::path> marty_path;
17 fs::path lha_file = fs::path(project_root.data()) /
"Test" /
"InputFiles" /
"testinput_thdm.lha";
18 std::string wilson =
"C7";
19 std::string model =
"SM";
20 double q_match = 81.0;
21 std::optional<fs::path> model_header;
22 bool validate_only =
false;
25void print_usage(
const char* argv0)
28 <<
"Usage: " << argv0 <<
" [options]\n\n"
30 <<
" --marty <path> Existing MARTY install prefix, include/, lib/, marty.h, or libmarty.*\n"
31 <<
" --lha <path> LHA input file used to initialize Hyperiso\n"
32 <<
" --model-header <path> MARTY model header used by generated code\n"
33 <<
" --wilson <name> Wilson coefficient/basis to generate, default: C7\n"
34 <<
" --model <name> Model name used in generated code, default: SM\n"
35 <<
" --q <value> Matching scale, default: 81\n"
36 <<
" --validate-only Resolve/validate MARTY and init Hyperiso, then stop\n"
37 <<
" -h, --help Show this help\n\n"
39 <<
" " << argv0 <<
" --marty /opt/MARTY_INSTALL --validate-only\n"
40 <<
" " << argv0 <<
" --marty /opt/MARTY_INSTALL --wilson C7 --model SM --q 81\n";
45 const fs::path installed_header = marty.
include_dir /
"marty" /
"models" /
"sm.h";
46 if (fs::exists(installed_header)) {
47 return installed_header;
50 const fs::path bundled_source_header =
51 fs::path(project_tp_root.data()) /
"MARTY" /
"src" /
"MARTY" /
"src" /
"marty" /
"models" /
"sm.h";
52 if (fs::exists(bundled_source_header)) {
53 return bundled_source_header;
58 return installed_header;
61CliOptions parse_args(
int argc,
char** argv)
65 const std::unordered_map<std::string, std::string> aliases = {
66 {
"--marty-path",
"--marty"},
67 {
"--marty-install",
"--marty"},
69 {
"--model-path",
"--model-header"},
73 for (
int i = 1; i < argc; ++i) {
74 std::string key = argv[i];
75 if (
auto alias = aliases.find(key); alias != aliases.end()) {
79 auto require_value = [&](
const std::string& option) -> std::string {
81 throw std::runtime_error(
"Missing value after " + option);
86 if (key ==
"-h" || key ==
"--help") {
89 }
else if (key ==
"--marty") {
90 opts.marty_path = fs::path(require_value(key));
91 }
else if (key ==
"--lha") {
92 opts.lha_file = fs::path(require_value(key));
93 }
else if (key ==
"--model-header") {
94 opts.model_header = fs::path(require_value(key));
95 }
else if (key ==
"--wilson") {
96 opts.wilson = require_value(key);
97 }
else if (key ==
"--model") {
98 opts.model = require_value(key);
99 }
else if (key ==
"--q") {
100 opts.q_match = std::stod(require_value(key));
101 }
else if (key ==
"--validate-only") {
102 opts.validate_only =
true;
104 throw std::runtime_error(
"Unknown option: " + key);
113 std::cout <<
"MARTY resolution:\n"
114 <<
" source : " << info.
source <<
"\n"
116 <<
" prefix : " << info.
prefix.string() <<
"\n"
117 <<
" include : " << info.
include_dir.string() <<
"\n"
123 std::cout <<
" executable: not found, not required by current generated-code pipeline\n";
132 const CliOptions opts = parse_args(argc, argv);
136 if (opts.marty_path.has_value()) {
144 std::cerr <<
"Invalid MARTY runtime: " << marty.
error <<
"\n";
145 std::cerr <<
"Pass --marty <MARTY_INSTALL> or build with -DBUILD_WITH_MARTY=ON.\n";
148 print_marty_resolution(marty);
157 std::cout <<
"Initializing Hyperiso with LHA: " << opts.lha_file.string() <<
"\n";
158 hyp.
init(opts.lha_file.string(), config);
160 if (opts.validate_only) {
161 std::cout <<
"Validation finished successfully.\n";
165 const fs::path model_header = opts.model_header.value_or(default_model_header_from(marty));
166 if (!fs::exists(model_header)) {
167 std::cerr <<
"Model header not found: " << model_header.string() <<
"\n";
168 std::cerr <<
"Pass --model-header <path/to/model.h>.\n";
172 std::cout <<
"Running MartyInterface.calculate(" << opts.wilson
173 <<
", " << opts.model
174 <<
", Q=" << opts.q_match
176 std::cout <<
"Model header: " << model_header.string() <<
"\n";
183 model_header.string()
186 std::cout <<
"MARTY pipeline finished.\n";
188 }
catch (
const std::exception& e) {
189 std::cerr <<
"Fatal error: " << e.what() <<
"\n";
@ HAS_TH_OBSERVABLE_INPUT
User provided theoretical observable input.
@ HAS_WILSON_INPUT
User provided Wilson coefficient input.
@ IS_LHA_SPECTRUM
Input LHA file already contains a spectrum.
@ HYP_AS_SM_MARTY
If true, use Hyperiso as SM values for Wilson coefficients (up to NNLO).
High-level helpers for initializing and monitoring the Hyperiso framework.
High-level façade around MARTY-based code generation and compilation.
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 pre_init_set_marty_path(const std::string &martyInstallPath)
Registers an existing MARTY installation before init().
High-level interface to MARTY-based code generation and execution.
void calculate(std::string wilson, std::string model, double Q_match, std::string model_path)
Convenience shortcut to generate, compile, and run the full pipeline.
static InstallInfo resolve()
Resolve the MARTY install that should be used now.
Configuration object controlling model, input flags and optional MARTY resources.
std::map< ExternalFlag, bool > flags
External flags describing the nature of the inputs.
Model model
Current model.
std::filesystem::path prefix
std::filesystem::path marty_executable
std::filesystem::path requested_path
std::filesystem::path marty_library
std::filesystem::path include_dir