ATLAS Offline Software
Loading...
Searching...
No Matches
BulkRun.BulkRun Class Reference
Collaboration diagram for BulkRun.BulkRun:

Public Member Functions

 __init__ (self, inputPattern="/raid02/schernau/ped/csc/csc/*.data", processedFilesList="ProcessedFiles.list", outputDirBase="/raid02/lampen/datasets/csc/PedProcessing2", debug=False, allowDirOverwrite=False)
 run (self, numToRun=10)
 ReadProcessedFilesList (self)
 AddProcessedFiles (self, newFiles)
 FindFiles (self)
 RunAthena (self, pattern, runNumber)

Public Attributes

 InputPattern = inputPattern
 ProcessedFilesList = processedFilesList
 OutputDirBase = outputDirBase
 debug = debug
 AllowDirOverwrite = allowDirOverwrite

Detailed Description

Run on multiple pedestal files

Used to run on multiple pedestal bytestream files located somewhere on disk.
Puts results into seperate directories by run-number. It extracts pertinent
information from the file names, which are expected to be of the form:

data10_calib.00157081.calibration_pedCSC.daq.RAW._lb0000._CSC-EB._0001.data

run(numToRun) - process NumToRun (at most) runs out of those not yet run out of. This is the primary interface. 
ReadProcessedFilesList() - find all files already run on from a local text file
AddProcessedFiles() - save newly run on files to disk
FindFiles() - Find pattern and run number of a set of files that have not yet been run on
RunAthena() - run athena job for a set of runs

Definition at line 10 of file BulkRun.py.

Constructor & Destructor Documentation

◆ __init__()

BulkRun.BulkRun.__init__ ( self,
inputPattern = "/raid02/schernau/ped/csc/csc/*.data",
processedFilesList = "ProcessedFiles.list",
outputDirBase = "/raid02/lampen/datasets/csc/PedProcessing2",
debug = False,
allowDirOverwrite = False )
initialize internal variables

Definition at line 26 of file BulkRun.py.

33 ):
34 """initialize internal variables"""
35 self.InputPattern = inputPattern
36 self.ProcessedFilesList = processedFilesList
37 self.OutputDirBase = outputDirBase
38 self.debug = debug
39 self.AllowDirOverwrite = allowDirOverwrite
40 print (self.InputPattern)
41

Member Function Documentation

◆ AddProcessedFiles()

BulkRun.BulkRun.AddProcessedFiles ( self,
newFiles )
Save new processed files to disk

Definition at line 92 of file BulkRun.py.

92 def AddProcessedFiles(self,newFiles):
93 """Save new processed files to disk"""
94 ProcessedFiles = self.ReadProcessedFilesList()
95 ProcessedFiles += newFiles
96 f = open(self.ProcessedFilesList,"wb")
97 pickle.dump(ProcessedFiles,f)
98 f.close()
99
100 return True
101
102

◆ FindFiles()

BulkRun.BulkRun.FindFiles ( self)

Definition at line 104 of file BulkRun.py.

104 def FindFiles(self):
105
106 #Initial setup
107 FoundUnprocessedFile = False
108
109 #Get processed file list
110 ProcessedFiles = self.ReadProcessedFilesList()
111
112 #Get list of files in input dir
113 print ("Input pattern: " + self.InputPattern)
114 inputFiles = glob(self.InputPattern)
115
116 if(self.debug):
117 print()
118 print ("Searching for file")
119 print ("InputPattern: " + self.InputPattern)
120 #print ("inputFiles: ")
121 #print (inputFiles)
122
123 pattern = ""
124 runNumber = ""
125
126 #Loop through list until find file that is
127 for file in inputFiles:
128 if not ProcessedFiles.count(file):
129
130 index = file.find("data10")
131 if(index == -1):
132 index = file.find("data11")
133 if(index == -1):
134 print ("ERROR! Index of -1!")
135 raise Exception("Index error")
136 FoundUnprocessedFile = True
137 pattern = file[0:index + 22] + "*" #includes run number
138 runNumber = file[index + 13: index + 21]
139
140 if(not FoundUnprocessedFile):
141 return "",""
142
143 if(self.debug) :
144 print ("Found unprocessed file with pattern: " + pattern)
145 print ("This includes files:")
146 print (glob(pattern))
147
148 return pattern, runNumber
149
if(febId1==febId2)
void print(char *figname, TCanvas *c1)

