#!/apps/python/python-2.7.1/bin/python2.7 import sys import os import fnmatch import subprocess import time def find(runNumber): result = [] runPeriods=["RunPeriod-2014-10", "RunPeriod-2015-03", "RunPeriod-2015-06"] for runPeriod in runPeriods: inputDirectory = "/mss/halld/%s/rawdata/Run%.6i/" % (runPeriod , runNumber) list = [] try: #list = sorted(os.listdir( inputDirectory)) list = sorted(os.path.join(inputDirectory, f) for f in os.listdir(inputDirectory)) except OSError: continue return list # main function # This is where the program starts def main(): ######################################################################### # Define the run list you want to use #runList = [1998] runList = [3221] #Comma seperated lists #runList = [3387] # Here is where to define all of the stuff to be passed to the run command Plugins="CDC_Cosmics" Options="-PJANA:BATCH_MODE=1 -PCDCCOSMIC:EXCLUDERING=13" #Plugins="GX_Millepede_Alignment" #Options="-PJANA:BATCH_MODE=1 -PTRKFIND:COSMICS=1 -PBFIELD_TYPE=NoField" # define paths for output MyOutHistDir="/volatile/halld/home/mstaib/CDC_Cosmic/" #MyOutHistDir="/volatile/halld/home/mstaib/millepede/" #MyOutLogDir="/work/halld/home/mstaib/HLDetectorTiming_Log/" # Not implemented # Pick a number of threads nThreads = 1 maxFiles = 1000 # You can use this to cut on the maximum number of files submitted for each run minFiles = 2 # Use this to cut on the minimum number of files a run must have in order to be submitted Test = 0 # Set Test to 0 to actually submit the jobs ######################################################################### print "=========================================================" print "Launching jobs with plugins: %s" % Plugins print "With options: %s" % Options print "Using %i thread(s)" % nThreads print "=========================================================" for run in runList: run_num_str = str("%d" % run) # find associated files counter = 0 allfiles = "" counter = 0 #for files in sorted(os.listdir( inputDirectory)): for files in find(run): if not files.endswith("evio"): continue; if files.find(run_num_str) == -1: continue; counter += 1 if counter > maxFiles: continue; allfiles += files + " " if counter > minFiles: if maxFiles > counter: print "Submitting %i of %s Files for Run %s" % (counter, counter, run_num_str) else: print "Submitting %i of %s Files for Run %s" % (maxFiles, counter, run_num_str) subprocess.call(["SubmitGenericJob.sh",Plugins,Options,run_num_str,str(nThreads),MyOutHistDir,allfiles,str(Test)]) if __name__=="__main__": main()