File indexing completed on 2025-08-05 08:14:56
0001 import sys, os
0002 from os import environ
0003 import argparse
0004
0005 parser = argparse.ArgumentParser(description='sPHENIX MDC2 Reco Job Creator')
0006 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')
0007 parser.add_argument('-f', '--nFilesPerJob', default=5, type=int, help='Number of input files to pass to each job')
0008 parser.add_argument('-t', '--nTotEvents', default=-1, type=int, help='Total number of events to run over')
0009 parser.add_argument('-r', '--run', default=6, type=int, help='Production run to use')
0010 parser.add_argument('--nopileup', help='Get data without pileup', action="store_true")
0011 parser.add_argument('--truth', help='Enable truth DST reading', action="store_true")
0012 parser.add_argument('--calo', help='Enable calo DST reading', action="store_true")
0013 parser.add_argument('--trkr_hit', help='Enable tracker hit DST reading', action="store_true")
0014 parser.add_argument('--bbc_g4hit', help='Enable BBC G4 hit DST reading', action="store_true")
0015 parser.add_argument('--g4hit', help='Enable G4 hit DST reading', action="store_true")
0016 parser.add_argument('--truth_table', help='Use DSTs for running tracking and making the truth/reco table', action="store_true")
0017
0018 args = parser.parse_args()
0019
0020 inputType = args.inputType.upper()
0021
0022 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
0023 , 'JET_30GEV' : 11, 'JET_10GEV' : 12, 'JET_PHOTON' : 13, 'SINGLE_PARTICLE' : 14 , 'D0JETS' : 16, 'D0JETS_5GEV' : 17, 'D0JETS_12GEV' : 18}
0024 if inputType not in types:
0025 print("The argument, {}, was not known. Use --help to see available types".format(args.inputType))
0026 sys.exit()
0027
0028
0029 dstSets = ['DST_TRACKS']
0030 if args.truth:
0031
0032 dstSets.append('DST_TRUTH')
0033
0034 dstSets.append('DST_TRACKSEEDS')
0035 dstSets.append('DST_TRKR_CLUSTER')
0036 if args.calo: dstSets.append('DST_CALO_CLUSTER')
0037 if args.trkr_hit: dstSets.append('DST_TRKR_HIT')
0038 if args.bbc_g4hit:
0039
0040 dstSets.append('DST_BBC_G4HIT')
0041 if args.g4hit: dstSets.append('G4Hits')
0042 if args.truth_table:
0043 dstSets.append('DST_TRUTH_RECO')
0044 if args.truth == False: dstSets.append('DST_TRUTH')
0045
0046 myShell = str(environ['SHELL'])
0047 goodShells = ['/bin/bash', '/bin/tcsh']
0048 if myShell not in goodShells:
0049 print("Your shell {} was not recognised".format(myShell))
0050 sys.exit()
0051
0052
0053 def makeCondorJob():
0054 print("Creating condor submission files for {} production".format(inputType))
0055 inputFiles = []
0056 line = []
0057 for i in range(len(dstSets)):
0058 inputFiles.append(open("{0}.list".format(dstSets[i].lower()), "r"))
0059 line.append(inputFiles[i].readline())
0060 myOutputPath = os.getcwd()
0061 condorDir = "{}/condorJob".format(myOutputPath)
0062 os.makedirs("{}/log".format(condorDir), exist_ok=True)
0063 os.makedirs("{}/fileLists".format(condorDir), exist_ok=True)
0064 nJob = 0;
0065 while line[0]:
0066 listFile = []
0067 listFileGeneric = []
0068 for i in range(len(dstSets)):
0069 fileStart = "fileLists/productionFiles-{1}-{2}-".format(condorDir, inputType, dstSets[i].lower())
0070 listFile.append("{0}/{1}{2:05d}.list".format(condorDir, fileStart, nJob))
0071 listFileGeneric.append("$(condorDir)/{0}$INT(Process,%05d).list".format(fileStart))
0072 productionFilesToUse = open(listFile[i], "w")
0073 for j in range(0, args.nFilesPerJob):
0074 splitLine = line[i].split("/")
0075 fileName = splitLine[-1]
0076 productionFilesToUse.write(fileName)
0077 line[i] = inputFiles[i].readline()
0078 nJob += 1
0079 condorFileName = "{0}/my{1}.job".format(condorDir, inputType)
0080 condorFile = open("{}".format(condorFileName), "w")
0081 condorFile.write("Universe = vanilla\n")
0082 condorFile.write("initialDir = {}\n".format(myOutputPath))
0083 if myShell == '/bin/bash': condorFile.write("Executable = $(initialDir)/run_MDC2reco.sh\n")
0084 if myShell == '/bin/tcsh': condorFile.write("Executable = $(initialDir)/run_MDC2reco.csh\n")
0085 condorFile.write("PeriodicHold = (NumJobStarts>=1 && JobStatus == 1)\n")
0086 condorFile.write("request_memory = 4GB\n")
0087 condorFile.write("Priority = 20\n")
0088 condorFile.write("job_lease_duration = 3600\n")
0089 condorFile.write("condorDir = $(initialDir)/condorJob\n")
0090 condorOutputInfo = "$(condorDir)/log/condor-{0}-$INT(Process,%05d)".format(inputType)
0091 condorFile.write("Output = {0}.out\n".format(condorOutputInfo))
0092 condorFile.write("Error = {0}.err\n".format(condorOutputInfo))
0093 condorFile.write("Log = /tmp/condor-{0}-$INT(Process,%05d).log\n".format(inputType))
0094 condorFile.write("Arguments = \"{}\"\n".format(' '.join(listFileGeneric)))
0095 condorFile.write("Queue {}\n".format(nJob))
0096 print("Submission setup complete!")
0097 print("This setup will submit {} subjobs".format(nJob))
0098 print("You can submit your job with the script:\n{}".format(condorFileName))
0099
0100 catalogCommand = "CreateFileList.pl -run {0} -nop -type {1} {2}".format(args.run, types[inputType], ' '.join(dstSets))
0101 if args.nTotEvents != -1: catalogCommand += " -n {}".format(args.nTotEvents)
0102 if args.nopileup: catalogCommand += " -nopileup"
0103 os.system(catalogCommand)
0104 makeCondorJob()