Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:12:07

0001 from optparse import OptionParser
0002 import time
0003 import os
0004 import pwd
0005 import sys
0006 import re
0007 
0008 def dir_empty(dir_path):
0009     return not any((True for _ in os.scandir(dir_path)))
0010 
0011 
0012 if __name__ == '__main__':
0013     parser = OptionParser(usage="usage: %prog ver [options -h]")
0014     parser.add_option("-f", "--filedesc", dest="filedesc", default='HIJING_ana398_xvtx-0p04cm_yvtx0p24cm_zvtx-20cm_dummyAlignParams', help="File description")
0015     parser.add_option("-j", "--nJob", dest="nJob", default=400, help="nJob")
0016     parser.add_option("-s", "--submitcondor", dest="submitcondor", action="store_true", default=False, help="Submit condor jobs")
0017 
0018     (opt, args) = parser.parse_args()
0019     print('opt: {}'.format(opt))
0020 
0021     filedesc = opt.filedesc
0022     nJob = int(opt.nJob)
0023     submitcondor = opt.submitcondor
0024     username = pwd.getpwuid(os.getuid())[0]
0025     
0026     twolevelup = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir))
0027     infiledir = '{}/production/{}'.format(twolevelup, filedesc)
0028     print ('infiledir: {}'.format(infiledir))
0029     parentdir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))
0030     finaloutfiledir = '{}/plot/hists/{}/TrkrHit'.format(parentdir, filedesc)
0031     os.makedirs(finaloutfiledir, exist_ok=True)
0032 
0033     os.makedirs('./log_plotTrkrHit/', exist_ok=True)
0034     if not dir_empty('./log_plotTrkrHit/'):
0035         os.system('rm ./log_plotTrkrHit/*')
0036 
0037     condorFileName = "submitCondor_plottrkrhit.job"
0038     condorFile = open("{}".format(condorFileName), "w")
0039     condorFile.write("Universe           = vanilla\n")
0040     condorFile.write("InitialDir         = {}\n".format(parentdir))
0041     condorFile.write("Executable         = $(InitialDir)/condor_plotTrkrHit.sh\n")
0042     condorFile.write("PeriodicHold       = (NumJobStarts>=1 && JobStatus == 1)\n")
0043     condorFile.write("request_memory     = 4GB\n")
0044     condorFile.write("Priority           = 20\n")
0045     condorFile.write("job_lease_duration = 3600\n")
0046     condorFile.write("Myindex            = $(Process)\n")
0047     condorFile.write("Extension          = $INT(Myindex,%05d)\n")
0048     condorFile.write("infilename         = {}/ntuple_$(Extension).root\n".format(infiledir))
0049     condorFile.write("outfilename        = {}/hists_$(Extension).root\n".format(finaloutfiledir))
0050     condorFile.write("Output             = $(Initialdir)/condor/log_plotTrkrHit/condorlog_$(Process).out\n")
0051     condorFile.write("Error              = $(Initialdir)/condor/log_plotTrkrHit/condorlog_$(Process).err\n")
0052     condorFile.write("Log                = $(Initialdir)/condor/log_plotTrkrHit/condorlog_$(Process).log\n")
0053     condorFile.write("Arguments          = \"$(infilename) $(outfilename)\"\n")
0054     condorFile.write("Queue {}\n".format(nJob))
0055     condorFile.close() # Close the file before submitting the job
0056 
0057     if submitcondor:
0058         cmd = 'condor_submit ' + condorFileName
0059         os.system(cmd)