36 global tclparams, pythiaparams
41 parser = argparse.ArgumentParser()
43 parser.add_argument(
"-n",
"--name", type=str,
44 help=
"name for this study set (e.g. bfield)")
45 parser.add_argument(
"-i",
"--input", type=str,
46 help=
"input directory of Delphes ROOT files")
47 parser.add_argument(
"-m",
"--modules", type=str,
48 help=
"analysis module list")
49 parser.add_argument(
"-f",
"--force", default=
False, action=
'store_true',
50 help=
"force-overwrite existing output")
53 args = parser.parse_args()
57 if not os.path.exists(args.name):
59 os.makedirs(args.name)
61 print(
"%s already exists... continuing..." % (args.name))
64 SLURM_ARRAY_TASK_ID=
"0"
67 SLURM_ARRAY_TASK_ID=os.environ[
"SLURM_ARRAY_TASK_ID"]
69 print(
"Please set the SLURM_ARRAY_TASK_ID environment variable to a number (e.g. 0) before running this script.")
73 print(
"Task ID requested: %d" % (int(SLURM_ARRAY_TASK_ID)))
79 root_files = glob.glob(args.input +
"/*/*.root")
80 root_files = sorted(root_files)
82 if len(root_files) == 0:
83 print(
"No appropriate ROOT files exist in the input directory")
86 print(
"Input directory contains %d files for processing" % (len(root_files)))
93 fileNumber = int(SLURM_ARRAY_TASK_ID)
97 for test_file
in root_files:
98 if test_file.find(
'%d/out.root' % fileNumber) != -1:
102 if root_file ==
None:
103 print(
"Unable to find an input file consistent with the task ID = %d" %
104 (int(SLURM_ARRAY_TASK_ID)))
108 root_file = os.path.abspath(root_file)
109 print(
"Processing %s" % (root_file))
114 taskdir=
"%s/%d" % (args.name, fileNumber)
116 if os.path.exists(taskdir)
and not args.force:
117 print(
"Skipping this task directory --- it already exists. Cleanup before overwriting!")
120 if not os.path.exists(taskdir):
124 subprocess.call(
"cp -a mva_taggers %s/" % (taskdir), shell=
True);
126 subprocess.call(
'cd {0[taskdir]}; SimpleAnalysis.exe --input_dir {0[root_file]} --output_file out.root --module_sequence "{0[modules]}"'.format({
'taskdir': taskdir,
'root_file': root_file,
'modules': args.modules}), shell=
True)