Skip to content

Commit f49296d

Browse files
committed
Preventively import model so that autoconversion triggers if not trivial
In some cases, the imported model during reweighting is still Python 2, so we need to setup autoconversion at the beginning of the launch card if the model is not trivial and it is not the Standard Model
1 parent 1f6f1c0 commit f49296d

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

.github/workflows/run_madtrex.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,25 @@
88
ALLOWED_PROCESSES = [ "ee_mumu", "gg_tt", "gg_tt01g", "gg_ttg", "gg_ttgg", "gg_ttggg", "gq_ttq", "heft_gg_bb", "nobm_pp_ttW", "pp_tt012j", "smeft_gg_tttt", "susy_gg_t1t1", "susy_gg_tt" ]
99
MADGRAPH_CLI = Path.cwd() / ".." / ".." / "MG5aMC" / "mg5amcnlo" / "bin" / "mg5_aMC"
1010

11-
def generate_dat_content(process_dir: str, rwgt_card_path: Path) -> str:
12-
run_card = "set auto_convert_model True\n"
13-
run_card += f"launch {process_dir}\n"
11+
PROCESSES_NON_TRIVIAL_MODELS = {
12+
"heft_gg_bb": "heft",
13+
"smeft_gg_tttt": "SMEFTsim_topU3l_MwScheme_UFO-massless",
14+
"susy_gg_t1t1": "MSSM_SLHA2",
15+
"susy_gg_tt": "MSSM_SLHA2",
16+
}
17+
18+
def generate_dat_content(process_dir: Path, rwgt_card_path: Path, process_name: str) -> str:
19+
run_card = f"launch {process_dir}\n"
1420
run_card += "reweight=madtrex\n"
1521
run_card += "set nevents 10000\n"
1622
run_card += "set iseed 489\n"
1723
run_card += f"{rwgt_card_path}\n"
24+
# if the model of this process is not trivial, import it preventively
25+
# so that if it is still Python 2, it will be converted before the
26+
# reweighting procedure takes place
27+
if process_name in PROCESSES_NON_TRIVIAL_MODELS:
28+
model = PROCESSES_NON_TRIVIAL_MODELS[process_name]
29+
run_card = f"set auto_convert_model True\nimport model {model}\n" + run_card
1830
return run_card
1931

2032
def is_executable(path: Path) -> bool:
@@ -45,9 +57,9 @@ def dump_logs(stdout_log, stderr_log):
4557

4658
def main() -> int:
4759
# Name of the directory of the process to test
48-
process_dir = sys.argv[1]
60+
process_dir = Path(sys.argv[1])
4961
# Label for the process (must be in the allowed list)
50-
process = process_dir.replace(".mad", "")
62+
process = process_dir.name.replace(".mad", "")
5163

5264
# Treat current working directory as HOME
5365
HOME = Path.cwd()
@@ -86,7 +98,7 @@ def main() -> int:
8698
# Write PROCESS.dat to HOME
8799
dat_path = HOME / f"{process}.dat"
88100
try:
89-
dat_content = generate_dat_content(process_dir, rwgt_card_path)
101+
dat_content = generate_dat_content(process_dir, rwgt_card_path, process)
90102
dat_path.write_text(dat_content, encoding="utf-8")
91103
except Exception as e:
92104
print(f"ERROR: Failed to write {dat_path}: {e}", file=sys.stderr)

0 commit comments

Comments
 (0)