1 from optparse
import OptionParser
9 return not any((
True for _
in os.scandir(dir_path)))
12 if __name__ ==
'__main__':
14 parser = OptionParser(usage=
"usage: %prog ver [options -h]")
15 parser.add_option(
"-d",
"--isdata", dest=
"isdata", action=
"store_true", default=
False, help=
"Is data")
16 parser.add_option(
"-i",
"--infiledir", dest=
"infiledir", default=
'/sphenix/user/hjheng/TrackletAna/data/INTT/HIJING_ana398_xvtx-0p04cm_yvtx0p24cm_zvtx-20cm_dummyAlignParams', help=
"Input file")
17 parser.add_option(
"-o",
"--outfiledir", dest=
"outfiledir", default=
'BeamspotMinitree_HIJING_ana398_xvtx-0p04cm_yvtx0p24cm_zvtx-20cm_dummyAlignParams', help=
"Output file directory (under /sphenix/user/hjheng/TrackletAna/minitree/INTT/)")
18 parser.add_option(
"-p",
"--dphicut", dest=
"dphicut", default=0.05, help=
"Delta phi cut")
19 parser.add_option(
"-j",
"--nJob", dest=
"nJob", default=400, help=
"nJob")
20 parser.add_option(
"-s",
"--submitcondor", dest=
"submitcondor", action=
"store_true", default=
False, help=
"Submit condor jobs")
22 (opt, args) = parser.parse_args()
26 infiledir = opt.infiledir
27 outfiledir = opt.outfiledir
28 dphicut = float(opt.dphicut)
30 submitcondor = opt.submitcondor
31 username = pwd.getpwuid(os.getuid())[0]
32 print (
'username: {}'.
format(username))
34 finaloutfiledir =
'/sphenix/user/{}/TrackletAna/minitree/INTT/{}'.
format(username, outfiledir)
35 os.makedirs(finaloutfiledir, exist_ok=
True)
37 os.makedirs(
'./log_beamspot/', exist_ok=
True)
39 os.system(
'rm ./log_beamspot/*')
42 condorFileName =
"submitCondor_BeamspotReco_{}.job".
format(
'data' if isdata
else 'sim')
44 condorFile.write(
"Universe = vanilla\n")
45 condorFile.write(
"InitialDir = /sphenix/user/{}/TrackletAna/analysis_INTT\n".
format(username))
46 condorFile.write(
"Executable = $(InitialDir)/condor_BeamspotReco.sh\n")
47 condorFile.write(
"PeriodicHold = (NumJobStarts>=1 && JobStatus == 1)\n")
48 condorFile.write(
"request_memory = 4GB\n")
49 condorFile.write(
"Priority = 20\n")
50 condorFile.write(
"job_lease_duration = 3600\n")
51 condorFile.write(
"inputfile = {}/ntuple_$(Process).root\n".
format(infiledir))
52 condorFile.write(
"dphicut = {}\n".
format(dphicut))
53 condorFile.write(
"outputfile = {}/minitree_$(Process).root\n".
format(finaloutfiledir))
54 condorFile.write(
"Output = $(Initialdir)/condor/log_beamspot/condorlog_$(Process).out\n")
55 condorFile.write(
"Error = $(Initialdir)/condor/log_beamspot/condorlog_$(Process).err\n")
56 condorFile.write(
"Log = $(Initialdir)/condor/log_beamspot/condorlog_$(Process).log\n")
57 condorFile.write(
"Arguments = \"$(inputfile) $(outputfile) $(dphicut)\"\n")
58 condorFile.write(
"Queue {}\n".
format(nJob))
62 cmd =
'condor_submit ' + condorFileName