1 from optparse
import OptionParser
9 return not any((
True for _
in os.scandir(dir_path)))
11 if __name__ ==
'__main__':
12 parser = OptionParser(usage=
"usage: %prog ver [options -h]")
13 parser.add_option(
"-d",
"--data", dest=
"data", action=
"store_true", default=
False, help=
"Is data or simulation")
14 parser.add_option(
"-g",
"--generator", dest=
"generator", default=
"HIJING", help=
"Generator type (HIJING, EPOS, AMPT)")
15 parser.add_option(
"-n",
"--eventPerJob", dest=
"eventPerJob", default=200, help=
"Number of events per job")
16 parser.add_option(
"-j",
"--nJob", dest=
"nJob", default=400, help=
"Number of jobs (queues)")
17 parser.add_option(
"-o",
"--outputdir", dest=
"outputdir", default=
"HIJING_ana398_zvtx-20cm_dummyAlignParams", help=
"Output directory (under /sphenix/user/hjheng/TrackletAna/data/INTT/)")
18 parser.add_option(
"-s",
"--softwareversion", dest=
"softwareversion", default=
"new", help=
"Software version (new, ana.3xx)")
19 parser.add_option(
"-c",
"--submitcondor", dest=
"submitcondor", action=
"store_true", default=
False, help=
"Submit condor jobs")
21 (opt, args) = parser.parse_args()
25 generator = opt.generator
26 eventPerJob = int(opt.eventPerJob)
28 outputdir = opt.outputdir
29 softwareversion = opt.softwareversion
30 submitcondor = opt.submitcondor
31 username = pwd.getpwuid(os.getuid())[0]
34 ntupledest =
'/sphenix/user/{}/TrackletAna/data/INTT/{}'.
format(username,outputdir)
35 os.makedirs(ntupledest, exist_ok=
True)
37 os.makedirs(
'./condorLog/', exist_ok=
True)
39 os.system(
'rm ./condorLog/*')
41 condorFileName =
"submitCondor_process{}.job".
format(
'Data' if data
else 'Sim{}'.
format(generator))
43 condorFile.write(
"Universe = vanilla\n")
44 condorFile.write(
"initialDir = /sphenix/user/{}/sPHENIXdNdEta/macros/\n".
format(username))
45 condorFile.write(
"Executable = $(initialDir)/production_INTT.sh\n")
46 condorFile.write(
"PeriodicHold = (NumJobStarts>=1 && JobStatus == 1)\n")
47 condorFile.write(
"request_memory = 4GB\n")
48 condorFile.write(
"Priority = 20\n")
49 condorFile.write(
"job_lease_duration = 3600\n")
50 condorFile.write(
"runData = {}\n".
format(1
if data
else 0))
51 condorFile.write(
"generator = {}\n".
format(generator))
52 condorFile.write(
"nEvents = {}\n".
format(eventPerJob))
53 condorFile.write(
"filename = {}/ntuple_$(Process).root\n".
format(ntupledest))
54 condorFile.write(
"Output = $(Initialdir)/condor_INTT/condorLog/process{}_$(Process).out\n".
format(
'Data' if data
else 'Sim{}'.
format(generator)))
55 condorFile.write(
"Error = $(Initialdir)/condor_INTT/condorLog/process{}_$(Process).err\n".
format(
'Data' if data
else 'Sim{}'.
format(generator)))
56 condorFile.write(
"Log = $(Initialdir)/condor_INTT/condorLog/process{}_$(Process).log\n".
format(
'Data' if data
else 'Sim{}'.
format(generator)))
57 condorFile.write(
"Arguments = \"$(runData) $(generator) $(nEvents) $(filename) $(Process) $(softwareversion)\"\n")
58 condorFile.write(
"Queue {}\n".
format(nJob))
62 cmd =
'condor_submit ' + condorFileName