Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions madminer/core/madminer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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"
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion madminer/utils/interfaces/delphes_root.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
10 changes: 8 additions & 2 deletions madminer/utils/interfaces/mg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")

Expand All @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions madminer/utils/interfaces/mg_cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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:
Expand Down