1 from __future__
import print_function
2 import os,coral,fnmatch,time
3 from RecoLuminosity.LumiDB
import nameDealer,dbUtil,revisionDML,lumiTime,CommonUtil,lumiCorrections
4 from datetime
import datetime
19 select data_id from lumicorrectionss [where entry_name=:tagname] 20 result lumicorrectionsdataid 25 qHandle=schema.newQuery()
27 qHandle.addToTableList( nameDealer.lumicorrectionsTableName() )
28 qHandle.addToOutputList(
'DATA_ID')
30 qConditionStr=
'ENTRY_NAME=:tagname ' 31 qCondition=coral.AttributeList()
32 qCondition.extend(
'tagname',
'string')
33 qCondition[
'tagname'].setData(tagname)
34 qResult=coral.AttributeList()
35 qResult.extend(
'DATA_ID',
'unsigned long long')
36 qHandle.defineOutput(qResult)
38 qHandle.setCondition(qConditionStr,qCondition)
39 cursor=qHandle.execute()
41 dataid=cursor.currentRow()[
'DATA_ID'].
data()
42 lumicorrectionids.append(dataid)
47 if len(lumicorrectionids) !=0:
return max(lumicorrectionids)
52 select entry_name,a1,a2,drift from lumicorrections where DATA_ID=:dataid 53 output: {tagname:(data_id(0),a1(1),a2(2),driftcoeff(3))} 56 qHandle=schema.newQuery()
58 qHandle.addToTableList(nameDealer.lumicorrectionsTableName())
59 qHandle.addToOutputList(
'ENTRY_NAME')
60 qHandle.addToOutputList(
'A1')
61 qHandle.addToOutputList(
'A2')
62 qHandle.addToOutputList(
'DRIFT')
63 qCondition=coral.AttributeList()
64 qCondition.extend(
'dataid',
'unsigned long long')
65 qCondition[
'dataid'].setData(correctiondataid)
66 qResult=coral.AttributeList()
67 qResult.extend(
'ENTRY_NAME',
'string')
68 qResult.extend(
'A1',
'float')
69 qResult.extend(
'A2',
'float')
70 qResult.extend(
'DRIFT',
'float')
71 qHandle.defineOutput(qResult)
72 qHandle.setCondition(
'DATA_ID=:dataid',qCondition)
73 cursor=qHandle.execute()
75 tagname=cursor.currentRow()[
'ENTRY_NAME'].
data()
76 a1=cursor.currentRow()[
'A1'].
data()
78 if cursor.currentRow()[
'A2'].
data():
79 a2=cursor.currentRow()[
'A2'].
data()
81 if cursor.currentRow()[
'DRIFT'].
data():
82 drift=cursor.currentRow()[
'DRIFT'].
data()
83 result={tagname:(correctiondataid,a1,a2,drift)}
90 def fillInRange(schema,fillmin,fillmax,amodetag,startT,stopT):
92 select fillnum,runnum,starttime from cmsrunsummary where [where fillnum>=:fillmin and fillnum<=:fillmax and amodetag=:amodetag] 97 qHandle=schema.newQuery()
101 qHandle.addToTableList(r)
104 qCondition=coral.AttributeList()
106 qConditionPieces.append(
'FILLNUM>=:fillmin')
107 qCondition.extend(
'fillmin',
'unsigned int')
108 qCondition[
'fillmin'].setData(
int(fillmin))
110 qConditionPieces.append(
'FILLNUM<=:fillmax')
111 qCondition.extend(
'fillmax',
'unsigned int')
112 qCondition[
'fillmax'].setData(
int(fillmax))
114 qConditionPieces.append(
'AMODETAG=:amodetag')
115 qCondition.extend(
'amodetag',
'string')
116 qCondition[
'amodetag'].setData(amodetag)
117 if len(qConditionPieces)!=0:
118 qConditionStr=(
' AND ').
join(qConditionPieces)
119 qResult=coral.AttributeList()
120 qResult.extend(
'fillnum',
'unsigned int')
121 qResult.extend(
'runnum',
'unsigned int')
122 qResult.extend(
'starttime',
'string')
123 qHandle.defineOutput(qResult)
124 if len(qConditionStr)!=0:
125 qHandle.setCondition(qConditionStr,qCondition)
126 qHandle.addToOutputList(
'FILLNUM',
'fillnum')
127 qHandle.addToOutputList(
'RUNNUM',
'runnum')
128 qHandle.addToOutputList(
'TO_CHAR('+r+
'.STARTTIME,\'MM/DD/YY HH24:MI:SS\')',
'starttime')
129 cursor=qHandle.execute()
131 currentfill=cursor.currentRow()[
'fillnum'].
data()
132 runnum=cursor.currentRow()[
'runnum'].
data()
133 starttimeStr=cursor.currentRow()[
'starttime'].
data()
134 runTime=lute.StrToDatetime(starttimeStr,customfm=
'%m/%d/%y %H:%M:%S')
138 minTime=lute.StrToDatetime(startT,customfm=
'%m/%d/%y %H:%M:%S')
139 maxTime=lute.StrToDatetime(stopT,customfm=
'%m/%d/%y %H:%M:%S')
140 if runTime>=minTime
and runTime<=maxTime:
141 tmpresult.setdefault(currentfill,[]).
append(runnum)
142 elif startT
is not None:
143 minTime=lute.StrToDatetime(startT,customfm=
'%m/%d/%y %H:%M:%S')
145 tmpresult.setdefault(currentfill,[]).
append(runnum)
146 elif stopT
is not None:
147 maxTime=lute.StrToDatetime(stopT,customfm=
'%m/%d/%y %H:%M:%S')
149 tmpresult.setdefault(currentfill,[]).
append(runnum)
151 tmpresult.setdefault(currentfill,[]).
append(runnum)
153 for f
in sorted(tmpresult):
161 def fillrunMap(schema,fillnum=None,runmin=None,runmax=None,startT=None,stopT=None,l1keyPattern=None,hltkeyPattern=None,amodetag=None):
163 select fillnum,runnum,starttime from cmsrunsummary [where fillnum=:fillnum and runnum>=runmin and runnum<=runmax and amodetag=:amodetag ] 164 output: {fill:[runnum,...]} 168 qHandle=schema.newQuery()
172 qHandle.addToTableList(r)
175 qCondition=coral.AttributeList()
177 qConditionPieces.append(
'FILLNUM=:fillnum')
178 qCondition.extend(
'fillnum',
'unsigned int')
179 qCondition[
'fillnum'].setData(
int(fillnum))
181 qConditionPieces.append(
'RUNNUM>=:runmin')
182 qCondition.extend(
'runmin',
'unsigned int')
183 qCondition[
'runmin'].setData(runmin)
185 qConditionPieces.append(
'RUNNUM<=:runmax')
186 qCondition.extend(
'runmax',
'unsigned int')
187 qCondition[
'runmax'].setData(runmax)
189 qConditionPieces.append(
'AMODETAG=:amodetag')
190 qCondition.extend(
'amodetag',
'string')
191 qCondition[
'amodetag'].setData(amodetag)
193 qConditionPieces.append(
'regexp_like(L1KEY,:l1keypattern)')
194 qCondition.extend(
'l1keypattern',
'string')
195 qCondition[
'l1keypattern'].setData(l1keyPattern)
197 qConditionPieces.append(
'regexp_like(HLTKEY,:hltkeypattern)')
198 qCondition.extend(
'hltkeypattern',
'string')
199 qCondition[
'hltkeypattern'].setData(hltkeyPattern)
200 if len(qConditionPieces)!=0:
201 qConditionStr=(
' AND ').
join(qConditionPieces)
202 qResult=coral.AttributeList()
203 qResult.extend(
'fillnum',
'unsigned int')
204 qResult.extend(
'runnum',
'unsigned int')
205 qResult.extend(
'starttime',
'string')
206 qHandle.defineOutput(qResult)
207 if len(qConditionStr) !=0:
208 qHandle.setCondition(qConditionStr,qCondition)
209 qHandle.addToOutputList(
'FILLNUM',
'fillnum')
210 qHandle.addToOutputList(
'RUNNUM',
'runnum')
211 qHandle.addToOutputList(
'TO_CHAR('+r+
'.STARTTIME,\'MM/DD/YY HH24:MI:SS\')',
'starttime')
212 cursor=qHandle.execute()
214 currentfill=cursor.currentRow()[
'fillnum'].
data()
215 starttimeStr=cursor.currentRow()[
'starttime'].
data()
216 runnum=cursor.currentRow()[
'runnum'].
data()
217 runTime=lute.StrToDatetime(starttimeStr,customfm=
'%m/%d/%y %H:%M:%S')
221 minTime=lute.StrToDatetime(startT,customfm=
'%m/%d/%y %H:%M:%S')
222 maxTime=lute.StrToDatetime(stopT,customfm=
'%m/%d/%y %H:%M:%S')
223 if runTime>=minTime
and runTime<=maxTime:
224 result.setdefault(currentfill,[]).
append(runnum)
225 elif startT
is not None:
226 minTime=lute.StrToDatetime(startT,customfm=
'%m/%d/%y %H:%M:%S')
228 result.setdefault(currentfill,[]).
append(runnum)
229 elif stopT
is not None:
230 maxTime=lute.StrToDatetime(stopT,customfm=
'%m/%d/%y %H:%M:%S')
232 result.setdefault(currentfill,[]).
append(runnum)
234 result.setdefault(currentfill,[]).
append(runnum)
241 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):
243 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 244 output: {runnum:[lumiid,trgid,hltid]} 247 if lumitype
not in [
'HF',
'PIXEL']:
248 raise ValueError(
'unknown lumitype '+lumitype)
254 elif lumitype ==
'PIXEL':
258 assert False,
"ERROR Unknown lumitype '%s'" % lumitype
261 qHandle=schema.newQuery()
269 qHandle.addToTableList(r)
270 qHandle.addToTableList(l)
271 qHandle.addToTableList(tag)
272 qConditionStr=r+
'.RUNNUM='+l+
'.RUNNUM AND '+tag+
'.RUNNUM='+l+
'.RUNNUM AND '+tag+
'.TAGID<=:tagid' 273 qCondition=coral.AttributeList()
274 qCondition.extend(
'tagid',
'unsigned long long')
275 qCondition[
'tagid'].setData(datatagid)
282 if runmin
and runmax :
284 qConditionStr+=
' AND '+r+
'.RUNNUM=:runmin' 285 qCondition.extend(
'runmin',
'unsigned int')
286 qCondition[
'runmin'].setData(
int(runmin))
288 qConditionStr+=
' AND '+r+
'.RUNNUM>=:runmin AND '+r+
'.RUNNUM<=:runmax' 289 qCondition.extend(
'runmin',
'unsigned int')
290 qCondition.extend(
'runmax',
'unsigned int')
291 qCondition[
'runmin'].setData(
int(runmin))
292 qCondition[
'runmax'].setData(
int(runmax))
294 raise 'runmin > runmax' 296 qConditionStr+=
' AND '+r+
'.RUNNUM>=:runmin' 297 qCondition.extend(
'runmin',
'unsigned int')
298 qCondition[
'runmin'].setData(
int(runmin))
300 qConditionStr+=
' AND '+r+
'.RUNNUM<=:runmax' 301 qCondition.extend(
'runmax',
'unsigned int')
302 qCondition[
'runmax'].setData(
int(runmax))
305 if fillmin
and fillmax:
307 qConditionStr+=
' AND '+r+
'.FILLNUM=:fillnum' 308 qCondition.extend(
'fillnum',
'unsigned int')
309 qCondition[
'fillnum'].setData(
int(fillmin))
310 elif fillmax>fillmin:
311 qConditionStr+=
' AND '+r+
'.FILLNUM>=:fillmin AND '+r+
'.FILLNUM<=:fillmax' 312 qCondition.extend(
'fillmin',
'unsigned int')
313 qCondition.extend(
'fillmax',
'unsigned int')
314 qCondition[
'fillmin'].setData(
int(fillmin))
315 qCondition[
'fillmax'].setData(
int(fillmax))
317 raise 'fillmin > fillmax' 319 qConditionStr+=
' AND '+r+
'.AMODETAG=:amodetag' 320 qCondition.extend(
'amodetag',
'string')
321 qCondition[
'amodetag'].setData(amodetag)
323 qHandle.addToTableList(t)
324 qConditionStr+=
' AND regexp_like('+r+
'.L1KEY,:l1keypattern )'+
' AND '+l+
'.RUNNUM='+t+
'.RUNNUM' 325 qCondition.extend(
'l1keypattern',
'string')
326 qCondition[
'l1keypattern'].setData(l1keyPattern)
328 qHandle.addToTableList(h)
329 qConditionStr+=
' AND regexp_like('+r+
'.HLTKEY,:hltkeypattern)'+
' AND '+l+
'.RUNNUM='+h+
'.RUNNUM' 330 qCondition.extend(
'hltkeypattern',
'string')
331 qCondition[
'hltkeypattern'].setData(hltkeyPattern)
333 emin=nominalEnergy*(1.0-energyFlut)
334 emax=nominalEnergy*(1.0+energyFlut)
335 qConditionStr+=
' AND '+l+
'.NOMINALEGEV>=:emin and '+l+
'.NOMINALEGEV<=:emax' 336 qCondition.extend(
'emin',
'float')
337 qCondition.extend(
'emax',
'float')
338 qCondition[
'emin'].setData(emin)
339 qCondition[
'emax'].setData(emax)
340 qResult=coral.AttributeList()
341 qResult.extend(
'runnum',
'unsigned int')
342 qResult.extend(
'starttime',
'string')
343 qResult.extend(
'stoptime',
'string')
344 qResult.extend(
'lumiid',
'unsigned long long')
346 qResult.extend(
'trgid',
'unsigned long long')
348 qResult.extend(
'hltid',
'unsigned long long')
349 qHandle.setCondition(qConditionStr,qCondition)
350 qHandle.addToOutputList(r+
'.RUNNUM',
'runnum')
351 qHandle.addToOutputList(
'TO_CHAR('+l+
'.STARTTIME,\'MM/DD/YY HH24:MI:SS\')',
'starttime')
352 qHandle.addToOutputList(
'TO_CHAR('+l+
'.STOPTIME,\'MM/DD/YY HH24:MI:SS\')',
'stoptime')
353 qHandle.addToOutputList(l+
'.DATA_ID',
'lumiid')
359 qHandle.addToOutputList(tag+
'.TRGDATAID',
'trgid')
361 qHandle.addToOutputList(tag+
'.HLTDATAID',
'hltid')
362 qHandle.defineOutput(qResult)
363 cursor=qHandle.execute()
368 runnum=cursor.currentRow()[
'runnum'].
data()
369 if preselectedruns
and runnum
not in preselectedruns:
371 if cursor.currentRow()[
'starttime'].isNull():
373 if cursor.currentRow()[
'stoptime'].isNull():
375 starttimeStr=cursor.currentRow()[
'starttime'].
data()
376 stoptimeStr=cursor.currentRow()[
'stoptime'].
data()
377 runstartTime=lute.StrToDatetime(starttimeStr,customfm=
'%m/%d/%y %H:%M:%S')
378 runstopTime=lute.StrToDatetime(stoptimeStr,customfm=
'%m/%d/%y %H:%M:%S')
379 minTime=datetime(2010,1,1,0,0,0,0)
380 maxTime=datetime.now()
382 minTime=lute.StrToDatetime(startT,customfm=
'%m/%d/%y %H:%M:%S')
383 maxTime=lute.StrToDatetime(stopT,customfm=
'%m/%d/%y %H:%M:%S')
384 if not (runstopTime>=minTime
and runstartTime<=maxTime):
386 elif startT
is not None:
387 minTime=lute.StrToDatetime(startT,customfm=
'%m/%d/%y %H:%M:%S')
388 if not (runstopTime>=minTime):
390 elif stopT
is not None:
391 maxTime=lute.StrToDatetime(stopT,customfm=
'%m/%d/%y %H:%M:%S')
392 runTime=lute.StrToDatetime(starttimeStr,customfm=
'%m/%d/%y %H:%M:%S')
393 if not (runTime<=maxTime):
397 if not cursor.currentRow()[
'lumiid'].isNull():
398 lumiid=cursor.currentRow()[
'lumiid'].
data()
400 if lumiid>result[runnum][0]:
401 result[runnum][0]=lumiid
403 result[runnum]=[lumiid,0,0]
405 if cursor.currentRow()[
'trgid'].isNull():
408 trgid=cursor.currentRow()[
'trgid'].
data()
410 if trgid>result[runnum][1]:
411 result[runnum][1]=trgid
412 if requirehlt
and not cursor.currentRow()[
'hltid'].isNull():
413 hltid=cursor.currentRow()[
'hltid'].
data()
415 if hltid>result[runnum][2]:
416 result[runnum][2]=hltid
425 select l1key,amodetag,hltkey,fillnum,fillscheme from cmsrunsummary where runnum=:runnum 426 output: [l1key(0),amodetag(1),hltkey(3),fillnum(4),fillscheme(5)] 429 qHandle=schema.newQuery()
433 qCondition=coral.AttributeList()
434 qCondition.extend(
'runnum',
'unsigned int')
435 qCondition[
'runnum'].setData(
int(runnum))
436 qHandle.addToOutputList(
'L1KEY',
'l1key')
437 qHandle.addToOutputList(
'AMODETAG',
'amodetag')
439 qHandle.addToOutputList(
'HLTKEY',
'hltkey')
440 qHandle.addToOutputList(
'FILLNUM',
'fillnum')
441 qHandle.addToOutputList(
'FILLSCHEME',
'fillscheme')
448 qHandle.setCondition(
'RUNNUM=:runnum',qCondition)
449 qResult=coral.AttributeList()
450 qResult.extend(
'l1key',
'string')
451 qResult.extend(
'amodetag',
'string')
453 qResult.extend(
'hltkey',
'string')
454 qResult.extend(
'fillnum',
'unsigned int')
455 qResult.extend(
'fillscheme',
'string')
458 qHandle.defineOutput(qResult)
459 cursor=qHandle.execute()
461 result.append(cursor.currentRow()[
'l1key'].
data())
462 result.append(cursor.currentRow()[
'amodetag'].
data())
464 result.append(cursor.currentRow()[
'hltkey'].
data())
465 result.append(cursor.currentRow()[
'fillnum'].
data())
467 if not cursor.currentRow()[
'fillscheme'].isNull():
468 fillscheme=cursor.currentRow()[
'fillscheme'].
data()
469 result.append(fillscheme)
558 select entry_name,amodetag,norm_1,egev_1,norm_2,egev_2 from luminorms where DATA_ID=:dataid 559 output: {norm_name:(amodetag(0),norm_1(1),egev_1(2),norm_occ2(3),norm_et(4),norm_pu(5),constfactor(6))} 562 qHandle=schema.newQuery()
565 qHandle.addToOutputList(
'ENTRY_NAME',
'normname')
566 qHandle.addToOutputList(
'AMODETAG',
'amodetag')
567 qHandle.addToOutputList(
'NORM_1',
'norm_1')
568 qHandle.addToOutputList(
'EGEV_1',
'energy_1')
569 qHandle.addToOutputList(
'NORM_OCC2',
'norm_occ2')
570 qHandle.addToOutputList(
'NORM_ET',
'norm_et')
571 qHandle.addToOutputList(
'NORM_PU',
'norm_pu')
572 qHandle.addToOutputList(
'CONSTFACTOR',
'constfactor')
573 qCondition=coral.AttributeList()
574 qCondition.extend(
'dataid',
'unsigned long long')
575 qCondition[
'dataid'].setData(dataid)
576 qResult=coral.AttributeList()
577 qResult.extend(
'normname',
'string')
578 qResult.extend(
'amodetag',
'string')
579 qResult.extend(
'norm_1',
'float')
580 qResult.extend(
'energy_1',
'unsigned int')
581 qResult.extend(
'norm_occ2',
'float')
582 qResult.extend(
'norm_et',
'float')
583 qResult.extend(
'norm_pu',
'float')
584 qResult.extend(
'constfactor',
'float')
585 qHandle.defineOutput(qResult)
586 qHandle.setCondition(
'DATA_ID=:dataid',qCondition)
587 cursor=qHandle.execute()
589 normname=cursor.currentRow()[
'normname'].
data()
590 amodetag=cursor.currentRow()[
'amodetag'].
data()
591 norm_1=cursor.currentRow()[
'norm_1'].
data()
592 energy_1=cursor.currentRow()[
'energy_1'].
data()
594 if cursor.currentRow()[
'norm_occ2'].
data():
595 norm_occ2=cursor.currentRow()[
'norm_occ2'].
data()
597 if cursor.currentRow()[
'norm_et'].
data():
598 norm_et=cursor.currentRow()[
'norm_et'].
data()
600 if cursor.currentRow()[
'norm_pu'].
data():
601 norm_pu=cursor.currentRow()[
'norm_pu'].
data()
603 if cursor.currentRow()[
'constfactor'].
data():
604 constfactor=cursor.currentRow()[
'constfactor'].
data()
605 result={normname:(amodetag,norm_1,energy_1,norm_occ2,norm_et,norm_pu,constfactor)}
676 select entry_name,amodetag,norm_1,egev_1,norm_2,egev_2 from luminorms where DATA_ID=:dataid 677 result (normname(0),amodetag(1),egev(2),norm(3),norm_occ2(4),norm_et(5),norm_pu(6),constfactor(7)) 680 qHandle=schema.newQuery()
683 qHandle.addToOutputList(
'ENTRY_NAME',
'normname')
684 qHandle.addToOutputList(
'AMODETAG',
'amodetag')
685 qHandle.addToOutputList(
'NORM_1',
'norm_1')
686 qHandle.addToOutputList(
'EGEV_1',
'energy_1')
687 qHandle.addToOutputList(
'NORM_OCC2',
'norm_occ2')
688 qHandle.addToOutputList(
'NORM_ET',
'norm_et')
689 qHandle.addToOutputList(
'NORM_PU',
'norm_pu')
690 qHandle.addToOutputList(
'CONSTFACTOR',
'constfactor')
691 qCondition=coral.AttributeList()
692 qCondition.extend(
'dataid',
'unsigned long long')
693 qCondition[
'dataid'].setData(dataid)
694 qResult=coral.AttributeList()
695 qResult.extend(
'normname',
'string')
696 qResult.extend(
'amodetag',
'string')
697 qResult.extend(
'norm_1',
'float')
698 qResult.extend(
'energy_1',
'unsigned int')
699 qResult.extend(
'norm_occ2',
'float')
700 qResult.extend(
'norm_et',
'float')
701 qResult.extend(
'norm_pu',
'float')
702 qResult.extend(
'constfactor',
'float')
703 qHandle.defineOutput(qResult)
704 qHandle.setCondition(
'DATA_ID=:dataid',qCondition)
705 cursor=qHandle.execute()
707 normname=cursor.currentRow()[
'normname'].
data()
708 amodetag=cursor.currentRow()[
'amodetag'].
data()
709 norm_1=cursor.currentRow()[
'norm_1'].
data()
710 energy_1=cursor.currentRow()[
'energy_1'].
data()
712 if cursor.currentRow()[
'norm_occ2'].
data():
713 norm_occ2=cursor.currentRow()[
'norm_occ2'].
data()
715 if cursor.currentRow()[
'norm_et'].
data():
716 norm_et=cursor.currentRow()[
'norm_et'].
data()
718 if cursor.currentRow()[
'norm_pu'].
data():
719 norm_pu=cursor.currentRow()[
'norm_pu'].
data()
721 if cursor.currentRow()[
'constfactor'].
data():
722 constfactor=cursor.currentRow()[
'constfactor'].
data()
723 result={normname:(amodetag,norm_1,energy_1,norm_occ2,norm_et,norm_pu,constfactor)}
730 def trgRunById(schema,dataid,trgbitname=None,trgbitnamepattern=None):
732 query: select RUNNUM,SOURCE,BITZERONAME,BITNAMECLOB,ALGOMASK_H,ALGOMASK_L,TECHMASK from trgdata where DATA_ID=:dataid 734 output: [runnum(0),datasource(1),bitzeroname(2),bitnamedict(3),algomask_h(4),algomask_l(5),techmask(6)] 736 -- original source database name 737 -- deadtime norm bitname 738 -- bitnamedict [(bitidx,bitname),...] 741 qHandle=schema.newQuery()
748 qHandle.addToOutputList(
'RUNNUM',
'runnum')
749 qHandle.addToOutputList(
'SOURCE',
'source')
750 qHandle.addToOutputList(
'BITZERONAME',
'bitzeroname')
751 qHandle.addToOutputList(
'BITNAMECLOB',
'bitnameclob')
752 qHandle.addToOutputList(
'ALGOMASK_H',
'algomask_h')
753 qHandle.addToOutputList(
'ALGOMASK_L',
'algomask_l')
754 qHandle.addToOutputList(
'TECHMASK',
'techmask')
755 qCondition=coral.AttributeList()
756 qCondition.extend(
'dataid',
'unsigned long long')
757 qCondition[
'dataid'].setData(dataid)
758 qResult=coral.AttributeList()
759 qResult.extend(
'runnum',
'unsigned int')
760 qResult.extend(
'source',
'string')
761 qResult.extend(
'bitzeroname',
'string')
762 qResult.extend(
'bitnameclob',
'string')
763 qResult.extend(
'algomask_h',
'unsigned long long')
764 qResult.extend(
'algomask_l',
'unsigned long long')
765 qResult.extend(
'techmask',
'unsigned long long')
766 qHandle.defineOutput(qResult)
767 qHandle.setCondition(
'DATA_ID=:dataid',qCondition)
768 cursor=qHandle.execute()
772 runnum=cursor.currentRow()[
'runnum'].
data()
773 source=cursor.currentRow()[
'source'].
data()
774 bitzeroname=cursor.currentRow()[
'bitzeroname'].
data()
775 bitnameclob=cursor.currentRow()[
'bitnameclob'].
data()
776 algomask_h=cursor.currentRow()[
'algomask_h'].
data()
777 algomask_l=cursor.currentRow()[
'algomask_l'].
data()
778 techmask=cursor.currentRow()[
'techmask'].
data()
780 bitnames=bitnameclob.split(
',')
781 for trgnameidx,trgname
in enumerate(bitnames):
783 if trgname==trgbitname:
784 bitnamedict.append((trgnameidx,trgname))
786 elif trgbitnamepattern:
787 if fnmatch.fnmatch(trgname,trgbitnamepattern):
788 bitnamedict.append((trgnameidx,trgname))
790 bitnamedict.append((trgnameidx,trgname))
791 result=[runnum,source,bitzeroname,bitnamedict,algomask_h,algomask_l,techmask]
798 def trgLSById(schema,dataid,trgbitname=None,trgbitnamepattern=None,withL1Count=False,withPrescale=False):
800 output: (runnum,{cmslsnum:[deadtimecount(0),bitzerocount(1),bitzeroprescale(2),deadfrac(3),[(bitname,trgcount,prescale,mask)](4)]}) 805 if trgbitname
or trgbitnamepattern
or withPrescale
or withL1Count:
806 trgrundata=
trgRunById(schema,dataid,trgbitname=trgbitname,trgbitnamepattern=trgbitnamepattern)
807 trgnamedict=trgrundata[3]
808 algomask_h=trgrundata[4]
809 algomask_l=trgrundata[5]
810 techmask=trgrundata[6]
811 qHandle=schema.newQuery()
814 qHandle.addToOutputList(
'RUNNUM',
'runnum')
815 qHandle.addToOutputList(
'CMSLSNUM',
'cmslsnum')
816 qHandle.addToOutputList(
'DEADTIMECOUNT',
'deadtimecount')
819 qHandle.addToOutputList(
'DEADFRAC',
'deadfrac')
821 qHandle.addToOutputList(
'PRESCALEBLOB',
'prescalesblob')
823 qHandle.addToOutputList(
'TRGCOUNTBLOB',
'trgcountblob')
824 qConditionStr=
'DATA_ID=:dataid' 825 qCondition=coral.AttributeList()
826 qCondition.extend(
'dataid',
'unsigned long long')
827 qCondition[
'dataid'].setData(dataid)
828 qResult=coral.AttributeList()
829 qResult.extend(
'runnum',
'unsigned int')
830 qResult.extend(
'cmslsnum',
'unsigned int')
831 qResult.extend(
'deadtimecount',
'unsigned long long')
834 qResult.extend(
'deadfrac',
'float')
836 qResult.extend(
'prescalesblob',
'blob')
838 qResult.extend(
'trgcountblob',
'blob')
839 qHandle.defineOutput(qResult)
840 qHandle.setCondition(qConditionStr,qCondition)
841 cursor=qHandle.execute()
843 runnum=cursor.currentRow()[
'runnum'].
data()
844 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
845 deadtimecount=cursor.currentRow()[
'deadtimecount'].
data()
850 deadfrac=cursor.currentRow()[
'deadfrac'].
data()
851 if cmslsnum
not in result:
853 result[cmslsnum].
append(deadtimecount)
854 result[cmslsnum].
append(bitzerocount)
855 result[cmslsnum].
append(bitzeroprescale)
856 result[cmslsnum].
append(deadfrac)
860 prescalesblob=cursor.currentRow()[
'prescalesblob'].
data()
862 trgcountblob=cursor.currentRow()[
'trgcountblob'].
data()
877 for (bitidx,thisbitname)
in trgnamedict:
881 thispresc=prescales[bitidx]
883 thistrgcount=trgcounts[bitidx]
886 if bitidx
in range(0,128):
888 maskval=algomask_l>>bitidx&1
890 maskval=algomask_h>>(bitidx-64)&1
893 maskval=techmask>>(bitidx-128)&1
894 thisbitinfo=(thisbitname,thistrgcount,thispresc,maskval)
895 bitinfo.append(thisbitinfo)
896 result[cmslsnum].
append(bitinfo)
903 return (runnum,result)
907 input dataidMap : {run:lumidataid} 908 result {runnum: (datasource(0),nominalegev(1),ncollidingbunches(2),starttime(3),stoptime(4),nls(5)} 913 inputRange=dataidMap.keys()
915 lumidataid=dataidMap[r][0]
917 perrundata=
lumiRunById(schema,lumidataid,lumitype=lumitype)
918 result[r]=(perrundata[1],perrundata[2],perrundata[3],perrundata[4],perrundata[5])
923 input dataidMap : {run:lumidataid} 924 result {runnum:{cmslsnum:beamstatus}} 929 inputRange=dataidMap.keys()
933 lumidataid=dataidMap[r][0]
935 qHandle=schema.newQuery()
938 qHandle.addToOutputList(
'CMSLSNUM')
939 qHandle.addToOutputList(
'BEAMSTATUS')
940 qConditionStr=
'DATA_ID=:dataid' 941 qCondition=coral.AttributeList()
942 qCondition.extend(
'dataid',
'unsigned long long')
943 qCondition[
'dataid'].setData(
int(lumidataid))
944 qResult=coral.AttributeList()
945 qResult.extend(
'CMSLSNUM',
'unsigned int')
946 qResult.extend(
'BEAMSTATUS',
'string')
947 qHandle.defineOutput(qResult)
948 qHandle.setCondition(qConditionStr,qCondition)
949 cursor=qHandle.execute()
951 cmslsnum=cursor.currentRow()[
'CMSLSNUM'].
data()
952 bs=cursor.currentRow()[
'BEAMSTATUS'].
data()
953 if bs!=
'STABLE BEAMS':
954 result[r][cmslsnum]=bs
964 output: (runnum(0),datasource(1),nominalegev(2),ncollidingbunches(3),starttimestr(4),stoptimestr(5),nls(6)) 967 if lumitype
not in [
'HF',
'PIXEL']:
968 raise ValueError(
'unknown lumitype '+lumitype)
974 qHandle=schema.newQuery()
976 qHandle.addToTableList(lumitableName)
977 qHandle.addToOutputList(
'RUNNUM')
978 qHandle.addToOutputList(
'SOURCE')
979 qHandle.addToOutputList(
'NOMINALEGEV')
980 qHandle.addToOutputList(
'NCOLLIDINGBUNCHES')
981 qHandle.addToOutputList(
'TO_CHAR('+lumitableName+
'.STARTTIME,\'MM/DD/YY HH24:MI:SS\')',
'startT')
982 qHandle.addToOutputList(
'TO_CHAR('+lumitableName+
'.STOPTIME,\'MM/DD/YY HH24:MI:SS\')',
'stopT')
983 qHandle.addToOutputList(
'NLS')
984 qConditionStr=
'DATA_ID=:dataid' 985 qCondition=coral.AttributeList()
986 qCondition.extend(
'dataid',
'unsigned long long')
987 qCondition[
'dataid'].setData(lumidataid)
988 qResult=coral.AttributeList()
989 qResult.extend(
'RUNNUM',
'unsigned int')
990 qResult.extend(
'SOURCE',
'string')
991 qResult.extend(
'NOMINALEGEV',
'float')
992 qResult.extend(
'NCOLLIDINGBUNCHES',
'unsigned int')
993 qResult.extend(
'startT',
'string')
994 qResult.extend(
'stopT',
'string')
995 qResult.extend(
'NLS',
'unsigned int')
996 qHandle.defineOutput(qResult)
997 qHandle.setCondition(qConditionStr,qCondition)
998 cursor=qHandle.execute()
1002 runnum=cursor.currentRow()[
'RUNNUM'].
data()
1003 datasource=cursor.currentRow()[
'SOURCE'].
data()
1005 if not cursor.currentRow()[
'NOMINALEGEV'].isNull():
1006 nominalegev=cursor.currentRow()[
'NOMINALEGEV'].
data()
1008 if not cursor.currentRow()[
'NCOLLIDINGBUNCHES'].isNull():
1009 ncollidingbunches=cursor.currentRow()[
'NCOLLIDINGBUNCHES'].
data()
1010 startTstr=cursor.currentRow()[
'startT'].
data()
1011 stopTstr=cursor.currentRow()[
'stopT'].
data()
1014 if not cursor.currentRow()[
'NLS'].isNull():
1015 nls=cursor.currentRow()[
'NLS'].
data()
1016 result=(runnum,datasource,nominalegev,ncollidingbunches,startTstr,stopTstr,nls)
1068 qHandle.addToTableList(s)
1069 qResult=coral.AttributeList()
1070 qResult.extend(
'FILLSCHEMEPATTERN',
'string')
1071 qResult.extend(
'CORRECTIONFACTOR',
'float')
1072 qHandle.defineOutput(qResult)
1073 qHandle.addToOutputList(
'FILLSCHEMEPATTERN')
1074 qHandle.addToOutputList(
'CORRECTIONFACTOR')
1075 cursor=qHandle.execute()
1077 fillschemePattern=cursor.currentRow()[
'FILLSCHEMEPATTERN'].
data()
1078 afterglowfac=cursor.currentRow()[
'CORRECTIONFACTOR'].
data()
1079 afterglows.append((fillschemePattern,afterglowfac))
1086 def lumiLSById(schema,dataid,beamstatus=None,withBXInfo=False,bxAlgo='OCC1',withBeamIntensity=False,tableName=None):
1089 beamstatus: filter on beam status flag 1091 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)]}) 1095 qHandle=schema.newQuery()
1096 if withBXInfo
and bxAlgo
not in [
'OCC1',
'OCC2',
'ET']:
1097 raise ValueError(
'unknown lumi algo '+bxAlgo)
1098 if beamstatus
and beamstatus
not in [
'STABLE BEAMS',]:
1099 raise ValueError(
'unknown beam status '+beamstatus)
1101 if tableName
is None:
1105 qHandle.addToTableList(lls)
1106 qHandle.addToOutputList(
'RUNNUM',
'runnum')
1107 qHandle.addToOutputList(
'LUMILSNUM',
'lumilsnum')
1108 qHandle.addToOutputList(
'CMSLSNUM',
'cmslsnum')
1109 qHandle.addToOutputList(
'INSTLUMI',
'instlumi')
1110 qHandle.addToOutputList(
'INSTLUMIERROR',
'instlumierr')
1111 qHandle.addToOutputList(
'INSTLUMIQUALITY',
'instlumiqlty')
1112 qHandle.addToOutputList(
'BEAMSTATUS',
'beamstatus')
1113 qHandle.addToOutputList(
'BEAMENERGY',
'beamenergy')
1114 qHandle.addToOutputList(
'NUMORBIT',
'numorbit')
1115 qHandle.addToOutputList(
'STARTORBIT',
'startorbit')
1117 qHandle.addToOutputList(
'BXLUMIVALUE_'+bxAlgo,
'bxvalue')
1118 qHandle.addToOutputList(
'BXLUMIERROR_'+bxAlgo,
'bxerror')
1119 if withBeamIntensity:
1120 qHandle.addToOutputList(
'CMSBXINDEXBLOB',
'bxindexblob')
1121 qHandle.addToOutputList(
'BEAMINTENSITYBLOB_1',
'beam1intensity')
1122 qHandle.addToOutputList(
'BEAMINTENSITYBLOB_2',
'beam2intensity')
1124 qConditionStr=
'DATA_ID=:dataid' 1125 qCondition=coral.AttributeList()
1126 qCondition.extend(
'dataid',
'unsigned long long')
1127 qCondition[
'dataid'].setData(
int(dataid))
1129 qConditionStr+=
' and BEAMSTATUS=:beamstatus' 1130 qCondition.extend(
'beamstatus',
'string')
1131 qCondition[
'beamstatus'].setData(beamstatus)
1132 qResult=coral.AttributeList()
1133 qResult.extend(
'runnum',
'unsigned int')
1134 qResult.extend(
'lumilsnum',
'unsigned int')
1135 qResult.extend(
'cmslsnum',
'unsigned int')
1136 qResult.extend(
'instlumi',
'float')
1137 qResult.extend(
'instlumierr',
'float')
1138 qResult.extend(
'instlumiqlty',
'short')
1139 qResult.extend(
'beamstatus',
'string')
1140 qResult.extend(
'beamenergy',
'float')
1141 qResult.extend(
'numorbit',
'unsigned int')
1142 qResult.extend(
'startorbit',
'unsigned int')
1144 qResult.extend(
'bxvalue',
'blob')
1145 qResult.extend(
'bxerror',
'blob')
1146 if withBeamIntensity:
1147 qResult.extend(
'bxindexblob',
'blob')
1148 qResult.extend(
'beam1intensity',
'blob')
1149 qResult.extend(
'beam2intensity',
'blob')
1150 qHandle.defineOutput(qResult)
1151 qHandle.setCondition(qConditionStr,qCondition)
1152 cursor=qHandle.execute()
1154 runnum=cursor.currentRow()[
'runnum'].
data()
1155 lumilsnum=cursor.currentRow()[
'lumilsnum'].
data()
1156 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
1157 instlumi=cursor.currentRow()[
'instlumi'].
data()
1158 instlumierr=cursor.currentRow()[
'instlumierr'].
data()
1159 instlumiqlty=cursor.currentRow()[
'instlumiqlty'].
data()
1160 bs=cursor.currentRow()[
'beamstatus'].
data()
1161 begev=cursor.currentRow()[
'beamenergy'].
data()
1162 numorbit=cursor.currentRow()[
'numorbit'].
data()
1163 startorbit=cursor.currentRow()[
'startorbit'].
data()
1168 bxvalueblob=cursor.currentRow()[
'bxvalue'].
data()
1169 bxerrblob=cursor.currentRow()[
'bxerror'].
data()
1170 if bxvalueblob
and bxerrblob:
1173 bxinfo=(bxvaluesArray,bxerrArray)
1178 if withBeamIntensity:
1179 bxindexblob=cursor.currentRow()[
'bxindexblob'].
data()
1180 beam1intensity=cursor.currentRow()[
'beam1intensity'].
data()
1181 beam2intensity=cursor.currentRow()[
'beam2intensity'].
data()
1186 beaminfo=(bxindexArray,beam1intensityArray,beam2intensityArray)
1187 result[lumilsnum]=[cmslsnum,instlumi,instlumierr,instlumiqlty,bs,begev,numorbit,startorbit,bxinfo,beaminfo]
1192 return (runnum,result)
1195 result (runnum,[(lumilsnum(0),cmslsnum(1),beamstatus(2),beamenergy(3),ncollidingbunches(4),beaminfolist(5),..]) 1196 beaminfolist=[(bxidx,beam1intensity,beam2intensity)] 1201 qHandle=schema.newQuery()
1204 qHandle.addToOutputList(
'NCOLLIDINGBUNCHES')
1205 qConditionStr=
'DATA_ID=:dataid' 1206 qCondition=coral.AttributeList()
1207 qCondition.extend(
'dataid',
'unsigned long long')
1208 qCondition[
'dataid'].setData(dataid)
1209 qResult=coral.AttributeList()
1210 qResult.extend(
'NCOLLIDINGBUNCHES',
'unsigned int')
1211 qHandle.defineOutput(qResult)
1212 qHandle.setCondition(qConditionStr,qCondition)
1213 cursor=qHandle.execute()
1215 ncollidingbunches=cursor.currentRow()[
'NCOLLIDINGBUNCHES'].
data()
1220 qHandle=schema.newQuery()
1223 qHandle.addToOutputList(
'RUNNUM')
1224 qHandle.addToOutputList(
'CMSLSNUM')
1225 qHandle.addToOutputList(
'LUMILSNUM')
1226 qHandle.addToOutputList(
'BEAMSTATUS')
1227 qHandle.addToOutputList(
'BEAMENERGY')
1228 if withBeamIntensity:
1229 qHandle.addToOutputList(
'CMSBXINDEXBLOB')
1230 qHandle.addToOutputList(
'BEAMINTENSITYBLOB_1')
1231 qHandle.addToOutputList(
'BEAMINTENSITYBLOB_2')
1232 qConditionStr=
'DATA_ID=:dataid' 1233 qCondition=coral.AttributeList()
1234 qCondition.extend(
'dataid',
'unsigned long long')
1235 qCondition[
'dataid'].setData(dataid)
1236 qResult=coral.AttributeList()
1237 qResult.extend(
'RUNNUM',
'unsigned int')
1238 qResult.extend(
'CMSLSNUM',
'unsigned int')
1239 qResult.extend(
'LUMILSNUM',
'unsigned int')
1240 qResult.extend(
'BEAMSTATUS',
'string')
1241 qResult.extend(
'BEAMENERGY',
'float')
1242 if withBeamIntensity:
1243 qResult.extend(
'BXINDEXBLOB',
'blob')
1244 qResult.extend(
'BEAM1INTENSITY',
'blob')
1245 qResult.extend(
'BEAM2INTENSITY',
'blob')
1246 qHandle.defineOutput(qResult)
1247 qHandle.setCondition(qConditionStr,qCondition)
1248 cursor=qHandle.execute()
1250 runnum=cursor.currentRow()[
'RUNNUM'].
data()
1251 cmslsnum=cursor.currentRow()[
'CMSLSNUM'].
data()
1252 lumilsnum=cursor.currentRow()[
'LUMILSNUM'].
data()
1253 beamstatus=cursor.currentRow()[
'BEAMSTATUS'].
data()
1254 beamenergy=cursor.currentRow()[
'BEAMENERGY'].
data()
1256 beaminfotupleList=[]
1257 if withBeamIntensity:
1258 bxindexblob=cursor.currentRow()[
'BXINDEXBLOB'].
data()
1259 beam1intensityblob=cursor.currentRow()[
'BEAM1INTENSITY'].
data()
1260 beam2intensityblob=cursor.currentRow()[
'BEAM2INTENSITY'].
data()
1262 beam1intensityArray=
None 1263 beam2intensityArray=
None 1266 if beam1intensityblob:
1268 if beam2intensityblob:
1270 if bxindexArray
and beam1intensityArray
and beam2intensityArray:
1271 for idx,bxindex
in enumerate(bxindexArray):
1272 if (beam1intensityArray[idx]
and beam1intensityArray[idx]>minIntensity)
or (beam2intensityArray[idx]
and beam2intensityArray[idx]>minIntensity):
1273 beaminfotuple=(bxindex,beam1intensityArray[idx],beam2intensityArray[idx])
1274 beaminfotupleList.append(beaminfotuple)
1276 del beam1intensityArray[:]
1277 del beam2intensityArray[:]
1278 result.append((lumilsnum,cmslsnum,beamstatus,beamenergy,ncollidingbunches,beaminfotupleList))
1283 return (runnum,result)
1286 result {lumilsnum:[cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty]} 1289 qHandle=schema.newQuery()
1292 qHandle.addToOutputList(
'CMSLSNUM',
'cmslsnum')
1293 qHandle.addToOutputList(
'LUMILSNUM',
'lumilsnum')
1295 qHandle.addToOutputList(
'NUMORBIT',
'numorbit')
1296 qHandle.addToOutputList(
'STARTORBIT',
'startorbit')
1297 qHandle.addToOutputList(
'BXLUMIVALUE_'+algoname,
'bxlumivalue')
1298 qHandle.addToOutputList(
'BXLUMIERROR_'+algoname,
'bxlumierr')
1299 qHandle.addToOutputList(
'BXLUMIQUALITY_'+algoname,
'bxlumiqlty')
1300 qConditionStr=
'DATA_ID=:dataid' 1301 qCondition=coral.AttributeList()
1302 qCondition.extend(
'dataid',
'unsigned long long')
1303 qCondition[
'dataid'].setData(dataid)
1304 qResult=coral.AttributeList()
1305 qResult.extend(
'cmslsnum',
'unsigned int')
1306 qResult.extend(
'lumilsnum',
'unsigned int')
1307 qResult.extend(
'numorbit',
'unsigned int')
1308 qResult.extend(
'startorbit',
'unsigned int')
1309 qResult.extend(
'bxlumivalue',
'blob')
1310 qResult.extend(
'bxlumierr',
'blob')
1311 qResult.extend(
'bxlumiqlty',
'blob')
1312 qHandle.defineOutput(qResult)
1313 qHandle.setCondition(qConditionStr,qCondition)
1314 cursor=qHandle.execute()
1316 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
1317 lumilsnum=cursor.currentRow()[
'lumilsnum'].
data()
1318 numorbit=cursor.currentRow()[
'numorbit'].
data()
1319 startorbit=cursor.currentRow()[
'startorbit'].
data()
1320 bxlumivalue=cursor.currentRow()[
'bxlumivalue'].
data()
1321 bxlumierr=cursor.currentRow()[
'bxlumierr'].
data()
1322 bxlumiqlty=cursor.currentRow()[
'bxlumiqlty'].
data()
1323 if algoname
not in result:
1325 if lumilsnum
not in result[algoname]:
1326 result[algoname][lumilsnum]=[]
1327 result[algoname][lumilsnum].extend([cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty])
1330 raise RuntimeError(
' dataDML.lumiBXById: '+
str(e))
1334 def hltRunById(schema,dataid,hltpathname=None,hltpathpattern=None):
1336 result [runnum(0),datasource(1),npath(2),hltnamedict(3)] 1338 npath : total number of hltpath in DB 1339 hltnamedict : list of all selected paths [(hltpathidx,hltname),(hltpathidx,hltname)] 1342 qHandle=schema.newQuery()
1349 qHandle.addToOutputList(
'RUNNUM',
'runnum')
1350 qHandle.addToOutputList(
'SOURCE',
'datasource')
1351 qHandle.addToOutputList(
'NPATH',
'npath')
1352 qHandle.addToOutputList(
'PATHNAMECLOB',
'pathnameclob')
1353 qConditionStr=
'DATA_ID=:dataid' 1354 qCondition=coral.AttributeList()
1355 qCondition.extend(
'dataid',
'unsigned long long')
1356 qCondition[
'dataid'].setData(dataid)
1357 qResult=coral.AttributeList()
1358 qResult.extend(
'runnum',
'unsigned int')
1359 qResult.extend(
'datasource',
'string')
1360 qResult.extend(
'npath',
'unsigned int')
1361 qResult.extend(
'pathnameclob',
'string')
1362 qHandle.defineOutput(qResult)
1363 qHandle.setCondition(qConditionStr,qCondition)
1364 cursor=qHandle.execute()
1368 runnum=cursor.currentRow()[
'runnum'].
data()
1369 datasource=cursor.currentRow()[
'datasource'].
data()
1370 npath=cursor.currentRow()[
'npath'].
data()
1371 pathnameclob=cursor.currentRow()[
'pathnameclob'].
data()
1373 pathnames=pathnameclob.split(
',')
1374 for pathnameidx,hltname
in enumerate(pathnames):
1376 if hltpathname==hltname:
1377 hltnamedict.append((pathnameidx,hltname))
1379 elif hltpathpattern:
1380 if fnmatch.fnmatch(hltname,hltpathpattern):
1381 hltnamedict.append((pathnameidx,hltname))
1384 result=[runnum,datasource,npath,hltnamedict]
1393 select m.hltpathname,m.l1seed from cmsrunsummary r,trghltmap m where r.runnum=:runnum and m.hltkey=r.hltkey and [m.hltpathname=:hltpathname] 1394 output: {hltpath:l1seed} 1397 queryHandle=schema.newQuery()
1400 if hltpathpattern
and hltpathpattern
in [
'*',
'all',
'All',
'ALL']:
1403 queryHandle.addToTableList(r)
1404 queryHandle.addToTableList(m)
1405 queryCondition=coral.AttributeList()
1406 queryCondition.extend(
'runnum',
'unsigned int')
1407 queryCondition[
'runnum'].setData(
int(runnum))
1409 queryHandle.addToOutputList(m+
'.HLTPATHNAME',
'hltpathname')
1410 queryHandle.addToOutputList(m+
'.L1SEED',
'l1seed')
1411 conditionStr=r+
'.RUNNUM=:runnum and '+m+
'.HLTKEY='+r+
'.HLTKEY' 1414 conditionStr+=
' AND '+m+
'.HLTPATHNAME=:hltpathname' 1415 queryCondition.extend(
'hltpathname',
'string')
1416 queryCondition[
'hltpathname'].setData(hltpathname)
1417 queryHandle.setCondition(conditionStr,queryCondition)
1418 queryResult=coral.AttributeList()
1419 queryResult.extend(
'pname',
'string')
1420 queryResult.extend(
'l1seed',
'string')
1421 queryHandle.defineOutput(queryResult)
1422 cursor=queryHandle.execute()
1424 pname=cursor.currentRow()[
'pname'].
data()
1425 l1seed=cursor.currentRow()[
'l1seed'].
data()
1426 if hltpathname
not in result:
1428 if fnmatch.fnmatch(pname,hltpathpattern):
1429 result[pname]=l1seed
1431 result[pname]=l1seed
1438 def hltLSById(schema,dataid,hltpathname=None,hltpathpattern=None,withL1Pass=False,withHLTAccept=False):
1440 result (runnum, {cmslsnum:[(pathname,prescale,1lpass,hltaccept)](0)]} 1445 hltrundata=
hltRunById(schema,dataid,hltpathname=hltpathname,hltpathpattern=hltpathpattern)
1448 hltnamedict=hltrundata[3]
1450 return (hltrundata[0],{})
1454 qHandle=schema.newQuery()
1457 qHandle.addToOutputList(
'RUNNUM',
'runnum')
1458 qHandle.addToOutputList(
'CMSLSNUM',
'cmslsnum')
1459 if len(hltnamedict)!=0:
1460 qHandle.addToOutputList(
'PRESCALEBLOB',
'prescaleblob')
1462 qHandle.addToOutputList(
'HLTCOUNTBLOB',
'hltcountblob')
1464 qHandle.addToOutputList(
'HLTACCEPTBLOB',
'hltacceptblob')
1465 qConditionStr=
'DATA_ID=:dataid' 1466 qCondition=coral.AttributeList()
1467 qCondition.extend(
'dataid',
'unsigned long long')
1468 qCondition[
'dataid'].setData(dataid)
1469 qResult=coral.AttributeList()
1470 qResult.extend(
'runnum',
'unsigned int')
1471 qResult.extend(
'cmslsnum',
'unsigned int')
1472 if len(hltnamedict)!=0:
1473 qResult.extend(
'prescaleblob',
'blob')
1475 qResult.extend(
'hltcountblob',
'blob')
1477 qResult.extend(
'hltacceptblob',
'blob')
1478 qHandle.defineOutput(qResult)
1479 qHandle.setCondition(qConditionStr,qCondition)
1480 cursor=qHandle.execute()
1482 runnum=cursor.currentRow()[
'runnum'].
data()
1483 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
1487 if len(hltnamedict)!=0:
1488 prescaleblob=cursor.currentRow()[
'prescaleblob'].
data()
1490 hltcountblob=cursor.currentRow()[
'hltcountblob'].
data()
1492 hltacceptblob=cursor.currentRow()[
'hltacceptblob'].
data()
1493 if cmslsnum
not in result:
1514 for (hltpathidx,thispathname)
in hltnamedict:
1519 thispresc=prescales[hltpathidx]
1521 thishltcount=hltcounts[hltpathidx]
1523 thisaccept=hltaccepts[hltpathidx]
1524 thispathinfo=(thispathname,thispresc,thishltcount,thisaccept)
1525 pathinfo.append(thispathinfo)
1526 result[cmslsnum]=pathinfo
1535 return (runnum,result)
1539 output: {run:intglumi_in_fb} 1546 qHandle=schema.newQuery()
1549 qResult=coral.AttributeList()
1550 qResult.extend(
'RUNNUM',
'unsigned int')
1551 qResult.extend(
'INTGLUMI',
'float')
1552 qConditionStr=
'RUNNUM>=:minrun AND RUNNUM<=:maxrun' 1553 qCondition=coral.AttributeList()
1554 qCondition.extend(
'minrun',
'unsigned int')
1555 qCondition.extend(
'maxrun',
'unsigned int')
1556 qCondition[
'minrun'].setData(minrun)
1557 qCondition[
'maxrun'].setData(maxrun)
1558 qHandle.addToOutputList(
'RUNNUM')
1559 qHandle.addToOutputList(
'INTGLUMI')
1560 qHandle.setCondition(qConditionStr,qCondition)
1561 qHandle.defineOutput(qResult)
1562 cursor=qHandle.execute()
1564 runnum=cursor.currentRow()[
'RUNNUM'].
data()
1565 intglumi=cursor.currentRow()[
'INTGLUMI'].
data()
1566 result[runnum]=intglumi
1575 output:(patternStr:correctionFac) 1577 if lumitype
not in [
'PIXEL',
'HF']:
1578 raise ValueError(
'[ERROR] unsupported lumitype '+lumitype)
1579 correctorField=
'CORRECTIONFACTOR' 1580 if lumitype==
'PIXEL':
1581 correctorField=
'PIXELCORRECTIONFACTOR' 1583 qHandle=schema.newQuery()
1586 qResult=coral.AttributeList()
1587 qResult.extend(
'FILLSCHEMEPATTERN',
'string')
1588 qResult.extend(
'CORRECTIONFACTOR',
'float')
1589 qHandle.defineOutput(qResult)
1590 qHandle.addToOutputList(
'FILLSCHEMEPATTERN')
1591 qHandle.addToOutputList(correctorField)
1592 cursor=qHandle.execute()
1594 fillschemePattern=cursor.currentRow()[
'FILLSCHEMEPATTERN'].
data()
1595 afterglowfac=cursor.currentRow()[
'CORRECTIONFACTOR'].
data()
1596 result[fillschemePattern]=afterglowfac
1607 return latestrevision
1613 return latestrevision
1619 return latestrevision
1623 select max data_id of the given run. In current design, it's the most recent data of the run 1627 qHandle=schema.newQuery()
1629 qHandle.addToTableList(tablename)
1630 qHandle.addToOutputList(
'DATA_ID')
1631 qConditionStr=
'RUNNUM=:runnum ' 1632 qCondition=coral.AttributeList()
1633 qCondition.extend(
'runnum',
'unsigned int')
1634 qCondition[
'runnum'].setData(runnum)
1635 qResult=coral.AttributeList()
1636 qResult.extend(
'DATA_ID',
'unsigned long long')
1637 qHandle.defineOutput(qResult)
1638 qHandle.setCondition(qConditionStr,qCondition)
1639 cursor=qHandle.execute()
1641 dataid=cursor.currentRow()[
'DATA_ID'].
data()
1654 input: inputRange [run] 1655 output: {run:lumiid} 1656 select data_id,runnum from hltdata where runnum<=runmax and runnum>=:runmin 1659 if not inputRange :
return result
1660 if len(inputRange)==1:
1662 result[inputRange[0]]=trgid
1664 rmin=
min(inputRange)
1665 rmax=
max(inputRange)
1666 result=dict.fromkeys(inputRange,
None)
1667 qHandle=schema.newQuery()
1669 qHandle.addToTableList(tablename)
1670 qHandle.addToOutputList(
'DATA_ID')
1671 qHandle.addToOutputList(
'RUNNUM')
1672 qConditionStr=
'RUNNUM>=:rmin' 1673 qCondition=coral.AttributeList()
1674 qCondition.extend(
'rmin',
'unsigned int')
1675 qCondition[
'rmin'].setData(rmin)
1677 qConditionStr+=
' AND RUNNUM<=:rmax' 1678 qCondition.extend(
'rmax',
'unsigned int')
1679 qCondition[
'rmax'].setData(rmax)
1680 qResult=coral.AttributeList()
1681 qResult.extend(
'DATA_ID',
'unsigned long long')
1682 qResult.extend(
'RUNNUM',
'unsigned int')
1683 qHandle.defineOutput(qResult)
1684 qHandle.setCondition(qConditionStr,qCondition)
1685 cursor=qHandle.execute()
1687 dataid=cursor.currentRow()[
'DATA_ID'].
data()
1688 runnum=cursor.currentRow()[
'RUNNUM'].
data()
1689 if runnum
in result:
1690 if dataid>result[runnum]:
1691 result[runnum]=dataid
1742 get norm dataids by amodetag, egev if there are duplicates, pick max(dataid).Bypass full version lookups 1743 select data_id from luminorm where amodetag=:amodetag and egev_1=:egev1 1746 qHandle=schema.newQuery()
1751 qHandle.addToOutputList(
'DATA_ID',
'normdataid')
1752 qConditionStr=
'AMODETAG=:amodetag AND EGEV_1>=:egevmin AND EGEV_1<=:egevmax' 1753 qCondition=coral.AttributeList()
1754 qCondition.extend(
'amodetag',
'string')
1755 qCondition.extend(
'egevmin',
'unsigned int')
1756 qCondition.extend(
'egevmax',
'unsigned int')
1757 qCondition[
'amodetag'].setData(amodetag)
1758 qCondition[
'egevmin'].setData(
int(egevmin))
1759 qCondition[
'egevmax'].setData(
int(egevmax))
1760 qResult=coral.AttributeList()
1761 qResult.extend(
'normdataid',
'unsigned long long')
1762 qHandle.defineOutput(qResult)
1763 qHandle.setCondition(qConditionStr,qCondition)
1764 cursor=qHandle.execute()
1766 normdataid=cursor.currentRow()[
'normdataid'].
data()
1767 luminormids.append(normdataid)
1772 if len(luminormids) !=0:
return max(luminormids)
1777 get norm dataids by name, if there are duplicates, pick max(dataid).Bypass full version lookups 1778 select data_id from luminorms where entry_name=:normname 1779 result luminormdataid 1782 qHandle=schema.newQuery()
1785 qHandle.addToOutputList(
'DATA_ID',
'normdataid')
1786 qConditionStr=
'ENTRY_NAME=:normname ' 1787 qCondition=coral.AttributeList()
1788 qCondition.extend(
'normname',
'string')
1789 qCondition[
'normname'].setData(normname)
1790 qResult=coral.AttributeList()
1791 qResult.extend(
'normdataid',
'unsigned long long')
1792 qHandle.defineOutput(qResult)
1793 qHandle.setCondition(qConditionStr,qCondition)
1794 cursor=qHandle.execute()
1796 normdataid=cursor.currentRow()[
'normdataid'].
data()
1797 luminormids.append(normdataid)
1802 if len(luminormids) !=0:
return max(luminormids)
1809 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; 1812 return [lumientryid,trgentryid,hltentryid] 1815 qHandle=schema.newQuery()
1824 qCondition=coral.AttributeList()
1825 qCondition.extend(
'runnumstr',
'string')
1826 qCondition[
'runnumstr'].setData(
str(runnum))
1827 qResult=coral.AttributeList()
1828 qResult.extend(
'lumientryid',
'unsigned long long')
1829 qResult.extend(
'trgentryid',
'unsigned long long')
1830 qResult.extend(
'hltentryid',
'unsigned long long')
1831 qHandle.defineOutput(qResult)
1832 qHandle.setCondition(qConditionStr,qCondition)
1833 cursor=qHandle.execute()
1835 lumientryid=cursor.currentRow()[
'lumientryid'].
data()
1836 trgentryid=cursor.currentRow()[
'trgentryid'].
data()
1837 hltentryid=cursor.currentRow()[
'hltentryid'].
data()
1838 if lumientryid
in branchfilter
and trgentryid
in branchfilter
and hltentryid
in branchfilter:
1839 result.extend([lumientryid,trgentryid,hltentryid])
1848 select l.data_id,rl.revision_id from lumidatatable l,lumirevisions rl where l.data_id=rl.data_id and l.entry_id=:entryid 1849 check revision_id is in branch 1854 if datatype==
'lumi':
1856 elif datatype==
'trg':
1858 elif dataytpe==
'hlt':
1861 raise RunTimeError(
'datatype '+datatype+
' is not supported')
1863 qHandle=schema.newQuery()
1865 qHandle.addToTableList(revmaptablename)
1866 qHandle.addToTableList(datatablename)
1867 qHandle.addToOutputList(
'l.DATA_ID',
'dataid')
1868 qHandle.addToOutputList(revmaptablename+
'.REVISION_ID',
'revisionid')
1869 qConditionStr=datatablename+
'.DATA_ID='+revmaptablename+
'.DATA_ID AND '+datatablename+
'.ENTRY_ID=:entryid' 1870 qCondition=coral.AttributeList()
1871 qCondition.extend(
'entryid',
'unsigned long long')
1872 qResult=coral.AttributeList()
1873 qResult.extend(
'dataid',
'unsigned long long')
1874 qResult.extend(
'revisionid',
'unsigned long long')
1875 qHandle.defineOutput(qResult)
1876 qHandle.setCondition(qConditionStr,qCondition)
1877 cursor=qHandle.execute()
1879 dataid=cursor.currentRow()[
'dataid'].
data()
1880 revisionid=cursor.currentRow()[
'revisionid'].
data()
1881 if revisionid
in branchfilter:
1882 dataids.append(dataid)
1887 if len(dataids)!=0:
return max(dataids)
1897 branchinfo(normrevisionid,branchname) 1898 optionalnormdata {'norm_occ2':norm_occ2,'norm_et':norm_et,'norm_pu':norm_pu,'constfactor':constfactor} 1900 (revision_id,entry_id,data_id) 1904 if 'normOcc2' in optionalnormdata:
1905 norm_occ2=optionalnormdata[
'norm_occ2']
1907 if 'norm_et' in optionalnormdata:
1908 norm_et=optionalnormdata[
'norm_et']
1910 if 'norm_pu' in optionalnormdata:
1911 norm_pu=optionalnormdata[
'norm_pu']
1913 if 'constfactor' in optionalnormdata:
1914 constfactor=optionalnormdata[
'constfactor']
1917 if entry_id
is None:
1919 entryinfo=(revision_id,entry_id,normname,data_id)
1924 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'}
1925 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}
1928 return (revision_id,entry_id,data_id)
1935 branchinfo(corrrevisionid,branchname) 1936 optionalcorrdata {'a2':a2,'drift':drif} 1938 (revision_id,entry_id,data_id) 1941 if 'a2' in optionalcorrdata:
1942 a2=optionalcorrdata[
'a2']
1944 if 'drift' in optionalcorrdata:
1945 drift=optionalcorrdata[
'drift']
1948 if entry_id
is None:
1950 entryinfo=(revision_id,entry_id,corrname,data_id)
1955 tabrowDefDict={
'DATA_ID':
'unsigned long long',
'ENTRY_ID':
'unsigned long long',
'ENTRY_NAME':
'string',
'A1':
'float',
'A2':
'float',
'DRIFT':
'float'}
1956 tabrowValueDict={
'DATA_ID':data_id,
'ENTRY_ID':entry_id,
'ENTRY_NAME':corrname,
'A1':a1,
'A2':a2,
'DRIFT':drift}
1958 db.insertOneRow(nameDealer.lumicorrectionsTableName(),tabrowDefDict,tabrowValueDict)
1959 return (revision_id,entry_id,data_id)
1966 lumirundata [datasource,nominalenergy,ncollidingbunches,starttime,stoptime,nls] 1967 branchinfo (branch_id,branch_name) 1968 tableName lumiruntablename 1970 (revision_id,entry_id,data_id) 1973 datasource=lumirundata[0]
1976 starttime=coral.TimeStamp()
1977 stoptime=coral.TimeStamp()
1979 if len(lumirundata)>1:
1980 nominalenergy=lumirundata[1]
1981 ncollidingbunches=lumirundata[2]
1982 starttime=lumirundata[3]
1983 stoptime=lumirundata[4]
1986 if entry_id
is None:
1988 entryinfo=(revision_id,entry_id,
str(runnumber),data_id)
1994 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'}
1995 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}
1997 db.insertOneRow(tableName,tabrowDefDict,tabrowValueDict)
1998 return (revision_id,entry_id,data_id)
2005 trgrundata [datasource(0),bitzeroname(1),bitnameclob(2)] 2006 bitnames clob, bitnames separated by ',' 2008 (revision_id,entry_id,data_id) 2011 datasource=trgrundata[0]
2012 bitzeroname=trgrundata[1]
2013 bitnames=trgrundata[2]
2015 if entry_id
is None:
2017 entryinfo=(revision_id,entry_id,
str(runnumber),data_id)
2022 tabrowDefDict={
'DATA_ID':
'unsigned long long',
'ENTRY_ID':
'unsigned long long',
'ENTRY_NAME':
'string',
'SOURCE':
'string',
'RUNNUM':
'unsigned int',
'BITZERONAME':
'string',
'BITNAMECLOB':
'string'}
2023 tabrowValueDict={
'DATA_ID':data_id,
'ENTRY_ID':entry_id,
'ENTRY_NAME':
str(runnumber),
'SOURCE':datasource,
'RUNNUM':
int(runnumber),
'BITZERONAME':bitzeroname,
'BITNAMECLOB':bitnames}
2026 return (revision_id,entry_id,data_id)
2032 hltrundata [pathnameclob(0),datasource(1)] 2034 (revision_id,entry_id,data_id) 2037 pathnames=hltrundata[0]
2038 datasource=hltrundata[1]
2039 npath=len(pathnames.split(
','))
2041 if entry_id
is None:
2043 entryinfo=(revision_id,entry_id,
str(runnumber),data_id)
2048 tabrowDefDict={
'DATA_ID':
'unsigned long long',
'ENTRY_ID':
'unsigned long long',
'ENTRY_NAME':
'string',
'RUNNUM':
'unsigned int',
'SOURCE':
'string',
'NPATH':
'unsigned int',
'PATHNAMECLOB':
'string'}
2049 tabrowValueDict={
'DATA_ID':data_id,
'ENTRY_ID':entry_id,
'ENTRY_NAME':
str(runnumber),
'RUNNUM':
int(runnumber),
'SOURCE':datasource,
'NPATH':npath,
'PATHNAMECLOB':pathnames}
2052 return (revision_id,entry_id,data_id)
2059 runsummarydata [l1key,amodetag,egev,sequence,hltkey,fillnum,starttime,stoptime] 2062 l1key=runsummarydata[0]
2063 amodetag=runsummarydata[1]
2064 egev=runsummarydata[2]
2070 if not complementalOnly:
2071 sequence=runsummarydata[3]
2072 hltkey=runsummarydata[4]
2073 fillnum=runsummarydata[5]
2074 starttime=runsummarydata[6]
2075 stoptime=runsummarydata[7]
2077 if not complementalOnly:
2078 tabrowDefDict={
'RUNNUM':
'unsigned int',
'L1KEY':
'string',
'AMODETAG':
'string',
'EGEV':
'unsigned int',
'SEQUENCE':
'string',
'HLTKEY':
'string',
'FILLNUM':
'unsigned int',
'STARTTIME':
'time stamp',
'STOPTIME':
'time stamp'}
2079 tabrowValueDict={
'RUNNUM':
int(runnumber),
'L1KEY':l1key,
'AMODETAG':amodetag,
'EGEV':
int(egev),
'SEQUENCE':sequence,
'HLTKEY':hltkey,
'FILLNUM':
int(fillnum),
'STARTTIME':starttime,
'STOPTIME':stoptime}
2083 setClause=
'L1KEY=:l1key,AMODETAG=:amodetag,EGEV=:egev' 2084 updateCondition=
'RUNNUM=:runnum' 2085 inputData=coral.AttributeList()
2086 inputData.extend(
'l1key',
'string')
2087 inputData.extend(
'amodetag',
'string')
2088 inputData.extend(
'egev',
'unsigned int')
2089 inputData.extend(
'runnum',
'unsigned int')
2090 inputData[
'l1key'].setData(l1key)
2091 inputData[
'amodetag'].setData(amodetag)
2092 inputData[
'egev'].setData(
int(egev))
2093 inputData[
'runnum'].setData(
int(runnumber))
2101 trghltmap {hltpath:l1seed} 2107 kQueryBindList=coral.AttributeList()
2108 kQueryBindList.extend(
'hltkey',
'string')
2109 kQuery=schema.newQuery()
2111 kQuery.setCondition(
'HLTKEY=:hltkey',kQueryBindList)
2112 kQueryBindList[
'hltkey'].setData(hltkey)
2113 kResult=kQuery.execute()
2114 while next(kResult):
2116 if not hltkeyExists:
2118 trghltDefDict=[(
'HLTKEY',
'string'),(
'HLTPATHNAME',
'string'),(
'L1SEED',
'string')]
2119 for hltpath,l1seed
in trghltmap.items():
2120 bulkvalues.append([(
'HLTKEY',hltkey),(
'HLTPATHNAME',hltpath),(
'L1SEED',l1seed)])
2123 nrows=len(bulkvalues)
2126 print(
'error in insertTrgHltMap ')
2130 insert trg per-LS data for given run and data_id, this operation can be split in transaction chuncks 2132 trglsdata {cmslsnum:[deadtime,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]} 2133 result nrows inserted 2134 if nrows==0, then this insertion failed 2136 print(
'total number of trg rows ',len(trglsdata))
2137 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')]
2142 for cmslsnum,perlstrg
in trglsdata.items():
2143 deadtimecount=perlstrg[0]
2144 bitzerocount=perlstrg[1]
2145 bitzeroprescale=perlstrg[2]
2146 trgcountblob=perlstrg[3]
2147 trgprescaleblob=perlstrg[4]
2148 bulkvalues.append([(
'DATA_ID',data_id),(
'RUNNUM',runnumber),(
'CMSLSNUM',cmslsnum),(
'DEADTIMECOUNT',deadtimecount),(
'BITZEROCOUNT',bitzerocount),(
'BITZEROPRESCALE',bitzeroprescale),(
'PRESCALEBLOB',trgprescaleblob),(
'TRGCOUNTBLOB',trgcountblob)])
2152 print(
'committing trg in LS chunck ',nrows)
2154 session.transaction().
start(
False)
2156 session.transaction().commit()
2159 elif committedrows==len(trglsdata):
2160 print(
'committing trg at the end ')
2162 session.transaction().
start(
False)
2164 session.transaction().commit()
2166 print(
'error in bulkInsertTrgLSData')
2171 hltlsdata {cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]} 2173 print(
'total number of hlt rows ',len(hltlsdata))
2174 lshltDefDict=[(
'DATA_ID',
'unsigned long long'),(
'RUNNUM',
'unsigned int'),(
'CMSLSNUM',
'unsigned int'),(
'PRESCALEBLOB',
'blob'),(
'HLTCOUNTBLOB',
'blob'),(
'HLTACCEPTBLOB',
'blob')]
2179 for cmslsnum,perlshlt
in hltlsdata.items():
2180 inputcountblob=perlshlt[0]
2181 acceptcountblob=perlshlt[1]
2182 prescaleblob=perlshlt[2]
2183 bulkvalues.append([(
'DATA_ID',data_id),(
'RUNNUM',runnumber),(
'CMSLSNUM',cmslsnum),(
'PRESCALEBLOB',prescaleblob),(
'HLTCOUNTBLOB',inputcountblob),(
'HLTACCEPTBLOB',acceptcountblob)])
2188 print(
'committing hlt in LS chunck ',nrows)
2190 session.transaction().
start(
False)
2192 session.transaction().commit()
2195 elif committedrows==len(hltlsdata):
2196 print(
'committing hlt at the end ')
2198 session.transaction().
start(
False)
2200 session.transaction().commit()
2202 print(
'error in bulkInsertHltLSData')
2208 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]} 2212 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')]
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')]
2215 print(
'total number of lumi rows ',len(lumilsdata))
2220 for lumilsnum,perlslumi
in lumilsdata.items():
2221 cmslsnum=perlslumi[0]
2222 instlumi=perlslumi[1]
2223 instlumierror=perlslumi[2]
2224 instlumiquality=perlslumi[3]
2225 beamstatus=perlslumi[4]
2226 beamenergy=perlslumi[5]
2227 numorbit=perlslumi[6]
2228 startorbit=perlslumi[7]
2230 cmsbxindexindexblob=perlslumi[8]
2231 beam1intensity=perlslumi[9]
2232 beam2intensity=perlslumi[10]
2233 bxlumivalue_occ1=perlslumi[11]
2234 bxlumierror_occ1=perlslumi[12]
2235 bxlumiquality_occ1=perlslumi[13]
2236 bxlumivalue_occ2=perlslumi[14]
2237 bxlumierror_occ2=perlslumi[15]
2238 bxlumiquality_occ2=perlslumi[16]
2239 bxlumivalue_et=perlslumi[17]
2240 bxlumierror_et=perlslumi[18]
2241 bxlumiquality_et=perlslumi[19]
2242 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)])
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)])
2248 print(
'committing lumi in LS chunck ',nrows)
2250 session.transaction().
start(
False)
2251 db.bulkInsert(tableName,lslumiDefDict,bulkvalues)
2252 session.transaction().commit()
2255 elif committedrows==len(lumilsdata):
2256 print(
'committing lumi at the end ')
2258 session.transaction().
start(
False)
2259 db.bulkInsert(tableName,lslumiDefDict,bulkvalues)
2260 session.transaction().commit()
2328 if __name__ ==
"__main__":
2329 import sessionManager
2330 import lumidbDDL,revisionDML,generateDummyData
2332 myconstr=
'oracle://devdb10/cms_xiezhen_dev' 2334 session=svc.openSession(isReadOnly=
False,cpp2sqltype=[(
'unsigned int',
'NUMBER(10)'),(
'unsigned long long',
'NUMBER(20)')])
2335 schema=session.nominalSchema()
2336 session.transaction().
start(
False)
2352 normbranchinfo=(normbranchid,
'NORM')
2353 addNormToBranch(schema,
'pp7TeV',
'PROTPHYS',6370.0,3500,{},normbranchinfo)
2356 branchinfo=(branchid,
'DATA')
2357 for runnum
in [1200,1211,1222,1233,1345]:
2363 lumirundata=[lumidummydata[0]]
2364 lumilsdata=lumidummydata[1]
2366 insertLumiLSSummary(schema,runnum,lumidataid,lumilsdata)
2368 trgrundata=[trgdata[0],trgdata[1],trgdata[2]]
2369 trglsdata=trgdata[3]
2371 insertTrgLSData(schema,runnum,trgdataid,trglsdata)
2373 hltrundata=[hltdata[0],hltdata[1]]
2374 hltlsdata=hltdata[2]
2376 insertHltLSData(schema,runnum,hltdataid,hltlsdata)
2377 session.transaction().commit()
2378 print(
'test reading')
2379 session.transaction().
start(
True)
2380 print(
'===inspecting NORM by name===')
2384 print(
'latest norm data_id for pp7TeV ',latestNorms)
2386 print(
'===inspecting DATA branch===')
2392 print(
'latest lumi data_id for run 1211 ',latestrevision)
2395 print(
'latest lumi data_id for run 1222 ',latestrevision)
2398 print(
'latest trg data_id for run 1222 ',latestrevision)
2399 session.transaction().commit()
2400 print(
'tagging data so far as data_orig')
2401 session.transaction().
start(
False)
2403 session.transaction().commit()
2404 session.transaction().
start(
True)
2408 session.transaction().commit()
2409 session.transaction().
start(
False)
2410 for runnum
in [1200,1222]:
2411 print(
'revising lumidata for run ',runnum)
2413 lumirundata=[lumidummydata[0]]
2414 lumilsdata=lumidummydata[1]
2416 insertLumiLSSummary(schema,runnum,lumidataid,lumilsdata)
2419 session.transaction().commit()
2422 print(
'===test reading===')
2423 session.transaction().
start(
True)
2445 print(
'trg run, trgdataid ',trgdataid)
2453 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)