3#include <unordered_set>
6const std::unordered_set<std::string>& wilsons_without_mudim() {
7 static const std::unordered_set<std::string> values = {
13const std::unordered_set<std::string>& wilsons_with_marty_split_sm_components() {
14 static const std::unordered_set<std::string> values = {
21bool should_read_marty_split_sm_components(
const std::string& wilson) {
22 return wilsons_with_marty_split_sm_components().find(wilson) != wilsons_with_marty_split_sm_components().end();
25bool uses_split_regprop_policy(
const std::string& wilson) {
26 return wilson ==
"C9" || wilson ==
"CP9" || wilson ==
"CP10";
31 const std::string& model,
32 bool bsm_split_generation,
33 bool full_target_generation) :
36 bsm_split_generation(bsm_split_generation),
37 full_target_generation(full_target_generation) {}
39bool MartyFileWriter::should_set_mudim()
const {
40 return wilsons_without_mudim().find(this->wilson) == wilsons_without_mudim().end();
44 outputFile <<
"\tconst std::string& path = output_file_path;\n";
46 if (should_set_mudim()) {
47 outputFile <<
"\tsetMu(Q_match);\n";
49 outputFile <<
"\t// setMu(Q_match) intentionally skipped for " << this->wilson
50 <<
" because LoopTools mudim must stay at its default value.\n";
53 if (bsm_split_generation && uses_split_regprop_policy(this->wilson)) {
54 outputFile <<
"\t// Split MARTY coefficient policy. " << wilson
55 <<
" is generated as non-photon and photon-linker pieces.\n";
56 outputFile <<
"\t// Non-photon pieces use reg_prop = 1e-6. Photon-linker pieces use reg_prop = 1.\n";
57 outputFile <<
"\tauto hyperiso_regprop_it = param.realParams.find(\"reg_prop\");\n";
58 outputFile <<
"\tbool hyperiso_has_regprop = hyperiso_regprop_it != param.realParams.end() && hyperiso_regprop_it->second != nullptr;\n";
59 const bool read_split_sm_components = should_read_marty_split_sm_components(this->wilson);
60 const bool expose_linker_components = (this->wilson ==
"CP10");
61 outputFile <<
"\tdouble hyperiso_regprop_saved = 1e-6;\n";
62 outputFile <<
"\tif (hyperiso_has_regprop) {\n";
63 outputFile <<
"\t\thyperiso_regprop_saved = static_cast<double>(*hyperiso_regprop_it->second);\n";
64 outputFile <<
"\t}\n";
66 outputFile <<
"\tif (hyperiso_has_regprop) {\n";
67 outputFile <<
"\t\t*hyperiso_regprop_it->second = 1e-6;\n";
68 outputFile <<
"\t}\n";
69 if (expose_linker_components) {
73 outputFile <<
"\tauto hyperiso_bsm_non_photon = " + wilson +
"(param);\n";
74 outputFile <<
"\tauto hyperiso_bsm_vector = " + wilson +
"_VECTOR(param);\n";
75 outputFile <<
"\tauto hyperiso_bsm_scalar = " + wilson +
"_SCALAR(param);\n";
77 outputFile <<
"\tauto hyperiso_bsm_non_photon = " + wilson +
"(param);\n";
78 outputFile <<
"\tauto hyperiso_bsm_vector = hyperiso_bsm_non_photon;\n";
79 outputFile <<
"\tauto hyperiso_bsm_scalar = 0.0 * hyperiso_bsm_non_photon;\n";
81 if (read_split_sm_components) {
82 if (expose_linker_components) {
83 outputFile <<
"\tauto hyperiso_sm_non_photon = " + wilson +
"_SM(param);\n";
84 outputFile <<
"\tauto hyperiso_sm_vector = " + wilson +
"_SM_VECTOR(param);\n";
85 outputFile <<
"\tauto hyperiso_sm_scalar = " + wilson +
"_SM_SCALAR(param);\n";
87 outputFile <<
"\tauto hyperiso_sm_non_photon = " + wilson +
"_SM(param);\n";
88 outputFile <<
"\tauto hyperiso_sm_vector = hyperiso_sm_non_photon;\n";
89 outputFile <<
"\tauto hyperiso_sm_scalar = 0.0 * hyperiso_sm_non_photon;\n";
92 outputFile <<
"\tauto hyperiso_sm_non_photon = 0.0 * hyperiso_bsm_non_photon;\n";
93 outputFile <<
"\tauto hyperiso_sm_vector = 0.0 * hyperiso_bsm_vector;\n";
94 outputFile <<
"\tauto hyperiso_sm_scalar = 0.0 * hyperiso_bsm_scalar;\n";
97 outputFile <<
"\tif (hyperiso_has_regprop) {\n";
98 outputFile <<
"\t\t*hyperiso_regprop_it->second = 1.0;\n";
99 outputFile <<
"\t}\n";
100 outputFile <<
"\tauto hyperiso_bsm_photon = " + wilson +
"_A(param);\n";
101 if (read_split_sm_components) {
102 outputFile <<
"\tauto hyperiso_sm_photon = " + wilson +
"_SM_A(param);\n";
104 outputFile <<
"\tauto hyperiso_sm_photon = 0.0 * hyperiso_bsm_photon;\n";
107 outputFile <<
"\tif (hyperiso_has_regprop) {\n";
108 outputFile <<
"\t\t*hyperiso_regprop_it->second = hyperiso_regprop_saved;\n";
109 outputFile <<
"\t}\n";
110 outputFile <<
"\tauto hyperiso_bsm_split = hyperiso_bsm_non_photon + hyperiso_bsm_photon;\n";
111 outputFile <<
"\tauto hyperiso_sm_split = hyperiso_sm_non_photon + hyperiso_sm_photon;\n";
112 outputFile <<
"\tauto hyperiso_total_split = hyperiso_sm_split + hyperiso_bsm_split;\n";
113 if (full_target_generation) {
114 outputFile <<
"\t// The analytical split contains the complete target model.\n";
115 outputFile <<
"\twriteWilsonCoefficients(\"" + wilson +
"\", hyperiso_bsm_split, Q_match, path);\n";
116 outputFile <<
"\twriteWilsonCoefficients(\"" + wilson +
"_TARGET_SPLIT\", hyperiso_bsm_split, Q_match, path);\n";
118 outputFile <<
"\twriteWilsonCoefficients(\"" + wilson +
"\", hyperiso_bsm_split, Q_match, path);\n";
120 outputFile <<
"\twriteWilsonCoefficients(\"" + wilson +
"_BSM_SPLIT\", hyperiso_bsm_split, Q_match, path);\n";
121 outputFile <<
"\twriteWilsonCoefficients(\"" + wilson +
"_SM_SPLIT\", hyperiso_sm_split, Q_match, path);\n";
122 outputFile <<
"\twriteWilsonCoefficients(\"" + wilson +
"_TOTAL_SPLIT\", hyperiso_total_split, Q_match, path);\n";
123 outputFile <<
"\twriteWilsonCoefficients(\"" + wilson +
"_NONPHOTON\", hyperiso_bsm_non_photon, Q_match, path);\n";
124 outputFile <<
"\twriteWilsonCoefficients(\"" + wilson +
"_A\", hyperiso_bsm_photon, Q_match, path);\n";
125 outputFile <<
"\twriteWilsonCoefficients(\"" + wilson +
"_SM_NONPHOTON\", hyperiso_sm_non_photon, Q_match, path);\n";
126 outputFile <<
"\twriteWilsonCoefficients(\"" + wilson +
"_SM_A\", hyperiso_sm_photon, Q_match, path);\n";
127 outputFile <<
"\twriteWilsonCoefficients(\"" + wilson +
"_VECTOR\", hyperiso_bsm_vector, Q_match, path);\n";
128 outputFile <<
"\twriteWilsonCoefficients(\"" + wilson +
"_SCALAR\", hyperiso_bsm_scalar, Q_match, path);\n";
129 outputFile <<
"\twriteWilsonCoefficients(\"" + wilson +
"_SM_VECTOR\", hyperiso_sm_vector, Q_match, path);\n";
130 outputFile <<
"\twriteWilsonCoefficients(\"" + wilson +
"_SM_SCALAR\", hyperiso_sm_scalar, Q_match, path);\n";
131 outputFile <<
"\twriteWilsonCoefficients(\"" + wilson +
"_TOTAL_VECTOR\", hyperiso_sm_vector + hyperiso_bsm_vector, Q_match, path);\n";
132 outputFile <<
"\twriteWilsonCoefficients(\"" + wilson +
"_TOTAL_SCALAR\", hyperiso_sm_scalar + hyperiso_bsm_scalar, Q_match, path);\n";
133 outputFile <<
"\twriteWilsonCoefficients(\"" + wilson +
"_SM_COMPONENT\", hyperiso_sm_split, Q_match, path);\n";
134 outputFile <<
"\twriteWilsonCoefficients(\"" + wilson +
"_TOTAL_COMPONENT\", hyperiso_total_split, Q_match, path);\n";
136 outputFile <<
"\twriteWilsonCoefficients(\"" + wilson +
"\", " + wilson +
"(param), Q_match, path);\n";
143 outputFile <<
"\tdouble Q_match = 80.379;\n";
144 outputFile <<
"\tstd::string param_file_path = \"" << files->getParamFileName() <<
"\";\n";
145 outputFile <<
"\tstd::string output_file_path = \"" << files->getCsvWilsonFileName() <<
"\";\n";
146 outputFile <<
"\tfor (int i = 1; i < argc; i++) {\n";
147 outputFile <<
"\t\tif (std::string(argv[i]) == \"--Q_match\" || std::string(argv[i]) == \"-Q\") {\n";
148 outputFile <<
"\t\t\tif (i + 1 >= argc) { throw std::runtime_error(\"Missing value after --Q_match\"); }\n";
149 outputFile <<
"\t\t\tQ_match = std::stod(argv[i + 1]);\n";
150 outputFile <<
"\t\t\ti++;\n";
151 outputFile <<
"\t\t} else if (std::string(argv[i]) == \"--param-file\") {\n";
152 outputFile <<
"\t\t\tif (i + 1 >= argc) { throw std::runtime_error(\"Missing value after --param-file\"); }\n";
153 outputFile <<
"\t\t\tparam_file_path = argv[++i];\n";
154 outputFile <<
"\t\t} else if (std::string(argv[i]) == \"--output-file\") {\n";
155 outputFile <<
"\t\t\tif (i + 1 >= argc) { throw std::runtime_error(\"Missing value after --output-file\"); }\n";
156 outputFile <<
"\t\t\toutput_file_path = argv[++i];\n";
157 outputFile <<
"\t\t} else if (std::string(argv[i]) == \"--help\" || std::string(argv[i]) == \"-h\") {\n";
158 outputFile <<
"\t\t\tstd::cout << \"Options availables :\" << std::endl;\n";
159 outputFile <<
"\t\t\tstd::cout << \"--Q_match/-Q : Value of Q_match (default 80.379)\" << std::endl;\n";
160 outputFile <<
"\t\t\tstd::cout << \"--param-file : Per-invocation parameter CSV\" << std::endl;\n";
161 outputFile <<
"\t\t\tstd::cout << \"--output-file : Per-invocation Wilson CSV\" << std::endl;\n";
162 outputFile <<
"\t\t\tstd::cout << \"--help/-h : Affiche ce message.\" << std::endl;\n";
163 outputFile <<
"\t\t\treturn 0;\n";
164 outputFile <<
"\t\t}\n";
165 outputFile <<
"\t}\n\n";
170 outputFile <<
"\tparam_t param;\n";
171 outputFile <<
"\tstd::ifstream ParamFile(param_file_path);" <<
"\n";
172 outputFile <<
"\tif (!ParamFile) { throw std::runtime_error(\"Cannot open MARTY parameter file: \" + param_file_path); }\n";
173 outputFile <<
"\treadParams(ParamFile, param.realParams, param.complexParams);" <<
"\n";
Declares utilities to generate C++ code for MARTY wrappers.
static std::shared_ptr< FileNameManager > getInstance(const std::string &wilson="", const std::string &model="")
Retrieves a FileNameManager for a given (wilson, model) pair.
void add_output_writer(std::ofstream &outputFile)
Writes C++ code that handles writing Wilson coefficients to a CSV.
MartyFileWriter(const std::string &wilson, const std::string &model, bool bsm_split_generation=false, bool full_target_generation=false)
Constructs a MartyFileWriter for a given (wilson, model) pair.
void add_argpars(std::ofstream &outputFile)
Writes C++ code to parse command-line arguments.
void add_input_reader(std::ofstream &outputFile)
Writes C++ code to read numerical parameters from disk.