3 from __future__
import print_function
12 """Run on multiple pedestal files
14 #Used to run on multiple pedestal bytestream files located somewhere on disk.
15 #Puts results into seperate directories by run-number. It extracts pertinent
16 #information from the file names, which are expected to be of the form:
18 Quickie folowup when BulkRun failed on a few. This will re-enter existing directories
19 of particular run numbers. It should be given a sepearte processedFiles.list
21 data10_calib.00157081.calibration_pedCSC.daq.RAW._lb0000._CSC-EB._0001.data
23 run() - run over all runs
24 ReadProcessedFilesList() - find all files already run on from a local text file
25 AddProcessedFiles() - save newly run on files to disk
26 FindFiles() - Find pattern and run number of a set of files that have not yet been run on
27 RunAthena() - run athena job for a set of runs
33 inputPattern = "/raid02/schernau/ped/csc/*.data",
34 processedFilesList = "ProcessedFiles_Followup.list",
35 outputDirBase = "/raid02/lampen/datasets/csc/PedProcessing",
37 allowDirOverwrite = False,
39 """initialize internal variables"""
47 def run(self, numToRun = 10) :
49 Run over all run numbers, find files for each, and submit each set to
53 print (
"Running on " +
str(numToRun) +
" runsSet.")
57 for runCnt
in range(numToRun) :
58 print (
">>>>Running on runSet " +
str(runCnt+1) +
" of " +
str(numToRun))
63 runNumbers += [runNumber]
67 print (
"Skipping file from runNumber " +
str(runNumber) +
" (Not allowed)")
69 newProcessedFiles = glob(pattern)
73 print (
"No more unprocessed files. Congrats!")
74 print (
"N runs done: " +
str(runCnt +1))
77 print (
"finished all " +
str(numToRun) )
78 print (
"Run numbers include:")
81 print (
"All Processed files:" )
91 ProcessedFiles = pickle.load(f)
94 print (
'Processed String: ')
95 print (ProcessedFiles)
100 """Save new processed files to disk"""
102 print (
"Got old processed files")
103 print (ProcessedFiles)
104 ProcessedFiles += newFiles
105 print (
"New version:")
106 print (ProcessedFiles)
108 pickle.dump(ProcessedFiles,f)
118 FoundUnprocessedFile =
False
128 print (
"Searching for file")
135 for file
in inputFiles:
136 if not ProcessedFiles.count(file):
138 index = file.find(
"data10")
140 index = file.find(
"data11")
142 print (
"ERROR! Index of -1 searching for data1X prefix in filename:")
144 raise Exception(
"Index error")
145 FoundUnprocessedFile =
True
146 pattern = file[0:index + 22] +
"*"
147 runNumber = file[index + 13: index + 21]
149 if(
not FoundUnprocessedFile):
151 print (
"Did not find unprocessed file")
155 print (
"Found unprocessed file with pattern: " + pattern)
156 print (
"This includes files:")
157 print (glob(pattern))
159 return pattern, runNumber
162 """Run athena on a particular set of files matching pattern"""
166 subprocess.call(
"rm -rf " + outputDirPath)
168 print (
"Making directory" + outputDirPath)
170 os.mkdir(outputDirPath,0o755)
173 athOpt =
"outputPre='" + outputDirPath +
"/" + runNumber
174 athOpt +=
"';inputPat='" + pattern
175 athOpt +=
"';reportPrefix='runNumber = "
176 athOpt += runNumber +
"'"
179 athArgs = [
"athena.py",
"-c", athOpt,
"CscCalcPedMon.py"]
182 logFile =
open(outputDirPath +
"/run2.log",
"w")
185 print (
"**************************************")
186 print (
"Starting running on run " +
str(runNumber))
188 subprocess.Popen(athArgs,stdout=logFile,stderr=subprocess.STDOUT).wait()
189 print (
"Finished run " +
str(runNumber))
190 print (
"**************************************")
196 newProcessedFiles = glob(pattern)