5 parser = argparse.ArgumentParser(description=
'sPHENIX MDC2 Reco Job Creator')
6 parser.add_argument(
'-i',
'--inputType', default=
"HF_CHARM", 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=40, type=int, help=
'Production run to use')
10 parser.add_argument(
'-o',
'--condorDir', default=
"./", help=
'Condor Output Folder')
11 parser.add_argument(
'--nopileup', help=
'Get data without pileup', action=
"store_true")
12 parser.add_argument(
'--truth', help=
'Enable truth DST reading', action=
"store_true")
13 parser.add_argument(
'--calo', help=
'Enable calo DST reading', action=
"store_true")
14 parser.add_argument(
'--trkr_hit', help=
'Enable tracker hit DST reading', action=
"store_true")
15 parser.add_argument(
'--bbc_g4hit', help=
'Enable BBC 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' : 16}
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']
31 dstSets.append(
'DST_CALO_CLUSTER')
32 dstSets.append(
'DST_TRUTH')
36 dstSets.append(
'DST_GLOBAL')
41 stSets.append('DST_VERTEX')
44 dstSets.append('DST_TRUTH')
46 dstSets.append('DST_TRKR_G4HIT')
47 dstSets.append('DST_TRACKSEEDS')
48 dstSets.append('DST_TRKR_CLUSTER')
49 if args.calo: dstSets.append('DST_CALO_CLUSTER')
50 if args.trkr_hit: dstSets.append('DST_TRKR_HIT')
53 dstSets.append('DST_BBC_G4HIT')
54 if args.g4hit: dstSets.append('G4Hits')
56 dstSets.append('DST_TRUTH_RECO')
57 if args.truth == False: dstSets.append('DST_TRUTH')
59 myShell =
str(environ[
'SHELL'])
60 goodShells = [
'/bin/bash',
'/bin/tcsh']
61 if myShell
not in goodShells:
62 print(
"Your shell {} was not recognised".
format(myShell))
67 print(
"Creating condor submission files for {} production".
format(inputType))
70 for i
in range(len(dstSets)):
72 line.append(inputFiles[i].readline())
73 myOutputPath = args.condorDir
74 os.makedirs(myOutputPath)
75 condorDir = "{}/condorJob".
format(myOutputPath)
76 os.makedirs(
"{}/log".
format(condorDir), exist_ok=
True)
77 os.makedirs(
"{}/fileLists".
format(condorDir), exist_ok=
True)
82 for i
in range(len(dstSets)):
83 fileStart =
"fileLists/productionFiles-{1}-{2}-".
format(condorDir, inputType, dstSets[i].
lower())
84 listFile.append(
"{0}/{1}{2:05d}.list".
format(condorDir, fileStart, nJob))
85 listFileGeneric.append(
"$(condorDir)/{0}$INT(Process,%05d).list".
format(fileStart))
86 productionFilesToUse =
open(listFile[i],
"w")
87 for j
in range(0, args.nFilesPerJob):
88 splitLine = line[i].split(
"/")
89 fileName = splitLine[-1]
90 productionFilesToUse.write(fileName)
91 line[i] = inputFiles[i].readline()
93 condorFileName =
"{0}/my{1}.job".
format(condorDir, inputType)
94 condorFile =
open(
"{}".
format(condorFileName),
"w")
95 condorFile.write(
"Universe = vanilla\n")
96 condorFile.write(
"initialDir = {}\n".
format(os.getcwd()))
97 if myShell ==
'/bin/bash': condorFile.write(
"Executable = $(initialDir)/run_MDC2reco.sh\n")
98 if myShell ==
'/bin/tcsh': condorFile.write(
"Executable = $(initialDir)/run_MDC2reco.csh\n")
99 condorFile.write(
"PeriodicHold = (NumJobStarts>=1 && JobStatus == 1)\n")
100 condorFile.write(
"request_memory = 4GB\n")
101 condorFile.write(
"Priority = 20\n")
102 condorFile.write(
"job_lease_duration = 3600\n")
103 condorFile.write(
"condorDir = {}\n".
format(condorDir))
104 condorOutputInfo =
"$(condorDir)/log/condor-{0}-$INT(Process,%05d)".
format(inputType)
105 condorFile.write(
"Output = {0}.out\n".
format(condorOutputInfo))
106 condorFile.write(
"Error = {0}.err\n".
format(condorOutputInfo))
107 condorFile.write(
"Log = {0}.log\n".
format(condorOutputInfo))
108 condorFile.write(
"Arguments = \"$(condorDir) {}\"\n".
format(
' '.
join(listFileGeneric)))
109 condorFile.write(
"Queue {}\n".
format(nJob))
110 print(
"Submission setup complete!")
111 print(
"This setup will submit {} subjobs".
format(nJob))
112 print(
"You can submit your job with the script:\n{}".
format(condorFileName))
114 catalogCommand =
"CreateFileList.pl -run {0} -type {1} {2}".
format(args.run, types[inputType],
' '.
join(dstSets))
115 if args.nTotEvents != -1: catalogCommand +=
" -n {}".
format(args.nTotEvents)
116 if args.nopileup: catalogCommand +=
" -nopileup"
117 print (catalogCommand)
118 os.system(catalogCommand)