2 from RecoLuminosity.LumiDB
import csvSelectionParser,selectionParser,CommonUtil
6 if comps
and comps[0].lower()==
'run':
13 filelist=inputfilename.split(
'+')
25 inputfilecontent=selectf.read() 34 csvReader=csv.reader(ifile,delimiter=
',')
37 if hasHeader
and irow==0:
40 self.__inputResult.append(row)
53 csvReader=csv.reader(open(f),delimiter=
',')
59 if runnumber
not in result:
60 result[runnumber]=
None 71 selectedruns=self.
runs()
72 for r
in selectedruns:
73 if r
in runswithresult:
85 selectedruns=self.
runs()
86 for r
in selectedruns:
87 if r
not in runswithresult:
91 '''return the input selection file name 95 '''if empty input selection filename give, I assume you only need to merge pieces of output result files into one 102 output [headerfields] 112 given the input result field name and typem return the list of values 117 fieldidx=self.__inputResultHeader.index(fieldname)
119 print 'field ',fieldname,
' not found' 122 stringvalue=r[fieldidx]
123 if fieldtype
in [
'int',
'unsigned int']:
125 print 'field ',fieldname,
' is not integer type' 128 result.append(
int(stringvalue))
130 elif fieldtype
in [
'float']:
132 print 'field ',fieldname,
' is not float type' 135 result.append(
float(stringvalue))
137 elif fieldtype
in [
'string',
'str']:
138 result.append(stringvalue)
140 raise 'unsupported type ',fieldtype
144 given the input result field name and type, return the total 149 fieldidx=self.__inputResultHeader.index(fieldname)
151 print 'field ',fieldname,
' not found' 154 stringvalue=r[fieldidx]
155 if fieldtype
in [
'int',
'unsigned int']:
157 print 'field ',fieldname,
' is not integer type' 160 result=
int(result)+
int(stringvalue)
162 elif fieldtype
in [
'float'] :
164 print 'field ',fieldname,
' is not float type' 170 raise 'cannot sum types other than int ,float' 175 return self.__inputSelectionFileparsingResult.runs()
179 return self.__inputSelectionFileparsingResult.runsandls()
183 return self.__inputSelectionFileparsingResult.runsandlsStr()
185 if __name__ ==
'__main__':
187 filename=
'163664-v2-overview.csv+163665-v2-overview.csv+163668-v2-overview.csv+../json_DCSONLY.txt' 189 print 'selection file ',p.selectionfilename()
190 print 'old result files ',p.resultfiles()
193 print 'do I only need to merge the results? ',p.mergeResultOnly()
194 resultheader=p.resultHeader()
196 print p.runsWithresult()
197 print 'selected runs with result ',p.selectedRunsWithresult()
198 print 'selected runs without result ',p.selectedRunsWithoutresult()
200 alreadyprocessedRuns=p.fieldvalues(
'Run',
'int')
201 print 'runs already have results ', alreadyprocessedRuns
202 print 'total delivered ',p.fieldtotal(
'Delivered(/ub)',
'float')
203 print 'total recorded ',p.fieldtotal(
'Recorded(/ub)',
'float')
204 print 'result header ',p.resultheader()
205 print 'result lines ',p.resultlines()