1 from __future__
import print_function
2 from __future__
import absolute_import
3 from builtins
import range
4 import os,coral,fnmatch,time
5 from RecoLuminosity.LumiDB
import nameDealer,dbUtil,revisionDML,lumiTime,CommonUtil,lumiCorrections
6 from datetime
import datetime
21 select data_id from lumicorrectionss [where entry_name=:tagname] 22 result lumicorrectionsdataid 27 qHandle=schema.newQuery()
29 qHandle.addToTableList( nameDealer.lumicorrectionsTableName() )
30 qHandle.addToOutputList(
'DATA_ID')
32 qConditionStr=
'ENTRY_NAME=:tagname ' 33 qCondition=coral.AttributeList()
34 qCondition.extend(
'tagname',
'string')
35 qCondition[
'tagname'].setData(tagname)
36 qResult=coral.AttributeList()
37 qResult.extend(
'DATA_ID',
'unsigned long long')
38 qHandle.defineOutput(qResult)
40 qHandle.setCondition(qConditionStr,qCondition)
41 cursor=qHandle.execute()
43 dataid=cursor.currentRow()[
'DATA_ID'].
data()
44 lumicorrectionids.append(dataid)
49 if len(lumicorrectionids) !=0:
return max(lumicorrectionids)
54 select entry_name,a1,a2,drift from lumicorrections where DATA_ID=:dataid 55 output: {tagname:(data_id(0),a1(1),a2(2),driftcoeff(3))} 58 qHandle=schema.newQuery()
60 qHandle.addToTableList(nameDealer.lumicorrectionsTableName())
61 qHandle.addToOutputList(
'ENTRY_NAME')
62 qHandle.addToOutputList(
'A1')
63 qHandle.addToOutputList(
'A2')
64 qHandle.addToOutputList(
'DRIFT')
65 qCondition=coral.AttributeList()
66 qCondition.extend(
'dataid',
'unsigned long long')
67 qCondition[
'dataid'].setData(correctiondataid)
68 qResult=coral.AttributeList()
69 qResult.extend(
'ENTRY_NAME',
'string')
70 qResult.extend(
'A1',
'float')
71 qResult.extend(
'A2',
'float')
72 qResult.extend(
'DRIFT',
'float')
73 qHandle.defineOutput(qResult)
74 qHandle.setCondition(
'DATA_ID=:dataid',qCondition)
75 cursor=qHandle.execute()
77 tagname=cursor.currentRow()[
'ENTRY_NAME'].
data()
78 a1=cursor.currentRow()[
'A1'].
data()
80 if cursor.currentRow()[
'A2'].
data():
81 a2=cursor.currentRow()[
'A2'].
data()
83 if cursor.currentRow()[
'DRIFT'].
data():
84 drift=cursor.currentRow()[
'DRIFT'].
data()
85 result={tagname:(correctiondataid,a1,a2,drift)}
92 def fillInRange(schema,fillmin,fillmax,amodetag,startT,stopT):
94 select fillnum,runnum,starttime from cmsrunsummary where [where fillnum>=:fillmin and fillnum<=:fillmax and amodetag=:amodetag] 99 qHandle=schema.newQuery()
103 qHandle.addToTableList(r)
106 qCondition=coral.AttributeList()
108 qConditionPieces.append(
'FILLNUM>=:fillmin')
109 qCondition.extend(
'fillmin',
'unsigned int')
110 qCondition[
'fillmin'].setData(
int(fillmin))
112 qConditionPieces.append(
'FILLNUM<=:fillmax')
113 qCondition.extend(
'fillmax',
'unsigned int')
114 qCondition[
'fillmax'].setData(
int(fillmax))
116 qConditionPieces.append(
'AMODETAG=:amodetag')
117 qCondition.extend(
'amodetag',
'string')
118 qCondition[
'amodetag'].setData(amodetag)
119 if len(qConditionPieces)!=0:
120 qConditionStr=(
' AND ').
join(qConditionPieces)
121 qResult=coral.AttributeList()
122 qResult.extend(
'fillnum',
'unsigned int')
123 qResult.extend(
'runnum',
'unsigned int')
124 qResult.extend(
'starttime',
'string')
125 qHandle.defineOutput(qResult)
126 if len(qConditionStr)!=0:
127 qHandle.setCondition(qConditionStr,qCondition)
128 qHandle.addToOutputList(
'FILLNUM',
'fillnum')
129 qHandle.addToOutputList(
'RUNNUM',
'runnum')
130 qHandle.addToOutputList(
'TO_CHAR('+r+
'.STARTTIME,\'MM/DD/YY HH24:MI:SS\')',
'starttime')
131 cursor=qHandle.execute()
133 currentfill=cursor.currentRow()[
'fillnum'].
data()
134 runnum=cursor.currentRow()[
'runnum'].
data()
135 starttimeStr=cursor.currentRow()[
'starttime'].
data()
136 runTime=lute.StrToDatetime(starttimeStr,customfm=
'%m/%d/%y %H:%M:%S')
140 minTime=lute.StrToDatetime(startT,customfm=
'%m/%d/%y %H:%M:%S')
141 maxTime=lute.StrToDatetime(stopT,customfm=
'%m/%d/%y %H:%M:%S')
142 if runTime>=minTime
and runTime<=maxTime:
143 tmpresult.setdefault(currentfill,[]).
append(runnum)
144 elif startT
is not None:
145 minTime=lute.StrToDatetime(startT,customfm=
'%m/%d/%y %H:%M:%S')
147 tmpresult.setdefault(currentfill,[]).
append(runnum)
148 elif stopT
is not None:
149 maxTime=lute.StrToDatetime(stopT,customfm=
'%m/%d/%y %H:%M:%S')
151 tmpresult.setdefault(currentfill,[]).
append(runnum)
153 tmpresult.setdefault(currentfill,[]).
append(runnum)
155 for f
in sorted(tmpresult):
163 def fillrunMap(schema,fillnum=None,runmin=None,runmax=None,startT=None,stopT=None,l1keyPattern=None,hltkeyPattern=None,amodetag=None):
165 select fillnum,runnum,starttime from cmsrunsummary [where fillnum=:fillnum and runnum>=runmin and runnum<=runmax and amodetag=:amodetag ] 166 output: {fill:[runnum,...]} 170 qHandle=schema.newQuery()
174 qHandle.addToTableList(r)
177 qCondition=coral.AttributeList()
179 qConditionPieces.append(
'FILLNUM=:fillnum')
180 qCondition.extend(
'fillnum',
'unsigned int')
181 qCondition[
'fillnum'].setData(
int(fillnum))
183 qConditionPieces.append(
'RUNNUM>=:runmin')
184 qCondition.extend(
'runmin',
'unsigned int')
185 qCondition[
'runmin'].setData(runmin)
187 qConditionPieces.append(
'RUNNUM<=:runmax')
188 qCondition.extend(
'runmax',
'unsigned int')
189 qCondition[
'runmax'].setData(runmax)
191 qConditionPieces.append(
'AMODETAG=:amodetag')
192 qCondition.extend(
'amodetag',
'string')
193 qCondition[
'amodetag'].setData(amodetag)
195 qConditionPieces.append(
'regexp_like(L1KEY,:l1keypattern)')
196 qCondition.extend(
'l1keypattern',
'string')
197 qCondition[
'l1keypattern'].setData(l1keyPattern)
199 qConditionPieces.append(
'regexp_like(HLTKEY,:hltkeypattern)')
200 qCondition.extend(
'hltkeypattern',
'string')
201 qCondition[
'hltkeypattern'].setData(hltkeyPattern)
202 if len(qConditionPieces)!=0:
203 qConditionStr=(
' AND ').
join(qConditionPieces)
204 qResult=coral.AttributeList()
205 qResult.extend(
'fillnum',
'unsigned int')
206 qResult.extend(
'runnum',
'unsigned int')
207 qResult.extend(
'starttime',
'string')
208 qHandle.defineOutput(qResult)
209 if len(qConditionStr) !=0:
210 qHandle.setCondition(qConditionStr,qCondition)
211 qHandle.addToOutputList(
'FILLNUM',
'fillnum')
212 qHandle.addToOutputList(
'RUNNUM',
'runnum')
213 qHandle.addToOutputList(
'TO_CHAR('+r+
'.STARTTIME,\'MM/DD/YY HH24:MI:SS\')',
'starttime')
214 cursor=qHandle.execute()
216 currentfill=cursor.currentRow()[
'fillnum'].
data()
217 starttimeStr=cursor.currentRow()[
'starttime'].
data()
218 runnum=cursor.currentRow()[
'runnum'].
data()
219 runTime=lute.StrToDatetime(starttimeStr,customfm=
'%m/%d/%y %H:%M:%S')
223 minTime=lute.StrToDatetime(startT,customfm=
'%m/%d/%y %H:%M:%S')
224 maxTime=lute.StrToDatetime(stopT,customfm=
'%m/%d/%y %H:%M:%S')
225 if runTime>=minTime
and runTime<=maxTime:
226 result.setdefault(currentfill,[]).
append(runnum)
227 elif startT
is not None:
228 minTime=lute.StrToDatetime(startT,customfm=
'%m/%d/%y %H:%M:%S')
230 result.setdefault(currentfill,[]).
append(runnum)
231 elif stopT
is not None:
232 maxTime=lute.StrToDatetime(stopT,customfm=
'%m/%d/%y %H:%M:%S')
234 result.setdefault(currentfill,[]).
append(runnum)
236 result.setdefault(currentfill,[]).
append(runnum)
243 def runList(schema,datatagid,runmin=None,runmax=None,fillmin=None,fillmax=None,startT=None,stopT=None,l1keyPattern=None,hltkeyPattern=None,amodetag=None,nominalEnergy=None,energyFlut=0.2,requiretrg=True,requirehlt=True,preselectedruns=None,lumitype=None):
245 select r.runnum,l.starttime,l.stoptime,l.data_id,tag.trgdataid,tag.hltdataid from cmsrunsummary r,tagruns tag,lumidata l,trgdata t,hltdata h where l.runnum=tag.runnum and r.runnum=l.runnum (and l.runnum=t.runnum and t.runnum=h.runnum) and r.fillnum>=:fillmin and r.fillnum<=fillmax and r.runnum>:runmin and r.runnum<:runmax and r.amodetag=:amodetag (and regexp_like(r.l1key,:l1keypattern) and regexp_like(hltkey,:hltkeypattern) ) and l.nominalEnergy>=:nominalEnergy*(1-energyFlut) and l.nominalEnergy<=:nominalEnergy*(1+energyFlut) and tag.tagid<=:tagid and l.starttime is not null and l.stoptime is not null 246 output: {runnum:[lumiid,trgid,hltid]} 249 if lumitype
not in [
'HF',
'PIXEL']:
250 raise ValueError(
'unknown lumitype '+lumitype)
256 elif lumitype ==
'PIXEL':
260 assert False,
"ERROR Unknown lumitype '%s'" % lumitype
263 qHandle=schema.newQuery()
271 qHandle.addToTableList(r)
272 qHandle.addToTableList(l)
273 qHandle.addToTableList(tag)
274 qConditionStr=r+
'.RUNNUM='+l+
'.RUNNUM AND '+tag+
'.RUNNUM='+l+
'.RUNNUM AND '+tag+
'.TAGID<=:tagid' 275 qCondition=coral.AttributeList()
276 qCondition.extend(
'tagid',
'unsigned long long')
277 qCondition[
'tagid'].setData(datatagid)
284 if runmin
and runmax :
286 qConditionStr+=
' AND '+r+
'.RUNNUM=:runmin' 287 qCondition.extend(
'runmin',
'unsigned int')
288 qCondition[
'runmin'].setData(
int(runmin))
290 qConditionStr+=
' AND '+r+
'.RUNNUM>=:runmin AND '+r+
'.RUNNUM<=:runmax' 291 qCondition.extend(
'runmin',
'unsigned int')
292 qCondition.extend(
'runmax',
'unsigned int')
293 qCondition[
'runmin'].setData(
int(runmin))
294 qCondition[
'runmax'].setData(
int(runmax))
296 raise 'runmin > runmax' 298 qConditionStr+=
' AND '+r+
'.RUNNUM>=:runmin' 299 qCondition.extend(
'runmin',
'unsigned int')
300 qCondition[
'runmin'].setData(
int(runmin))
302 qConditionStr+=
' AND '+r+
'.RUNNUM<=:runmax' 303 qCondition.extend(
'runmax',
'unsigned int')
304 qCondition[
'runmax'].setData(
int(runmax))
307 if fillmin
and fillmax:
309 qConditionStr+=
' AND '+r+
'.FILLNUM=:fillnum' 310 qCondition.extend(
'fillnum',
'unsigned int')
311 qCondition[
'fillnum'].setData(
int(fillmin))
312 elif fillmax>fillmin:
313 qConditionStr+=
' AND '+r+
'.FILLNUM>=:fillmin AND '+r+
'.FILLNUM<=:fillmax' 314 qCondition.extend(
'fillmin',
'unsigned int')
315 qCondition.extend(
'fillmax',
'unsigned int')
316 qCondition[
'fillmin'].setData(
int(fillmin))
317 qCondition[
'fillmax'].setData(
int(fillmax))
319 raise 'fillmin > fillmax' 321 qConditionStr+=
' AND '+r+
'.AMODETAG=:amodetag' 322 qCondition.extend(
'amodetag',
'string')
323 qCondition[
'amodetag'].setData(amodetag)
325 qHandle.addToTableList(t)
326 qConditionStr+=
' AND regexp_like('+r+
'.L1KEY,:l1keypattern )'+
' AND '+l+
'.RUNNUM='+t+
'.RUNNUM' 327 qCondition.extend(
'l1keypattern',
'string')
328 qCondition[
'l1keypattern'].setData(l1keyPattern)
330 qHandle.addToTableList(h)
331 qConditionStr+=
' AND regexp_like('+r+
'.HLTKEY,:hltkeypattern)'+
' AND '+l+
'.RUNNUM='+h+
'.RUNNUM' 332 qCondition.extend(
'hltkeypattern',
'string')
333 qCondition[
'hltkeypattern'].setData(hltkeyPattern)
335 emin=nominalEnergy*(1.0-energyFlut)
336 emax=nominalEnergy*(1.0+energyFlut)
337 qConditionStr+=
' AND '+l+
'.NOMINALEGEV>=:emin and '+l+
'.NOMINALEGEV<=:emax' 338 qCondition.extend(
'emin',
'float')
339 qCondition.extend(
'emax',
'float')
340 qCondition[
'emin'].setData(emin)
341 qCondition[
'emax'].setData(emax)
342 qResult=coral.AttributeList()
343 qResult.extend(
'runnum',
'unsigned int')
344 qResult.extend(
'starttime',
'string')
345 qResult.extend(
'stoptime',
'string')
346 qResult.extend(
'lumiid',
'unsigned long long')
348 qResult.extend(
'trgid',
'unsigned long long')
350 qResult.extend(
'hltid',
'unsigned long long')
351 qHandle.setCondition(qConditionStr,qCondition)
352 qHandle.addToOutputList(r+
'.RUNNUM',
'runnum')
353 qHandle.addToOutputList(
'TO_CHAR('+l+
'.STARTTIME,\'MM/DD/YY HH24:MI:SS\')',
'starttime')
354 qHandle.addToOutputList(
'TO_CHAR('+l+
'.STOPTIME,\'MM/DD/YY HH24:MI:SS\')',
'stoptime')
355 qHandle.addToOutputList(l+
'.DATA_ID',
'lumiid')
361 qHandle.addToOutputList(tag+
'.TRGDATAID',
'trgid')
363 qHandle.addToOutputList(tag+
'.HLTDATAID',
'hltid')
364 qHandle.defineOutput(qResult)
365 cursor=qHandle.execute()
370 runnum=cursor.currentRow()[
'runnum'].
data()
371 if preselectedruns
and runnum
not in preselectedruns:
373 if cursor.currentRow()[
'starttime'].isNull():
375 if cursor.currentRow()[
'stoptime'].isNull():
377 starttimeStr=cursor.currentRow()[
'starttime'].
data()
378 stoptimeStr=cursor.currentRow()[
'stoptime'].
data()
379 runstartTime=lute.StrToDatetime(starttimeStr,customfm=
'%m/%d/%y %H:%M:%S')
380 runstopTime=lute.StrToDatetime(stoptimeStr,customfm=
'%m/%d/%y %H:%M:%S')
381 minTime=datetime(2010,1,1,0,0,0,0)
382 maxTime=datetime.now()
384 minTime=lute.StrToDatetime(startT,customfm=
'%m/%d/%y %H:%M:%S')
385 maxTime=lute.StrToDatetime(stopT,customfm=
'%m/%d/%y %H:%M:%S')
386 if not (runstopTime>=minTime
and runstartTime<=maxTime):
388 elif startT
is not None:
389 minTime=lute.StrToDatetime(startT,customfm=
'%m/%d/%y %H:%M:%S')
390 if not (runstopTime>=minTime):
392 elif stopT
is not None:
393 maxTime=lute.StrToDatetime(stopT,customfm=
'%m/%d/%y %H:%M:%S')
394 runTime=lute.StrToDatetime(starttimeStr,customfm=
'%m/%d/%y %H:%M:%S')
395 if not (runTime<=maxTime):
399 if not cursor.currentRow()[
'lumiid'].isNull():
400 lumiid=cursor.currentRow()[
'lumiid'].
data()
402 if lumiid>result[runnum][0]:
403 result[runnum][0]=lumiid
405 result[runnum]=[lumiid,0,0]
407 if cursor.currentRow()[
'trgid'].isNull():
410 trgid=cursor.currentRow()[
'trgid'].
data()
412 if trgid>result[runnum][1]:
413 result[runnum][1]=trgid
414 if requirehlt
and not cursor.currentRow()[
'hltid'].isNull():
415 hltid=cursor.currentRow()[
'hltid'].
data()
417 if hltid>result[runnum][2]:
418 result[runnum][2]=hltid
427 select l1key,amodetag,hltkey,fillnum,fillscheme from cmsrunsummary where runnum=:runnum 428 output: [l1key(0),amodetag(1),hltkey(3),fillnum(4),fillscheme(5)] 431 qHandle=schema.newQuery()
435 qCondition=coral.AttributeList()
436 qCondition.extend(
'runnum',
'unsigned int')
437 qCondition[
'runnum'].setData(
int(runnum))
438 qHandle.addToOutputList(
'L1KEY',
'l1key')
439 qHandle.addToOutputList(
'AMODETAG',
'amodetag')
441 qHandle.addToOutputList(
'HLTKEY',
'hltkey')
442 qHandle.addToOutputList(
'FILLNUM',
'fillnum')
443 qHandle.addToOutputList(
'FILLSCHEME',
'fillscheme')
450 qHandle.setCondition(
'RUNNUM=:runnum',qCondition)
451 qResult=coral.AttributeList()
452 qResult.extend(
'l1key',
'string')
453 qResult.extend(
'amodetag',
'string')
455 qResult.extend(
'hltkey',
'string')
456 qResult.extend(
'fillnum',
'unsigned int')
457 qResult.extend(
'fillscheme',
'string')
460 qHandle.defineOutput(qResult)
461 cursor=qHandle.execute()
463 result.append(cursor.currentRow()[
'l1key'].
data())
464 result.append(cursor.currentRow()[
'amodetag'].
data())
466 result.append(cursor.currentRow()[
'hltkey'].
data())
467 result.append(cursor.currentRow()[
'fillnum'].
data())
469 if not cursor.currentRow()[
'fillscheme'].isNull():
470 fillscheme=cursor.currentRow()[
'fillscheme'].
data()
471 result.append(fillscheme)
560 select entry_name,amodetag,norm_1,egev_1,norm_2,egev_2 from luminorms where DATA_ID=:dataid 561 output: {norm_name:(amodetag(0),norm_1(1),egev_1(2),norm_occ2(3),norm_et(4),norm_pu(5),constfactor(6))} 564 qHandle=schema.newQuery()
567 qHandle.addToOutputList(
'ENTRY_NAME',
'normname')
568 qHandle.addToOutputList(
'AMODETAG',
'amodetag')
569 qHandle.addToOutputList(
'NORM_1',
'norm_1')
570 qHandle.addToOutputList(
'EGEV_1',
'energy_1')
571 qHandle.addToOutputList(
'NORM_OCC2',
'norm_occ2')
572 qHandle.addToOutputList(
'NORM_ET',
'norm_et')
573 qHandle.addToOutputList(
'NORM_PU',
'norm_pu')
574 qHandle.addToOutputList(
'CONSTFACTOR',
'constfactor')
575 qCondition=coral.AttributeList()
576 qCondition.extend(
'dataid',
'unsigned long long')
577 qCondition[
'dataid'].setData(dataid)
578 qResult=coral.AttributeList()
579 qResult.extend(
'normname',
'string')
580 qResult.extend(
'amodetag',
'string')
581 qResult.extend(
'norm_1',
'float')
582 qResult.extend(
'energy_1',
'unsigned int')
583 qResult.extend(
'norm_occ2',
'float')
584 qResult.extend(
'norm_et',
'float')
585 qResult.extend(
'norm_pu',
'float')
586 qResult.extend(
'constfactor',
'float')
587 qHandle.defineOutput(qResult)
588 qHandle.setCondition(
'DATA_ID=:dataid',qCondition)
589 cursor=qHandle.execute()
591 normname=cursor.currentRow()[
'normname'].
data()
592 amodetag=cursor.currentRow()[
'amodetag'].
data()
593 norm_1=cursor.currentRow()[
'norm_1'].
data()
594 energy_1=cursor.currentRow()[
'energy_1'].
data()
596 if cursor.currentRow()[
'norm_occ2'].
data():
597 norm_occ2=cursor.currentRow()[
'norm_occ2'].
data()
599 if cursor.currentRow()[
'norm_et'].
data():
600 norm_et=cursor.currentRow()[
'norm_et'].
data()
602 if cursor.currentRow()[
'norm_pu'].
data():
603 norm_pu=cursor.currentRow()[
'norm_pu'].
data()
605 if cursor.currentRow()[
'constfactor'].
data():
606 constfactor=cursor.currentRow()[
'constfactor'].
data()
607 result={normname:(amodetag,norm_1,energy_1,norm_occ2,norm_et,norm_pu,constfactor)}
678 select entry_name,amodetag,norm_1,egev_1,norm_2,egev_2 from luminorms where DATA_ID=:dataid 679 result (normname(0),amodetag(1),egev(2),norm(3),norm_occ2(4),norm_et(5),norm_pu(6),constfactor(7)) 682 qHandle=schema.newQuery()
685 qHandle.addToOutputList(
'ENTRY_NAME',
'normname')
686 qHandle.addToOutputList(
'AMODETAG',
'amodetag')
687 qHandle.addToOutputList(
'NORM_1',
'norm_1')
688 qHandle.addToOutputList(
'EGEV_1',
'energy_1')
689 qHandle.addToOutputList(
'NORM_OCC2',
'norm_occ2')
690 qHandle.addToOutputList(
'NORM_ET',
'norm_et')
691 qHandle.addToOutputList(
'NORM_PU',
'norm_pu')
692 qHandle.addToOutputList(
'CONSTFACTOR',
'constfactor')
693 qCondition=coral.AttributeList()
694 qCondition.extend(
'dataid',
'unsigned long long')
695 qCondition[
'dataid'].setData(dataid)
696 qResult=coral.AttributeList()
697 qResult.extend(
'normname',
'string')
698 qResult.extend(
'amodetag',
'string')
699 qResult.extend(
'norm_1',
'float')
700 qResult.extend(
'energy_1',
'unsigned int')
701 qResult.extend(
'norm_occ2',
'float')
702 qResult.extend(
'norm_et',
'float')
703 qResult.extend(
'norm_pu',
'float')
704 qResult.extend(
'constfactor',
'float')
705 qHandle.defineOutput(qResult)
706 qHandle.setCondition(
'DATA_ID=:dataid',qCondition)
707 cursor=qHandle.execute()
709 normname=cursor.currentRow()[
'normname'].
data()
710 amodetag=cursor.currentRow()[
'amodetag'].
data()
711 norm_1=cursor.currentRow()[
'norm_1'].
data()
712 energy_1=cursor.currentRow()[
'energy_1'].
data()
714 if cursor.currentRow()[
'norm_occ2'].
data():
715 norm_occ2=cursor.currentRow()[
'norm_occ2'].
data()
717 if cursor.currentRow()[
'norm_et'].
data():
718 norm_et=cursor.currentRow()[
'norm_et'].
data()
720 if cursor.currentRow()[
'norm_pu'].
data():
721 norm_pu=cursor.currentRow()[
'norm_pu'].
data()
723 if cursor.currentRow()[
'constfactor'].
data():
724 constfactor=cursor.currentRow()[
'constfactor'].
data()
725 result={normname:(amodetag,norm_1,energy_1,norm_occ2,norm_et,norm_pu,constfactor)}
732 def trgRunById(schema,dataid,trgbitname=None,trgbitnamepattern=None):
734 query: select RUNNUM,SOURCE,BITZERONAME,BITNAMECLOB,ALGOMASK_H,ALGOMASK_L,TECHMASK from trgdata where DATA_ID=:dataid 736 output: [runnum(0),datasource(1),bitzeroname(2),bitnamedict(3),algomask_h(4),algomask_l(5),techmask(6)] 738 -- original source database name 739 -- deadtime norm bitname 740 -- bitnamedict [(bitidx,bitname),...] 743 qHandle=schema.newQuery()
750 qHandle.addToOutputList(
'RUNNUM',
'runnum')
751 qHandle.addToOutputList(
'SOURCE',
'source')
752 qHandle.addToOutputList(
'BITZERONAME',
'bitzeroname')
753 qHandle.addToOutputList(
'BITNAMECLOB',
'bitnameclob')
754 qHandle.addToOutputList(
'ALGOMASK_H',
'algomask_h')
755 qHandle.addToOutputList(
'ALGOMASK_L',
'algomask_l')
756 qHandle.addToOutputList(
'TECHMASK',
'techmask')
757 qCondition=coral.AttributeList()
758 qCondition.extend(
'dataid',
'unsigned long long')
759 qCondition[
'dataid'].setData(dataid)
760 qResult=coral.AttributeList()
761 qResult.extend(
'runnum',
'unsigned int')
762 qResult.extend(
'source',
'string')
763 qResult.extend(
'bitzeroname',
'string')
764 qResult.extend(
'bitnameclob',
'string')
765 qResult.extend(
'algomask_h',
'unsigned long long')
766 qResult.extend(
'algomask_l',
'unsigned long long')
767 qResult.extend(
'techmask',
'unsigned long long')
768 qHandle.defineOutput(qResult)
769 qHandle.setCondition(
'DATA_ID=:dataid',qCondition)
770 cursor=qHandle.execute()
774 runnum=cursor.currentRow()[
'runnum'].
data()
775 source=cursor.currentRow()[
'source'].
data()
776 bitzeroname=cursor.currentRow()[
'bitzeroname'].
data()
777 bitnameclob=cursor.currentRow()[
'bitnameclob'].
data()
778 algomask_h=cursor.currentRow()[
'algomask_h'].
data()
779 algomask_l=cursor.currentRow()[
'algomask_l'].
data()
780 techmask=cursor.currentRow()[
'techmask'].
data()
782 bitnames=bitnameclob.split(
',')
783 for trgnameidx,trgname
in enumerate(bitnames):
785 if trgname==trgbitname:
786 bitnamedict.append((trgnameidx,trgname))
788 elif trgbitnamepattern:
789 if fnmatch.fnmatch(trgname,trgbitnamepattern):
790 bitnamedict.append((trgnameidx,trgname))
792 bitnamedict.append((trgnameidx,trgname))
793 result=[runnum,source,bitzeroname,bitnamedict,algomask_h,algomask_l,techmask]
800 def trgLSById(schema,dataid,trgbitname=None,trgbitnamepattern=None,withL1Count=False,withPrescale=False):
802 output: (runnum,{cmslsnum:[deadtimecount(0),bitzerocount(1),bitzeroprescale(2),deadfrac(3),[(bitname,trgcount,prescale,mask)](4)]}) 807 if trgbitname
or trgbitnamepattern
or withPrescale
or withL1Count:
808 trgrundata=
trgRunById(schema,dataid,trgbitname=trgbitname,trgbitnamepattern=trgbitnamepattern)
809 trgnamedict=trgrundata[3]
810 algomask_h=trgrundata[4]
811 algomask_l=trgrundata[5]
812 techmask=trgrundata[6]
813 qHandle=schema.newQuery()
816 qHandle.addToOutputList(
'RUNNUM',
'runnum')
817 qHandle.addToOutputList(
'CMSLSNUM',
'cmslsnum')
818 qHandle.addToOutputList(
'DEADTIMECOUNT',
'deadtimecount')
821 qHandle.addToOutputList(
'DEADFRAC',
'deadfrac')
823 qHandle.addToOutputList(
'PRESCALEBLOB',
'prescalesblob')
825 qHandle.addToOutputList(
'TRGCOUNTBLOB',
'trgcountblob')
826 qConditionStr=
'DATA_ID=:dataid' 827 qCondition=coral.AttributeList()
828 qCondition.extend(
'dataid',
'unsigned long long')
829 qCondition[
'dataid'].setData(dataid)
830 qResult=coral.AttributeList()
831 qResult.extend(
'runnum',
'unsigned int')
832 qResult.extend(
'cmslsnum',
'unsigned int')
833 qResult.extend(
'deadtimecount',
'unsigned long long')
836 qResult.extend(
'deadfrac',
'float')
838 qResult.extend(
'prescalesblob',
'blob')
840 qResult.extend(
'trgcountblob',
'blob')
841 qHandle.defineOutput(qResult)
842 qHandle.setCondition(qConditionStr,qCondition)
843 cursor=qHandle.execute()
845 runnum=cursor.currentRow()[
'runnum'].
data()
846 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
847 deadtimecount=cursor.currentRow()[
'deadtimecount'].
data()
852 deadfrac=cursor.currentRow()[
'deadfrac'].
data()
853 if cmslsnum
not in result:
855 result[cmslsnum].
append(deadtimecount)
856 result[cmslsnum].
append(bitzerocount)
857 result[cmslsnum].
append(bitzeroprescale)
858 result[cmslsnum].
append(deadfrac)
862 prescalesblob=cursor.currentRow()[
'prescalesblob'].
data()
864 trgcountblob=cursor.currentRow()[
'trgcountblob'].
data()
879 for (bitidx,thisbitname)
in trgnamedict:
883 thispresc=prescales[bitidx]
885 thistrgcount=trgcounts[bitidx]
888 if bitidx
in range(0,128):
890 maskval=algomask_l>>bitidx&1
892 maskval=algomask_h>>(bitidx-64)&1
895 maskval=techmask>>(bitidx-128)&1
896 thisbitinfo=(thisbitname,thistrgcount,thispresc,maskval)
897 bitinfo.append(thisbitinfo)
898 result[cmslsnum].
append(bitinfo)
905 return (runnum,result)
909 input dataidMap : {run:lumidataid} 910 result {runnum: (datasource(0),nominalegev(1),ncollidingbunches(2),starttime(3),stoptime(4),nls(5)} 915 inputRange=dataidMap.keys()
917 lumidataid=dataidMap[r][0]
919 perrundata=
lumiRunById(schema,lumidataid,lumitype=lumitype)
920 result[r]=(perrundata[1],perrundata[2],perrundata[3],perrundata[4],perrundata[5])
925 input dataidMap : {run:lumidataid} 926 result {runnum:{cmslsnum:beamstatus}} 931 inputRange=dataidMap.keys()
935 lumidataid=dataidMap[r][0]
937 qHandle=schema.newQuery()
940 qHandle.addToOutputList(
'CMSLSNUM')
941 qHandle.addToOutputList(
'BEAMSTATUS')
942 qConditionStr=
'DATA_ID=:dataid' 943 qCondition=coral.AttributeList()
944 qCondition.extend(
'dataid',
'unsigned long long')
945 qCondition[
'dataid'].setData(
int(lumidataid))
946 qResult=coral.AttributeList()
947 qResult.extend(
'CMSLSNUM',
'unsigned int')
948 qResult.extend(
'BEAMSTATUS',
'string')
949 qHandle.defineOutput(qResult)
950 qHandle.setCondition(qConditionStr,qCondition)
951 cursor=qHandle.execute()
953 cmslsnum=cursor.currentRow()[
'CMSLSNUM'].
data()
954 bs=cursor.currentRow()[
'BEAMSTATUS'].
data()
955 if bs!=
'STABLE BEAMS':
956 result[r][cmslsnum]=bs
966 output: (runnum(0),datasource(1),nominalegev(2),ncollidingbunches(3),starttimestr(4),stoptimestr(5),nls(6)) 969 if lumitype
not in [
'HF',
'PIXEL']:
970 raise ValueError(
'unknown lumitype '+lumitype)
976 qHandle=schema.newQuery()
978 qHandle.addToTableList(lumitableName)
979 qHandle.addToOutputList(
'RUNNUM')
980 qHandle.addToOutputList(
'SOURCE')
981 qHandle.addToOutputList(
'NOMINALEGEV')
982 qHandle.addToOutputList(
'NCOLLIDINGBUNCHES')
983 qHandle.addToOutputList(
'TO_CHAR('+lumitableName+
'.STARTTIME,\'MM/DD/YY HH24:MI:SS\')',
'startT')
984 qHandle.addToOutputList(
'TO_CHAR('+lumitableName+
'.STOPTIME,\'MM/DD/YY HH24:MI:SS\')',
'stopT')
985 qHandle.addToOutputList(
'NLS')
986 qConditionStr=
'DATA_ID=:dataid' 987 qCondition=coral.AttributeList()
988 qCondition.extend(
'dataid',
'unsigned long long')
989 qCondition[
'dataid'].setData(lumidataid)
990 qResult=coral.AttributeList()
991 qResult.extend(
'RUNNUM',
'unsigned int')
992 qResult.extend(
'SOURCE',
'string')
993 qResult.extend(
'NOMINALEGEV',
'float')
994 qResult.extend(
'NCOLLIDINGBUNCHES',
'unsigned int')
995 qResult.extend(
'startT',
'string')
996 qResult.extend(
'stopT',
'string')
997 qResult.extend(
'NLS',
'unsigned int')
998 qHandle.defineOutput(qResult)
999 qHandle.setCondition(qConditionStr,qCondition)
1000 cursor=qHandle.execute()
1004 runnum=cursor.currentRow()[
'RUNNUM'].
data()
1005 datasource=cursor.currentRow()[
'SOURCE'].
data()
1007 if not cursor.currentRow()[
'NOMINALEGEV'].isNull():
1008 nominalegev=cursor.currentRow()[
'NOMINALEGEV'].
data()
1010 if not cursor.currentRow()[
'NCOLLIDINGBUNCHES'].isNull():
1011 ncollidingbunches=cursor.currentRow()[
'NCOLLIDINGBUNCHES'].
data()
1012 startTstr=cursor.currentRow()[
'startT'].
data()
1013 stopTstr=cursor.currentRow()[
'stopT'].
data()
1016 if not cursor.currentRow()[
'NLS'].isNull():
1017 nls=cursor.currentRow()[
'NLS'].
data()
1018 result=(runnum,datasource,nominalegev,ncollidingbunches,startTstr,stopTstr,nls)
1070 qHandle.addToTableList(s)
1071 qResult=coral.AttributeList()
1072 qResult.extend(
'FILLSCHEMEPATTERN',
'string')
1073 qResult.extend(
'CORRECTIONFACTOR',
'float')
1074 qHandle.defineOutput(qResult)
1075 qHandle.addToOutputList(
'FILLSCHEMEPATTERN')
1076 qHandle.addToOutputList(
'CORRECTIONFACTOR')
1077 cursor=qHandle.execute()
1079 fillschemePattern=cursor.currentRow()[
'FILLSCHEMEPATTERN'].
data()
1080 afterglowfac=cursor.currentRow()[
'CORRECTIONFACTOR'].
data()
1081 afterglows.append((fillschemePattern,afterglowfac))
1088 def lumiLSById(schema,dataid,beamstatus=None,withBXInfo=False,bxAlgo='OCC1',withBeamIntensity=False,tableName=None):
1091 beamstatus: filter on beam status flag 1093 result (runnum,{lumilsnum,[cmslsnum(0),instlumi(1),instlumierr(2),instlumiqlty(3),beamstatus(4),beamenergy(5),numorbit(6),startorbit(7),(bxvalueArray,bxerrArray)(8),(bxindexArray,beam1intensityArray,beam2intensityArray)(9)]}) 1097 qHandle=schema.newQuery()
1098 if withBXInfo
and bxAlgo
not in [
'OCC1',
'OCC2',
'ET']:
1099 raise ValueError(
'unknown lumi algo '+bxAlgo)
1100 if beamstatus
and beamstatus
not in [
'STABLE BEAMS',]:
1101 raise ValueError(
'unknown beam status '+beamstatus)
1103 if tableName
is None:
1107 qHandle.addToTableList(lls)
1108 qHandle.addToOutputList(
'RUNNUM',
'runnum')
1109 qHandle.addToOutputList(
'LUMILSNUM',
'lumilsnum')
1110 qHandle.addToOutputList(
'CMSLSNUM',
'cmslsnum')
1111 qHandle.addToOutputList(
'INSTLUMI',
'instlumi')
1112 qHandle.addToOutputList(
'INSTLUMIERROR',
'instlumierr')
1113 qHandle.addToOutputList(
'INSTLUMIQUALITY',
'instlumiqlty')
1114 qHandle.addToOutputList(
'BEAMSTATUS',
'beamstatus')
1115 qHandle.addToOutputList(
'BEAMENERGY',
'beamenergy')
1116 qHandle.addToOutputList(
'NUMORBIT',
'numorbit')
1117 qHandle.addToOutputList(
'STARTORBIT',
'startorbit')
1119 qHandle.addToOutputList(
'BXLUMIVALUE_'+bxAlgo,
'bxvalue')
1120 qHandle.addToOutputList(
'BXLUMIERROR_'+bxAlgo,
'bxerror')
1121 if withBeamIntensity:
1122 qHandle.addToOutputList(
'CMSBXINDEXBLOB',
'bxindexblob')
1123 qHandle.addToOutputList(
'BEAMINTENSITYBLOB_1',
'beam1intensity')
1124 qHandle.addToOutputList(
'BEAMINTENSITYBLOB_2',
'beam2intensity')
1126 qConditionStr=
'DATA_ID=:dataid' 1127 qCondition=coral.AttributeList()
1128 qCondition.extend(
'dataid',
'unsigned long long')
1129 qCondition[
'dataid'].setData(
int(dataid))
1131 qConditionStr+=
' and BEAMSTATUS=:beamstatus' 1132 qCondition.extend(
'beamstatus',
'string')
1133 qCondition[
'beamstatus'].setData(beamstatus)
1134 qResult=coral.AttributeList()
1135 qResult.extend(
'runnum',
'unsigned int')
1136 qResult.extend(
'lumilsnum',
'unsigned int')
1137 qResult.extend(
'cmslsnum',
'unsigned int')
1138 qResult.extend(
'instlumi',
'float')
1139 qResult.extend(
'instlumierr',
'float')
1140 qResult.extend(
'instlumiqlty',
'short')
1141 qResult.extend(
'beamstatus',
'string')
1142 qResult.extend(
'beamenergy',
'float')
1143 qResult.extend(
'numorbit',
'unsigned int')
1144 qResult.extend(
'startorbit',
'unsigned int')
1146 qResult.extend(
'bxvalue',
'blob')
1147 qResult.extend(
'bxerror',
'blob')
1148 if withBeamIntensity:
1149 qResult.extend(
'bxindexblob',
'blob')
1150 qResult.extend(
'beam1intensity',
'blob')
1151 qResult.extend(
'beam2intensity',
'blob')
1152 qHandle.defineOutput(qResult)
1153 qHandle.setCondition(qConditionStr,qCondition)
1154 cursor=qHandle.execute()
1156 runnum=cursor.currentRow()[
'runnum'].
data()
1157 lumilsnum=cursor.currentRow()[
'lumilsnum'].
data()
1158 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
1159 instlumi=cursor.currentRow()[
'instlumi'].
data()
1160 instlumierr=cursor.currentRow()[
'instlumierr'].
data()
1161 instlumiqlty=cursor.currentRow()[
'instlumiqlty'].
data()
1162 bs=cursor.currentRow()[
'beamstatus'].
data()
1163 begev=cursor.currentRow()[
'beamenergy'].
data()
1164 numorbit=cursor.currentRow()[
'numorbit'].
data()
1165 startorbit=cursor.currentRow()[
'startorbit'].
data()
1170 bxvalueblob=cursor.currentRow()[
'bxvalue'].
data()
1171 bxerrblob=cursor.currentRow()[
'bxerror'].
data()
1172 if bxvalueblob
and bxerrblob:
1175 bxinfo=(bxvaluesArray,bxerrArray)
1180 if withBeamIntensity:
1181 bxindexblob=cursor.currentRow()[
'bxindexblob'].
data()
1182 beam1intensity=cursor.currentRow()[
'beam1intensity'].
data()
1183 beam2intensity=cursor.currentRow()[
'beam2intensity'].
data()
1188 beaminfo=(bxindexArray,beam1intensityArray,beam2intensityArray)
1189 result[lumilsnum]=[cmslsnum,instlumi,instlumierr,instlumiqlty,bs,begev,numorbit,startorbit,bxinfo,beaminfo]
1194 return (runnum,result)
1197 result (runnum,[(lumilsnum(0),cmslsnum(1),beamstatus(2),beamenergy(3),ncollidingbunches(4),beaminfolist(5),..]) 1198 beaminfolist=[(bxidx,beam1intensity,beam2intensity)] 1203 qHandle=schema.newQuery()
1206 qHandle.addToOutputList(
'NCOLLIDINGBUNCHES')
1207 qConditionStr=
'DATA_ID=:dataid' 1208 qCondition=coral.AttributeList()
1209 qCondition.extend(
'dataid',
'unsigned long long')
1210 qCondition[
'dataid'].setData(dataid)
1211 qResult=coral.AttributeList()
1212 qResult.extend(
'NCOLLIDINGBUNCHES',
'unsigned int')
1213 qHandle.defineOutput(qResult)
1214 qHandle.setCondition(qConditionStr,qCondition)
1215 cursor=qHandle.execute()
1217 ncollidingbunches=cursor.currentRow()[
'NCOLLIDINGBUNCHES'].
data()
1222 qHandle=schema.newQuery()
1225 qHandle.addToOutputList(
'RUNNUM')
1226 qHandle.addToOutputList(
'CMSLSNUM')
1227 qHandle.addToOutputList(
'LUMILSNUM')
1228 qHandle.addToOutputList(
'BEAMSTATUS')
1229 qHandle.addToOutputList(
'BEAMENERGY')
1230 if withBeamIntensity:
1231 qHandle.addToOutputList(
'CMSBXINDEXBLOB')
1232 qHandle.addToOutputList(
'BEAMINTENSITYBLOB_1')
1233 qHandle.addToOutputList(
'BEAMINTENSITYBLOB_2')
1234 qConditionStr=
'DATA_ID=:dataid' 1235 qCondition=coral.AttributeList()
1236 qCondition.extend(
'dataid',
'unsigned long long')
1237 qCondition[
'dataid'].setData(dataid)
1238 qResult=coral.AttributeList()
1239 qResult.extend(
'RUNNUM',
'unsigned int')
1240 qResult.extend(
'CMSLSNUM',
'unsigned int')
1241 qResult.extend(
'LUMILSNUM',
'unsigned int')
1242 qResult.extend(
'BEAMSTATUS',
'string')
1243 qResult.extend(
'BEAMENERGY',
'float')
1244 if withBeamIntensity:
1245 qResult.extend(
'BXINDEXBLOB',
'blob')
1246 qResult.extend(
'BEAM1INTENSITY',
'blob')
1247 qResult.extend(
'BEAM2INTENSITY',
'blob')
1248 qHandle.defineOutput(qResult)
1249 qHandle.setCondition(qConditionStr,qCondition)
1250 cursor=qHandle.execute()
1252 runnum=cursor.currentRow()[
'RUNNUM'].
data()
1253 cmslsnum=cursor.currentRow()[
'CMSLSNUM'].
data()
1254 lumilsnum=cursor.currentRow()[
'LUMILSNUM'].
data()
1255 beamstatus=cursor.currentRow()[
'BEAMSTATUS'].
data()
1256 beamenergy=cursor.currentRow()[
'BEAMENERGY'].
data()
1258 beaminfotupleList=[]
1259 if withBeamIntensity:
1260 bxindexblob=cursor.currentRow()[
'BXINDEXBLOB'].
data()
1261 beam1intensityblob=cursor.currentRow()[
'BEAM1INTENSITY'].
data()
1262 beam2intensityblob=cursor.currentRow()[
'BEAM2INTENSITY'].
data()
1264 beam1intensityArray=
None 1265 beam2intensityArray=
None 1268 if beam1intensityblob:
1270 if beam2intensityblob:
1272 if bxindexArray
and beam1intensityArray
and beam2intensityArray:
1273 for idx,bxindex
in enumerate(bxindexArray):
1274 if (beam1intensityArray[idx]
and beam1intensityArray[idx]>minIntensity)
or (beam2intensityArray[idx]
and beam2intensityArray[idx]>minIntensity):
1275 beaminfotuple=(bxindex,beam1intensityArray[idx],beam2intensityArray[idx])
1276 beaminfotupleList.append(beaminfotuple)
1278 del beam1intensityArray[:]
1279 del beam2intensityArray[:]
1280 result.append((lumilsnum,cmslsnum,beamstatus,beamenergy,ncollidingbunches,beaminfotupleList))
1285 return (runnum,result)
1288 result {lumilsnum:[cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty]} 1291 qHandle=schema.newQuery()
1294 qHandle.addToOutputList(
'CMSLSNUM',
'cmslsnum')
1295 qHandle.addToOutputList(
'LUMILSNUM',
'lumilsnum')
1297 qHandle.addToOutputList(
'NUMORBIT',
'numorbit')
1298 qHandle.addToOutputList(
'STARTORBIT',
'startorbit')
1299 qHandle.addToOutputList(
'BXLUMIVALUE_'+algoname,
'bxlumivalue')
1300 qHandle.addToOutputList(
'BXLUMIERROR_'+algoname,
'bxlumierr')
1301 qHandle.addToOutputList(
'BXLUMIQUALITY_'+algoname,
'bxlumiqlty')
1302 qConditionStr=
'DATA_ID=:dataid' 1303 qCondition=coral.AttributeList()
1304 qCondition.extend(
'dataid',
'unsigned long long')
1305 qCondition[
'dataid'].setData(dataid)
1306 qResult=coral.AttributeList()
1307 qResult.extend(
'cmslsnum',
'unsigned int')
1308 qResult.extend(
'lumilsnum',
'unsigned int')
1309 qResult.extend(
'numorbit',
'unsigned int')
1310 qResult.extend(
'startorbit',
'unsigned int')
1311 qResult.extend(
'bxlumivalue',
'blob')
1312 qResult.extend(
'bxlumierr',
'blob')
1313 qResult.extend(
'bxlumiqlty',
'blob')
1314 qHandle.defineOutput(qResult)
1315 qHandle.setCondition(qConditionStr,qCondition)
1316 cursor=qHandle.execute()
1318 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
1319 lumilsnum=cursor.currentRow()[
'lumilsnum'].
data()
1320 numorbit=cursor.currentRow()[
'numorbit'].
data()
1321 startorbit=cursor.currentRow()[
'startorbit'].
data()
1322 bxlumivalue=cursor.currentRow()[
'bxlumivalue'].
data()
1323 bxlumierr=cursor.currentRow()[
'bxlumierr'].
data()
1324 bxlumiqlty=cursor.currentRow()[
'bxlumiqlty'].
data()
1325 if algoname
not in result:
1327 if lumilsnum
not in result[algoname]:
1328 result[algoname][lumilsnum]=[]
1329 result[algoname][lumilsnum].extend([cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty])
1332 raise RuntimeError(
' dataDML.lumiBXById: '+
str(e))
1336 def hltRunById(schema,dataid,hltpathname=None,hltpathpattern=None):
1338 result [runnum(0),datasource(1),npath(2),hltnamedict(3)] 1340 npath : total number of hltpath in DB 1341 hltnamedict : list of all selected paths [(hltpathidx,hltname),(hltpathidx,hltname)] 1344 qHandle=schema.newQuery()
1351 qHandle.addToOutputList(
'RUNNUM',
'runnum')
1352 qHandle.addToOutputList(
'SOURCE',
'datasource')
1353 qHandle.addToOutputList(
'NPATH',
'npath')
1354 qHandle.addToOutputList(
'PATHNAMECLOB',
'pathnameclob')
1355 qConditionStr=
'DATA_ID=:dataid' 1356 qCondition=coral.AttributeList()
1357 qCondition.extend(
'dataid',
'unsigned long long')
1358 qCondition[
'dataid'].setData(dataid)
1359 qResult=coral.AttributeList()
1360 qResult.extend(
'runnum',
'unsigned int')
1361 qResult.extend(
'datasource',
'string')
1362 qResult.extend(
'npath',
'unsigned int')
1363 qResult.extend(
'pathnameclob',
'string')
1364 qHandle.defineOutput(qResult)
1365 qHandle.setCondition(qConditionStr,qCondition)
1366 cursor=qHandle.execute()
1370 runnum=cursor.currentRow()[
'runnum'].
data()
1371 datasource=cursor.currentRow()[
'datasource'].
data()
1372 npath=cursor.currentRow()[
'npath'].
data()
1373 pathnameclob=cursor.currentRow()[
'pathnameclob'].
data()
1375 pathnames=pathnameclob.split(
',')
1376 for pathnameidx,hltname
in enumerate(pathnames):
1378 if hltpathname==hltname:
1379 hltnamedict.append((pathnameidx,hltname))
1381 elif hltpathpattern:
1382 if fnmatch.fnmatch(hltname,hltpathpattern):
1383 hltnamedict.append((pathnameidx,hltname))
1386 result=[runnum,datasource,npath,hltnamedict]
1395 select m.hltpathname,m.l1seed from cmsrunsummary r,trghltmap m where r.runnum=:runnum and m.hltkey=r.hltkey and [m.hltpathname=:hltpathname] 1396 output: {hltpath:l1seed} 1399 queryHandle=schema.newQuery()
1402 if hltpathpattern
and hltpathpattern
in [
'*',
'all',
'All',
'ALL']:
1405 queryHandle.addToTableList(r)
1406 queryHandle.addToTableList(m)
1407 queryCondition=coral.AttributeList()
1408 queryCondition.extend(
'runnum',
'unsigned int')
1409 queryCondition[
'runnum'].setData(
int(runnum))
1411 queryHandle.addToOutputList(m+
'.HLTPATHNAME',
'hltpathname')
1412 queryHandle.addToOutputList(m+
'.L1SEED',
'l1seed')
1413 conditionStr=r+
'.RUNNUM=:runnum and '+m+
'.HLTKEY='+r+
'.HLTKEY' 1416 conditionStr+=
' AND '+m+
'.HLTPATHNAME=:hltpathname' 1417 queryCondition.extend(
'hltpathname',
'string')
1418 queryCondition[
'hltpathname'].setData(hltpathname)
1419 queryHandle.setCondition(conditionStr,queryCondition)
1420 queryResult=coral.AttributeList()
1421 queryResult.extend(
'pname',
'string')
1422 queryResult.extend(
'l1seed',
'string')
1423 queryHandle.defineOutput(queryResult)
1424 cursor=queryHandle.execute()
1426 pname=cursor.currentRow()[
'pname'].
data()
1427 l1seed=cursor.currentRow()[
'l1seed'].
data()
1428 if hltpathname
not in result:
1430 if fnmatch.fnmatch(pname,hltpathpattern):
1431 result[pname]=l1seed
1433 result[pname]=l1seed
1440 def hltLSById(schema,dataid,hltpathname=None,hltpathpattern=None,withL1Pass=False,withHLTAccept=False):
1442 result (runnum, {cmslsnum:[(pathname,prescale,1lpass,hltaccept)](0)]} 1447 hltrundata=
hltRunById(schema,dataid,hltpathname=hltpathname,hltpathpattern=hltpathpattern)
1450 hltnamedict=hltrundata[3]
1452 return (hltrundata[0],{})
1456 qHandle=schema.newQuery()
1459 qHandle.addToOutputList(
'RUNNUM',
'runnum')
1460 qHandle.addToOutputList(
'CMSLSNUM',
'cmslsnum')
1461 if len(hltnamedict)!=0:
1462 qHandle.addToOutputList(
'PRESCALEBLOB',
'prescaleblob')
1464 qHandle.addToOutputList(
'HLTCOUNTBLOB',
'hltcountblob')
1466 qHandle.addToOutputList(
'HLTACCEPTBLOB',
'hltacceptblob')
1467 qConditionStr=
'DATA_ID=:dataid' 1468 qCondition=coral.AttributeList()
1469 qCondition.extend(
'dataid',
'unsigned long long')
1470 qCondition[
'dataid'].setData(dataid)
1471 qResult=coral.AttributeList()
1472 qResult.extend(
'runnum',
'unsigned int')
1473 qResult.extend(
'cmslsnum',
'unsigned int')
1474 if len(hltnamedict)!=0:
1475 qResult.extend(
'prescaleblob',
'blob')
1477 qResult.extend(
'hltcountblob',
'blob')
1479 qResult.extend(
'hltacceptblob',
'blob')
1480 qHandle.defineOutput(qResult)
1481 qHandle.setCondition(qConditionStr,qCondition)
1482 cursor=qHandle.execute()
1484 runnum=cursor.currentRow()[
'runnum'].
data()
1485 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
1489 if len(hltnamedict)!=0:
1490 prescaleblob=cursor.currentRow()[
'prescaleblob'].
data()
1492 hltcountblob=cursor.currentRow()[
'hltcountblob'].
data()
1494 hltacceptblob=cursor.currentRow()[
'hltacceptblob'].
data()
1495 if cmslsnum
not in result:
1516 for (hltpathidx,thispathname)
in hltnamedict:
1521 thispresc=prescales[hltpathidx]
1523 thishltcount=hltcounts[hltpathidx]
1525 thisaccept=hltaccepts[hltpathidx]
1526 thispathinfo=(thispathname,thispresc,thishltcount,thisaccept)
1527 pathinfo.append(thispathinfo)
1528 result[cmslsnum]=pathinfo
1537 return (runnum,result)
1541 output: {run:intglumi_in_fb} 1548 qHandle=schema.newQuery()
1551 qResult=coral.AttributeList()
1552 qResult.extend(
'RUNNUM',
'unsigned int')
1553 qResult.extend(
'INTGLUMI',
'float')
1554 qConditionStr=
'RUNNUM>=:minrun AND RUNNUM<=:maxrun' 1555 qCondition=coral.AttributeList()
1556 qCondition.extend(
'minrun',
'unsigned int')
1557 qCondition.extend(
'maxrun',
'unsigned int')
1558 qCondition[
'minrun'].setData(minrun)
1559 qCondition[
'maxrun'].setData(maxrun)
1560 qHandle.addToOutputList(
'RUNNUM')
1561 qHandle.addToOutputList(
'INTGLUMI')
1562 qHandle.setCondition(qConditionStr,qCondition)
1563 qHandle.defineOutput(qResult)
1564 cursor=qHandle.execute()
1566 runnum=cursor.currentRow()[
'RUNNUM'].
data()
1567 intglumi=cursor.currentRow()[
'INTGLUMI'].
data()
1568 result[runnum]=intglumi
1577 output:(patternStr:correctionFac) 1579 if lumitype
not in [
'PIXEL',
'HF']:
1580 raise ValueError(
'[ERROR] unsupported lumitype '+lumitype)
1581 correctorField=
'CORRECTIONFACTOR' 1582 if lumitype==
'PIXEL':
1583 correctorField=
'PIXELCORRECTIONFACTOR' 1585 qHandle=schema.newQuery()
1588 qResult=coral.AttributeList()
1589 qResult.extend(
'FILLSCHEMEPATTERN',
'string')
1590 qResult.extend(
'CORRECTIONFACTOR',
'float')
1591 qHandle.defineOutput(qResult)
1592 qHandle.addToOutputList(
'FILLSCHEMEPATTERN')
1593 qHandle.addToOutputList(correctorField)
1594 cursor=qHandle.execute()
1596 fillschemePattern=cursor.currentRow()[
'FILLSCHEMEPATTERN'].
data()
1597 afterglowfac=cursor.currentRow()[
'CORRECTIONFACTOR'].
data()
1598 result[fillschemePattern]=afterglowfac
1609 return latestrevision
1615 return latestrevision
1621 return latestrevision
1625 select max data_id of the given run. In current design, it's the most recent data of the run 1629 qHandle=schema.newQuery()
1631 qHandle.addToTableList(tablename)
1632 qHandle.addToOutputList(
'DATA_ID')
1633 qConditionStr=
'RUNNUM=:runnum ' 1634 qCondition=coral.AttributeList()
1635 qCondition.extend(
'runnum',
'unsigned int')
1636 qCondition[
'runnum'].setData(runnum)
1637 qResult=coral.AttributeList()
1638 qResult.extend(
'DATA_ID',
'unsigned long long')
1639 qHandle.defineOutput(qResult)
1640 qHandle.setCondition(qConditionStr,qCondition)
1641 cursor=qHandle.execute()
1643 dataid=cursor.currentRow()[
'DATA_ID'].
data()
1656 input: inputRange [run] 1657 output: {run:lumiid} 1658 select data_id,runnum from hltdata where runnum<=runmax and runnum>=:runmin 1661 if not inputRange :
return result
1662 if len(inputRange)==1:
1664 result[inputRange[0]]=trgid
1666 rmin=
min(inputRange)
1667 rmax=
max(inputRange)
1668 result=dict.fromkeys(inputRange,
None)
1669 qHandle=schema.newQuery()
1671 qHandle.addToTableList(tablename)
1672 qHandle.addToOutputList(
'DATA_ID')
1673 qHandle.addToOutputList(
'RUNNUM')
1674 qConditionStr=
'RUNNUM>=:rmin' 1675 qCondition=coral.AttributeList()
1676 qCondition.extend(
'rmin',
'unsigned int')
1677 qCondition[
'rmin'].setData(rmin)
1679 qConditionStr+=
' AND RUNNUM<=:rmax' 1680 qCondition.extend(
'rmax',
'unsigned int')
1681 qCondition[
'rmax'].setData(rmax)
1682 qResult=coral.AttributeList()
1683 qResult.extend(
'DATA_ID',
'unsigned long long')
1684 qResult.extend(
'RUNNUM',
'unsigned int')
1685 qHandle.defineOutput(qResult)
1686 qHandle.setCondition(qConditionStr,qCondition)
1687 cursor=qHandle.execute()
1689 dataid=cursor.currentRow()[
'DATA_ID'].
data()
1690 runnum=cursor.currentRow()[
'RUNNUM'].
data()
1691 if runnum
in result:
1692 if dataid>result[runnum]:
1693 result[runnum]=dataid
1744 get norm dataids by amodetag, egev if there are duplicates, pick max(dataid).Bypass full version lookups 1745 select data_id from luminorm where amodetag=:amodetag and egev_1=:egev1 1748 qHandle=schema.newQuery()
1753 qHandle.addToOutputList(
'DATA_ID',
'normdataid')
1754 qConditionStr=
'AMODETAG=:amodetag AND EGEV_1>=:egevmin AND EGEV_1<=:egevmax' 1755 qCondition=coral.AttributeList()
1756 qCondition.extend(
'amodetag',
'string')
1757 qCondition.extend(
'egevmin',
'unsigned int')
1758 qCondition.extend(
'egevmax',
'unsigned int')
1759 qCondition[
'amodetag'].setData(amodetag)
1760 qCondition[
'egevmin'].setData(
int(egevmin))
1761 qCondition[
'egevmax'].setData(
int(egevmax))
1762 qResult=coral.AttributeList()
1763 qResult.extend(
'normdataid',
'unsigned long long')
1764 qHandle.defineOutput(qResult)
1765 qHandle.setCondition(qConditionStr,qCondition)
1766 cursor=qHandle.execute()
1768 normdataid=cursor.currentRow()[
'normdataid'].
data()
1769 luminormids.append(normdataid)
1774 if len(luminormids) !=0:
return max(luminormids)
1779 get norm dataids by name, if there are duplicates, pick max(dataid).Bypass full version lookups 1780 select data_id from luminorms where entry_name=:normname 1781 result luminormdataid 1784 qHandle=schema.newQuery()
1787 qHandle.addToOutputList(
'DATA_ID',
'normdataid')
1788 qConditionStr=
'ENTRY_NAME=:normname ' 1789 qCondition=coral.AttributeList()
1790 qCondition.extend(
'normname',
'string')
1791 qCondition[
'normname'].setData(normname)
1792 qResult=coral.AttributeList()
1793 qResult.extend(
'normdataid',
'unsigned long long')
1794 qHandle.defineOutput(qResult)
1795 qHandle.setCondition(qConditionStr,qCondition)
1796 cursor=qHandle.execute()
1798 normdataid=cursor.currentRow()[
'normdataid'].
data()
1799 luminormids.append(normdataid)
1804 if len(luminormids) !=0:
return max(luminormids)
1811 select el.entry_id,et.entry_id,eh.entry_id,el.revision_id,et.revision_id,eh.revision_id from lumidataentiries el,trgdataentries et,hltdataentries eh where el.name=et.name and et.name=eh.name and el.name=:entryname; 1814 return [lumientryid,trgentryid,hltentryid] 1817 qHandle=schema.newQuery()
1826 qCondition=coral.AttributeList()
1827 qCondition.extend(
'runnumstr',
'string')
1828 qCondition[
'runnumstr'].setData(
str(runnum))
1829 qResult=coral.AttributeList()
1830 qResult.extend(
'lumientryid',
'unsigned long long')
1831 qResult.extend(
'trgentryid',
'unsigned long long')
1832 qResult.extend(
'hltentryid',
'unsigned long long')
1833 qHandle.defineOutput(qResult)
1834 qHandle.setCondition(qConditionStr,qCondition)
1835 cursor=qHandle.execute()
1837 lumientryid=cursor.currentRow()[
'lumientryid'].
data()
1838 trgentryid=cursor.currentRow()[
'trgentryid'].
data()
1839 hltentryid=cursor.currentRow()[
'hltentryid'].
data()
1840 if lumientryid
in branchfilter
and trgentryid
in branchfilter
and hltentryid
in branchfilter:
1841 result.extend([lumientryid,trgentryid,hltentryid])
1850 select l.data_id,rl.revision_id from lumidatatable l,lumirevisions rl where l.data_id=rl.data_id and l.entry_id=:entryid 1851 check revision_id is in branch 1856 if datatype==
'lumi':
1858 elif datatype==
'trg':
1860 elif dataytpe==
'hlt':
1863 raise RunTimeError(
'datatype '+datatype+
' is not supported')
1865 qHandle=schema.newQuery()
1867 qHandle.addToTableList(revmaptablename)
1868 qHandle.addToTableList(datatablename)
1869 qHandle.addToOutputList(
'l.DATA_ID',
'dataid')
1870 qHandle.addToOutputList(revmaptablename+
'.REVISION_ID',
'revisionid')
1871 qConditionStr=datatablename+
'.DATA_ID='+revmaptablename+
'.DATA_ID AND '+datatablename+
'.ENTRY_ID=:entryid' 1872 qCondition=coral.AttributeList()
1873 qCondition.extend(
'entryid',
'unsigned long long')
1874 qResult=coral.AttributeList()
1875 qResult.extend(
'dataid',
'unsigned long long')
1876 qResult.extend(
'revisionid',
'unsigned long long')
1877 qHandle.defineOutput(qResult)
1878 qHandle.setCondition(qConditionStr,qCondition)
1879 cursor=qHandle.execute()
1881 dataid=cursor.currentRow()[
'dataid'].
data()
1882 revisionid=cursor.currentRow()[
'revisionid'].
data()
1883 if revisionid
in branchfilter:
1884 dataids.append(dataid)
1889 if len(dataids)!=0:
return max(dataids)
1899 branchinfo(normrevisionid,branchname) 1900 optionalnormdata {'norm_occ2':norm_occ2,'norm_et':norm_et,'norm_pu':norm_pu,'constfactor':constfactor} 1902 (revision_id,entry_id,data_id) 1906 if 'normOcc2' in optionalnormdata:
1907 norm_occ2=optionalnormdata[
'norm_occ2']
1909 if 'norm_et' in optionalnormdata:
1910 norm_et=optionalnormdata[
'norm_et']
1912 if 'norm_pu' in optionalnormdata:
1913 norm_pu=optionalnormdata[
'norm_pu']
1915 if 'constfactor' in optionalnormdata:
1916 constfactor=optionalnormdata[
'constfactor']
1919 if entry_id
is None:
1921 entryinfo=(revision_id,entry_id,normname,data_id)
1926 tabrowDefDict={
'DATA_ID':
'unsigned long long',
'ENTRY_ID':
'unsigned long long',
'ENTRY_NAME':
'string',
'AMODETAG':
'string',
'NORM_1':
'float',
'EGEV_1':
'unsigned int',
'NORM_OCC2':
'float',
'NORM_ET':
'float',
'NORM_PU':
'float',
'CONSTFACTOR':
'float'}
1927 tabrowValueDict={
'DATA_ID':data_id,
'ENTRY_ID':entry_id,
'ENTRY_NAME':normname,
'AMODETAG':amodetag,
'NORM_1':norm1,
'EGEV_1':egev1,
'NORM_OCC2':norm_occ2,
'NORM_ET':norm_et,
'NORM_PU':norm_pu,
'CONSTFACTOR':constfactor}
1930 return (revision_id,entry_id,data_id)
1937 branchinfo(corrrevisionid,branchname) 1938 optionalcorrdata {'a2':a2,'drift':drif} 1940 (revision_id,entry_id,data_id) 1943 if 'a2' in optionalcorrdata:
1944 a2=optionalcorrdata[
'a2']
1946 if 'drift' in optionalcorrdata:
1947 drift=optionalcorrdata[
'drift']
1950 if entry_id
is None:
1952 entryinfo=(revision_id,entry_id,corrname,data_id)
1957 tabrowDefDict={
'DATA_ID':
'unsigned long long',
'ENTRY_ID':
'unsigned long long',
'ENTRY_NAME':
'string',
'A1':
'float',
'A2':
'float',
'DRIFT':
'float'}
1958 tabrowValueDict={
'DATA_ID':data_id,
'ENTRY_ID':entry_id,
'ENTRY_NAME':corrname,
'A1':a1,
'A2':a2,
'DRIFT':drift}
1960 db.insertOneRow(nameDealer.lumicorrectionsTableName(),tabrowDefDict,tabrowValueDict)
1961 return (revision_id,entry_id,data_id)
1968 lumirundata [datasource,nominalenergy,ncollidingbunches,starttime,stoptime,nls] 1969 branchinfo (branch_id,branch_name) 1970 tableName lumiruntablename 1972 (revision_id,entry_id,data_id) 1975 datasource=lumirundata[0]
1978 starttime=coral.TimeStamp()
1979 stoptime=coral.TimeStamp()
1981 if len(lumirundata)>1:
1982 nominalenergy=lumirundata[1]
1983 ncollidingbunches=lumirundata[2]
1984 starttime=lumirundata[3]
1985 stoptime=lumirundata[4]
1988 if entry_id
is None:
1990 entryinfo=(revision_id,entry_id,
str(runnumber),data_id)
1996 tabrowDefDict={
'DATA_ID':
'unsigned long long',
'ENTRY_ID':
'unsigned long long',
'ENTRY_NAME':
'string',
'RUNNUM':
'unsigned int',
'SOURCE':
'string',
'NOMINALEGEV':
'float',
'NCOLLIDINGBUNCHES':
'unsigned int',
'STARTTIME':
'time stamp',
'STOPTIME':
'time stamp',
'NLS':
'unsigned int'}
1997 tabrowValueDict={
'DATA_ID':data_id,
'ENTRY_ID':entry_id,
'ENTRY_NAME':
str(runnumber),
'RUNNUM':
int(runnumber),
'SOURCE':datasource,
'NOMINALEGEV':nominalegev,
'NCOLLIDINGBUNCHES':ncollidingbunches,
'STARTTIME':starttime,
'STOPTIME':stoptime,
'NLS':nls}
1999 db.insertOneRow(tableName,tabrowDefDict,tabrowValueDict)
2000 return (revision_id,entry_id,data_id)
2007 trgrundata [datasource(0),bitzeroname(1),bitnameclob(2)] 2008 bitnames clob, bitnames separated by ',' 2010 (revision_id,entry_id,data_id) 2013 datasource=trgrundata[0]
2014 bitzeroname=trgrundata[1]
2015 bitnames=trgrundata[2]
2017 if entry_id
is None:
2019 entryinfo=(revision_id,entry_id,
str(runnumber),data_id)
2024 tabrowDefDict={
'DATA_ID':
'unsigned long long',
'ENTRY_ID':
'unsigned long long',
'ENTRY_NAME':
'string',
'SOURCE':
'string',
'RUNNUM':
'unsigned int',
'BITZERONAME':
'string',
'BITNAMECLOB':
'string'}
2025 tabrowValueDict={
'DATA_ID':data_id,
'ENTRY_ID':entry_id,
'ENTRY_NAME':
str(runnumber),
'SOURCE':datasource,
'RUNNUM':
int(runnumber),
'BITZERONAME':bitzeroname,
'BITNAMECLOB':bitnames}
2028 return (revision_id,entry_id,data_id)
2034 hltrundata [pathnameclob(0),datasource(1)] 2036 (revision_id,entry_id,data_id) 2039 pathnames=hltrundata[0]
2040 datasource=hltrundata[1]
2041 npath=len(pathnames.split(
','))
2043 if entry_id
is None:
2045 entryinfo=(revision_id,entry_id,
str(runnumber),data_id)
2050 tabrowDefDict={
'DATA_ID':
'unsigned long long',
'ENTRY_ID':
'unsigned long long',
'ENTRY_NAME':
'string',
'RUNNUM':
'unsigned int',
'SOURCE':
'string',
'NPATH':
'unsigned int',
'PATHNAMECLOB':
'string'}
2051 tabrowValueDict={
'DATA_ID':data_id,
'ENTRY_ID':entry_id,
'ENTRY_NAME':
str(runnumber),
'RUNNUM':
int(runnumber),
'SOURCE':datasource,
'NPATH':npath,
'PATHNAMECLOB':pathnames}
2054 return (revision_id,entry_id,data_id)
2061 runsummarydata [l1key,amodetag,egev,sequence,hltkey,fillnum,starttime,stoptime] 2064 l1key=runsummarydata[0]
2065 amodetag=runsummarydata[1]
2066 egev=runsummarydata[2]
2072 if not complementalOnly:
2073 sequence=runsummarydata[3]
2074 hltkey=runsummarydata[4]
2075 fillnum=runsummarydata[5]
2076 starttime=runsummarydata[6]
2077 stoptime=runsummarydata[7]
2079 if not complementalOnly:
2080 tabrowDefDict={
'RUNNUM':
'unsigned int',
'L1KEY':
'string',
'AMODETAG':
'string',
'EGEV':
'unsigned int',
'SEQUENCE':
'string',
'HLTKEY':
'string',
'FILLNUM':
'unsigned int',
'STARTTIME':
'time stamp',
'STOPTIME':
'time stamp'}
2081 tabrowValueDict={
'RUNNUM':
int(runnumber),
'L1KEY':l1key,
'AMODETAG':amodetag,
'EGEV':
int(egev),
'SEQUENCE':sequence,
'HLTKEY':hltkey,
'FILLNUM':
int(fillnum),
'STARTTIME':starttime,
'STOPTIME':stoptime}
2085 setClause=
'L1KEY=:l1key,AMODETAG=:amodetag,EGEV=:egev' 2086 updateCondition=
'RUNNUM=:runnum' 2087 inputData=coral.AttributeList()
2088 inputData.extend(
'l1key',
'string')
2089 inputData.extend(
'amodetag',
'string')
2090 inputData.extend(
'egev',
'unsigned int')
2091 inputData.extend(
'runnum',
'unsigned int')
2092 inputData[
'l1key'].setData(l1key)
2093 inputData[
'amodetag'].setData(amodetag)
2094 inputData[
'egev'].setData(
int(egev))
2095 inputData[
'runnum'].setData(
int(runnumber))
2103 trghltmap {hltpath:l1seed} 2109 kQueryBindList=coral.AttributeList()
2110 kQueryBindList.extend(
'hltkey',
'string')
2111 kQuery=schema.newQuery()
2113 kQuery.setCondition(
'HLTKEY=:hltkey',kQueryBindList)
2114 kQueryBindList[
'hltkey'].setData(hltkey)
2115 kResult=kQuery.execute()
2116 while next(kResult):
2118 if not hltkeyExists:
2120 trghltDefDict=[(
'HLTKEY',
'string'),(
'HLTPATHNAME',
'string'),(
'L1SEED',
'string')]
2121 for hltpath,l1seed
in trghltmap.items():
2122 bulkvalues.append([(
'HLTKEY',hltkey),(
'HLTPATHNAME',hltpath),(
'L1SEED',l1seed)])
2125 nrows=len(bulkvalues)
2128 print(
'error in insertTrgHltMap ')
2132 insert trg per-LS data for given run and data_id, this operation can be split in transaction chuncks 2134 trglsdata {cmslsnum:[deadtime,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]} 2135 result nrows inserted 2136 if nrows==0, then this insertion failed 2138 print(
'total number of trg rows ',len(trglsdata))
2139 lstrgDefDict=[(
'DATA_ID',
'unsigned long long'),(
'RUNNUM',
'unsigned int'),(
'CMSLSNUM',
'unsigned int'),(
'DEADTIMECOUNT',
'unsigned long long'),(
'BITZEROCOUNT',
'unsigned int'),(
'BITZEROPRESCALE',
'unsigned int'),(
'PRESCALEBLOB',
'blob'),(
'TRGCOUNTBLOB',
'blob')]
2144 for cmslsnum,perlstrg
in trglsdata.items():
2145 deadtimecount=perlstrg[0]
2146 bitzerocount=perlstrg[1]
2147 bitzeroprescale=perlstrg[2]
2148 trgcountblob=perlstrg[3]
2149 trgprescaleblob=perlstrg[4]
2150 bulkvalues.append([(
'DATA_ID',data_id),(
'RUNNUM',runnumber),(
'CMSLSNUM',cmslsnum),(
'DEADTIMECOUNT',deadtimecount),(
'BITZEROCOUNT',bitzerocount),(
'BITZEROPRESCALE',bitzeroprescale),(
'PRESCALEBLOB',trgprescaleblob),(
'TRGCOUNTBLOB',trgcountblob)])
2154 print(
'committing trg in LS chunck ',nrows)
2156 session.transaction().
start(
False)
2158 session.transaction().commit()
2161 elif committedrows==len(trglsdata):
2162 print(
'committing trg at the end ')
2164 session.transaction().
start(
False)
2166 session.transaction().commit()
2168 print(
'error in bulkInsertTrgLSData')
2173 hltlsdata {cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]} 2175 print(
'total number of hlt rows ',len(hltlsdata))
2176 lshltDefDict=[(
'DATA_ID',
'unsigned long long'),(
'RUNNUM',
'unsigned int'),(
'CMSLSNUM',
'unsigned int'),(
'PRESCALEBLOB',
'blob'),(
'HLTCOUNTBLOB',
'blob'),(
'HLTACCEPTBLOB',
'blob')]
2181 for cmslsnum,perlshlt
in hltlsdata.items():
2182 inputcountblob=perlshlt[0]
2183 acceptcountblob=perlshlt[1]
2184 prescaleblob=perlshlt[2]
2185 bulkvalues.append([(
'DATA_ID',data_id),(
'RUNNUM',runnumber),(
'CMSLSNUM',cmslsnum),(
'PRESCALEBLOB',prescaleblob),(
'HLTCOUNTBLOB',inputcountblob),(
'HLTACCEPTBLOB',acceptcountblob)])
2190 print(
'committing hlt in LS chunck ',nrows)
2192 session.transaction().
start(
False)
2194 session.transaction().commit()
2197 elif committedrows==len(hltlsdata):
2198 print(
'committing hlt at the end ')
2200 session.transaction().
start(
False)
2202 session.transaction().commit()
2204 print(
'error in bulkInsertHltLSData')
2210 lumilsdata {lumilsnum:[cmslsnum,instlumi,instlumierror,instlumiquality,beamstatus,beamenergy,numorbit,startorbit,cmsbxindexblob,beam1intensity,beam2intensity,bxlumivalue_occ1,bxlumierror_occ1,bxlumiquality_occ1,bxlumivalue_occ2,bxlumierror_occ2,bxlumiquality_occ2,bxlumivalue_et,bxlumierror_et,bxlumiquality_et]} 2214 lslumiDefDict=[(
'DATA_ID',
'unsigned long long'),(
'RUNNUM',
'unsigned int'),(
'LUMILSNUM',
'unsigned int'),(
'CMSLSNUM',
'unsigned int'),(
'INSTLUMI',
'float'),(
'INSTLUMIERROR',
'float'),(
'INSTLUMIQUALITY',
'short'),(
'BEAMSTATUS',
'string'),(
'BEAMENERGY',
'float'),(
'NUMORBIT',
'unsigned int'),(
'STARTORBIT',
'unsigned int'),(
'CMSBXINDEXBLOB',
'blob'),(
'BEAMINTENSITYBLOB_1',
'blob'),(
'BEAMINTENSITYBLOB_2',
'blob'),(
'BXLUMIVALUE_OCC1',
'blob'),(
'BXLUMIERROR_OCC1',
'blob'),(
'BXLUMIQUALITY_OCC1',
'blob'),(
'BXLUMIVALUE_OCC2',
'blob'),(
'BXLUMIERROR_OCC2',
'blob'),(
'BXLUMIQUALITY_OCC2',
'blob'),(
'BXLUMIVALUE_ET',
'blob'),(
'BXLUMIERROR_ET',
'blob'),(
'BXLUMIQUALITY_ET',
'blob')]
2216 lslumiDefDict=[(
'DATA_ID',
'unsigned long long'),(
'RUNNUM',
'unsigned int'),(
'LUMILSNUM',
'unsigned int'),(
'CMSLSNUM',
'unsigned int'),(
'INSTLUMI',
'float'),(
'INSTLUMIERROR',
'float'),(
'INSTLUMIQUALITY',
'short'),(
'BEAMSTATUS',
'string'),(
'BEAMENERGY',
'float'),(
'NUMORBIT',
'unsigned int'),(
'STARTORBIT',
'unsigned int')]
2217 print(
'total number of lumi rows ',len(lumilsdata))
2222 for lumilsnum,perlslumi
in lumilsdata.items():
2223 cmslsnum=perlslumi[0]
2224 instlumi=perlslumi[1]
2225 instlumierror=perlslumi[2]
2226 instlumiquality=perlslumi[3]
2227 beamstatus=perlslumi[4]
2228 beamenergy=perlslumi[5]
2229 numorbit=perlslumi[6]
2230 startorbit=perlslumi[7]
2232 cmsbxindexindexblob=perlslumi[8]
2233 beam1intensity=perlslumi[9]
2234 beam2intensity=perlslumi[10]
2235 bxlumivalue_occ1=perlslumi[11]
2236 bxlumierror_occ1=perlslumi[12]
2237 bxlumiquality_occ1=perlslumi[13]
2238 bxlumivalue_occ2=perlslumi[14]
2239 bxlumierror_occ2=perlslumi[15]
2240 bxlumiquality_occ2=perlslumi[16]
2241 bxlumivalue_et=perlslumi[17]
2242 bxlumierror_et=perlslumi[18]
2243 bxlumiquality_et=perlslumi[19]
2244 bulkvalues.append([(
'DATA_ID',data_id),(
'RUNNUM',runnumber),(
'LUMILSNUM',lumilsnum),(
'CMSLSNUM',cmslsnum),(
'INSTLUMI',instlumi),(
'INSTLUMIERROR',instlumierror),(
'INSTLUMIQUALITY',instlumiquality),(
'BEAMSTATUS',beamstatus),(
'BEAMENERGY',beamenergy),(
'NUMORBIT',numorbit),(
'STARTORBIT',startorbit),(
'CMSBXINDEXBLOB',cmsbxindexindexblob),(
'BEAMINTENSITYBLOB_1',beam1intensity),(
'BEAMINTENSITYBLOB_2',beam2intensity),(
'BXLUMIVALUE_OCC1',bxlumivalue_occ1),(
'BXLUMIERROR_OCC1',bxlumierror_occ1),(
'BXLUMIQUALITY_OCC1',bxlumiquality_occ1),(
'BXLUMIVALUE_OCC2',bxlumivalue_occ2),(
'BXLUMIERROR_OCC2',bxlumierror_occ2),(
'BXLUMIQUALITY_OCC2',bxlumiquality_occ2),(
'BXLUMIVALUE_ET',bxlumivalue_et),(
'BXLUMIERROR_ET',bxlumierror_et),(
'BXLUMIQUALITY_ET',bxlumiquality_et)])
2246 bulkvalues.append([(
'DATA_ID',data_id),(
'RUNNUM',runnumber),(
'LUMILSNUM',lumilsnum),(
'CMSLSNUM',cmslsnum),(
'INSTLUMI',instlumi),(
'INSTLUMIERROR',instlumierror),(
'INSTLUMIQUALITY',instlumiquality),(
'BEAMSTATUS',beamstatus),(
'BEAMENERGY',beamenergy),(
'NUMORBIT',numorbit),(
'STARTORBIT',startorbit)])
2250 print(
'committing lumi in LS chunck ',nrows)
2252 session.transaction().
start(
False)
2253 db.bulkInsert(tableName,lslumiDefDict,bulkvalues)
2254 session.transaction().commit()
2257 elif committedrows==len(lumilsdata):
2258 print(
'committing lumi at the end ')
2260 session.transaction().
start(
False)
2261 db.bulkInsert(tableName,lslumiDefDict,bulkvalues)
2262 session.transaction().commit()
2330 if __name__ ==
"__main__":
2331 from .
import sessionManager
2332 from .
import lumidbDDL,revisionDML,generateDummyData
2334 myconstr=
'oracle://devdb10/cms_xiezhen_dev' 2336 session=svc.openSession(isReadOnly=
False,cpp2sqltype=[(
'unsigned int',
'NUMBER(10)'),(
'unsigned long long',
'NUMBER(20)')])
2337 schema=session.nominalSchema()
2338 session.transaction().
start(
False)
2354 normbranchinfo=(normbranchid,
'NORM')
2355 addNormToBranch(schema,
'pp7TeV',
'PROTPHYS',6370.0,3500,{},normbranchinfo)
2358 branchinfo=(branchid,
'DATA')
2359 for runnum
in [1200,1211,1222,1233,1345]:
2365 lumirundata=[lumidummydata[0]]
2366 lumilsdata=lumidummydata[1]
2368 insertLumiLSSummary(schema,runnum,lumidataid,lumilsdata)
2370 trgrundata=[trgdata[0],trgdata[1],trgdata[2]]
2371 trglsdata=trgdata[3]
2373 insertTrgLSData(schema,runnum,trgdataid,trglsdata)
2375 hltrundata=[hltdata[0],hltdata[1]]
2376 hltlsdata=hltdata[2]
2378 insertHltLSData(schema,runnum,hltdataid,hltlsdata)
2379 session.transaction().commit()
2380 print(
'test reading')
2381 session.transaction().
start(
True)
2382 print(
'===inspecting NORM by name===')
2386 print(
'latest norm data_id for pp7TeV ',latestNorms)
2388 print(
'===inspecting DATA branch===')
2394 print(
'latest lumi data_id for run 1211 ',latestrevision)
2397 print(
'latest lumi data_id for run 1222 ',latestrevision)
2400 print(
'latest trg data_id for run 1222 ',latestrevision)
2401 session.transaction().commit()
2402 print(
'tagging data so far as data_orig')
2403 session.transaction().
start(
False)
2405 session.transaction().commit()
2406 session.transaction().
start(
True)
2410 session.transaction().commit()
2411 session.transaction().
start(
False)
2412 for runnum
in [1200,1222]:
2413 print(
'revising lumidata for run ',runnum)
2415 lumirundata=[lumidummydata[0]]
2416 lumilsdata=lumidummydata[1]
2418 insertLumiLSSummary(schema,runnum,lumidataid,lumilsdata)
2421 session.transaction().commit()
2424 print(
'===test reading===')
2425 session.transaction().
start(
True)
2447 print(
'trg run, trgdataid ',trgdataid)
2455 session.transaction().commit()
def revisionsInBranchName(schema, branchname)
def dropTables(schema, tablelist)
def guessnormIdByContext(schema, amodetag, egev1)
def guessDataIdForRange(schema, inputRange, tablename)
def runList(schema, datatagid, runmin=None, runmax=None, fillmin=None, fillmax=None, startT=None, stopT=None, l1keyPattern=None, hltkeyPattern=None, amodetag=None, nominalEnergy=None, energyFlut=0.2, requiretrg=True, requirehlt=True, preselectedruns=None, lumitype=None)
def luminormById(schema, dataid)
def lumicorrById(schema, correctiondataid)
def insertRunSummaryData(schema, runnumber, runsummarydata, complementalOnly=False)
def lumiRunById(schema, lumidataid, lumitype='HF')
def insertTrgHltMap(schema, hltkey, trghltmap)
def beamstatusByIds(schema, dataidMap)
def lumisummaryv2TableName()
def addTrgRunDataToBranch(schema, runnumber, trgrundata, branchinfo)
def latestdataIdByEntry(schema, entryid, datatype, branchfilter)
def trgRunById(schema, dataid, trgbitname=None, trgbitnamepattern=None)
def revisionsInBranch(schema, branchid)
def runsummary(schema, amodetag, egev)
def revisionsInTag(schema, tagrevisionid, branchid)
def unpackBlobtoArray(iblob, itemtypecode)
def hltRunById(schema, dataid, hltpathname=None, hltpathpattern=None)
def pixeltagRunsTableName()
def guessDataIdByRun(schema, runnum, tablename, revfilter=None)
S & print(S &os, JobReport::InputFile const &f)
def bulkInsertTrgLSData(session, runnumber, data_id, trglsdata, bulksize=500)
def lumiLSById(schema, dataid, beamstatus=None, withBXInfo=False, bxAlgo='OCC1', withBeamIntensity=False, tableName=None)
def addEntry(schema, datatableName, entryinfo, branchinfo)
def entryTableName(dataTableName)
def intglumiForRange(schema, runlist)
def addNormToBranch(schema, normname, amodetag, norm1, egev1, optionalnormdata, branchinfo)
def entryInBranch(schema, datatableName, entryname, branch)
def guessLumiDataIdByRunInBranch(schema, runnum, tablename, branchName)
def addLumiRunDataToBranch(schema, runnumber, lumirundata, branchinfo, tableName)
def lumiSummary(schema, nlumils)
def bulkInsertHltLSData(session, runnumber, data_id, hltlsdata, bulksize=500)
def bookNewRevision(schema, datatableName)
def bulkInsertLumiLSSummary(session, runnumber, data_id, lumilsdata, tableName, bulksize=500, withDetails=True)
def revmapTableName(dataTableName)
def bookNewEntry(schema, datatableName)
def lumiBXByAlgo(schema, dataid, algoname)
def addRevision(schema, datatableName, revisioninfo, branchinfo)
def fillrunMap(schema, fillnum=None, runmin=None, runmax=None, startT=None, stopT=None, l1keyPattern=None, hltkeyPattern=None, amodetag=None)
def lumiRunByIds(schema, dataidMap, lumitype='HF')
def addCorrToBranch(schema, corrname, a1, optionalcorrdata, branchinfo)
def hltLSById(schema, dataid, hltpathname=None, hltpathpattern=None, withL1Pass=False, withHLTAccept=False)
def guesscorrIdByName(schema, tagname=None)
LumiDB DML API # # Author: Zhen Xie #.
def trgLSById(schema, dataid, trgbitname=None, trgbitnamepattern=None, withL1Count=False, withPrescale=False)
static std::string join(char **cmd)
def branchInfoByName(schema, branchName)
def hlttrgMappingByrun(schema, runnum, hltpathname=None, hltpathpattern=None)
def intglumiv2TableName()
def runsummary(schema, runnum, sessionflavor='')
def allfillschemes(schema)
def dataentryIdByRun(schema, runnum, branchfilter)
def fillschemeTableName()
char data[epos_bytes_allocation]
def beamInfoById(schema, dataid, withBeamIntensity=False, minIntensity=0.1)
def fillInRange(schema, fillmin, fillmax, amodetag, startT, stopT)
def cmsrunsummaryTableName()
def pixellumidataTableName()
def guessnormIdByName(schema, normname)
def guessHltDataIdByRunInBranch(schema, runnum, tablename, branchName)
def createBranch(schema, name, parentname, comment='')
def addHLTRunDataToBranch(schema, runnumber, hltrundata, branchinfo)
def branchType(schema, name)
def fillschemePatternMap(schema, lumitype)
def guessTrgDataIdByRunInBranch(schema, runnum, tablename, branchName)
def latestDataRevisionOfEntry(schema, datatableName, entry, revrange)