1 from optparse
import OptionParser
10 return not any((
True for _
in os.scandir(dir_path)))
13 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(
"-f",
"--filedesc", dest=
"filedesc", default=
'ana398_xvtx-0p04cm_yvtx0p24cm_zvtx-20cm_dummyAlignParams', help=
"File description")
17 parser.add_option(
"-n",
"--nevents", dest=
"nevents", default=400, help=
"Number of events to process")
18 parser.add_option(
"-x",
"--vtxx", dest=
"vtxx", default=-0.04, help=
"Vertex x")
19 parser.add_option(
"-y",
"--vtxy", dest=
"vtxy", default=0.24, help=
"Vertex y")
20 parser.add_option(
"-p",
"--dphicut", dest=
"dphicut", default=0.03, help=
"Delta phi cut [degree]")
21 parser.add_option(
"-c",
"--dcacut", dest=
"dcacut", default=0.15, help=
"DCA cut [cm]")
22 parser.add_option(
"-g",
"--debug", dest=
"debug", action=
"store_true", default=
False, help=
"Debug mode")
23 parser.add_option(
"-m",
"--makedemoplot", dest=
"makedemoplot", action=
"store_true", default=
False, help=
"Make demo plots")
24 parser.add_option(
"-j",
"--nJob", dest=
"nJob", default=400, help=
"nJob")
25 parser.add_option(
"-s",
"--submitcondor", dest=
"submitcondor", action=
"store_true", default=
False, help=
"Submit condor jobs")
27 (opt, args) = parser.parse_args()
31 filedesc = opt.filedesc
32 nevents = int(opt.nevents)
33 vtxx = float(opt.vtxx)
34 vtxy = float(opt.vtxy)
35 dphicut = float(opt.dphicut)
36 dcacut = float(opt.dcacut)
38 makedemoplot = opt.makedemoplot
40 submitcondor = opt.submitcondor
41 username = pwd.getpwuid(os.getuid())[0]
43 infiledir =
'/sphenix/user/{}/TrackletAna/data/INTT/{}'.
format(username, filedesc)
44 finaloutfiledir =
'/sphenix/user/{}/TrackletAna/minitree/INTT/VtxEvtMap_{}'.
format(username, filedesc)
45 os.makedirs(finaloutfiledir, exist_ok=
True)
47 os.makedirs(
'./log_recovtxz/', exist_ok=
True)
49 os.system(
'rm ./log_recovtxz/*')
52 condorFileName =
"submitCondor_recovtxz_{}.job".
format(
'data' if isdata
else 'sim')
54 condorFile.write(
"Universe = vanilla\n")
55 condorFile.write(
"InitialDir = /sphenix/user/{}/TrackletAna/analysis_INTT\n".
format(username))
56 condorFile.write(
"Executable = $(InitialDir)/condor_recovtxz.sh\n")
57 condorFile.write(
"PeriodicHold = (NumJobStarts>=1 && JobStatus == 1)\n")
58 condorFile.write(
"request_memory = 6GB\n")
59 condorFile.write(
"Priority = 20\n")
60 condorFile.write(
"job_lease_duration = 3600\n")
61 condorFile.write(
"isdata = {}\n".
format(1
if isdata
else 0))
62 condorFile.write(
"nevt = {}\n".
format(nevents))
63 condorFile.write(
"avgvtxx = {}\n".
format(vtxx))
64 condorFile.write(
"avgvtxy = {}\n".
format(vtxy))
65 condorFile.write(
"dphicut = {}\n".
format(dphicut * (np.pi / 180.)))
66 condorFile.write(
"dcacut = {}\n".
format(dcacut))
67 condorFile.write(
"infilename = {}/ntuple_$(Process).root\n".
format(infiledir))
68 condorFile.write(
"outfilename = {}/minitree_$(Process).root\n".
format(finaloutfiledir))
69 condorFile.write(
"demoplotpath = ./plot/RecoPV_demo/RecoPV_{}/{}\n".
format(
'data' if isdata
else 'sim', filedesc))
70 condorFile.write(
"debug = {}\n".
format(1
if debug
else 0))
71 condorFile.write(
"makedemoplot = {}\n".
format(1
if makedemoplot
else 0))
72 condorFile.write(
"Output = $(Initialdir)/condor/log_recovtxz/condorlog_$(Process).out\n")
73 condorFile.write(
"Error = $(Initialdir)/condor/log_recovtxz/condorlog_$(Process).err\n")
74 condorFile.write(
"Log = $(Initialdir)/condor/log_recovtxz/condorlog_$(Process).log\n")
75 condorFile.write(
"Arguments = \"$(isdata) $(nevt) $(avgvtxx) $(avgvtxy) $(dphicut) $(dcacut) $(infilename) $(outfilename) $(demoplotpath) $(debug) $(makedemoplot)\"\n")
76 condorFile.write(
"Queue {}\n".
format(nJob))
80 cmd =
'condor_submit ' + condorFileName