diff --git a/madminer/core/madminer.py b/madminer/core/madminer.py index b6b39629d..455287b78 100644 --- a/madminer/core/madminer.py +++ b/madminer/core/madminer.py @@ -611,6 +611,7 @@ def _export_cards( reweight_card_filename=None, include_param_card=True, benchmarks=None, + order="LO" ): """ Writes out a param_card and reweight_card for MadGraph. Instead of this low-level function, it is recommended to @@ -681,6 +682,7 @@ def _export_cards( parameters=self.parameters, mg_process_directory=mg_process_directory, reweight_card_filename=reweight_card_filename, + order=order ) def run( @@ -821,6 +823,7 @@ def run_multiple( run_card_files, mg_process_directory=None, pythia8_card_file=None, + madspin_card_file=None, configuration_file=None, sample_benchmarks=None, is_background=False, @@ -978,6 +981,9 @@ def run_multiple( new_pythia8_card_file = None if pythia8_card_file is not None: new_pythia8_card_file = f"madminer/cards/pythia8_card_{i}.dat" + new_madspin_card_file = None + if madspin_card_file is not None: + new_madspin_card_file = f"madminer/cards/madspin_card_{i}.dat" new_run_card_file = None if run_card_file is not None: new_run_card_file = f"madminer/cards/run_card_{i}.dat" @@ -989,9 +995,11 @@ def run_multiple( logger.info(" Sampling from benchmark: %s", sample_benchmark) logger.info(" Original run card: %s", run_card_file) logger.info(" Original Pythia8 card: %s", pythia8_card_file) + logger.info(" Original MadSpin card: %s", madspin_card_file) logger.info(" Original config card: %s", configuration_file) logger.info(" Copied run card: %s", new_run_card_file) logger.info(" Copied Pythia8 card: %s", new_pythia8_card_file) + logger.info(" Copied MadSpin card: %s", new_madspin_card_file) logger.info(" Copied config card: %s", new_configuration_file) logger.info(" Param card: %s", param_card_file) logger.info(" Reweight card: %s", reweight_card_file) @@ -1013,6 +1021,7 @@ def run_multiple( sample_benchmark=sample_benchmark, param_card_filename=f"{mg_process_directory}/{param_card_file}", reweight_card_filename=f"{mg_process_directory}/{reweight_card_file}", + order=order, ) # Create run card @@ -1027,6 +1036,10 @@ def run_multiple( # Copy Pythia card if pythia8_card_file is not None: copy_file(pythia8_card_file, f"{mg_process_directory}/{new_pythia8_card_file}") + + # Copy MadSpin card + if madspin_card_file is not None: + copy_file(madspin_card_file, f"{mg_process_directory}/{new_madspin_card_file}") # Copy Configuration card if configuration_file is not None: @@ -1060,6 +1073,7 @@ def run_multiple( f"{mg_process_directory}/{param_card_file}", f"{mg_process_directory}/{reweight_card_file}", None if new_pythia8_card_file is None else f"{mg_process_directory}/{new_pythia8_card_file}", + None if new_madspin_card_file is None else f"{mg_process_directory}/{new_madspin_card_file}", None if new_configuration_file is None else f"{mg_process_directory}/{new_configuration_file}", is_background=is_background, initial_command=initial_command, diff --git a/madminer/utils/interfaces/delphes_root.py b/madminer/utils/interfaces/delphes_root.py index 312741fa1..47aaa37a4 100644 --- a/madminer/utils/interfaces/delphes_root.py +++ b/madminer/utils/interfaces/delphes_root.py @@ -157,7 +157,7 @@ def get_objects(ievent): values_this_observable = np.array(values_this_observable, dtype=np.float64) observable_values[name] = values_this_observable - logger.debug(" First 10 values for observable %s:\n%s", name, values_this_observable[:10]) + logger.debug(" First 10 values for observable %s:\n%s", name, values_this_observable[:20]) # Cuts cut_values = [] diff --git a/madminer/utils/interfaces/mg.py b/madminer/utils/interfaces/mg.py index 1254a6293..daf262de0 100644 --- a/madminer/utils/interfaces/mg.py +++ b/madminer/utils/interfaces/mg.py @@ -317,6 +317,7 @@ def run_mg( param_card_file=None, reweight_card_file=None, pythia8_card_file=None, + madspin_card_file=None, configuration_card_file=None, is_background=False, initial_command=None, @@ -401,6 +402,8 @@ def run_mg( shutil.copyfile(pythia8_card_file, f"{mg_process_directory}/Cards/pythia8_card.dat") if pythia8_card_file is not None and order == "NLO": shutil.copyfile(pythia8_card_file, f"{mg_process_directory}/Cards/shower_card.dat") + if madspin_card_file is not None: + shutil.copyfile(madspin_card_file, f"{mg_process_directory}/Cards/madspin_card.dat") if configuration_card_file is not None: shutil.copyfile(configuration_card_file, f"{mg_process_directory}/Cards/me5_configuration.txt") @@ -414,17 +417,20 @@ def run_mg( # MG commands shower_option = "OFF" if pythia8_card_file is None else "Pythia8" reweight_option = "OFF" if is_background else "ON" + madspin_option = "OFF" if madspin_card_file is None else "ON" + mg_commands = """ launch {} + order={} shower={} detector=OFF analysis=OFF - madspin=OFF + madspin={} reweight={} done """.format( - mg_process_directory, shower_option, reweight_option + mg_process_directory, order, shower_option, madspin_option, reweight_option ) with open(proc_card_filename, "w") as file: diff --git a/madminer/utils/interfaces/mg_cards.py b/madminer/utils/interfaces/mg_cards.py index 65c2f8582..71cdff2c9 100644 --- a/madminer/utils/interfaces/mg_cards.py +++ b/madminer/utils/interfaces/mg_cards.py @@ -97,6 +97,7 @@ def export_reweight_card( parameters: Dict[str, AnalysisParameter], mg_process_directory: str, reweight_card_filename: str = None, + order: str="LO" ): # Global setup lines = [ @@ -106,6 +107,8 @@ def export_reweight_card( "change output default", "change helicity False", ] + if order == "NLO": + lines.append("change mode NLO") for benchmark_name, benchmark in benchmarks.items(): if benchmark_name == sample_benchmark: