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")
25 parser.add_option(
"-f",
"--filedesc", dest=
"filedesc", default=
'HIJING_ana398_xvtx-0p04cm_yvtx0p24cm_zvtx-20cm_dummyAlignParams', help=
"File description")
26 parser.add_option(
"-e",
"--nEvents", dest=
"nEvents", default=200, help=
"Number of events per job")
27 parser.add_option(
"-j",
"--nJob", dest=
"nJob", default=400, help=
"nJob")
28 parser.add_option(
"-r",
"--drcut", dest=
"drcut", default=0.5, help=
"Delta R cut for tracklets")
29 parser.add_option(
"-s",
"--submitcondor", dest=
"submitcondor", action=
"store_true", default=
False, help=
"Submit condor jobs")
31 (opt, args) = parser.parse_args()
35 filedesc = opt.filedesc
36 nEvents = int(opt.nEvents)
37 drcut = float(opt.drcut)
39 submitcondor = opt.submitcondor
40 username = pwd.getpwuid(os.getuid())[0]
42 finaloutfiledir =
'/sphenix/user/{}/TrackletAna/minitree/INTT/TrackletMinitree_{}/{}'.
format(username, filedesc,
'dRcut'+
str(drcut).replace(
'.',
'p'))
43 os.makedirs(finaloutfiledir, exist_ok=
True)
45 os.makedirs(
'./log_recotracklet/', exist_ok=
True)
47 os.system(
'rm ./log_recotracklet/*')
49 condorFileName =
"submitCondor_recotracklet_{}.job".
format(
'data' if isdata
else 'sim')
51 condorFile.write(
"Universe = vanilla\n")
52 condorFile.write(
"InitialDir = /sphenix/user/{}/TrackletAna/analysis_INTT\n".
format(username))
53 condorFile.write(
"Executable = $(InitialDir)/condor_recotracklet.sh\n")
54 condorFile.write(
"PeriodicHold = (NumJobStarts>=1 && JobStatus == 1)\n")
55 condorFile.write(
"request_memory = 6GB\n")
56 condorFile.write(
"Priority = 20\n")
57 condorFile.write(
"job_lease_duration = 3600\n")
58 condorFile.write(
"isdata = {}\n".
format(1
if isdata
else 0))
59 condorFile.write(
"evtvtxmap = /sphenix/user/{}/TrackletAna/minitree/INTT/VtxEvtMap_{}/minitree_$(Process).root\n".
format(username, filedesc))
60 condorFile.write(
"infilename = /sphenix/user/{}/TrackletAna/data/INTT/{}/ntuple_$(Process).root\n".
format(username, filedesc))
61 condorFile.write(
"outfilename = {}/minitree_$(Process).root\n".
format(finaloutfiledir))
62 condorFile.write(
"nevt = {}\n".
format(nEvents))
63 condorFile.write(
"drcut = {:.3g}\n".
format(drcut))
64 condorFile.write(
"Output = $(Initialdir)/condor/log_recotracklet/condorlog_$(Process).out\n")
65 condorFile.write(
"Error = $(Initialdir)/condor/log_recotracklet/condorlog_$(Process).err\n")
66 condorFile.write(
"Log = $(Initialdir)/condor/log_recotracklet/condorlog_$(Process).log\n")
67 condorFile.write(
"Arguments = \"$(isdata) $(evtvtxmap) $(infilename) $(outfilename) $(nevt) $(drcut)\"\n")
68 condorFile.write(
"Queue {}\n".
format(nJob))
72 cmd =
'condor_submit ' + condorFileName