|
8 | 8 | import os |
9 | 9 | import shutil |
10 | 10 | import time |
| 11 | +import glob |
11 | 12 | import random |
12 | 13 | from datetime import datetime |
13 | 14 | from common import bcolors, msg, fatal_msg, verbose_msg, run_in_parallel, set_verbose_mode, get_default_parser, warning_msg |
@@ -158,7 +159,28 @@ def check_duplicate(option_name): |
158 | 159 | "as it will be automatically set") |
159 | 160 | for i in ["--output", "-o", "--nevents", "-n"]: |
160 | 161 | check_duplicate(i) |
161 | | - msg("Using custom generator", custom_gen) |
| 162 | + if "INPUT_FILES" in custom_gen: |
| 163 | + input_hepmc_files = custom_gen.replace("INPUT_FILES", |
| 164 | + "").strip().split(" ") |
| 165 | + input_hepmc_file_list = [] |
| 166 | + for i in input_hepmc_files: |
| 167 | + input_hepmc_file_list += glob.glob(os.path.normpath(i)) |
| 168 | + |
| 169 | + if len(input_hepmc_file_list) >= nruns: |
| 170 | + input_hepmc_file_list = input_hepmc_file_list[0:nruns] |
| 171 | + else: |
| 172 | + nruns = len(input_hepmc_file_list) |
| 173 | + |
| 174 | + if len(input_hepmc_file_list) <= 0: |
| 175 | + fatal_msg("Did not find any input file matching to the request:", |
| 176 | + custom_gen) |
| 177 | + custom_gen = f"INPUT_FILES "+" ".join(input_hepmc_file_list) |
| 178 | + msg("Using", len(input_hepmc_file_list), |
| 179 | + "input HepMC file" + |
| 180 | + ("" if len(input_hepmc_file_list) == 1 else "s"), |
| 181 | + input_hepmc_file_list) |
| 182 | + else: |
| 183 | + msg("Using custom generator", custom_gen) |
162 | 184 |
|
163 | 185 | # Printing configuration |
164 | 186 | msg(" --- running createO2tables.py", color=bcolors.HEADER) |
@@ -297,10 +319,7 @@ def copy_and_link(file_name): |
297 | 319 | if "INPUT_FILES" in custom_gen: |
298 | 320 | input_hepmc_file = custom_gen.replace("INPUT_FILES", |
299 | 321 | "").strip().split(" ") |
300 | | - if run_number < len(input_hepmc_file): |
301 | | - input_hepmc_file = input_hepmc_file[run_number] |
302 | | - else: |
303 | | - return |
| 322 | + input_hepmc_file = input_hepmc_file[run_number] |
304 | 323 | write_to_runner(f"ln -s {input_hepmc_file}" |
305 | 324 | f" {hepmc_file} \n") |
306 | 325 | else: |
|
0 commit comments