3 from RecoLuminosity.LumiDB
import nameDealer,lumiTime,CommonUtil
5 from RecoLuminosity.LumiDB
import argparse, nameDealer, selectionParser, hltTrgSeedMapper, \
6 connectstrParser, cacheconfigParser, tablePrinter, csvReporter, csvSelectionParser
7 from RecoLuminosity.LumiDB.wordWrappers
import wrap_always, wrap_onspace, wrap_onspace_strict
8 from pprint
import pprint, pformat
11 This module defines lowlevel SQL query API for lumiDB
12 We do not like range queries so far because of performance of range scan.Use only necessary.
13 The principle is to query by runnumber and per each coral queryhandle
14 Try reuse db session/transaction and just renew query handle each time to reduce metadata queries.
15 Avoid unnecessary explicit order by
16 Do not handle transaction in here.
17 Do not do explicit del queryhandle in here.
18 Note: all the returned dict format are not sorted by itself.Sort it outside if needed.
46 '''Given the rotation rate, calculate lumi section length and
47 rotation time. This should be called if rotationRate is
53 return '''<frontier-connect><proxy url = "http://cmst0frontier.cern.ch:3128"/><proxy url = "http://cmst0frontier.cern.ch:3128"/><proxy url = "http://cmst0frontier1.cern.ch:3128"/><proxy url = "http://cmst0frontier2.cern.ch:3128"/><server url = "http://cmsfrontier.cern.ch:8000/FrontierInt"/><server url = "http://cmsfrontier.cern.ch:8000/FrontierInt"/><server url = "http://cmsfrontier1.cern.ch:8000/FrontierInt"/><server url = "http://cmsfrontier2.cern.ch:8000/FrontierInt"/><server url = "http://cmsfrontier3.cern.ch:8000/FrontierInt"/><server url = "http://cmsfrontier4.cern.ch:8000/FrontierInt"/></frontier-connect>'''
57 l = numorbit * numbx * 25.0e-09
62 input: {lsnum:[deadtime, instlumi, bit_0, norbits,prescale...]}
63 output: {lsnum:[instlumi, recordedlumi...]}
66 for myls, deadArray
in deadtable.items():
67 lstime = lslengthsec (deadArray[3], 3564)
68 instlumi = deadArray[1] * lstime
69 if float( deadArray[2] ) == 0.0:
72 deadfrac = float (deadArray[0]) / (float (deadArray[2])*float(deadArray[4]))
73 recordedLumi = instlumi * (1.0 - deadfrac)
74 myLsList = [instlumi, recordedLumi]
76 if len (deadArray) > 5:
77 myLsList.extend (deadArray[5:])
78 result[myls] = myLsList
83 '''Takes either single run as a string or dictionary of run ranges'''
86 if isinstance (inputRange, str):
87 lumidata.append( deliveredLumiForRun (dbsession, parameters, inputRange) )
90 for run
in sorted( inputRange.runs() ):
91 if parameters.verbose:
93 lumidata.append( deliveredLumiForRun (dbsession, parameters, run) )
99 '''Takes either single run as a string or dictionary of run ranges'''
102 if isinstance (inputRange, str):
103 lumiDataPiece = recordedLumiForRun (dbsession, parameters, inputRange)
104 if parameters.lumiXing:
106 xingLumiDict = xingLuminosityForRun (dbsession, inputRange,
108 mergeXingLumi (lumiDataPiece, xingLumiDict)
109 lumidata.append (lumiDataPiece)
114 maxLumiSectionDict = {}
115 for (run, lslist)
in sorted (inputRange.runsandls().items() ):
117 maxLumiSectionDict[run] = max ( max (lslist),
118 maxLumiSectionDict.get(run,0) )
119 runLsDict.setdefault (run, []).append (lslist)
120 for run, metaLsList
in sorted (runLsDict.iteritems()):
121 if parameters.verbose:
124 for lslist
in metaLsList:
125 runLumiData.append( recordedLumiForRun (dbsession, parameters,
127 if parameters.lumiXing:
129 xingLumiDict = xingLuminosityForRun (dbsession, run,
132 maxLumiSectionDict[run])
134 for lumiDataPiece
in runLumiData:
135 mergeXingLumi (lumiDataPiece, xingLumiDict)
136 lumidata.append (lumiDataPiece)
138 lumidata.extend( runLumiData )
145 select sum (INSTLUMI), count (INSTLUMI) from lumisummary where runnum = 124025 and lumiversion = '0001';
146 select INSTLUMI,NUMORBIT from lumisummary where runnum = 124025 and lumiversion = '0001'
147 query result unit E27cm^-2 (= 1 / mb)"""
154 conditionstring=
"RUNNUM = :runnum AND LUMIVERSION = :lumiversion"
155 dbsession.transaction().start (
True)
156 schema = dbsession.nominalSchema()
160 query.addToOutputList(
"INSTLUMI",
'instlumi')
161 query.addToOutputList (
"NUMORBIT",
"norbits")
162 queryBind = coral.AttributeList()
163 queryBind.extend (
"runnum",
"unsigned int")
164 queryBind.extend (
"lumiversion",
"string")
165 queryBind[
"runnum"].setData (int (runnum))
166 queryBind[
"lumiversion"].setData (parameters.lumiversion)
168 if len(parameters.beammode)!=0:
169 conditionstring=conditionstring+
' and BEAMSTATUS=:beamstatus'
170 queryBind.extend(
'beamstatus',
'string')
171 queryBind[
'beamstatus'].setData(parameters.beammode)
172 result = coral.AttributeList()
173 result.extend (
"instlumi",
"float")
174 result.extend (
"norbits",
"unsigned int")
175 query.defineOutput (result)
176 query.setCondition (conditionstring,queryBind)
179 cursor = query.execute()
181 instlumi = cursor.currentRow()[
'instlumi'].
data()
182 norbits = cursor.currentRow()[
'norbits'].
data()
184 if instlumi
is not None and norbits
is not None:
186 delivered=delivered+instlumi*parameters.norm*lstime
189 dbsession.transaction().commit()
192 lumidata = [str (runnum),
'N/A',
'N/A',
'N/A']
194 lumidata = [str (runnum), str (totalls),
'%.3f'%delivered, parameters.beammode]
198 dbsession.transaction().rollback()
203 lslist = [] means take none in the db
204 lslist = None means to take all in the db
205 output: ['runnumber', 'trgtable{}', 'deadtable{}']
211 lumidata.append (runnum)
212 lumidata.append (trgtable)
213 lumidata.append (deadtable)
215 conditionstring=
'trghltmap.HLTKEY = cmsrunsummary.HLTKEY AND cmsrunsummary.RUNNUM = :runnumber'
217 dbsession.transaction().start (
True)
218 schema = dbsession.nominalSchema()
219 query = schema.newQuery()
222 queryCondition = coral.AttributeList()
223 queryCondition.extend (
"runnumber",
"unsigned int")
224 queryCondition[
"runnumber"].setData (int (runnum))
225 query.setCondition (conditionstring,queryCondition)
226 query.addToOutputList (
"trghltmap.HLTPATHNAME",
"hltpathname")
227 query.addToOutputList (
"trghltmap.L1SEED",
"l1seed")
228 result = coral.AttributeList()
229 result.extend (
"hltpathname",
"string")
230 result.extend (
"l1seed",
"string")
231 query.defineOutput (result)
232 cursor = query.execute()
234 hltpathname = cursor.currentRow()[
"hltpathname"].
data()
235 l1seed = cursor.currentRow()[
"l1seed"].
data()
236 collectedseeds.append ( (hltpathname, l1seed))
239 dbsession.transaction().commit()
241 for (hname, sname)
in collectedseeds:
242 l1bitname = hltTrgSeedMapper.findUniqueSeed (hname, sname)
245 lumidata[1][hname] = []
246 lumidata[1][hname].append (l1bitname.replace (
'\"',
''))
247 dbsession.transaction().start (
True)
248 schema = dbsession.nominalSchema()
250 hltprescQuery.addToOutputList (
"PATHNAME",
"hltpath")
251 hltprescQuery.addToOutputList (
"PRESCALE",
"hltprescale")
252 hltprescCondition = coral.AttributeList()
253 hltprescCondition.extend (
'runnumber',
'unsigned int')
254 hltprescCondition.extend (
'cmslsnum',
'unsigned int')
255 hltprescCondition.extend (
'inf',
'unsigned int')
256 hltprescResult = coral.AttributeList()
257 hltprescResult.extend (
'hltpath',
'string')
258 hltprescResult.extend (
'hltprescale',
'unsigned int')
259 hltprescQuery.defineOutput (hltprescResult)
260 hltprescCondition[
'runnumber'].setData (int (runnum))
261 hltprescCondition[
'cmslsnum'].setData (1)
262 hltprescCondition[
'inf'].setData (0)
263 hltprescQuery.setCondition (
"RUNNUM = :runnumber and CMSLSNUM = :cmslsnum and PRESCALE != :inf",
265 cursor = hltprescQuery.execute()
267 hltpath = cursor.currentRow()[
'hltpath'].
data()
268 hltprescale = cursor.currentRow()[
'hltprescale'].
data()
269 if lumidata[1].has_key (hltpath):
270 lumidata[1][hltpath].append (hltprescale)
274 dbsession.transaction().commit()
275 dbsession.transaction().start (
True)
276 schema = dbsession.nominalSchema()
277 query = schema.newQuery()
280 queryCondition = coral.AttributeList()
281 queryCondition.extend (
"runnumber",
"unsigned int")
282 queryCondition.extend (
"lumiversion",
"string")
283 queryCondition[
"runnumber"].setData (int (runnum))
284 queryCondition[
"lumiversion"].setData (parameters.lumiversion)
285 conditionstring=
'lumisummary.RUNNUM =:runnumber and lumisummary.LUMIVERSION =:lumiversion AND lumisummary.CMSLSNUM=trg.CMSLSNUM and lumisummary.RUNNUM=trg.RUNNUM'
286 if len(parameters.beammode)!=0:
287 conditionstring=conditionstring+
' and lumisummary.BEAMSTATUS=:beamstatus'
288 queryCondition.extend(
'beamstatus',
'string')
289 queryCondition[
'beamstatus'].setData(parameters.beammode)
290 query.setCondition(conditionstring,queryCondition)
291 query.addToOutputList (
"lumisummary.CMSLSNUM",
"cmsls")
292 query.addToOutputList (
"lumisummary.INSTLUMI",
"instlumi")
293 query.addToOutputList (
"lumisummary.NUMORBIT",
"norbits")
294 query.addToOutputList (
"trg.TRGCOUNT",
"trgcount")
295 query.addToOutputList (
"trg.BITNAME",
"bitname")
296 query.addToOutputList (
"trg.DEADTIME",
"trgdeadtime")
297 query.addToOutputList (
"trg.PRESCALE",
"trgprescale")
298 query.addToOutputList (
"trg.BITNUM",
"trgbitnum")
300 result = coral.AttributeList()
301 result.extend (
"cmsls",
"unsigned int")
302 result.extend (
"instlumi",
"float")
303 result.extend (
"norbits",
"unsigned int")
304 result.extend (
"trgcount",
"unsigned int")
305 result.extend (
"bitname",
"string")
306 result.extend (
"trgdeadtime",
"unsigned long long")
307 result.extend (
"trgprescale",
"unsigned int")
308 result.extend (
"trgbitnum",
"unsigned int")
310 query.defineOutput (result)
311 cursor = query.execute()
313 cmsls = cursor.currentRow()[
"cmsls"].
data()
314 instlumi = cursor.currentRow()[
"instlumi"].
data()*parameters.norm
315 norbits = cursor.currentRow()[
"norbits"].
data()
316 trgcount = cursor.currentRow()[
"trgcount"].
data()
317 trgbitname = cursor.currentRow()[
"bitname"].
data()
318 trgdeadtime = cursor.currentRow()[
"trgdeadtime"].
data()
319 trgprescale = cursor.currentRow()[
"trgprescale"].
data()
320 trgbitnum = cursor.currentRow()[
"trgbitnum"].
data()
322 if not trgprescalemap.has_key (trgbitname):
323 trgprescalemap[trgbitname] = trgprescale
325 if not deadtable.has_key (cmsls):
326 deadtable[cmsls] = []
327 deadtable[cmsls].append (trgdeadtime)
328 deadtable[cmsls].append (instlumi)
329 deadtable[cmsls].append (trgcount)
330 deadtable[cmsls].append (norbits)
331 deadtable[cmsls].append (trgprescale)
334 dbsession.transaction().commit()
342 for hpath, trgdataseq
in lumidata[1].items():
344 if trgprescalemap.has_key (bitn)
and len (trgdataseq) == 2:
345 lumidata[1][hpath].append (trgprescalemap[bitn])
347 lumidata[2] = filterDeadtable (deadtable, lslist)
349 if not parameters.noWarnings:
350 if len(lumidata[2])!=0:
351 for lumi, deaddata
in lumidata[2].items():
352 if deaddata[1] == 0.0
and deaddata[2]!=0
and deaddata[0]!=0:
353 print '[Warning] : run %s :ls %d has 0 instlumi but trigger has data' % (runnum, lumi)
354 if (deaddata[2] == 0
or deaddata[0] == 0)
and deaddata[1]!=0.0:
355 print '[Warning] : run %s :ls %d has 0 dead counts or 0 zerobias bit counts, but inst!=0' % (runnum, lumi)
359 dbsession.transaction().rollback()
372 if len (lslist) == 0:
374 for existingLS
in inTable.keys():
375 if existingLS
in lslist:
376 result[existingLS] = inTable[existingLS]
381 labels = [ (
'Run',
'Delivered LS',
'Delivered'+
u' (/\u03bcb)'.encode (
'utf-8'),
'Beam Mode')]
382 print tablePrinter.indent (labels+lumidata, hasHeader =
True, separateRows =
False,
383 prefix =
'| ', postfix =
' |', justify =
'right',
384 delim =
' | ', wrapfunc =
lambda x: wrap_onspace (x, 20) )
388 input params: lumidata [{'fieldname':value}]
393 r.writeRows(lumidata)
397 input: {lsnum:[deadtime, instlumi, bit_0, norbits,prescale]}
401 for myls, d
in deadtable.items():
405 if float (d[2]) == 0.0:
408 deadfrac = float (d[0])/(float (d[2])*float (d[-1]))
409 lstime = lslengthsec (d[3], 3564)
410 recordedLumi += instLumi* (1.0-deadfrac)*lstime
418 result.append ([inPut[0]])
422 result[counter].append (i)
427 return ', '.join ([
'['+str (min (x))+
'-'+str (max (x))+
']' for x
in result])
432 input: trgtable{hltpath:[l1seed, hltprescale, l1prescale]}, totalrecorded (float)
433 output:{hltpath, recorded}
437 for hltpath, data
in trgtable.items():
439 result[hltpath] = totalrecorded/ (data[1]*data[2])
441 result[hltpath] = 0.0
447 inputtable: {lsnum:[deadtime, instlumi, bit_0, norbits,bit_0_prescale]}
448 output: {lsnum:deadfraction}
451 for myls, d
in deadtable.items():
453 if float (d[2]) == 0.0:
456 deadfrac = float (d[0])/ (float (d[2])*float(d[-1]))
457 result[myls] = deadfrac
462 input lumidata [['runnumber', 'trgtable{}', 'deadtable{}']]
463 deadtable {lsnum:[deadtime, instlumi, bit_0, norbits,prescale]}
467 labels = [ (
'Run',
'LS',
'Delivered',
'Recorded'+
u' (/\u03bcb)'.encode (
'utf-8'))]
468 lastrowlabels = [ (
'Selected LS',
'Delivered'+
u' (/\u03bcb)'.encode (
'utf-8'),
'Recorded'+
u' (/\u03bcb)'.encode (
'utf-8'))]
474 for perrundata
in lumidata:
475 runnumber = perrundata[0]
476 deadtable = perrundata[2]
477 lumiresult = lsBylsLumi (deadtable)
478 totalSelectedLS = totalSelectedLS+len (deadtable)
479 for lsnum, dataperls
in lumiresult.items():
481 if len (dataperls) == 0:
482 rowdata += [str (runnumber), str (lsnum),
'N/A',
'N/A']
484 rowdata += [str (runnumber), str (lsnum),
'%.3f' % (dataperls[0]),
'%.3f' % (dataperls[1])]
485 totalDelivered = totalDelivered+dataperls[0]
486 totalRecorded = totalRecorded+dataperls[1]
487 datatoprint.append (rowdata)
488 totalrow.append ([str (totalSelectedLS),
'%.3f'% (totalDelivered),
'%.3f'% (totalRecorded)])
490 print tablePrinter.indent (labels+datatoprint, hasHeader =
True, separateRows =
False, prefix =
'| ',
491 postfix =
' |', justify =
'right', delim =
' | ',
492 wrapfunc =
lambda x: wrap_onspace_strict (x, 22))
493 print ' == = Total : '
494 print tablePrinter.indent (lastrowlabels+totalrow, hasHeader =
True, separateRows =
False, prefix =
'| ',
495 postfix =
' |', justify =
'right', delim =
' | ',
496 wrapfunc =
lambda x: wrap_onspace (x, 20))
501 for perrundata
in lumidata:
502 runnumber = perrundata[0]
503 deadtable = perrundata[2]
504 lumiresult = lsBylsLumi (deadtable)
505 for lsnum, dataperls
in lumiresult.items():
507 if len (dataperls) == 0:
508 rowdata += [str (runnumber), str (lsnum),
'N/A',
'N/A']
510 rowdata += [str (runnumber), str (lsnum), dataperls[0], dataperls[1]]
511 if len (dataperls) > 2:
512 rowdata.extend ( flatten (dataperls[2:]) )
513 datatodump.append (rowdata)
520 labels = [ (
'Run',
'HLT path',
'Recorded'+
u' (/\u03bcb)'.encode (
'utf-8'))]
521 lastrowlabels = [ (
'Selected LS',
'Recorded'+
u' (/\u03bcb)'.encode (
'utf-8'))]
522 if len (hltpath) != 0
and hltpath !=
'all':
523 lastrowlabels = [ (
'Selected LS',
'Recorded'+
u' (/\u03bcb)'.encode (
'utf-8'),
524 'Effective '+
u' (/\u03bcb) '.encode (
'utf-8')+hltpath)]
526 labels = [ (
'Run',
'HLT-path',
'L1-bit',
'L1-presc',
'HLT-presc',
'Recorded'+
u' (/\u03bcb)'.encode (
'utf-8'))]
529 totalRecordedInPath = 0.0
531 for dataperRun
in lumidata:
532 runnum = dataperRun[0]
533 if len (dataperRun[1]) == 0:
535 rowdata += [str (runnum)]+2*[
'N/A']
536 datatoprint.append (rowdata)
538 perlsdata = dataperRun[2]
539 totalSelectedLS = totalSelectedLS+len (perlsdata)
542 recordedLumi = calculateTotalRecorded (perlsdata)
543 totalRecorded = totalRecorded+recordedLumi
544 trgdict = dataperRun[1]
545 effective = calculateEffective (trgdict, recordedLumi)
546 if trgdict.has_key (hltpath)
and effective.has_key (hltpath):
548 l1bit = trgdict[hltpath][0]
549 if len (trgdict[hltpath]) != 3:
551 rowdata += [str (runnum), hltpath,
'N/A']
553 rowdata += [str (runnum), hltpath, l1bit,
'N/A',
'N/A',
'N/A']
556 rowdata += [str (runnum), hltpath,
'%.3f'% (effective[hltpath])]
558 hltprescale = trgdict[hltpath][1]
559 l1prescale = trgdict[hltpath][2]
560 rowdata += [str (runnum), hltpath, l1bit, str (l1prescale), str (hltprescale),
561 '%.3f'% (effective[hltpath])]
562 totalRecordedInPath = totalRecordedInPath+effective[hltpath]
563 datatoprint.append (rowdata)
566 for trg, trgdata
in trgdict.items():
569 if trg == trgdict.keys()[0]:
570 rowdata += [str (runnum)]
574 if len (trgdata) == 3:
576 rowdata += [trg,
'%.3f'% (effective[trg])]
578 hltprescale = trgdata[1]
579 l1prescale = trgdata[2]
580 rowdata += [trg, l1bit, str (l1prescale), str (hltprescale),
'%.3f'% (effective[trg])]
583 rowdata += [trg,
'N/A']
585 rowdata += [trg, l1bit,
'N/A',
'N/A',
'%.3f'% (effective[trg])]
586 datatoprint.append (rowdata)
589 print tablePrinter.indent (labels+datatoprint, hasHeader =
True, separateRows =
False, prefix =
'| ',
590 postfix =
' |', justify =
'right', delim =
' | ',
591 wrapfunc =
lambda x: wrap_onspace_strict (x, 22))
593 if len (hltpath) != 0
and hltpath !=
'all':
594 totalrow.append ([str (totalSelectedLS),
'%.3f'% (totalRecorded),
'%.3f'% (totalRecordedInPath)])
596 totalrow.append ([str (totalSelectedLS),
'%.3f'% (totalRecorded)])
597 print ' == = Total : '
598 print tablePrinter.indent (lastrowlabels+totalrow, hasHeader =
True, separateRows =
False, prefix =
'| ',
599 postfix =
' |', justify =
'right', delim =
' | ',
600 wrapfunc =
lambda x: wrap_onspace (x, 20))
603 deadtimelabels = [ (
'Run',
'Lumi section : Dead fraction')]
605 for dataperRun
in lumidata:
606 runnum = dataperRun[0]
607 if len (dataperRun[1]) == 0:
608 deadtoprint.append ([str (runnum),
'N/A'])
610 perlsdata = dataperRun[2]
612 deadT = getDeadfractions (perlsdata)
614 for myls, de
in deadT.items():
616 t += str (myls)+
':nobeam '
618 t += str (myls)+
':'+
'%.5f'% (de)+
' '
619 deadtoprint.append ([str (runnum), t])
621 print tablePrinter.indent (deadtimelabels+deadtoprint, hasHeader =
True, separateRows =
True, prefix =
'| ',
622 postfix =
' |', justify =
'right', delim =
' | ',
623 wrapfunc =
lambda x: wrap_onspace (x, 80))
629 for dataperRun
in lumidata:
630 runnum = dataperRun[0]
631 if len (dataperRun[1]) == 0:
633 rowdata += [str (runnum)]+2*[
'N/A']
634 datatodump.append (rowdata)
636 perlsdata = dataperRun[2]
639 recordedLumi = calculateTotalRecorded (perlsdata)
640 trgdict = dataperRun[1]
641 effective = calculateEffective (trgdict, recordedLumi)
642 if trgdict.has_key (hltpath)
and effective.has_key (hltpath):
644 l1bit = trgdict[hltpath][0]
645 if len (trgdict[hltpath]) != 3:
646 rowdata += [str (runnum), hltpath,
'N/A']
648 hltprescale = trgdict[hltpath][1]
649 l1prescale = trgdict[hltpath][2]
650 rowdata += [str (runnum), hltpath, effective[hltpath]]
651 datatodump.append (rowdata)
654 for trg, trgdata
in trgdict.items():
657 rowdata += [str (runnum)]
659 if len (trgdata) == 3:
660 rowdata += [trg, effective[trg]]
662 rowdata += [trg,
'N/A']
663 datatodump.append (rowdata)
668 if len (hltpath) == 0
or hltpath ==
'all':
669 toprowlabels = [ (
'Run',
'Delivered LS',
'Delivered'+
u' (/\u03bcb)'.encode (
'utf-8'),
'Selected LS',
'Recorded'+
u' (/\u03bcb)'.encode (
'utf-8') )]
670 lastrowlabels = [ (
'Delivered LS',
'Delivered'+
u' (/\u03bcb)'.encode (
'utf-8'),
'Selected LS',
'Recorded'+
u' (/\u03bcb)'.encode (
'utf-8') ) ]
672 toprowlabels = [ (
'Run',
'Delivered LS',
'Delivered'+
u' (/\u03bcb)'.encode (
'utf-8'),
'Selected LS',
'Recorded'+
u' (/\u03bcb)'.encode (
'utf-8'),
'Effective'+
u' (/\u03bcb) '.encode (
'utf-8')+hltpath )]
673 lastrowlabels = [ (
'Delivered LS',
'Delivered'+
u' (/\u03bcb)'.encode (
'utf-8'),
'Selected LS',
'Recorded'+
u' (/\u03bcb)'.encode (
'utf-8'),
'Effective '+
u' (/\u03bcb) '.encode (
'utf-8')+hltpath)]
680 totalRecordedInPath = 0.0
682 for runidx, deliveredrowdata
in enumerate (delivered):
684 rowdata += [deliveredrowdata[0], deliveredrowdata[1], deliveredrowdata[2]]
685 if deliveredrowdata[1] ==
'N/A':
686 if hltpath !=
'' and hltpath !=
'all':
687 rowdata += [
'N/A',
'N/A',
'N/A']
689 rowdata += [
'N/A',
'N/A']
690 datatable.append (rowdata)
692 totalDeliveredLS += int (deliveredrowdata[1])
693 totalDelivered += float (deliveredrowdata[2])
694 selectedls = recorded[runidx][2].
keys()
697 if len (selectedls) == 0:
700 if hltpath !=
'' and hltpath !=
'all':
701 rowdata += [selectedlsStr,
'N/A',
'N/A']
703 rowdata += [selectedlsStr,
'N/A']
705 selectedlsStr = splitlistToRangeString (selectedls)
706 recordedLumi = calculateTotalRecorded (recorded[runidx][2])
707 lumiinPaths = calculateEffective (recorded[runidx][1], recordedLumi)
708 if hltpath !=
'' and hltpath !=
'all':
709 if lumiinPaths.has_key (hltpath):
710 rowdata += [selectedlsStr,
'%.3f'% (recordedLumi),
'%.3f'% (lumiinPaths[hltpath])]
711 totalRecordedInPath += lumiinPaths[hltpath]
713 rowdata += [selectedlsStr,
'%.3f'% (recordedLumi),
'N/A']
716 rowdata += [selectedlsStr,
'%.3f'% (recordedLumi)]
717 totalSelectedLS += len (selectedls)
718 totalRecorded += recordedLumi
719 datatable.append (rowdata)
721 if hltpath !=
'' and hltpath !=
'all':
722 totaltable = [[str (totalDeliveredLS),
'%.3f'% (totalDelivered), str (totalSelectedLS),
723 '%.3f'% (totalRecorded),
'%.3f'% (totalRecordedInPath)]]
725 totaltable = [[str (totalDeliveredLS),
'%.3f'% (totalDelivered), str (totalSelectedLS),
726 '%.3f'% (totalRecorded)]]
727 print tablePrinter.indent (toprowlabels+datatable, hasHeader =
True, separateRows =
False, prefix =
'| ',
728 postfix =
' |', justify =
'right', delim =
' | ',
729 wrapfunc =
lambda x: wrap_onspace (x, 20))
730 print ' == = Total : '
731 print tablePrinter.indent (lastrowlabels+totaltable, hasHeader =
True, separateRows =
False, prefix =
'| ',
732 postfix =
' |', justify =
'right', delim =
' | ',
733 wrapfunc =
lambda x: wrap_onspace (x, 20))
739 for runidx, deliveredrowdata
in enumerate (delivered):
741 rowdata += [deliveredrowdata[0], deliveredrowdata[2]]
742 if deliveredrowdata[1] ==
'N/A':
743 rowdata += [
'N/A',
'N/A']
744 datatable.append (rowdata)
746 recordedLumi = calculateTotalRecorded (recorded[runidx][2])
747 lumiinPaths = calculateEffective (recorded[runidx][1], recordedLumi)
748 if hltpath !=
'' and hltpath !=
'all':
749 if lumiinPaths.has_key (hltpath):
750 rowdata += [recordedLumi, lumiinPaths[hltpath]]
752 rowdata += [recordedLumi,
'N/A']
754 rowdata += [recordedLumi, recordedLumi]
755 datatable.append (rowdata)
760 maxLumiSection =
None):
761 '''Given a run number and a minimum xing luminosity value,
762 returns a dictionary (keyed by (run, lumi section)) where the
763 value is a list of tuples of (xingID, xingLum).
765 - For all xing luminosities, simply set minLumValue to 0.
767 - If you want one dictionary for several runs, pass it in to
772 s.cmslsnum, d.bxlumivalue, d.bxlumierror, d.bxlumiquality, d.algoname from LUMIDETAIL d, LUMISUMMARY s where s.runnum = 133885 and d.algoname = 'OCC1' and s.lumisummary_id = d.lumisummary_id order by s.startorbit, s.cmslsnum
775 runnum = int (runnum)
776 dbsession.transaction().start (
True)
777 schema = dbsession.schema (parameters.lumischema)
779 raise 'cannot connect to schema ', parameters.lumischema
780 detailOutput = coral.AttributeList()
781 detailOutput.extend (
'startorbit',
'unsigned int')
782 detailOutput.extend (
'cmslsnum',
'unsigned int')
783 detailOutput.extend (
'bxlumivalue',
'blob')
784 detailOutput.extend (
'bxlumierror',
'blob')
785 detailOutput.extend (
'bxlumiquality',
'blob')
786 detailOutput.extend (
'algoname',
'string')
787 detailCondition = coral.AttributeList()
788 detailCondition.extend (
'runnum',
'unsigned int')
789 detailCondition.extend (
'algoname',
'string')
790 detailCondition[
'runnum'].setData (runnum)
791 detailCondition[
'algoname'].setData (
'OCC1')
792 query = schema.newQuery()
795 query.addToOutputList (
's.STARTORBIT',
'startorbit')
796 query.addToOutputList (
's.CMSLSNUM',
'cmslsnum')
797 query.addToOutputList (
'd.BXLUMIVALUE',
'bxlumivalue')
798 query.addToOutputList (
'd.BXLUMIERROR',
'bxlumierror')
799 query.addToOutputList (
'd.BXLUMIQUALITY',
'bxlumiquality')
800 query.addToOutputList (
'd.ALGONAME',
'algoname')
801 query.setCondition (
's.RUNNUM =:runnum and d.ALGONAME =:algoname and s.LUMISUMMARY_ID=d.LUMISUMMARY_ID',detailCondition)
802 query.addToOrderList (
's.CMSLSNUM')
803 query.defineOutput (detailOutput)
804 cursor = query.execute()
814 cmslsnum = cursor.currentRow()[
'cmslsnum'].
data()
815 algoname = cursor.currentRow()[
'algoname'].
data()
816 bxlumivalue = cursor.currentRow()[
'bxlumivalue'].
data()
817 startorbit = cursor.currentRow()[
'startorbit'].
data()
819 if maxLumiSection
and maxLumiSection < cmslsnum:
823 xingArray = array.array (
'f')
824 xingArray.fromstring( bxlumivalue.readline() )
827 for index, lum
in enumerate (xingArray):
828 lum *= parameters.normFactor
829 if lum < parameters.xingMinLum:
831 xingLum.append( (index, lum) )
832 lumiXingDict[ (runnum, cmslsnum) ] = xingLum
834 dbsession.transaction().commit()
839 dbsession.transaction().rollback()
844 '''Given nested lists or tuples, returns a single flattened list'''
847 if hasattr (piece,
'__iter__')
and not isinstance (piece, basestring):
848 result.extend( flatten (piece) )
850 result.append (piece)
855 '''Given general xing information and a xingLumiDict, the xing
856 luminosity information is merged with the general information'''
857 runNumber = triplet[0]
858 deadTable = triplet[2]
859 for lumi, lumiList
in deadTable.iteritems():
860 key = ( int(runNumber), int(lumi) )
861 xingLumiValues = xingLumiDict.get (key)
863 lumiList.append( flatten (xingLumiValues) )
866 def setupSession (connectString, siteconfpath, parameters, debug = False):
867 '''returns database session'''
869 connectparser.parse()
870 usedefaultfrontierconfig =
False
872 if connectparser.needsitelocalinfo():
874 cacheconfigpath = os.environ[
'CMS_PATH']
876 cacheconfigpath = os.path.join (cacheconfigpath,
'SITECONF',
'local',
'JobConfig',
'site-local-config.xml')
878 usedefaultfrontierconfig =
True
880 cacheconfigpath = siteconfpath
881 cacheconfigpath = os.path.join (cacheconfigpath,
'site-local-config.xml')
883 if usedefaultfrontierconfig:
884 ccp.parseString (parameters.defaultfrontierConfigString)
886 ccp.parse (cacheconfigpath)
887 connectString = connectparser.fullfrontierStr (connectparser.schemaname(), ccp.parameterdict())
888 svc = coral.ConnectionService()
890 msg = coral.MessageStream (
'')
891 msg.setMsgVerbosity (coral.message_Level_Debug)
892 parameters.verbose =
True
893 session = svc.connect (connectString, accessMode = coral.access_ReadOnly)
894 session.typeConverter().setCppTypeForSqlType (
"unsigned int",
"NUMBER (10)")
895 session.typeConverter().setCppTypeForSqlType (
"unsigned long long",
"NUMBER (20)")
902 def allruns(schemaHandle,requireRunsummary=True,requireLumisummary=False,requireTrg=False,requireHlt=False):
904 find all runs in the DB. By default requires cmsrunsummary table contain the run. The condition can be loosed in situation where db loading failed on certain data portions.
906 if not requireRunsummary
and not requireLumiummary
and not requireTrg
and not requireHlt:
907 print 'must require at least one table'
912 if requireRunsummary:
914 queryHandle=schemaHandle.newQuery()
916 queryHandle.addToOutputList(
"RUNNUM",
"run")
918 result=coral.AttributeList()
919 result.extend(
"run",
"unsigned int")
920 queryHandle.defineOutput(result)
921 cursor=queryHandle.execute()
923 r=cursor.currentRow()[
'run'].
data()
926 if requireLumisummary:
928 queryHandle=schemaHandle.newQuery()
930 queryHandle.addToOutputList(
"distinct RUNNUM",
"run")
932 result=coral.AttributeList()
933 result.extend(
"run",
"unsigned int")
934 queryHandle.defineOutput(result)
935 cursor=queryHandle.execute()
937 r=cursor.currentRow()[
'run'].
data()
942 queryHandle=schemaHandle.newQuery()
944 queryHandle.addToOutputList(
"distinct RUNNUM",
"run")
946 result=coral.AttributeList()
947 result.extend(
"run",
"unsigned int")
948 queryHandle.defineOutput(result)
949 cursor=queryHandle.execute()
951 r=cursor.currentRow()[
'run'].
data()
956 queryHandle=schemaHandle.newQuery()
958 queryHandle.addToOutputList(
"distinct RUNNUM",
"run")
960 result=coral.AttributeList()
961 result.extend(
"run",
"unsigned int")
962 queryHandle.defineOutput(result)
963 cursor=queryHandle.execute()
965 r=cursor.currentRow()[
'run'].
data()
969 for dup
in dupresult:
971 runresult.append(dup[0])
976 '''retrieve validation data per run or all
977 input: run. if not run, retrive all; if cmslsnum selection list pesent, filter out unselected result
978 output: {run:[[cmslsnum,status,comment]]}
982 queryHandle.addToOutputList(
'RUNNUM',
'runnum')
983 queryHandle.addToOutputList(
'CMSLSNUM',
'cmslsnum')
984 queryHandle.addToOutputList(
'FLAG',
'flag')
985 queryHandle.addToOutputList(
'COMMENT',
'comment')
987 queryCondition=
'RUNNUM=:runnum'
988 queryBind=coral.AttributeList()
989 queryBind.extend(
'runnum',
'unsigned int')
990 queryBind[
'runnum'].setData(run)
991 queryHandle.setCondition(queryCondition,queryBind)
992 queryResult=coral.AttributeList()
993 queryResult.extend(
'runnum',
'unsigned int')
994 queryResult.extend(
'cmslsnum',
'unsigned int')
995 queryResult.extend(
'flag',
'string')
996 queryResult.extend(
'comment',
'string')
997 queryHandle.defineOutput(queryResult)
998 cursor=queryHandle.execute()
1000 runnum=cursor.currentRow()[
'runnum'].
data()
1001 if not result.has_key(runnum):
1003 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
1004 flag=cursor.currentRow()[
'flag'].
data()
1005 comment=cursor.currentRow()[
'comment'].
data()
1006 result[runnum].
append([cmslsnum,flag,comment])
1007 if run
and cmsls
and len(cmsls)!=0:
1009 for runnum,perrundata
in result.items():
1010 for lsdata
in perrundata:
1011 if lsdata[0]
not in cmsls:
1013 if not selectedresult.has_key(runnum):
1014 selectedresult[runnum]=[]
1015 selectedresult[runnum].
append(lsdata)
1016 return selectedresult
1021 '''select distinct fillnum from cmsrunsummary
1022 there are crazy fill numbers. we assume they are not valid runs
1026 queryHandle.addToOutputList(
'distinct FILLNUM',
'fillnum')
1029 queryCondition=
'FILLNUM>:zero and FILLNUM<:crazybig'
1030 queryBind=coral.AttributeList()
1031 queryBind.extend(
'zero',
'unsigned int')
1032 queryBind.extend(
'crazybig',
'unsigned int')
1033 queryBind[
'zero'].setData(int(0))
1034 queryBind[
'crazybig'].setData(int(29701))
1035 queryHandle.setCondition(queryCondition,queryBind)
1036 queryResult=coral.AttributeList()
1037 queryResult.extend(
'fillnum',
'unsigned int')
1038 queryHandle.defineOutput(queryResult)
1039 cursor=queryHandle.execute()
1040 while cursor.next():
1041 result.append(cursor.currentRow()[
'fillnum'].
data())
1046 select fillnum,sequence,hltkey,to_char(starttime),to_char(stoptime) from cmsrunsummary where runnum=:runnum
1047 output: [fillnum,sequence,hltkey,starttime,stoptime]
1052 queryCondition=coral.AttributeList()
1053 queryCondition.extend(
'runnum',
'unsigned int')
1054 queryCondition[
'runnum'].setData(int(runnum))
1055 queryHandle.addToOutputList(
'FILLNUM',
'fillnum')
1056 queryHandle.addToOutputList(
'SEQUENCE',
'sequence')
1057 queryHandle.addToOutputList(
'HLTKEY',
'hltkey')
1058 queryHandle.addToOutputList(
'to_char(STARTTIME,\''+t.coraltimefm+
'\')',
'starttime')
1059 queryHandle.addToOutputList(
'to_char(STOPTIME,\''+t.coraltimefm+
'\')',
'stoptime')
1060 queryHandle.setCondition(
'RUNNUM=:runnum',queryCondition)
1061 queryResult=coral.AttributeList()
1062 queryResult.extend(
'fillnum',
'unsigned int')
1063 queryResult.extend(
'sequence',
'string')
1064 queryResult.extend(
'hltkey',
'string')
1065 queryResult.extend(
'starttime',
'string')
1066 queryResult.extend(
'stoptime',
'string')
1067 queryHandle.defineOutput(queryResult)
1068 cursor=queryHandle.execute()
1069 while cursor.next():
1070 result.append(cursor.currentRow()[
'fillnum'].
data())
1071 result.append(cursor.currentRow()[
'sequence'].
data())
1072 result.append(cursor.currentRow()[
'hltkey'].
data())
1073 result.append(cursor.currentRow()[
'starttime'].
data())
1074 result.append(cursor.currentRow()[
'stoptime'].
data())
1080 def lumisummaryByrun(queryHandle,runnum,lumiversion,beamstatus=None,beamenergy=None,beamenergyfluctuation=0.09):
1082 one can impose beamstatus, beamenergy selections at the SQL query level or process them later from the general result
1083 select cmslsnum,instlumi,numorbit,startorbit,beamstatus,beamenery from lumisummary where runnum=:runnum and lumiversion=:lumiversion order by startorbit;
1084 output: [[cmslsnum,instlumi,numorbit,startorbit,beamstatus,beamenergy,cmsalive]]
1085 Note: the non-cmsalive LS are included in the result
1089 queryCondition=coral.AttributeList()
1090 queryCondition.extend(
'runnum',
'unsigned int')
1091 queryCondition.extend(
'lumiversion',
'string')
1092 conditionstring=
'RUNNUM=:runnum and LUMIVERSION=:lumiversion'
1093 queryCondition[
'runnum'].setData(int(runnum))
1094 queryCondition[
'lumiversion'].setData(lumiversion)
1095 queryHandle.addToOutputList(
'CMSLSNUM',
'cmslsnum')
1096 queryHandle.addToOutputList(
'INSTLUMI',
'instlumi')
1097 queryHandle.addToOutputList(
'NUMORBIT',
'numorbit')
1098 queryHandle.addToOutputList(
'STARTORBIT',
'startorbit')
1099 queryHandle.addToOutputList(
'BEAMSTATUS',
'beamstatus')
1100 queryHandle.addToOutputList(
'BEAMENERGY',
'beamenergy')
1101 queryHandle.addToOutputList(
'CMSALIVE',
'cmsalive')
1102 if beamstatus
and len(beamstatus)!=0:
1103 conditionstring=conditionstring+
' and BEAMSTATUS=:beamstatus'
1104 queryCondition.extend(
'beamstatus',
'string')
1105 queryCondition[
'beamstatus'].setData(beamstatus)
1107 minBeamenergy=float(beamenergy*(1.0-beamenergyfluctuation))
1108 maxBeamenergy=float(beamenergy*(1.0+beamenergyfluctuation))
1109 conditionstring=conditionstring+
' and BEAMENERGY>:minBeamenergy and BEAMENERGY<:maxBeamenergy'
1110 queryCondition.extend(
'minBeamenergy',
'float')
1111 queryCondition.extend(
'maxBeamenergy',
'float')
1112 queryCondition[
'minBeamenergy'].setData(float(minBeamenergy))
1113 queryCondition[
'maxBeamenergy'].setData(float(maxBeamenergy))
1114 queryResult=coral.AttributeList()
1115 queryResult.extend(
'cmslsnum',
'unsigned int')
1116 queryResult.extend(
'instlumi',
'float')
1117 queryResult.extend(
'numorbit',
'unsigned int')
1118 queryResult.extend(
'startorbit',
'unsigned int')
1119 queryResult.extend(
'beamstatus',
'string')
1120 queryResult.extend(
'beamenergy',
'float')
1121 queryResult.extend(
'cmsalive',
'unsigned int')
1122 queryHandle.defineOutput(queryResult)
1123 queryHandle.setCondition(conditionstring,queryCondition)
1124 queryHandle.addToOrderList(
'startorbit')
1125 cursor=queryHandle.execute()
1126 while cursor.next():
1127 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
1128 instlumi=cursor.currentRow()[
'instlumi'].
data()
1129 numorbit=cursor.currentRow()[
'numorbit'].
data()
1130 startorbit=cursor.currentRow()[
'startorbit'].
data()
1131 beamstatus=cursor.currentRow()[
'beamstatus'].
data()
1132 beamenergy=cursor.currentRow()[
'beamenergy'].
data()
1133 cmsalive=cursor.currentRow()[
'cmsalive'].
data()
1134 result.append([cmslsnum,instlumi,numorbit,startorbit,beamstatus,beamenergy,cmsalive])
1137 def lumisumByrun(queryHandle,runnum,lumiversion,beamstatus=None,beamenergy=None,beamenergyfluctuation=0.09):
1139 beamenergy unit : GeV
1140 beamenergyfluctuation : fraction allowed to fluctuate around beamenergy value
1141 select sum(instlumi) from lumisummary where runnum=:runnum and lumiversion=:lumiversion
1142 output: float totallumi
1143 Note: the output is the raw result, need to apply LS length in time(sec)
1147 queryCondition=coral.AttributeList()
1148 queryCondition.extend(
'runnum',
'unsigned int')
1149 queryCondition.extend(
'lumiversion',
'string')
1151 queryCondition[
'runnum'].setData(int(runnum))
1152 queryCondition[
'lumiversion'].setData(lumiversion)
1153 queryHandle.addToOutputList(
'sum(INSTLUMI)',
'lumitotal')
1154 conditionstring=
'RUNNUM=:runnum and LUMIVERSION=:lumiversion'
1155 if beamstatus
and len(beamstatus)!=0:
1156 conditionstring=conditionstring+
' and BEAMSTATUS=:beamstatus'
1157 queryCondition.extend(
'beamstatus',
'string')
1158 queryCondition[
'beamstatus'].setData(beamstatus)
1159 if beamenergy
and beamenergy!=0.0:
1160 minBeamenergy=float(beamenergy*(1.0-beamenergyfluctuation))
1161 maxBeamenergy=float(beamenergy*(1.0+beamenergyfluctuation))
1162 conditionstring=conditionstring+
' and BEAMENERGY>:minBeamenergy and BEAMENERGY<:maxBeamenergy'
1163 queryCondition.extend(
'minBeamenergy',
'float')
1164 queryCondition.extend(
'maxBeamenergy',
'float')
1165 queryCondition[
'minBeamenergy'].setData(float(minBeamenergy))
1166 queryCondition[
'maxBeamenergy'].setData(float(maxBeamenergy))
1167 queryHandle.setCondition(conditionstring,queryCondition)
1168 queryResult=coral.AttributeList()
1169 queryResult.extend(
'lumitotal',
'float')
1170 queryHandle.defineOutput(queryResult)
1171 cursor=queryHandle.execute()
1172 while cursor.next():
1173 result=cursor.currentRow()[
'lumitotal'].
data()
1178 select cmslsnum,trgcount,deadtime,bitname,prescale from trg where runnum=:runnum and bitnum=0;
1179 output: {cmslsnum:[trgcount,deadtime,bitname,prescale]}
1183 queryCondition=coral.AttributeList()
1184 queryCondition.extend(
'runnum',
'unsigned int')
1185 queryCondition.extend(
'bitnum',
'unsigned int')
1186 queryCondition[
'runnum'].setData(int(runnum))
1187 queryCondition[
'bitnum'].setData(int(0))
1188 queryHandle.addToOutputList(
'CMSLSNUM',
'cmslsnum')
1189 queryHandle.addToOutputList(
'TRGCOUNT',
'trgcount')
1190 queryHandle.addToOutputList(
'DEADTIME',
'deadtime')
1191 queryHandle.addToOutputList(
'BITNAME',
'bitname')
1192 queryHandle.addToOutputList(
'PRESCALE',
'prescale')
1193 queryHandle.setCondition(
'RUNNUM=:runnum and BITNUM=:bitnum',queryCondition)
1194 queryResult=coral.AttributeList()
1195 queryResult.extend(
'cmslsnum',
'unsigned int')
1196 queryResult.extend(
'trgcount',
'unsigned int')
1197 queryResult.extend(
'deadtime',
'unsigned int')
1198 queryResult.extend(
'bitname',
'string')
1199 queryResult.extend(
'prescale',
'unsigned int')
1200 queryHandle.defineOutput(queryResult)
1201 cursor=queryHandle.execute()
1202 while cursor.next():
1203 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
1204 trgcount=cursor.currentRow()[
'trgcount'].
data()
1205 deadtime=cursor.currentRow()[
'deadtime'].
data()
1206 bitname=cursor.currentRow()[
'bitname'].
data()
1207 prescale=cursor.currentRow()[
'prescale'].
data()
1208 if not result.has_key(cmslsnum):
1209 result[cmslsnum]=[trgcount,deadtime,bitname,prescale]
1214 select l.cmslsnum,l.instlumi,l.numorbit,l.startorbit,l.beamstatus,l.beamenery,t.trgcount,t.deadtime,t.bitname,t.prescale from trg t,lumisummary l where t.bitnum=:bitnum and l.runnum=:runnum and l.lumiversion=:lumiversion and l.runnum=t.runnum and t.cmslsnum=l.cmslsnum;
1215 Everything you ever need to know about bitzero and avg luminosity. Since we do not know if joint query is better of sperate, support both.
1216 output: {cmslsnum:[instlumi,numorbit,startorbit,beamstatus,beamenergy,bitzerocount,deadtime,bitname,prescale]}
1217 Note: only cmsalive LS are included in the result. Therefore, this function cannot be used for calculating delivered!
1222 queryCondition=coral.AttributeList()
1223 queryCondition.extend(
'bitnum',
'unsigned int')
1224 queryCondition.extend(
'runnum',
'unsigned int')
1225 queryCondition.extend(
'lumiversion',
'string')
1226 queryCondition[
'bitnum'].setData(int(0))
1227 queryCondition[
'runnum'].setData(int(runnum))
1228 queryCondition[
'lumiversion'].setData(lumiversion)
1230 queryHandle.addToOutputList(
'l.CMSLSNUM',
'cmslsnum')
1231 queryHandle.addToOutputList(
'l.INSTLUMI',
'instlumi')
1232 queryHandle.addToOutputList(
'l.NUMORBIT',
'numorbit')
1233 queryHandle.addToOutputList(
'l.STARTORBIT',
'startorbit')
1234 queryHandle.addToOutputList(
'l.BEAMSTATUS',
'beamstatus')
1235 queryHandle.addToOutputList(
'l.BEAMENERGY',
'beamenergy')
1236 queryHandle.addToOutputList(
't.TRGCOUNT',
'trgcount')
1237 queryHandle.addToOutputList(
't.DEADTIME',
'deadtime')
1238 queryHandle.addToOutputList(
't.BITNAME',
'bitname')
1239 queryHandle.addToOutputList(
't.PRESCALE',
'prescale')
1240 conditionstring=
't.BITNUM=:bitnum and l.RUNNUM=:runnum and l.LUMIVERSION=:lumiversion and l.RUNNUM=t.RUNNUM and t.CMSLSNUM=l.CMSLSNUM'
1241 if beamstatus
and len(beamstatus)!=0:
1242 conditionstring=conditionstring+
' and l.BEAMSTATUS=:beamstatus'
1243 queryCondition.extend(
'beamstatus',
'string')
1244 queryCondition[
'beamstatus'].setData(beamstatus)
1245 if beamenergy
and beamenergy!=0.0:
1246 minBeamenergy=float(beamenergy*(1-beamenergyfluctuation))
1247 maxBeamenergy=float(beamenergy*(1+beamenergyfluctuation))
1248 conditionstring=conditionstring+
' and l.BEAMENERGY>:minBeamenergy and l.BEAMENERGY<:maxBeamenergy'
1249 queryCondition.extend(
'minBeamenergy',
'float')
1250 queryCondition.extend(
'maxBeamenergy',
'float')
1251 queryCondition[
'minBeamenergy'].setData(float(minBeamenergy))
1252 queryCondition[
'maxBeamenergy'].setData(float(maxBeamenergy))
1253 queryHandle.setCondition(conditionstring,queryCondition)
1254 queryResult=coral.AttributeList()
1255 queryResult.extend(
'cmslsnum',
'unsigned int')
1256 queryResult.extend(
'instlumi',
'float')
1257 queryResult.extend(
'numorbit',
'unsigned int')
1258 queryResult.extend(
'startorbit',
'unsigned int')
1259 queryResult.extend(
'beamstatus',
'string')
1260 queryResult.extend(
'beamenergy',
'float')
1261 queryResult.extend(
'trgcount',
'unsigned int')
1262 queryResult.extend(
'deadtime',
'unsigned int')
1263 queryResult.extend(
'bitname',
'string')
1264 queryResult.extend(
'prescale',
'unsigned int')
1265 queryHandle.defineOutput(queryResult)
1266 cursor=queryHandle.execute()
1267 while cursor.next():
1268 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
1269 instlumi=cursor.currentRow()[
'instlumi'].
data()
1270 numorbit=cursor.currentRow()[
'numorbit'].
data()
1271 startorbit=cursor.currentRow()[
'startorbit'].
data()
1272 beamstatus=cursor.currentRow()[
'beamstatus'].
data()
1273 beamenergy=cursor.currentRow()[
'beamenergy'].
data()
1274 trgcount=cursor.currentRow()[
'trgcount'].
data()
1275 deadtime=cursor.currentRow()[
'deadtime'].
data()
1276 bitname=cursor.currentRow()[
'bitname'].
data()
1277 prescale=cursor.currentRow()[
'prescale'].
data()
1278 if not result.has_key(cmslsnum):
1279 result[cmslsnum]=[instlumi,numorbit,startorbit,beamstatus,beamenergy,trgcount,deadtime,bitname,prescale]
1284 select cmslsnum,trgcount,deadtime,bitnum,prescale from trg where runnum=:runnum and bitname=:bitname;
1285 output: {cmslsnum:[trgcount,deadtime,bitnum,prescale]}
1289 queryCondition=coral.AttributeList()
1290 queryCondition.extend(
'runnum',
'unsigned int')
1291 queryCondition.extend(
'bitname',
'string')
1292 queryCondition[
'runnum'].setData(int(runnum))
1293 queryCondition[
'bitname'].setData(bitname)
1294 queryHandle.addToOutputList(
'CMSLSNUM',
'cmslsnum')
1295 queryHandle.addToOutputList(
'TRGCOUNT',
'trgcount')
1296 queryHandle.addToOutputList(
'DEADTIME',
'deadtime')
1297 queryHandle.addToOutputList(
'BITNUM',
'bitnum')
1298 queryHandle.addToOutputList(
'PRESCALE',
'prescale')
1299 queryHandle.setCondition(
'RUNNUM=:runnum and BITNAME=:bitname',queryCondition)
1300 queryResult=coral.AttributeList()
1301 queryResult.extend(
'cmslsnum',
'unsigned int')
1302 queryResult.extend(
'trgcount',
'unsigned int')
1303 queryResult.extend(
'deadtime',
'unsigned long long')
1304 queryResult.extend(
'bitnum',
'unsigned int')
1305 queryResult.extend(
'prescale',
'unsigned int')
1306 queryHandle.defineOutput(queryResult)
1307 cursor=queryHandle.execute()
1308 while cursor.next():
1309 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
1310 trgcount=cursor.currentRow()[
'trgcount'].
data()
1311 deadtime=cursor.currentRow()[
'deadtime'].
data()
1312 bitnum=cursor.currentRow()[
'bitnum'].
data()
1313 prescale=cursor.currentRow()[
'prescale'].
data()
1314 if not result.has_key(cmslsnum):
1315 result[cmslsnum]=[trgcount,deadtime,bitnum,prescale]
1320 all you ever want to know about trigger
1321 select cmslsnum,trgcount,deadtime,bitnum,bitname,prescale from trg where runnum=:runnum order by bitnum,cmslsnum
1322 this can be changed to blob query later
1323 output: {cmslsnum:{bitname:[bitnum,trgcount,deadtime,prescale]}}
1327 queryCondition=coral.AttributeList()
1328 queryCondition.extend(
'runnum',
'unsigned int')
1329 queryCondition[
'runnum'].setData(int(runnum))
1330 queryHandle.addToOutputList(
'cmslsnum')
1331 queryHandle.addToOutputList(
'trgcount')
1332 queryHandle.addToOutputList(
'deadtime')
1333 queryHandle.addToOutputList(
'bitnum')
1334 queryHandle.addToOutputList(
'bitname')
1335 queryHandle.addToOutputList(
'prescale')
1336 queryHandle.setCondition(
'runnum=:runnum',queryCondition)
1337 queryResult=coral.AttributeList()
1338 queryResult.extend(
'cmslsnum',
'unsigned int')
1339 queryResult.extend(
'trgcount',
'unsigned int')
1340 queryResult.extend(
'deadtime',
'unsigned long long')
1341 queryResult.extend(
'bitnum',
'unsigned int')
1342 queryResult.extend(
'bitname',
'string')
1343 queryResult.extend(
'prescale',
'unsigned int')
1344 queryHandle.defineOutput(queryResult)
1345 queryHandle.addToOrderList(
'bitnum')
1346 queryHandle.addToOrderList(
'cmslsnum')
1347 cursor=queryHandle.execute()
1348 while cursor.next():
1349 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
1350 trgcount=cursor.currentRow()[
'trgcount'].
data()
1351 deadtime=cursor.currentRow()[
'deadtime'].
data()
1352 bitnum=cursor.currentRow()[
'bitnum'].
data()
1353 bitname=cursor.currentRow()[
'bitname'].
data()
1354 prescale=cursor.currentRow()[
'prescale'].
data()
1355 if not result.has_key(cmslsnum):
1357 dataperLS[bitname]=[bitnum,trgcount,deadtime,prescale]
1358 result[cmslsnum]=dataperLS
1360 result[cmslsnum][bitname]=[bitnum,trgcount,deadtime,prescale]
1366 select cmslsnum,inputcount,acceptcount,prescale from hlt where runnum=:runnum and pathname=:pathname
1367 output: {cmslsnum:[inputcount,acceptcount,prescale]}
1371 queryCondition=coral.AttributeList()
1372 queryCondition.extend(
'runnum',
'unsigned int')
1373 queryCondition.extend(
'pathname',
'string')
1374 queryCondition[
'runnum'].setData(int(runnum))
1375 queryCondition[
'pathname'].setData(hltpath)
1376 queryHandle.addToOutputList(
'CMSLSNUM',
'cmslsnum')
1377 queryHandle.addToOutputList(
'INPUTCOUNT',
'inputcount')
1378 queryHandle.addToOutputList(
'ACCEPTCOUNT',
'acceptcount')
1379 queryHandle.addToOutputList(
'PRESCALE',
'prescale')
1380 queryHandle.setCondition(
'RUNNUM=:runnum and PATHNAME=:pathname',queryCondition)
1381 queryResult=coral.AttributeList()
1382 queryResult.extend(
'cmslsnum',
'unsigned int')
1383 queryResult.extend(
'inputcount',
'unsigned int')
1384 queryResult.extend(
'acceptcount',
'unsigned int')
1385 queryResult.extend(
'prescale',
'unsigned int')
1386 queryHandle.defineOutput(queryResult)
1387 cursor=queryHandle.execute()
1388 while cursor.next():
1389 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
1390 inputcount=cursor.currentRow()[
'inputcount'].
data()
1391 acceptcount=cursor.currentRow()[
'acceptcount'].
data()
1392 prescale=cursor.currentRow()[
'prescale'].
data()
1393 if not result.has_key(cmslsnum):
1394 result[cmslsnum]=[inputcount,acceptcount,prescale]
1399 select cmslsnum,inputcount,acceptcount,prescale,pathname from hlt where runnum=:runnum
1400 this can be changed to blob query later
1401 output: {cmslsnum:{pathname:[inputcount,acceptcount,prescale]}}
1405 queryCondition=coral.AttributeList()
1406 queryCondition.extend(
'runnum',
'unsigned int')
1407 queryCondition[
'runnum'].setData(int(runnum))
1408 queryHandle.addToOutputList(
'CMSLSNUM',
'cmslsnum')
1409 queryHandle.addToOutputList(
'INPUTCOUNT',
'inputcount')
1410 queryHandle.addToOutputList(
'ACCEPTCOUNT',
'acceptcount')
1411 queryHandle.addToOutputList(
'PRESCALE',
'prescale')
1412 queryHandle.addToOutputList(
'PATHNAME',
'pathname')
1413 queryHandle.setCondition(
'RUNNUM=:runnum',queryCondition)
1414 queryResult=coral.AttributeList()
1415 queryResult.extend(
'cmslsnum',
'unsigned int')
1416 queryResult.extend(
'inputcount',
'unsigned int')
1417 queryResult.extend(
'acceptcount',
'unsigned int')
1418 queryResult.extend(
'prescale',
'unsigned int')
1419 queryResult.extend(
'pathname',
'string')
1420 queryHandle.defineOutput(queryResult)
1421 cursor=queryHandle.execute()
1422 while cursor.next():
1423 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
1424 inputcount=cursor.currentRow()[
'inputcount'].
data()
1425 acceptcount=cursor.currentRow()[
'acceptcount'].
data()
1426 prescale=cursor.currentRow()[
'prescale'].
data()
1427 pathname=cursor.currentRow()[
'pathname'].
data()
1428 if not result.has_key(cmslsnum):
1430 dataperLS[pathname]=[inputcount,acceptcount,prescale]
1431 result[cmslsnum]=dataperLS
1433 result[cmslsnum][pathname]=[inputcount,acceptcount,prescale]
1439 select CMSBXINDEXBLOB,BEAMINTENSITYBLOB_1,BEAMINTENSITYBLOB_2 from LUMISUMMARY where runnum=146315 and LUMIVERSION='0001'
1441 output : result {startorbit: [(bxidx,beam1intensity,beam2intensity)]}
1445 lumisummaryOutput=coral.AttributeList()
1446 lumisummaryOutput.extend(
'cmslsnum',
'unsigned int')
1447 lumisummaryOutput.extend(
'startorbit',
'unsigned int')
1448 lumisummaryOutput.extend(
'bxindexblob',
'blob');
1449 lumisummaryOutput.extend(
'beamintensityblob1',
'blob');
1450 lumisummaryOutput.extend(
'beamintensityblob2',
'blob');
1451 condition=coral.AttributeList()
1452 condition.extend(
'runnum',
'unsigned int')
1453 condition.extend(
'lumiversion',
'string')
1454 condition[
'runnum'].setData(int(runnum))
1455 condition[
'lumiversion'].setData(parameters.lumiversion)
1457 query.addToTableList(parameters.lumisummaryname)
1458 query.addToOutputList(
'CMSLSNUM',
'cmslsnum')
1459 query.addToOutputList(
'STARTORBIT',
'startorbit')
1460 query.addToOutputList(
'CMSBXINDEXBLOB',
'bxindexblob')
1461 query.addToOutputList(
'BEAMINTENSITYBLOB_1',
'beamintensityblob1')
1462 query.addToOutputList(
'BEAMINTENSITYBLOB_2',
'beamintensityblob2')
1463 query.setCondition(
'RUNNUM=:runnum AND LUMIVERSION=:lumiversion',condition)
1464 query.defineOutput(lumisummaryOutput)
1465 cursor=query.execute()
1466 while cursor.next():
1468 startorbit=cursor.currentRow()[
'startorbit'].
data()
1469 if not cursor.currentRow()[
"bxindexblob"].isNull():
1470 bxindexblob=cursor.currentRow()[
'bxindexblob'].
data()
1471 beamintensityblob1=cursor.currentRow()[
'beamintensityblob1'].
data()
1472 beamintensityblob2=cursor.currentRow()[
'beamintensityblob2'].
data()
1473 if bxindexblob.readline()
is not None and beamintensityblob1.readline()
is not None and beamintensityblob2.readline()
is not None:
1474 bxidx=array.array(
'h')
1475 bxidx.fromstring(bxindexblob.readline())
1476 bb1=array.array(
'f')
1477 bb1.fromstring(beamintensityblob1.readline())
1478 bb2=array.array(
'f')
1479 bb2.fromstring(beamintensityblob2.readline())
1480 for index,bxidxvalue
in enumerate(bxidx):
1481 if not result.has_key(startorbit):
1482 result[startorbit]=[]
1483 b1intensity=bb1[index]
1484 b2intensity=bb2[index]
1485 result[startorbit].
append((bxidxvalue,b1intensity,b2intensity))
1490 s.cmslsnum,d.bxlumivalue,d.bxlumierror,d.bxlumiquality,d.algoname from LUMIDETAIL d,LUMISUMMARY s where s.runnum=133885 and d.algoname='OCC1' and s.lumisummary_id=d.lumisummary_id order by s.startorbit,s.cmslsnum
1491 result={(startorbit,cmslsnum):[(lumivalue,lumierr),]}
1494 detailOutput=coral.AttributeList()
1495 detailOutput.extend(
'cmslsnum',
'unsigned int')
1496 detailOutput.extend(
'startorbit',
'unsigned int')
1497 detailOutput.extend(
'bxlumivalue',
'blob')
1498 detailOutput.extend(
'bxlumierror',
'blob')
1499 detailCondition=coral.AttributeList()
1500 detailCondition.extend(
'runnum',
'unsigned int')
1501 detailCondition.extend(
'algoname',
'string')
1502 detailCondition[
'runnum'].setData(runnum)
1503 detailCondition[
'algoname'].setData(algoname)
1505 query.addToTableList(parameters.lumisummaryname,
's')
1506 query.addToTableList(parameters.lumidetailname,
'd')
1507 query.addToOutputList(
's.CMSLSNUM',
'cmslsnum')
1508 query.addToOutputList(
's.STARTORBIT',
'startorbit')
1509 query.addToOutputList(
'd.BXLUMIVALUE',
'bxlumivalue')
1510 query.addToOutputList(
'd.BXLUMIERROR',
'bxlumierror')
1511 query.addToOutputList(
'd.BXLUMIQUALITY',
'bxlumiquality')
1512 query.setCondition(
's.RUNNUM=:runnum and d.ALGONAME=:algoname and s.LUMISUMMARY_ID=d.LUMISUMMARY_ID',detailCondition)
1513 query.defineOutput(detailOutput)
1514 cursor=query.execute()
1515 while cursor.next():
1516 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
1517 bxlumivalue=cursor.currentRow()[
'bxlumivalue'].
data()
1518 bxlumierror=cursor.currentRow()[
'bxlumierror'].
data()
1519 startorbit=cursor.currentRow()[
'startorbit'].
data()
1521 bxlumivalueArray=array.array(
'f')
1522 bxlumivalueArray.fromstring(bxlumivalue.readline())
1523 bxlumierrorArray=array.array(
'f')
1524 bxlumierrorArray.fromstring(bxlumierror.readline())
1527 maxlumi=
max(bxlumivalueArray)*parameters.normFactor
1528 for index,lum
in enumerate(bxlumivalueArray):
1529 lum *= parameters.normFactor
1530 lumierror = bxlumierrorArray[index]*parameters.normFactor
1531 if lum<
max(parameters.xingMinLum,maxlumi*0.2):
1533 xingLum.append( (index,lum,lumierror) )
1535 result[(startorbit,cmslsnum)]=xingLum
1540 select s.cmslsnum,d.bxlumivalue,d.bxlumierror,d.bxlumiquality,s.startorbit from LUMIDETAIL d,LUMISUMMARY s where s.runnum=:runnum and d.algoname=:algoname and s.lumisummary_id=d.lumisummary_id order by s.startorbit
1541 output: [[cmslsnum,bxlumivalue,bxlumierror,bxlumiquality,startorbit]]
1542 since the output is ordered by time, it has to be in seq list format
1547 queryCondition=coral.AttributeList()
1548 queryCondition.extend(
'runnum',
'unsigned int')
1549 queryCondition.extend(
'algoname',
'string')
1550 queryCondition[
'runnum'].setData(int(runnum))
1551 queryCondition[
'algoname'].setData(algoname)
1552 queryHandle.addToOutputList(
's.CMSLSNUM',
'cmslsnum')
1553 queryHandle.addToOutputList(
'd.BXLUMIVALUE',
'bxlumivalue')
1554 queryHandle.addToOutputList(
'd.BXLUMIERROR',
'bxlumierror')
1555 queryHandle.addToOutputList(
'd.BXLUMIQUALITY',
'bxlumiquality')
1556 queryHandle.addToOutputList(
's.STARTORBIT',
'startorbit')
1557 queryHandle.setCondition(
's.runnum=:runnum and d.algoname=:algoname and s.lumisummary_id=d.lumisummary_id',queryCondition)
1558 queryResult=coral.AttributeList()
1559 queryResult.extend(
'cmslsnum',
'unsigned int')
1560 queryResult.extend(
'bxlumivalue',
'blob')
1561 queryResult.extend(
'bxlumierror',
'blob')
1562 queryResult.extend(
'bxlumiquality',
'blob')
1563 queryResult.extend(
'startorbit',
'unsigned int')
1564 queryHandle.addToOrderList(
's.STARTORBIT')
1565 queryHandle.defineOutput(queryResult)
1566 cursor=queryHandle.execute()
1567 while cursor.next():
1568 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
1569 bxlumivalue=cursor.currentRow()[
'bxlumivalue'].
data()
1570 bxlumierror=cursor.currentRow()[
'bxlumierror'].
data()
1571 bxlumiquality=cursor.currentRow()[
'bxlumiquality'].
data()
1572 startorbit=cursor.currentRow()[
'startorbit'].
data()
1573 result.append([cmslsnum,bxlumivalue,bxlumierror,bxlumiquality,startorbit])
1578 select s.cmslsnum,d.bxlumivalue,d.bxlumierror,d.bxlumiquality,d.algoname,s.startorbit from LUMIDETAIL d,LUMISUMMARY s where s.runnum=:runnumber and s.lumisummary_id=d.lumisummary_id order by s.startorbit,d.algoname
1579 output: {algoname:{cmslsnum:[bxlumivalue,bxlumierror,bxlumiquality,startorbit]}}
1584 queryCondition=coral.AttributeList()
1585 queryCondition.extend(
'runnum',
'unsigned int')
1586 queryCondition[
'runnum'].setData(int(runnum))
1587 queryHandle.addToOutputList(
's.CMSLSNUM',
'cmslsnum')
1588 queryHandle.addToOutputList(
'd.BXLUMIVALUE',
'bxlumivalue')
1589 queryHandle.addToOutputList(
'd.BXLUMIERROR',
'bxlumierror')
1590 queryHandle.addToOutputList(
'd.BXLUMIQUALITY',
'bxlumiquality')
1591 queryHandle.addToOutputList(
'd.ALGONAME',
'algoname')
1592 queryHandle.addToOutputList(
's.STARTORBIT',
'startorbit')
1593 queryHandle.setCondition(
's.RUNNUM=:runnum and s.LUMISUMMARY_ID=d.LUMISUMMARY_ID',queryCondition)
1594 queryResult=coral.AttributeList()
1595 queryResult.extend(
'cmslsnum',
'unsigned int')
1596 queryResult.extend(
'bxlumivalue',
'blob')
1597 queryResult.extend(
'bxlumierror',
'blob')
1598 queryResult.extend(
'bxlumiquality',
'blob')
1599 queryResult.extend(
'algoname',
'string')
1600 queryResult.extend(
'startorbit',
'unsigned int')
1601 queryHandle.addToOrderList(
'startorbit')
1602 queryHandle.addToOrderList(
'algoname')
1603 queryHandle.defineOutput(queryResult)
1604 cursor=queryHandle.execute()
1605 while cursor.next():
1606 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
1607 bxlumivalue=cursor.currentRow()[
'bxlumivalue'].
data()
1608 bxlumierror=cursor.currentRow()[
'bxlumierror'].
data()
1609 bxlumiquality=cursor.currentRow()[
'bxlumiquality'].
data()
1610 algoname=cursor.currentRow()[
'algoname'].
data()
1611 startorbit=cursor.currentRow()[
'startorbit'].
data()
1612 if not result.has_key(algoname):
1614 dataPerAlgo[cmslsnum]=[bxlumivalue,bxlumierror,bxlumiquality,startorbit]
1615 result[algoname]=dataPerAlgo
1617 result[algoname][cmslsnum]=[bxlumivalue,bxlumierror,bxlumiquality,startorbit]
1622 select m.hltpathname,m.l1seed from cmsrunsummary r,trghltmap m where r.runnum=:runnum and m.hltkey=r.hltkey
1623 output: {hltpath:l1seed}
1628 queryCondition=coral.AttributeList()
1629 queryCondition.extend(
'runnum',
'unsigned int')
1630 queryCondition[
'runnum'].setData(int(runnum))
1631 queryHandle.addToOutputList(
'm.HLTPATHNAME',
'hltpathname')
1632 queryHandle.addToOutputList(
'm.L1SEED',
'l1seed')
1633 queryHandle.setCondition(
'r.RUNNUM=:runnum and m.HLTKEY=r.HLTKEY',queryCondition)
1634 queryResult=coral.AttributeList()
1635 queryResult.extend(
'hltpathname',
'string')
1636 queryResult.extend(
'l1seed',
'string')
1637 queryHandle.defineOutput(queryResult)
1638 cursor=queryHandle.execute()
1639 while cursor.next():
1640 hltpathname=cursor.currentRow()[
'hltpathname'].
data()
1641 l1seed=cursor.currentRow()[
'l1seed'].
data()
1642 if not result.has_key(hltpathname):
1643 result[hltpathname]=l1seed
1648 find all runs in the fill range inclusive
1649 select runnum,fillnum from cmsrunsummary where fillnum>=:minFill and fillnum<=:maxFill
1650 output: fillDict={fillnum:[runlist]}
1654 queryCondition=coral.AttributeList()
1655 queryCondition.extend(
'minFill',
'unsigned int')
1656 queryCondition.extend(
'maxFill',
'unsigned int')
1657 queryCondition[
'minFill'].setData(int(minFill))
1658 queryCondition[
'maxFill'].setData(int(maxFill))
1659 queryHandle.addToOutputList(
'RUNNUM',
'runnum')
1660 queryHandle.addToOutputList(
'FILLNUM',
'fillnum')
1661 queryHandle.setCondition(
'FILLNUM>=:minFill and FILLNUM<=:maxFill',queryCondition)
1662 queryResult=coral.AttributeList()
1663 queryResult.extend(
'runnum',
'unsigned int')
1664 queryResult.extend(
'fillnum',
'unsigned int')
1665 queryHandle.defineOutput(queryResult)
1666 cursor=queryHandle.execute()
1667 while cursor.next():
1668 runnum=cursor.currentRow()[
'runnum'].
data()
1669 fillnum=cursor.currentRow()[
'fillnum'].
data()
1670 if not result.has_key(fillnum):
1671 result[fillnum]=[runnum]
1673 result[fillnum].
append(runnum)
1678 find all runs in the time range inclusive
1679 the selected run must have started after minTime and finished by maxTime
1680 select runnum,to_char(startTime),to_char(stopTime) from cmsrunsummary where startTime>=timestamp(minTime) and stopTime<=timestamp(maxTime);
1681 input: minTime,maxTime in python obj datetime.datetime
1682 output: {runnum:[starttime,stoptime]} return in python obj datetime.datetime
1686 coralminTime=coral.TimeStamp(minTime.year,minTime.month,minTime.day,minTime.hour,minTime.minute,minTime.second,0)
1687 coralmaxTime=coral.TimeStamp(maxTime.year,maxTime.month,maxTime.day,maxTime.hour,maxTime.minute,maxTime.second,0)
1689 queryCondition=coral.AttributeList()
1690 queryCondition.extend(
'minTime',
'time stamp')
1691 queryCondition.extend(
'maxTime',
'time stamp')
1692 queryCondition[
'minTime'].setData(coralminTime)
1693 queryCondition[
'maxTime'].setData(coralmaxTime)
1694 queryHandle.addToOutputList(
'RUNNUM',
'runnum')
1695 queryHandle.addToOutputList(
'TO_CHAR(STARTTIME,\''+t.coraltimefm+
'\')',
'starttime')
1696 queryHandle.addToOutputList(
'TO_CHAR(STOPTIME,\''+t.coraltimefm+
'\')',
'stoptime')
1697 queryHandle.setCondition(
'STARTTIME>=:minTime and STOPTIME<=:maxTime',queryCondition)
1698 queryResult=coral.AttributeList()
1699 queryResult.extend(
'runnum',
'unsigned int')
1700 queryResult.extend(
'starttime',
'string')
1701 queryResult.extend(
'stoptime',
'string')
1702 queryHandle.defineOutput(queryResult)
1703 cursor=queryHandle.execute()
1704 while cursor.next():
1705 runnum=cursor.currentRow()[
'runnum'].
data()
1706 starttimeStr=cursor.currentRow()[
'starttime'].
data()
1707 stoptimeStr=cursor.currentRow()[
'stoptime'].
data()
1708 if not result.has_key(runnum):
1709 result[runnum]=[t.StrToDatetime(starttimeStr),t.StrToDatetime(stoptimeStr)]
1712 if __name__==
'__main__':
1713 msg=coral.MessageStream(
'')
1715 msg.setMsgVerbosity(coral.message_Level_Error)
1716 os.environ[
'CORAL_AUTH_PATH']=
'/afs/cern.ch/cms/DB/lumi'
1717 svc = coral.ConnectionService()
1718 connectstr=
'oracle://cms_orcoff_prod/cms_lumi_prod'
1719 session=svc.connect(connectstr,accessMode=coral.access_ReadOnly)
1720 session.typeConverter().setCppTypeForSqlType(
"unsigned int",
"NUMBER(10)")
1721 session.typeConverter().setCppTypeForSqlType(
"unsigned long long",
"NUMBER(20)")
1722 session.transaction().
start(
True)
1723 schema=session.nominalSchema()
1724 allruns=
allruns(schema,requireLumisummary=
True,requireTrg=
True,requireHlt=
True)
1725 print 'allruns in runsummary and lumisummary and trg and hlt ',len(allruns)
1784 session.transaction().commit()
1819 print 'all fills ',allfills
def lumivalidationTableName
def calculateTimeParameters
def defaultfrontierConfigString
==============temporarilly here======###
def lumidetailByrunByAlgo
const T & max(const T &a, const T &b)
def lumidetailAllalgosByrun
def lumisummarytrgbitzeroByrun
def calibratedDetailForRunLimitresult
def deliveredLumiForRange
def calculateTotalRecorded
perl if(1 lt scalar(@::datatypes))
def splitlistToRangeString
def cmsrunsummaryTableName