1 from optparse
import OptionParser
9 return not any((
True for _
in os.scandir(dir_path)))
13 with
open(filename,
'r+')
as f:
15 file = re.sub(search_text, replace_text, file)
22 if __name__ ==
'__main__':
23 parser = OptionParser(usage=
"usage: %prog ver [options -n]")
24 parser.add_option(
"-d",
"--isdata", dest=
"isdata", action=
"store_true", default=
False, help=
"Is data")
26 parser.add_option(
"-f",
"--filedesc", dest=
"filedesc", default=
'HIJING_ana398_xvtx-0p04cm_yvtx0p24cm_zvtx-20cm_dummyAlignParams', help=
"File description")
29 parser.add_option(
"-j",
"--nJob", dest=
"nJob", default=400, help=
"nJob")
30 parser.add_option(
"-r",
"--drcut", dest=
"drcut", default=0.5, help=
"Delta R cut for tracklets")
31 parser.add_option(
"-s",
"--submitcondor", dest=
"submitcondor", action=
"store_true", default=
False, help=
"Submit condor jobs")
33 (opt, args) = parser.parse_args()
38 filedesc = opt.filedesc
42 submitcondor = opt.submitcondor
43 drcut = float(opt.drcut)
44 username = pwd.getpwuid(os.getuid())[0]
47 finaloutfiledir =
'/sphenix/user/{}/TrackletAna/analysis_INTT/plot/hists/{}/{}'.
format(username, filedesc,
'dRcut'+
str(drcut).replace(
'.',
'p'))
48 os.makedirs(finaloutfiledir, exist_ok=
True)
50 os.makedirs(
'./log_plottracklet/', exist_ok=
True)
52 os.system(
'rm ./log_plottracklet/*')
54 condorFileName =
"submitCondor_plottracklet_{}.job".
format(
'data' if isdata
else 'sim')
56 condorFile.write(
"Universe = vanilla\n")
57 condorFile.write(
"InitialDir = /sphenix/user/{}/TrackletAna/analysis_INTT\n".
format(username))
58 condorFile.write(
"Executable = $(InitialDir)/condor_plotTracklet.sh\n")
59 condorFile.write(
"PeriodicHold = (NumJobStarts>=1 && JobStatus == 1)\n")
60 condorFile.write(
"request_memory = 4GB\n")
61 condorFile.write(
"Priority = 20\n")
62 condorFile.write(
"job_lease_duration = 3600\n")
63 condorFile.write(
"isdata = {}\n".
format(1
if isdata
else 0))
64 condorFile.write(
"infilename = /sphenix/user/{}/TrackletAna/minitree/INTT/TrackletMinitree_{}/{}/minitree_$(Process).root\n".
format(username, filedesc,
'dRcut'+
str(drcut).replace(
'.',
'p')))
65 condorFile.write(
"outfilename = {}/hists_$(Process).root\n".
format(finaloutfiledir))
66 condorFile.write(
"Output = $(Initialdir)/condor/log_plottracklet/condorlog_$(Process).out\n")
67 condorFile.write(
"Error = $(Initialdir)/condor/log_plottracklet/condorlog_$(Process).err\n")
68 condorFile.write(
"Log = $(Initialdir)/condor/log_plottracklet/condorlog_$(Process).log\n")
69 condorFile.write(
"Arguments = \"$(isdata) $(infilename) $(outfilename)\"\n")
70 condorFile.write(
"Queue {}\n".
format(nJob))
74 cmd =
'condor_submit ' + condorFileName