◆ ReadProcessedFilesList()

BulkRun.BulkRun.ReadProcessedFilesList ( self)

Definition at line 72 of file BulkRun.py.

72 def ReadProcessedFilesList(self):
73
74 ProcessedFiles = []
75
76 #Get processed files
77 f = open(self.ProcessedFilesList,"rb")
78 ProcessedFiles = pickle.load(f)
79 f.close()
80
81 #Remove newline character from each filename
82
83 #for index in range(len(ProcessedFiles)) :
84 # file = ProcessedFiles[index]
85 # ProcessedFiles[index] = file[0:len(file)-1]
86
87 print ('Processed String: ')
88 print (ProcessedFiles)
89
90 return ProcessedFiles
91

◆ run()

BulkRun.BulkRun.run ( self,
numToRun = 10 )
Run over all run numbers, find files for each, and submit each set to
CscCalcPedMon.py

Definition at line 42 of file BulkRun.py.

42 def run(self, numToRun = 10) :
43 """
44 Run over all run numbers, find files for each, and submit each set to
45 CscCalcPedMon.py
46 """
47
48 print ("Running on " + str(numToRun) + " runsSet.")
49
50
51 runNumbers = []
52 for runCnt in range(numToRun) :
53 print (">>>>Running on runSet " + str(runCnt+1) + " of " + str(numToRun))
54 pattern,runNumber = self.FindFiles()
55 if(pattern != ""):
56 #have files to run on
57 runNumbers += [runNumber]
58 self.RunAthena(pattern,runNumber)
59 else:
60 print ("No more unprocessed files. Congrats!")
61 print ("N runs done: " + str(runCnt +1))
62 print (runNumbers)
63 return
64 print ("finished all " + str(numToRun) )
65 print ("Run numbers include:")
66 print (runNumbers)
67 print()
68 print ("All Processed files:" )
69 print (self.ReadProcessedFilesList())
70
Definition run.py:1

◆ RunAthena()

BulkRun.BulkRun.RunAthena ( self,
pattern,
runNumber )
Run athena on a particular set of files matching pattern

Definition at line 150 of file BulkRun.py.

150 def RunAthena(self, pattern, runNumber):
151 """Run athena on a particular set of files matching pattern"""
152 outputDirPath = self.OutputDirBase + "/" + runNumber
153
154 if(self.AllowDirOverwrite):
155 subprocess.call("rm -rf " + outputDirPath)
156
157 print ("Making directory" + outputDirPath)
158 #Create output directory
159 os.mkdir(outputDirPath,0o755)
160
161 #Change directory to output directory
162 #os.chdir(outputDirPath)
163
164 #Athena options
165 athOpt = "outputPre='" + outputDirPath +"/" + runNumber
166 athOpt += "';inputPat='" + pattern
167 athOpt += "';reportPrefix='runNumber = "
168 athOpt += runNumber + "'"
169
170 #athena arguments
171 athArgs = ["athena.py", "-c", athOpt, "CscCalcPedMon.py"]
172
173 #Output log file
174 logFile = open(outputDirPath + "/run.log","w")
175
176 print()
177 print ("**************************************")
178 print ("Starting running on run " + str(runNumber))
179 sys.stdout.flush()
180 subprocess.Popen(athArgs,stdout=logFile,stderr=subprocess.STDOUT).wait()
181 print ("Finished run " + str(runNumber))
182 print ("**************************************")
183 print()
184
185 logFile.close()
186
187
188 #Add files we just ran on to file list
189 newProcessedFiles = glob(pattern)
190 self.AddProcessedFiles(newProcessedFiles)

Member Data Documentation

◆ AllowDirOverwrite

BulkRun.BulkRun.AllowDirOverwrite = allowDirOverwrite

Definition at line 39 of file BulkRun.py.

◆ debug

BulkRun.BulkRun.debug = debug

Definition at line 38 of file BulkRun.py.

◆ InputPattern

BulkRun.BulkRun.InputPattern = inputPattern

Definition at line 35 of file BulkRun.py.

◆ OutputDirBase

BulkRun.BulkRun.OutputDirBase = outputDirBase

Definition at line 37 of file BulkRun.py.

◆ ProcessedFilesList

BulkRun.BulkRun.ProcessedFilesList = processedFilesList

Definition at line 36 of file BulkRun.py.


The documentation for this class was generated from the following file: