madminer-tool / madminer

Machine learning–based inference toolkit for particle physics
https://arxiv.org/abs/1907.10621
MIT License
86 stars 45 forks source link

FileNotFoundError for event generation #540

Open samiur06 opened 1 year ago

samiur06 commented 1 year ago

Hi there, I am using MadMiner v0.9.6. CUrrently, I am getting an error to generate events in MadGraph through MadMiner. Here is my code and the error:

miner.run(
    sample_benchmark='sm',
    mg_directory=mg_dir,
    mg_process_directory="./tth_event",
    proc_card_file='../cards/proc_card_mg5.dat',
    param_card_template_file='../cards/param_card.dat',
)
17:35 madminer.utils.inter INFO    Calling MadGraph: /Users/samiur/Documents/MG5_aMC_v3_4_2//bin/mg5_aMC /var/folders/nf/tkjc_md55g704s30wfmx4wzh0000gn/T/generate.mg5
17:35 madminer.core.madmin INFO    Run 0
17:35 madminer.core.madmin INFO      Sampling from benchmark: sm
17:35 madminer.core.madmin INFO      Original run card:       None
17:35 madminer.core.madmin INFO      Original Pythia8 card:   None
17:35 madminer.core.madmin INFO      Original config card:    None
17:35 madminer.core.madmin INFO      Copied run card:         None
17:35 madminer.core.madmin INFO      Copied Pythia8 card:     None
17:35 madminer.core.madmin INFO      Copied config card:      None
17:35 madminer.core.madmin INFO      Param card:              madminer/cards/param_card_0.dat
17:35 madminer.core.madmin INFO      Reweight card:           madminer/cards/reweight_card_0.dat
17:35 madminer.core.madmin INFO      Log file:                run_0.log
17:35 madminer.core.madmin INFO    Creating param and reweight cards in ./tth_event/madminer/cards/param_card_0.dat, ./tth_event/madminer/cards/reweight_card_0.dat
17:35 madminer.utils.inter INFO    Starting MadGraph and Pythia in ./tth_event
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In [11], line 1
----> 1 miner.run(
      2     sample_benchmark='sm',
      3     mg_directory=mg_dir,
      4     mg_process_directory="./tth_event",
      5     proc_card_file='../cards/proc_card_mg5.dat',
      6     param_card_template_file='../cards/param_card.dat',
      7 )

File ~/opt/miniconda3/envs/torch/lib/python3.9/site-packages/madminer/core/madminer.py:798, in MadMiner.run(self, mg_directory, proc_card_file, param_card_template_file, run_card_file, mg_process_directory, pythia8_card_file, configuration_file, sample_benchmark, is_background, only_prepare_script, ufo_model_directory, log_directory, temp_directory, initial_command, systematics, order, python_executable)
    795 if sample_benchmark is None:
    796     sample_benchmark = self.default_benchmark
--> 798 self.run_multiple(
    799     mg_directory=mg_directory,
    800     proc_card_file=proc_card_file,
    801     param_card_template_file=param_card_template_file,
    802     run_card_files=[run_card_file],
    803     mg_process_directory=mg_process_directory,
    804     pythia8_card_file=pythia8_card_file,
    805     configuration_file=configuration_file,
    806     sample_benchmarks=[sample_benchmark],
    807     is_background=is_background,
    808     only_prepare_script=only_prepare_script,
    809     ufo_model_directory=ufo_model_directory,
    810     log_directory=log_directory,
    811     temp_directory=temp_directory,
    812     initial_command=initial_command,
    813     systematics=systematics,
    814     order=order,
    815     python_executable=python_executable,
    816 )

File ~/opt/miniconda3/envs/torch/lib/python3.9/site-packages/madminer/core/madminer.py:1059, in MadMiner.run_multiple(self, mg_directory, proc_card_file, param_card_template_file, run_card_files, mg_process_directory, pythia8_card_file, configuration_file, sample_benchmarks, is_background, only_prepare_script, ufo_model_directory, log_directory, temp_directory, initial_command, systematics, order, python_executable)
   1057             mg_scripts.append(mg_script)
   1058         else:
-> 1059             run_mg(
   1060                 mg_directory,
   1061                 mg_process_directory,
   1062                 f"{mg_process_directory}/{mg_commands_filename}",
   1063                 f"{mg_process_directory}/{new_run_card_file}",
   1064                 f"{mg_process_directory}/{param_card_file}",
   1065                 f"{mg_process_directory}/{reweight_card_file}",
   1066                 None if new_pythia8_card_file is None else f"{mg_process_directory}/{new_pythia8_card_file}",
   1067                 None if new_configuration_file is None else f"{mg_process_directory}/{new_configuration_file}",
   1068                 is_background=is_background,
   1069                 initial_command=initial_command,
   1070                 log_file=f"{log_directory}/{log_file_run}",
   1071                 python_executable=python_executable,
   1072                 order=order,
   1073             )
   1075         i += 1
   1077 n_runs_total = i

File ~/opt/miniconda3/envs/torch/lib/python3.9/site-packages/madminer/utils/interfaces/mg.py:396, in run_mg(mg_directory, mg_process_directory, proc_card_filename, run_card_file, param_card_file, reweight_card_file, pythia8_card_file, configuration_card_file, is_background, initial_command, log_file, order, python_executable)
    394 # Copy cards
    395 if run_card_file is not None:
--> 396     shutil.copyfile(run_card_file, f"{mg_process_directory}/Cards/run_card.dat")
    397 if param_card_file is not None:
    398     shutil.copyfile(param_card_file, f"{mg_process_directory}/Cards/param_card.dat")

File ~/opt/miniconda3/envs/torch/lib/python3.9/shutil.py:264, in copyfile(src, dst, follow_symlinks)
    262     os.symlink(os.readlink(src), dst)
    263 else:
--> 264     with open(src, 'rb') as fsrc:
    265         try:
    266             with open(dst, 'wb') as fdst:
    267                 # macOS

FileNotFoundError: [Errno 2] No such file or directory: './tth_event/None'

Note that these are the files created in the tth_event directory:

tth_event
└── madminer
    ├── cards
    │   ├── param_card_0.dat
    │   └── reweight_card_0.dat
    └── scripts

I suspect that the auto-naming of the files 'param_card_0' and 'reweight_card_0' in tth_event could be a problem. (I have never generated events in MadMiner environment before, I always had some issues. This is the latest one.) Any help on this will be highly appreciated. Thanks!

Sinclert commented 1 year ago

👋🏻 Hey @samiur06 ,

This project is not actively maintained anymore, but for what I can see, you are using MadGraph's latest version (3.4.2). IIRC, we only had support for the latest branch of MadGraph 2 versions (2.9.X).

Could you try again, using MadGraph 2.9.14?