ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
BulkRun.BulkRun Class Reference
Collaboration diagram for BulkRun.BulkRun:

Public Member Functions

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

Public Attributes

 InputPattern
 
 ProcessedFilesList
 
 OutputDirBase
 
 debug
 
 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 11 of file BulkRun.py.

Constructor & Destructor Documentation

◆ __init__()

def 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 27 of file BulkRun.py.

27  def __init__(
28  self,
29  inputPattern = "/raid02/schernau/ped/csc/csc/*.data" ,
30  processedFilesList = "ProcessedFiles.list",
31  outputDirBase = "/raid02/lampen/datasets/csc/PedProcessing2",
32  debug = False,
33  allowDirOverwrite = False,
34  ):
35  """initialize internal variables"""
36  self.InputPattern = inputPattern
37  self.ProcessedFilesList = processedFilesList
38  self.OutputDirBase = outputDirBase
39  self.debug = debug
40  self.AllowDirOverwrite = allowDirOverwrite
41  print (self.InputPattern)
42 

Member Function Documentation

◆ AddProcessedFiles()

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

Definition at line 93 of file BulkRun.py.

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

◆ FindFiles()

def BulkRun.BulkRun.FindFiles (   self)

Definition at line 105 of file BulkRun.py.

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

◆ ReadProcessedFilesList()

def BulkRun.BulkRun.ReadProcessedFilesList (   self)

Definition at line 73 of file BulkRun.py.

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

◆ run()

def 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 43 of file BulkRun.py.

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

◆ RunAthena()

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

Definition at line 151 of file BulkRun.py.

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

Member Data Documentation

◆ AllowDirOverwrite

BulkRun.BulkRun.AllowDirOverwrite

Definition at line 33 of file BulkRun.py.

◆ debug

BulkRun.BulkRun.debug

Definition at line 32 of file BulkRun.py.

◆ InputPattern

BulkRun.BulkRun.InputPattern

Definition at line 29 of file BulkRun.py.

◆ OutputDirBase

BulkRun.BulkRun.OutputDirBase

Definition at line 31 of file BulkRun.py.

◆ ProcessedFilesList

BulkRun.BulkRun.ProcessedFilesList

Definition at line 30 of file BulkRun.py.


The documentation for this class was generated from the following file:
run
int run(int argc, char *argv[])
Definition: ttree2hdf5.cxx:28
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
Trk::open
@ open
Definition: BinningType.h:40
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
str
Definition: BTagTrackIpAccessor.cxx:11