5 parser = argparse.ArgumentParser(description=
'sPHENIX MDC2 Reco Job Creator')
6 parser.add_argument(
'-i',
'--inputType', default=
"PYTHIA8_PP_MB", help=
'Input type: PYTHIA8_PP_MB, HIJING_[0-20/0-4P88], HF_CHARM[D0], HF_BOTTOM[D0], JET_[10GEV/30GEV/PHOTON], SINGLE_PARTICLE')
7 parser.add_argument(
'-f',
'--nFilesPerJob', default=5, type=int, help=
'Number of input files to pass to each job')
8 parser.add_argument(
'-t',
'--nTotEvents', default=-1, type=int, help=
'Total number of events to run over')
9 parser.add_argument(
'-r',
'--run', default=11, type=int, help=
'Production run to use')
10 parser.add_argument(
'--nopileup', help=
'Get data without pileup', action=
"store_true")
11 parser.add_argument(
'--truth', help=
'Enable truth DST reading', action=
"store_true")
12 parser.add_argument(
'--calo', help=
'Enable calo DST reading', action=
"store_true")
13 parser.add_argument(
'--trkr_hit', help=
'Enable tracker hit DST reading', action=
"store_true")
14 parser.add_argument(
'--mbd', help=
'Enable MBD/ZDC DST reading', action=
"store_true")
15 parser.add_argument(
'--mbd_g4hit', help=
'Enable MBD G4 hit DST reading', action=
"store_true")
16 parser.add_argument(
'--g4hit', help=
'Enable G4 hit DST reading', action=
"store_true")
17 parser.add_argument(
'--truth_table', help=
'Use DSTs for running tracking and making the truth/reco table', action=
"store_true")
19 args = parser.parse_args()
21 inputType = args.inputType.upper()
23 types = {
'PYTHIA8_PP_MB' : 3,
'HIJING_0-20' : 4,
'HIJING_0-4P88' : 6,
'HF_CHARM' : 7,
'HF_BOTTOM' : 8,
'HF_CHARMD0' : 9,
'HF_BOTTOMD0' : 10
24 ,
'JET_30GEV' : 11,
'JET_10GEV' : 12,
'JET_PHOTON' : 13,
'SINGLE_PARTICLE' : 14 ,
'D0JETS' : 17}
25 if inputType
not in types:
26 print(
"The argument, {}, was not known. Use --help to see available types".
format(args.inputType))
30 dstSets = [
'DST_TRACKS',
'DST_GLOBAL']
33 dstSets.append(
'DST_TRUTH')
35 dstSets.append(
'G4Hits')
36 dstSets.append(
'DST_TRACKSEEDS')
37 dstSets.append(
'DST_TRKR_CLUSTER')
38 if args.calo: dstSets.append(
'DST_CALO_CLUSTER')
39 if args.trkr_hit: dstSets.append(
'DST_TRKR_HIT')
41 dstSets.append(
'DST_MBD_EPD')
44 dstSets.append(
'DST_BBC_G4HIT')
45 if args.g4hit: dstSets.append(
'G4Hits')
47 dstSets.append(
'DST_TRUTH_RECO')
48 if args.truth ==
False: dstSets.append(
'DST_TRUTH')
50 myShell =
str(environ[
'SHELL'])
51 goodShells = [
'/bin/bash',
'/bin/tcsh']
52 if myShell
not in goodShells:
53 print(
"Your shell {} was not recognised".
format(myShell))
59 print(
"Creating condor submission files for {} production".
format(inputType))
62 for i
in range(len(dstSets)):
64 line.append(inputFiles[i].readline())
65 myOutputPath = os.getcwd()
66 condorDir = "{}/condorJob".
format(myOutputPath)
67 os.makedirs(
"{}/log".
format(condorDir), exist_ok=
True)
68 os.makedirs(
"{}/fileLists".
format(condorDir), exist_ok=
True)
73 for i
in range(len(dstSets)):
74 fileStart =
"fileLists/productionFiles-{1}-{2}-".
format(condorDir, inputType, dstSets[i].
lower())
75 listFile.append(
"{0}/{1}{2:05d}.list".
format(condorDir, fileStart, nJob))
76 listFileGeneric.append(
"$(condorDir)/{0}$INT(Process,%05d).list".
format(fileStart))
77 productionFilesToUse =
open(listFile[i],
"w")
78 for j
in range(0, args.nFilesPerJob):
79 splitLine = line[i].split(
"/")
80 fileName = splitLine[-1]
81 productionFilesToUse.write(fileName)
82 line[i] = inputFiles[i].readline()
84 condorFileName =
"{0}/my{1}.job".
format(condorDir, inputType)
85 condorFile =
open(
"{}".
format(condorFileName),
"w")
86 condorFile.write(
"Universe = vanilla\n")
87 condorFile.write(
"initialDir = {}\n".
format(myOutputPath))
88 if myShell ==
'/bin/bash': condorFile.write(
"Executable = $(initialDir)/run_MDC2reco.sh\n")
89 if myShell ==
'/bin/tcsh': condorFile.write(
"Executable = $(initialDir)/run_MDC2reco.csh\n")
90 condorFile.write(
"PeriodicHold = (NumJobStarts>=1 && JobStatus == 1)\n")
91 condorFile.write(
"request_memory = {}GB\n".
format(memory))
92 condorFile.write(
"Priority = 20\n")
93 condorFile.write(
"job_lease_duration = 3600\n")
94 condorFile.write(
"condorDir = $(initialDir)/condorJob\n")
95 condorOutputInfo =
"$(condorDir)/log/condor-{0}-$INT(Process,%05d)".
format(inputType)
96 condorFile.write(
"Output = {0}.out\n".
format(condorOutputInfo))
97 condorFile.write(
"Error = {0}.err\n".
format(condorOutputInfo))
98 condorFile.write(
"Log = {0}.log\n".
format(condorOutputInfo))
99 condorFile.write(
"Arguments = \"{}\"\n".
format(
' '.
join(listFileGeneric)))
100 condorFile.write(
"Queue {}\n".
format(nJob))
101 print(
"Submission setup complete!")
102 print(
"This setup will submit {} subjobs".
format(nJob))
103 print(
"You can submit your job with the script:\n{}".
format(condorFileName))
105 catalogCommand =
"CreateFileList.pl -run {0} -type {1} {2}".
format(args.run, types[inputType],
' '.
join(dstSets))
106 if args.nTotEvents != -1: catalogCommand +=
" -n {}".
format(args.nTotEvents)
107 if args.nopileup: catalogCommand +=
" -nopileup"
108 os.system(catalogCommand)