1 import os,coral,fnmatch,time
2 from RecoLuminosity.LumiDB
import nameDealer,dbUtil,revisionDML,lumiTime,CommonUtil,lumiCorrections
3 from datetime
import datetime
18 select data_id from lumicorrectionss [where entry_name=:tagname]
19 result lumicorrectionsdataid
24 qHandle=schema.newQuery()
26 qHandle.addToTableList( nameDealer.lumicorrectionsTableName() )
27 qHandle.addToOutputList(
'DATA_ID')
29 qConditionStr=
'ENTRY_NAME=:tagname '
30 qCondition=coral.AttributeList()
31 qCondition.extend(
'tagname',
'string')
32 qCondition[
'tagname'].setData(tagname)
33 qResult=coral.AttributeList()
34 qResult.extend(
'DATA_ID',
'unsigned long long')
35 qHandle.defineOutput(qResult)
37 qHandle.setCondition(qConditionStr,qCondition)
38 cursor=qHandle.execute()
40 dataid=cursor.currentRow()[
'DATA_ID'].
data()
41 lumicorrectionids.append(dataid)
46 if len(lumicorrectionids) !=0:
return max(lumicorrectionids)
51 select entry_name,a1,a2,drift from lumicorrections where DATA_ID=:dataid
52 output: {tagname:(data_id(0),a1(1),a2(2),driftcoeff(3))}
55 qHandle=schema.newQuery()
57 qHandle.addToTableList(nameDealer.lumicorrectionsTableName())
58 qHandle.addToOutputList(
'ENTRY_NAME')
59 qHandle.addToOutputList(
'A1')
60 qHandle.addToOutputList(
'A2')
61 qHandle.addToOutputList(
'DRIFT')
62 qCondition=coral.AttributeList()
63 qCondition.extend(
'dataid',
'unsigned long long')
64 qCondition[
'dataid'].setData(correctiondataid)
65 qResult=coral.AttributeList()
66 qResult.extend(
'ENTRY_NAME',
'string')
67 qResult.extend(
'A1',
'float')
68 qResult.extend(
'A2',
'float')
69 qResult.extend(
'DRIFT',
'float')
70 qHandle.defineOutput(qResult)
71 qHandle.setCondition(
'DATA_ID=:dataid',qCondition)
72 cursor=qHandle.execute()
74 tagname=cursor.currentRow()[
'ENTRY_NAME'].
data()
75 a1=cursor.currentRow()[
'A1'].
data()
77 if cursor.currentRow()[
'A2'].
data():
78 a2=cursor.currentRow()[
'A2'].
data()
80 if cursor.currentRow()[
'DRIFT'].
data():
81 drift=cursor.currentRow()[
'DRIFT'].
data()
82 result={tagname:(correctiondataid,a1,a2,drift)}
89 def fillInRange(schema,fillmin,fillmax,amodetag,startT,stopT):
91 select fillnum,runnum,starttime from cmsrunsummary where [where fillnum>=:fillmin and fillnum<=:fillmax and amodetag=:amodetag]
96 qHandle=schema.newQuery()
100 qHandle.addToTableList(r)
103 qCondition=coral.AttributeList()
105 qConditionPieces.append(
'FILLNUM>=:fillmin')
106 qCondition.extend(
'fillmin',
'unsigned int')
107 qCondition[
'fillmin'].setData(int(fillmin))
109 qConditionPieces.append(
'FILLNUM<=:fillmax')
110 qCondition.extend(
'fillmax',
'unsigned int')
111 qCondition[
'fillmax'].setData(int(fillmax))
113 qConditionPieces.append(
'AMODETAG=:amodetag')
114 qCondition.extend(
'amodetag',
'string')
115 qCondition[
'amodetag'].setData(amodetag)
116 if len(qConditionPieces)!=0:
117 qConditionStr=(
' AND ').
join(qConditionPieces)
118 qResult=coral.AttributeList()
119 qResult.extend(
'fillnum',
'unsigned int')
120 qResult.extend(
'runnum',
'unsigned int')
121 qResult.extend(
'starttime',
'string')
122 qHandle.defineOutput(qResult)
123 if len(qConditionStr)!=0:
124 qHandle.setCondition(qConditionStr,qCondition)
125 qHandle.addToOutputList(
'FILLNUM',
'fillnum')
126 qHandle.addToOutputList(
'RUNNUM',
'runnum')
127 qHandle.addToOutputList(
'TO_CHAR('+r+
'.STARTTIME,\'MM/DD/YY HH24:MI:SS\')',
'starttime')
128 cursor=qHandle.execute()
130 currentfill=cursor.currentRow()[
'fillnum'].
data()
131 runnum=cursor.currentRow()[
'runnum'].
data()
132 starttimeStr=cursor.currentRow()[
'starttime'].
data()
133 runTime=lute.StrToDatetime(starttimeStr,customfm=
'%m/%d/%y %H:%M:%S')
137 minTime=lute.StrToDatetime(startT,customfm=
'%m/%d/%y %H:%M:%S')
138 maxTime=lute.StrToDatetime(stopT,customfm=
'%m/%d/%y %H:%M:%S')
139 if runTime>=minTime
and runTime<=maxTime:
140 tmpresult.setdefault(currentfill,[]).
append(runnum)
141 elif startT
is not None:
142 minTime=lute.StrToDatetime(startT,customfm=
'%m/%d/%y %H:%M:%S')
144 tmpresult.setdefault(currentfill,[]).
append(runnum)
145 elif stopT
is not None:
146 maxTime=lute.StrToDatetime(stopT,customfm=
'%m/%d/%y %H:%M:%S')
148 tmpresult.setdefault(currentfill,[]).
append(runnum)
150 tmpresult.setdefault(currentfill,[]).
append(runnum)
152 for f
in sorted(tmpresult):
160 def fillrunMap(schema,fillnum=None,runmin=None,runmax=None,startT=None,stopT=None,l1keyPattern=None,hltkeyPattern=None,amodetag=None):
162 select fillnum,runnum,starttime from cmsrunsummary [where fillnum=:fillnum and runnum>=runmin and runnum<=runmax and amodetag=:amodetag ]
163 output: {fill:[runnum,...]}
167 qHandle=schema.newQuery()
171 qHandle.addToTableList(r)
174 qCondition=coral.AttributeList()
176 qConditionPieces.append(
'FILLNUM=:fillnum')
177 qCondition.extend(
'fillnum',
'unsigned int')
178 qCondition[
'fillnum'].setData(int(fillnum))
180 qConditionPieces.append(
'RUNNUM>=:runmin')
181 qCondition.extend(
'runmin',
'unsigned int')
182 qCondition[
'runmin'].setData(runmin)
184 qConditionPieces.append(
'RUNNUM<=:runmax')
185 qCondition.extend(
'runmax',
'unsigned int')
186 qCondition[
'runmax'].setData(runmax)
188 qConditionPieces.append(
'AMODETAG=:amodetag')
189 qCondition.extend(
'amodetag',
'string')
190 qCondition[
'amodetag'].setData(amodetag)
192 qConditionPieces.append(
'regexp_like(L1KEY,:l1keypattern)')
193 qCondition.extend(
'l1keypattern',
'string')
194 qCondition[
'l1keypattern'].setData(l1keyPattern)
196 qConditionPieces.append(
'regexp_like(HLTKEY,:hltkeypattern)')
197 qCondition.extend(
'hltkeypattern',
'string')
198 qCondition[
'hltkeypattern'].setData(hltkeyPattern)
199 if len(qConditionPieces)!=0:
200 qConditionStr=(
' AND ').
join(qConditionPieces)
201 qResult=coral.AttributeList()
202 qResult.extend(
'fillnum',
'unsigned int')
203 qResult.extend(
'runnum',
'unsigned int')
204 qResult.extend(
'starttime',
'string')
205 qHandle.defineOutput(qResult)
206 if len(qConditionStr) !=0:
207 qHandle.setCondition(qConditionStr,qCondition)
208 qHandle.addToOutputList(
'FILLNUM',
'fillnum')
209 qHandle.addToOutputList(
'RUNNUM',
'runnum')
210 qHandle.addToOutputList(
'TO_CHAR('+r+
'.STARTTIME,\'MM/DD/YY HH24:MI:SS\')',
'starttime')
211 cursor=qHandle.execute()
213 currentfill=cursor.currentRow()[
'fillnum'].
data()
214 starttimeStr=cursor.currentRow()[
'starttime'].
data()
215 runnum=cursor.currentRow()[
'runnum'].
data()
216 runTime=lute.StrToDatetime(starttimeStr,customfm=
'%m/%d/%y %H:%M:%S')
220 minTime=lute.StrToDatetime(startT,customfm=
'%m/%d/%y %H:%M:%S')
221 maxTime=lute.StrToDatetime(stopT,customfm=
'%m/%d/%y %H:%M:%S')
222 if runTime>=minTime
and runTime<=maxTime:
223 result.setdefault(currentfill,[]).
append(runnum)
224 elif startT
is not None:
225 minTime=lute.StrToDatetime(startT,customfm=
'%m/%d/%y %H:%M:%S')
227 result.setdefault(currentfill,[]).
append(runnum)
228 elif stopT
is not None:
229 maxTime=lute.StrToDatetime(stopT,customfm=
'%m/%d/%y %H:%M:%S')
231 result.setdefault(currentfill,[]).
append(runnum)
233 result.setdefault(currentfill,[]).
append(runnum)
240 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):
242 select r.runnum,l.starttime,l.stoptime,l.data_id,t.data_id,h.data_id 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
243 output: {runnum:[lumiid,trgid,hltid]}
246 if lumitype
not in [
'HF',
'PIXEL']:
247 raise ValueError(
'unknown lumitype '+lumitype)
253 elif lumitype ==
'PIXEL':
257 assert False,
"ERROR Unknown lumitype '%s'" % lumitype
260 qHandle=schema.newQuery()
268 qHandle.addToTableList(r)
269 qHandle.addToTableList(l)
270 qHandle.addToTableList(tag)
271 qConditionStr=r+
'.RUNNUM='+l+
'.RUNNUM AND '+tag+
'.RUNNUM='+l+
'.RUNNUM AND '+tag+
'.TAGID<=:tagid'
272 qCondition=coral.AttributeList()
273 qCondition.extend(
'tagid',
'unsigned long long')
274 qCondition[
'tagid'].setData(datatagid)
276 qHandle.addToTableList(t)
277 qConditionStr+=
' and '+l+
'.RUNNUM='+t+
'.RUNNUM'
279 qHandle.addToTableList(h)
280 qConditionStr+=
' and '+l+
'.RUNNUM='+h+
'.RUNNUM'
281 if runmin
and runmax :
283 qConditionStr+=
' AND '+r+
'.RUNNUM=:runmin'
284 qCondition.extend(
'runmin',
'unsigned int')
285 qCondition[
'runmin'].setData(int(runmin))
287 qConditionStr+=
' AND '+r+
'.RUNNUM>=:runmin AND '+r+
'.RUNNUM<=:runmax'
288 qCondition.extend(
'runmin',
'unsigned int')
289 qCondition.extend(
'runmax',
'unsigned int')
290 qCondition[
'runmin'].setData(int(runmin))
291 qCondition[
'runmax'].setData(int(runmax))
293 raise 'runmin > runmax'
295 qConditionStr+=
' AND '+r+
'.RUNNUM>=:runmin'
296 qCondition.extend(
'runmin',
'unsigned int')
297 qCondition[
'runmin'].setData(int(runmin))
299 qConditionStr+=
' AND '+r+
'.RUNNUM<=:runmax'
300 qCondition.extend(
'runmax',
'unsigned int')
301 qCondition[
'runmax'].setData(int(runmax))
304 if fillmin
and fillmax:
306 qConditionStr+=
' AND '+r+
'.FILLNUM=:fillnum'
307 qCondition.extend(
'fillnum',
'unsigned int')
308 qCondition[
'fillnum'].setData(int(fillmin))
309 elif fillmax>fillmin:
310 qConditionStr+=
' AND '+r+
'.FILLNUM>=:fillmin AND '+r+
'.FILLNUM<=:fillmax'
311 qCondition.extend(
'fillmin',
'unsigned int')
312 qCondition.extend(
'fillmax',
'unsigned int')
313 qCondition[
'fillmin'].setData(int(fillmin))
314 qCondition[
'fillmax'].setData(int(fillmax))
316 raise 'fillmin > fillmax'
318 qConditionStr+=
' AND '+r+
'.AMODETAG=:amodetag'
319 qCondition.extend(
'amodetag',
'string')
320 qCondition[
'amodetag'].setData(amodetag)
322 qConditionStr+=
' AND regexp_like('+r+
'.L1KEY,:l1keypattern)'
323 qCondition.extend(
'l1keypattern',
'string')
324 qCondition[
'l1keypattern'].setData(l1keyPattern)
326 qConditionStr+=
' AND regexp_like('+r+
'.HLTKEY,:hltkeypattern)'
327 qCondition.extend(
'hltkeypattern',
'string')
328 qCondition[
'hltkeypattern'].setData(hltkeyPattern)
330 emin=nominalEnergy*(1.0-energyFlut)
331 emax=nominalEnergy*(1.0+energyFlut)
332 qConditionStr+=
' AND '+l+
'.NOMINALEGEV>=:emin and '+l+
'.NOMINALEGEV<=:emax'
333 qCondition.extend(
'emin',
'float')
334 qCondition.extend(
'emax',
'float')
335 qCondition[
'emin'].setData(emin)
336 qCondition[
'emax'].setData(emax)
337 qResult=coral.AttributeList()
338 qResult.extend(
'runnum',
'unsigned int')
339 qResult.extend(
'starttime',
'string')
340 qResult.extend(
'stoptime',
'string')
341 qResult.extend(
'lumiid',
'unsigned long long')
343 qResult.extend(
'trgid',
'unsigned long long')
345 qResult.extend(
'hltid',
'unsigned long long')
346 qHandle.setCondition(qConditionStr,qCondition)
347 qHandle.addToOutputList(r+
'.RUNNUM',
'runnum')
348 qHandle.addToOutputList(
'TO_CHAR('+l+
'.STARTTIME,\'MM/DD/YY HH24:MI:SS\')',
'starttime')
349 qHandle.addToOutputList(
'TO_CHAR('+l+
'.STOPTIME,\'MM/DD/YY HH24:MI:SS\')',
'stoptime')
350 qHandle.addToOutputList(l+
'.DATA_ID',
'lumiid')
352 qHandle.addToOutputList(t+
'.DATA_ID',
'trgid')
354 qHandle.addToOutputList(h+
'.DATA_ID',
'hltid')
355 qHandle.defineOutput(qResult)
356 cursor=qHandle.execute()
361 runnum=cursor.currentRow()[
'runnum'].
data()
362 if preselectedruns
and runnum
not in preselectedruns:
364 if cursor.currentRow()[
'starttime'].isNull():
366 if cursor.currentRow()[
'stoptime'].isNull():
368 starttimeStr=cursor.currentRow()[
'starttime'].
data()
369 stoptimeStr=cursor.currentRow()[
'stoptime'].
data()
370 runstartTime=lute.StrToDatetime(starttimeStr,customfm=
'%m/%d/%y %H:%M:%S')
371 runstopTime=lute.StrToDatetime(stoptimeStr,customfm=
'%m/%d/%y %H:%M:%S')
372 minTime=datetime(2010,1,1,0,0,0,0)
373 maxTime=datetime.now()
375 minTime=lute.StrToDatetime(startT,customfm=
'%m/%d/%y %H:%M:%S')
376 maxTime=lute.StrToDatetime(stopT,customfm=
'%m/%d/%y %H:%M:%S')
377 if not (runstopTime>=minTime
and runstartTime<=maxTime):
379 elif startT
is not None:
380 minTime=lute.StrToDatetime(startT,customfm=
'%m/%d/%y %H:%M:%S')
381 if not (runstopTime>=minTime):
383 elif stopT
is not None:
384 maxTime=lute.StrToDatetime(stopT,customfm=
'%m/%d/%y %H:%M:%S')
385 runTime=lute.StrToDatetime(starttimeStr,customfm=
'%m/%d/%y %H:%M:%S')
386 if not (runTime<=maxTime):
390 if not cursor.currentRow()[
'lumiid'].isNull():
391 lumiid=cursor.currentRow()[
'lumiid'].
data()
392 if result.has_key(runnum):
393 if lumiid>result[runnum][0]:
394 result[runnum][0]=lumiid
396 result[runnum]=[lumiid,0,0]
397 if requiretrg
and not cursor.currentRow()[
'trgid'].isNull():
398 trgid=cursor.currentRow()[
'trgid'].
data()
399 if result.has_key(runnum):
400 if trgid>result[runnum][1]:
401 result[runnum][1]=trgid
402 if requirehlt
and not cursor.currentRow()[
'hltid'].isNull():
403 hltid=cursor.currentRow()[
'hltid'].
data()
404 if result.has_key(runnum):
405 if hltid>result[runnum][2]:
406 result[runnum][2]=hltid
415 select l1key,amodetag,hltkey,fillnum,fillscheme from cmsrunsummary where runnum=:runnum
416 output: [l1key(0),amodetag(1),hltkey(3),fillnum(4),fillscheme(5)]
419 qHandle=schema.newQuery()
423 qCondition=coral.AttributeList()
424 qCondition.extend(
'runnum',
'unsigned int')
425 qCondition[
'runnum'].setData(int(runnum))
426 qHandle.addToOutputList(
'L1KEY',
'l1key')
427 qHandle.addToOutputList(
'AMODETAG',
'amodetag')
429 qHandle.addToOutputList(
'HLTKEY',
'hltkey')
430 qHandle.addToOutputList(
'FILLNUM',
'fillnum')
431 qHandle.addToOutputList(
'FILLSCHEME',
'fillscheme')
438 qHandle.setCondition(
'RUNNUM=:runnum',qCondition)
439 qResult=coral.AttributeList()
440 qResult.extend(
'l1key',
'string')
441 qResult.extend(
'amodetag',
'string')
443 qResult.extend(
'hltkey',
'string')
444 qResult.extend(
'fillnum',
'unsigned int')
445 qResult.extend(
'fillscheme',
'string')
448 qHandle.defineOutput(qResult)
449 cursor=qHandle.execute()
451 result.append(cursor.currentRow()[
'l1key'].
data())
452 result.append(cursor.currentRow()[
'amodetag'].
data())
454 result.append(cursor.currentRow()[
'hltkey'].
data())
455 result.append(cursor.currentRow()[
'fillnum'].
data())
457 if not cursor.currentRow()[
'fillscheme'].isNull():
458 fillscheme=cursor.currentRow()[
'fillscheme'].
data()
459 result.append(fillscheme)
548 select entry_name,amodetag,norm_1,egev_1,norm_2,egev_2 from luminorms where DATA_ID=:dataid
549 output: {norm_name:(amodetag(0),norm_1(1),egev_1(2),norm_occ2(3),norm_et(4),norm_pu(5),constfactor(6))}
552 qHandle=schema.newQuery()
555 qHandle.addToOutputList(
'ENTRY_NAME',
'normname')
556 qHandle.addToOutputList(
'AMODETAG',
'amodetag')
557 qHandle.addToOutputList(
'NORM_1',
'norm_1')
558 qHandle.addToOutputList(
'EGEV_1',
'energy_1')
559 qHandle.addToOutputList(
'NORM_OCC2',
'norm_occ2')
560 qHandle.addToOutputList(
'NORM_ET',
'norm_et')
561 qHandle.addToOutputList(
'NORM_PU',
'norm_pu')
562 qHandle.addToOutputList(
'CONSTFACTOR',
'constfactor')
563 qCondition=coral.AttributeList()
564 qCondition.extend(
'dataid',
'unsigned long long')
565 qCondition[
'dataid'].setData(dataid)
566 qResult=coral.AttributeList()
567 qResult.extend(
'normname',
'string')
568 qResult.extend(
'amodetag',
'string')
569 qResult.extend(
'norm_1',
'float')
570 qResult.extend(
'energy_1',
'unsigned int')
571 qResult.extend(
'norm_occ2',
'float')
572 qResult.extend(
'norm_et',
'float')
573 qResult.extend(
'norm_pu',
'float')
574 qResult.extend(
'constfactor',
'float')
575 qHandle.defineOutput(qResult)
576 qHandle.setCondition(
'DATA_ID=:dataid',qCondition)
577 cursor=qHandle.execute()
579 normname=cursor.currentRow()[
'normname'].
data()
580 amodetag=cursor.currentRow()[
'amodetag'].
data()
581 norm_1=cursor.currentRow()[
'norm_1'].
data()
582 energy_1=cursor.currentRow()[
'energy_1'].
data()
584 if cursor.currentRow()[
'norm_occ2'].
data():
585 norm_occ2=cursor.currentRow()[
'norm_occ2'].
data()
587 if cursor.currentRow()[
'norm_et'].
data():
588 norm_et=cursor.currentRow()[
'norm_et'].
data()
590 if cursor.currentRow()[
'norm_pu'].
data():
591 norm_pu=cursor.currentRow()[
'norm_pu'].
data()
593 if cursor.currentRow()[
'constfactor'].
data():
594 constfactor=cursor.currentRow()[
'constfactor'].
data()
595 result={normname:(amodetag,norm_1,energy_1,norm_occ2,norm_et,norm_pu,constfactor)}
666 select entry_name,amodetag,norm_1,egev_1,norm_2,egev_2 from luminorms where DATA_ID=:dataid
667 result (normname(0),amodetag(1),egev(2),norm(3),norm_occ2(4),norm_et(5),norm_pu(6),constfactor(7))
670 qHandle=schema.newQuery()
673 qHandle.addToOutputList(
'ENTRY_NAME',
'normname')
674 qHandle.addToOutputList(
'AMODETAG',
'amodetag')
675 qHandle.addToOutputList(
'NORM_1',
'norm_1')
676 qHandle.addToOutputList(
'EGEV_1',
'energy_1')
677 qHandle.addToOutputList(
'NORM_OCC2',
'norm_occ2')
678 qHandle.addToOutputList(
'NORM_ET',
'norm_et')
679 qHandle.addToOutputList(
'NORM_PU',
'norm_pu')
680 qHandle.addToOutputList(
'CONSTFACTOR',
'constfactor')
681 qCondition=coral.AttributeList()
682 qCondition.extend(
'dataid',
'unsigned long long')
683 qCondition[
'dataid'].setData(dataid)
684 qResult=coral.AttributeList()
685 qResult.extend(
'normname',
'string')
686 qResult.extend(
'amodetag',
'string')
687 qResult.extend(
'norm_1',
'float')
688 qResult.extend(
'energy_1',
'unsigned int')
689 qResult.extend(
'norm_occ2',
'float')
690 qResult.extend(
'norm_et',
'float')
691 qResult.extend(
'norm_pu',
'float')
692 qResult.extend(
'constfactor',
'float')
693 qHandle.defineOutput(qResult)
694 qHandle.setCondition(
'DATA_ID=:dataid',qCondition)
695 cursor=qHandle.execute()
697 normname=cursor.currentRow()[
'normname'].
data()
698 amodetag=cursor.currentRow()[
'amodetag'].
data()
699 norm_1=cursor.currentRow()[
'norm_1'].
data()
700 energy_1=cursor.currentRow()[
'energy_1'].
data()
702 if cursor.currentRow()[
'norm_occ2'].
data():
703 norm_occ2=cursor.currentRow()[
'norm_occ2'].
data()
705 if cursor.currentRow()[
'norm_et'].
data():
706 norm_et=cursor.currentRow()[
'norm_et'].
data()
708 if cursor.currentRow()[
'norm_pu'].
data():
709 norm_pu=cursor.currentRow()[
'norm_pu'].
data()
711 if cursor.currentRow()[
'constfactor'].
data():
712 constfactor=cursor.currentRow()[
'constfactor'].
data()
713 result={normname:(amodetag,norm_1,energy_1,norm_occ2,norm_et,norm_pu,constfactor)}
720 def trgRunById(schema,dataid,trgbitname=None,trgbitnamepattern=None):
722 query: select RUNNUM,SOURCE,BITZERONAME,BITNAMECLOB,ALGOMASK_H,ALGOMASK_L,TECHMASK from trgdata where DATA_ID=:dataid
724 output: [runnum(0),datasource(1),bitzeroname(2),bitnamedict(3),algomask_h(4),algomask_l(5),techmask(6)]
726 -- original source database name
727 -- deadtime norm bitname
728 -- bitnamedict [(bitidx,bitname),...]
731 qHandle=schema.newQuery()
738 qHandle.addToOutputList(
'RUNNUM',
'runnum')
739 qHandle.addToOutputList(
'SOURCE',
'source')
740 qHandle.addToOutputList(
'BITZERONAME',
'bitzeroname')
741 qHandle.addToOutputList(
'BITNAMECLOB',
'bitnameclob')
742 qHandle.addToOutputList(
'ALGOMASK_H',
'algomask_h')
743 qHandle.addToOutputList(
'ALGOMASK_L',
'algomask_l')
744 qHandle.addToOutputList(
'TECHMASK',
'techmask')
745 qCondition=coral.AttributeList()
746 qCondition.extend(
'dataid',
'unsigned long long')
747 qCondition[
'dataid'].setData(dataid)
748 qResult=coral.AttributeList()
749 qResult.extend(
'runnum',
'unsigned int')
750 qResult.extend(
'source',
'string')
751 qResult.extend(
'bitzeroname',
'string')
752 qResult.extend(
'bitnameclob',
'string')
753 qResult.extend(
'algomask_h',
'unsigned long long')
754 qResult.extend(
'algomask_l',
'unsigned long long')
755 qResult.extend(
'techmask',
'unsigned long long')
756 qHandle.defineOutput(qResult)
757 qHandle.setCondition(
'DATA_ID=:dataid',qCondition)
758 cursor=qHandle.execute()
762 runnum=cursor.currentRow()[
'runnum'].
data()
763 source=cursor.currentRow()[
'source'].
data()
764 bitzeroname=cursor.currentRow()[
'bitzeroname'].
data()
765 bitnameclob=cursor.currentRow()[
'bitnameclob'].
data()
766 algomask_h=cursor.currentRow()[
'algomask_h'].
data()
767 algomask_l=cursor.currentRow()[
'algomask_l'].
data()
768 techmask=cursor.currentRow()[
'techmask'].
data()
770 bitnames=bitnameclob.split(
',')
771 for trgnameidx,trgname
in enumerate(bitnames):
773 if trgname==trgbitname:
774 bitnamedict.append((trgnameidx,trgname))
776 elif trgbitnamepattern:
777 if fnmatch.fnmatch(trgname,trgbitnamepattern):
778 bitnamedict.append((trgnameidx,trgname))
780 bitnamedict.append((trgnameidx,trgname))
781 result=[runnum,source,bitzeroname,bitnamedict,algomask_h,algomask_l,techmask]
788 def trgLSById(schema,dataid,trgbitname=None,trgbitnamepattern=None,withL1Count=False,withPrescale=False):
790 output: (runnum,{cmslsnum:[deadtimecount(0),bitzerocount(1),bitzeroprescale(2),deadfrac(3),[(bitname,trgcount,prescale,mask)](4)]})
795 if trgbitname
or trgbitnamepattern
or withPrescale
or withL1Count:
796 trgrundata=
trgRunById(schema,dataid,trgbitname=trgbitname,trgbitnamepattern=trgbitnamepattern)
797 trgnamedict=trgrundata[3]
798 algomask_h=trgrundata[4]
799 algomask_l=trgrundata[5]
800 techmask=trgrundata[6]
801 qHandle=schema.newQuery()
804 qHandle.addToOutputList(
'RUNNUM',
'runnum')
805 qHandle.addToOutputList(
'CMSLSNUM',
'cmslsnum')
806 qHandle.addToOutputList(
'DEADTIMECOUNT',
'deadtimecount')
809 qHandle.addToOutputList(
'DEADFRAC',
'deadfrac')
811 qHandle.addToOutputList(
'PRESCALEBLOB',
'prescalesblob')
813 qHandle.addToOutputList(
'TRGCOUNTBLOB',
'trgcountblob')
814 qConditionStr=
'DATA_ID=:dataid'
815 qCondition=coral.AttributeList()
816 qCondition.extend(
'dataid',
'unsigned long long')
817 qCondition[
'dataid'].setData(dataid)
818 qResult=coral.AttributeList()
819 qResult.extend(
'runnum',
'unsigned int')
820 qResult.extend(
'cmslsnum',
'unsigned int')
821 qResult.extend(
'deadtimecount',
'unsigned long long')
824 qResult.extend(
'deadfrac',
'float')
826 qResult.extend(
'prescalesblob',
'blob')
828 qResult.extend(
'trgcountblob',
'blob')
829 qHandle.defineOutput(qResult)
830 qHandle.setCondition(qConditionStr,qCondition)
831 cursor=qHandle.execute()
833 runnum=cursor.currentRow()[
'runnum'].
data()
834 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
835 deadtimecount=cursor.currentRow()[
'deadtimecount'].
data()
840 deadfrac=cursor.currentRow()[
'deadfrac'].
data()
841 if not result.has_key(cmslsnum):
843 result[cmslsnum].
append(deadtimecount)
844 result[cmslsnum].
append(bitzerocount)
845 result[cmslsnum].
append(bitzeroprescale)
846 result[cmslsnum].
append(deadfrac)
850 prescalesblob=cursor.currentRow()[
'prescalesblob'].
data()
852 trgcountblob=cursor.currentRow()[
'trgcountblob'].
data()
867 for (bitidx,thisbitname)
in trgnamedict:
871 thispresc=prescales[bitidx]
873 thistrgcount=trgcounts[bitidx]
876 if bitidx
in range(0,128):
878 maskval=algomask_l>>bitidx&1
880 maskval=algomask_h>>(bitidx-64)&1
883 maskval=techmask>>(bitidx-128)&1
884 thisbitinfo=(thisbitname,thistrgcount,thispresc,maskval)
885 bitinfo.append(thisbitinfo)
886 result[cmslsnum].
append(bitinfo)
893 return (runnum,result)
897 input dataidMap : {run:lumidataid}
898 result {runnum: (datasource(0),nominalegev(1),ncollidingbunches(2),starttime(3),stoptime(4),nls(5)}
903 inputRange=dataidMap.keys()
905 lumidataid=dataidMap[r][0]
907 perrundata=
lumiRunById(schema,lumidataid,lumitype=lumitype)
908 result[r]=(perrundata[1],perrundata[2],perrundata[3],perrundata[4],perrundata[5])
913 input dataidMap : {run:lumidataid}
914 result {runnum:{cmslsnum:beamstatus}}
919 inputRange=dataidMap.keys()
921 if not result.has_key(r):
923 lumidataid=dataidMap[r][0]
925 qHandle=schema.newQuery()
928 qHandle.addToOutputList(
'CMSLSNUM')
929 qHandle.addToOutputList(
'BEAMSTATUS')
930 qConditionStr=
'DATA_ID=:dataid'
931 qCondition=coral.AttributeList()
932 qCondition.extend(
'dataid',
'unsigned long long')
933 qCondition[
'dataid'].setData(int(lumidataid))
934 qResult=coral.AttributeList()
935 qResult.extend(
'CMSLSNUM',
'unsigned int')
936 qResult.extend(
'BEAMSTATUS',
'string')
937 qHandle.defineOutput(qResult)
938 qHandle.setCondition(qConditionStr,qCondition)
939 cursor=qHandle.execute()
941 cmslsnum=cursor.currentRow()[
'CMSLSNUM'].
data()
942 bs=cursor.currentRow()[
'BEAMSTATUS'].
data()
943 if bs!=
'STABLE BEAMS':
944 result[r][cmslsnum]=bs
954 output: (runnum(0),datasource(1),nominalegev(2),ncollidingbunches(3),starttimestr(4),stoptimestr(5),nls(6))
957 if lumitype
not in [
'HF',
'PIXEL']:
958 raise ValueError(
'unknown lumitype '+lumitype)
964 qHandle=schema.newQuery()
966 qHandle.addToTableList(lumitableName)
967 qHandle.addToOutputList(
'RUNNUM')
968 qHandle.addToOutputList(
'SOURCE')
969 qHandle.addToOutputList(
'NOMINALEGEV')
970 qHandle.addToOutputList(
'NCOLLIDINGBUNCHES')
971 qHandle.addToOutputList(
'TO_CHAR('+lumitableName+
'.STARTTIME,\'MM/DD/YY HH24:MI:SS\')',
'startT')
972 qHandle.addToOutputList(
'TO_CHAR('+lumitableName+
'.STOPTIME,\'MM/DD/YY HH24:MI:SS\')',
'stopT')
973 qHandle.addToOutputList(
'NLS')
974 qConditionStr=
'DATA_ID=:dataid'
975 qCondition=coral.AttributeList()
976 qCondition.extend(
'dataid',
'unsigned long long')
977 qCondition[
'dataid'].setData(lumidataid)
978 qResult=coral.AttributeList()
979 qResult.extend(
'RUNNUM',
'unsigned int')
980 qResult.extend(
'SOURCE',
'string')
981 qResult.extend(
'NOMINALEGEV',
'float')
982 qResult.extend(
'NCOLLIDINGBUNCHES',
'unsigned int')
983 qResult.extend(
'startT',
'string')
984 qResult.extend(
'stopT',
'string')
985 qResult.extend(
'NLS',
'unsigned int')
986 qHandle.defineOutput(qResult)
987 qHandle.setCondition(qConditionStr,qCondition)
988 cursor=qHandle.execute()
992 runnum=cursor.currentRow()[
'RUNNUM'].
data()
993 datasource=cursor.currentRow()[
'SOURCE'].
data()
995 if not cursor.currentRow()[
'NOMINALEGEV'].isNull():
996 nominalegev=cursor.currentRow()[
'NOMINALEGEV'].
data()
998 if not cursor.currentRow()[
'NCOLLIDINGBUNCHES'].isNull():
999 ncollidingbunches=cursor.currentRow()[
'NCOLLIDINGBUNCHES'].
data()
1000 startTstr=cursor.currentRow()[
'startT'].
data()
1001 stopTstr=cursor.currentRow()[
'stopT'].
data()
1004 if not cursor.currentRow()[
'NLS'].isNull():
1005 nls=cursor.currentRow()[
'NLS'].
data()
1006 result=(runnum,datasource,nominalegev,ncollidingbunches,startTstr,stopTstr,nls)
1058 qHandle.addToTableList(s)
1059 qResult=coral.AttributeList()
1060 qResult.extend(
'FILLSCHEMEPATTERN',
'string')
1061 qResult.extend(
'CORRECTIONFACTOR',
'float')
1062 qHandle.defineOutput(qResult)
1063 qHandle.addToOutputList(
'FILLSCHEMEPATTERN')
1064 qHandle.addToOutputList(
'CORRECTIONFACTOR')
1065 cursor=qHandle.execute()
1066 while cursor.next():
1067 fillschemePattern=cursor.currentRow()[
'FILLSCHEMEPATTERN'].
data()
1068 afterglowfac=cursor.currentRow()[
'CORRECTIONFACTOR'].
data()
1069 afterglows.append((fillschemePattern,afterglowfac))
1076 def lumiLSById(schema,dataid,beamstatus=None,withBXInfo=False,bxAlgo='OCC1',withBeamIntensity=False,tableName=None):
1079 beamstatus: filter on beam status flag
1081 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)]})
1085 qHandle=schema.newQuery()
1086 if withBXInfo
and bxAlgo
not in [
'OCC1',
'OCC2',
'ET']:
1087 raise ValueError(
'unknown lumi algo '+bxAlgo)
1088 if beamstatus
and beamstatus
not in [
'STABLE BEAMS',]:
1089 raise ValueError(
'unknown beam status '+beamstatus)
1091 if tableName
is None:
1095 qHandle.addToTableList(lls)
1096 qHandle.addToOutputList(
'RUNNUM',
'runnum')
1097 qHandle.addToOutputList(
'LUMILSNUM',
'lumilsnum')
1098 qHandle.addToOutputList(
'CMSLSNUM',
'cmslsnum')
1099 qHandle.addToOutputList(
'INSTLUMI',
'instlumi')
1100 qHandle.addToOutputList(
'INSTLUMIERROR',
'instlumierr')
1101 qHandle.addToOutputList(
'INSTLUMIQUALITY',
'instlumiqlty')
1102 qHandle.addToOutputList(
'BEAMSTATUS',
'beamstatus')
1103 qHandle.addToOutputList(
'BEAMENERGY',
'beamenergy')
1104 qHandle.addToOutputList(
'NUMORBIT',
'numorbit')
1105 qHandle.addToOutputList(
'STARTORBIT',
'startorbit')
1107 qHandle.addToOutputList(
'BXLUMIVALUE_'+bxAlgo,
'bxvalue')
1108 qHandle.addToOutputList(
'BXLUMIERROR_'+bxAlgo,
'bxerror')
1109 if withBeamIntensity:
1110 qHandle.addToOutputList(
'CMSBXINDEXBLOB',
'bxindexblob')
1111 qHandle.addToOutputList(
'BEAMINTENSITYBLOB_1',
'beam1intensity')
1112 qHandle.addToOutputList(
'BEAMINTENSITYBLOB_2',
'beam2intensity')
1114 qConditionStr=
'DATA_ID=:dataid'
1115 qCondition=coral.AttributeList()
1116 qCondition.extend(
'dataid',
'unsigned long long')
1117 qCondition[
'dataid'].setData(int(dataid))
1119 qConditionStr+=
' and BEAMSTATUS=:beamstatus'
1120 qCondition.extend(
'beamstatus',
'string')
1121 qCondition[
'beamstatus'].setData(beamstatus)
1122 qResult=coral.AttributeList()
1123 qResult.extend(
'runnum',
'unsigned int')
1124 qResult.extend(
'lumilsnum',
'unsigned int')
1125 qResult.extend(
'cmslsnum',
'unsigned int')
1126 qResult.extend(
'instlumi',
'float')
1127 qResult.extend(
'instlumierr',
'float')
1128 qResult.extend(
'instlumiqlty',
'short')
1129 qResult.extend(
'beamstatus',
'string')
1130 qResult.extend(
'beamenergy',
'float')
1131 qResult.extend(
'numorbit',
'unsigned int')
1132 qResult.extend(
'startorbit',
'unsigned int')
1134 qResult.extend(
'bxvalue',
'blob')
1135 qResult.extend(
'bxerror',
'blob')
1136 if withBeamIntensity:
1137 qResult.extend(
'bxindexblob',
'blob')
1138 qResult.extend(
'beam1intensity',
'blob')
1139 qResult.extend(
'beam2intensity',
'blob')
1140 qHandle.defineOutput(qResult)
1141 qHandle.setCondition(qConditionStr,qCondition)
1142 cursor=qHandle.execute()
1143 while cursor.next():
1144 runnum=cursor.currentRow()[
'runnum'].
data()
1145 lumilsnum=cursor.currentRow()[
'lumilsnum'].
data()
1146 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
1147 instlumi=cursor.currentRow()[
'instlumi'].
data()
1148 instlumierr=cursor.currentRow()[
'instlumierr'].
data()
1149 instlumiqlty=cursor.currentRow()[
'instlumiqlty'].
data()
1150 bs=cursor.currentRow()[
'beamstatus'].
data()
1151 begev=cursor.currentRow()[
'beamenergy'].
data()
1152 numorbit=cursor.currentRow()[
'numorbit'].
data()
1153 startorbit=cursor.currentRow()[
'startorbit'].
data()
1158 bxvalueblob=cursor.currentRow()[
'bxvalue'].
data()
1159 bxerrblob=cursor.currentRow()[
'bxerror'].
data()
1160 if bxvalueblob
and bxerrblob:
1163 bxinfo=(bxvaluesArray,bxerrArray)
1168 if withBeamIntensity:
1169 bxindexblob=cursor.currentRow()[
'bxindexblob'].
data()
1170 beam1intensity=cursor.currentRow()[
'beam1intensity'].
data()
1171 beam2intensity=cursor.currentRow()[
'beam2intensity'].
data()
1176 beaminfo=(bxindexArray,beam1intensityArray,beam2intensityArray)
1177 result[lumilsnum]=[cmslsnum,instlumi,instlumierr,instlumiqlty,bs,begev,numorbit,startorbit,bxinfo,beaminfo]
1182 return (runnum,result)
1185 result (runnum,[(lumilsnum(0),cmslsnum(1),beamstatus(2),beamenergy(3),ncollidingbunches(4),beaminfolist(5),..])
1186 beaminfolist=[(bxidx,beam1intensity,beam2intensity)]
1191 qHandle=schema.newQuery()
1194 qHandle.addToOutputList(
'NCOLLIDINGBUNCHES')
1195 qConditionStr=
'DATA_ID=:dataid'
1196 qCondition=coral.AttributeList()
1197 qCondition.extend(
'dataid',
'unsigned long long')
1198 qCondition[
'dataid'].setData(dataid)
1199 qResult=coral.AttributeList()
1200 qResult.extend(
'NCOLLIDINGBUNCHES',
'unsigned int')
1201 qHandle.defineOutput(qResult)
1202 qHandle.setCondition(qConditionStr,qCondition)
1203 cursor=qHandle.execute()
1204 while cursor.next():
1205 ncollidingbunches=cursor.currentRow()[
'NCOLLIDINGBUNCHES'].
data()
1210 qHandle=schema.newQuery()
1213 qHandle.addToOutputList(
'RUNNUM')
1214 qHandle.addToOutputList(
'CMSLSNUM')
1215 qHandle.addToOutputList(
'LUMILSNUM')
1216 qHandle.addToOutputList(
'BEAMSTATUS')
1217 qHandle.addToOutputList(
'BEAMENERGY')
1218 if withBeamIntensity:
1219 qHandle.addToOutputList(
'CMSBXINDEXBLOB')
1220 qHandle.addToOutputList(
'BEAMINTENSITYBLOB_1')
1221 qHandle.addToOutputList(
'BEAMINTENSITYBLOB_2')
1222 qConditionStr=
'DATA_ID=:dataid'
1223 qCondition=coral.AttributeList()
1224 qCondition.extend(
'dataid',
'unsigned long long')
1225 qCondition[
'dataid'].setData(dataid)
1226 qResult=coral.AttributeList()
1227 qResult.extend(
'RUNNUM',
'unsigned int')
1228 qResult.extend(
'CMSLSNUM',
'unsigned int')
1229 qResult.extend(
'LUMILSNUM',
'unsigned int')
1230 qResult.extend(
'BEAMSTATUS',
'string')
1231 qResult.extend(
'BEAMENERGY',
'float')
1232 if withBeamIntensity:
1233 qResult.extend(
'BXINDEXBLOB',
'blob')
1234 qResult.extend(
'BEAM1INTENSITY',
'blob')
1235 qResult.extend(
'BEAM2INTENSITY',
'blob')
1236 qHandle.defineOutput(qResult)
1237 qHandle.setCondition(qConditionStr,qCondition)
1238 cursor=qHandle.execute()
1239 while cursor.next():
1240 runnum=cursor.currentRow()[
'RUNNUM'].
data()
1241 cmslsnum=cursor.currentRow()[
'CMSLSNUM'].
data()
1242 lumilsnum=cursor.currentRow()[
'LUMILSNUM'].
data()
1243 beamstatus=cursor.currentRow()[
'BEAMSTATUS'].
data()
1244 beamenergy=cursor.currentRow()[
'BEAMENERGY'].
data()
1246 beaminfotupleList=[]
1247 if withBeamIntensity:
1248 bxindexblob=cursor.currentRow()[
'BXINDEXBLOB'].
data()
1249 beam1intensityblob=cursor.currentRow()[
'BEAM1INTENSITY'].
data()
1250 beam2intensityblob=cursor.currentRow()[
'BEAM2INTENSITY'].
data()
1252 beam1intensityArray=
None
1253 beam2intensityArray=
None
1256 if beam1intensityblob:
1258 if beam2intensityblob:
1260 if bxindexArray
and beam1intensityArray
and beam2intensityArray:
1261 for idx,bxindex
in enumerate(bxindexArray):
1262 if (beam1intensityArray[idx]
and beam1intensityArray[idx]>minIntensity)
or (beam2intensityArray[idx]
and beam2intensityArray[idx]>minIntensity):
1263 beaminfotuple=(bxindex,beam1intensityArray[idx],beam2intensityArray[idx])
1264 beaminfotupleList.append(beaminfotuple)
1266 del beam1intensityArray[:]
1267 del beam2intensityArray[:]
1268 result.append((lumilsnum,cmslsnum,beamstatus,beamenergy,ncollidingbunches,beaminfotupleList))
1273 return (runnum,result)
1276 result {lumilsnum:[cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty]}
1279 qHandle=schema.newQuery()
1282 qHandle.addToOutputList(
'CMSLSNUM',
'cmslsnum')
1283 qHandle.addToOutputList(
'LUMILSNUM',
'lumilsnum')
1285 qHandle.addToOutputList(
'NUMORBIT',
'numorbit')
1286 qHandle.addToOutputList(
'STARTORBIT',
'startorbit')
1287 qHandle.addToOutputList(
'BXLUMIVALUE_'+algoname,
'bxlumivalue')
1288 qHandle.addToOutputList(
'BXLUMIERROR_'+algoname,
'bxlumierr')
1289 qHandle.addToOutputList(
'BXLUMIQUALITY_'+algoname,
'bxlumiqlty')
1290 qConditionStr=
'DATA_ID=:dataid'
1291 qCondition=coral.AttributeList()
1292 qCondition.extend(
'dataid',
'unsigned long long')
1293 qCondition[
'dataid'].setData(dataid)
1294 qResult=coral.AttributeList()
1295 qResult.extend(
'cmslsnum',
'unsigned int')
1296 qResult.extend(
'lumilsnum',
'unsigned int')
1297 qResult.extend(
'numorbit',
'unsigned int')
1298 qResult.extend(
'startorbit',
'unsigned int')
1299 qResult.extend(
'bxlumivalue',
'blob')
1300 qResult.extend(
'bxlumierr',
'blob')
1301 qResult.extend(
'bxlumiqlty',
'blob')
1302 qHandle.defineOutput(qResult)
1303 qHandle.setCondition(qConditionStr,qCondition)
1304 cursor=qHandle.execute()
1305 while cursor.next():
1306 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
1307 lumilsnum=cursor.currentRow()[
'lumilsnum'].
data()
1308 numorbit=cursor.currentRow()[
'numorbit'].
data()
1309 startorbit=cursor.currentRow()[
'startorbit'].
data()
1310 bxlumivalue=cursor.currentRow()[
'bxlumivalue'].
data()
1311 bxlumierr=cursor.currentRow()[
'bxlumierr'].
data()
1312 bxlumiqlty=cursor.currentRow()[
'bxlumiqlty'].
data()
1313 if not result.has_key(algoname):
1315 if not result[algoname].has_key(lumilsnum):
1316 result[algoname][lumilsnum]=[]
1317 result[algoname][lumilsnum].extend([cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty])
1320 raise RuntimeError(
' dataDML.lumiBXById: '+str(e))
1324 def hltRunById(schema,dataid,hltpathname=None,hltpathpattern=None):
1326 result [runnum(0),datasource(1),npath(2),hltnamedict(3)]
1328 npath : total number of hltpath in DB
1329 hltnamedict : list of all selected paths [(hltpathidx,hltname),(hltpathidx,hltname)]
1332 qHandle=schema.newQuery()
1339 qHandle.addToOutputList(
'RUNNUM',
'runnum')
1340 qHandle.addToOutputList(
'SOURCE',
'datasource')
1341 qHandle.addToOutputList(
'NPATH',
'npath')
1342 qHandle.addToOutputList(
'PATHNAMECLOB',
'pathnameclob')
1343 qConditionStr=
'DATA_ID=:dataid'
1344 qCondition=coral.AttributeList()
1345 qCondition.extend(
'dataid',
'unsigned long long')
1346 qCondition[
'dataid'].setData(dataid)
1347 qResult=coral.AttributeList()
1348 qResult.extend(
'runnum',
'unsigned int')
1349 qResult.extend(
'datasource',
'string')
1350 qResult.extend(
'npath',
'unsigned int')
1351 qResult.extend(
'pathnameclob',
'string')
1352 qHandle.defineOutput(qResult)
1353 qHandle.setCondition(qConditionStr,qCondition)
1354 cursor=qHandle.execute()
1357 while cursor.next():
1358 runnum=cursor.currentRow()[
'runnum'].
data()
1359 datasource=cursor.currentRow()[
'datasource'].
data()
1360 npath=cursor.currentRow()[
'npath'].
data()
1361 pathnameclob=cursor.currentRow()[
'pathnameclob'].
data()
1363 pathnames=pathnameclob.split(
',')
1364 for pathnameidx,hltname
in enumerate(pathnames):
1366 if hltpathname==hltname:
1367 hltnamedict.append((pathnameidx,hltname))
1369 elif hltpathpattern:
1370 if fnmatch.fnmatch(hltname,hltpathpattern):
1371 hltnamedict.append((pathnameidx,hltname))
1374 result=[runnum,datasource,npath,hltnamedict]
1383 select m.hltpathname,m.l1seed from cmsrunsummary r,trghltmap m where r.runnum=:runnum and m.hltkey=r.hltkey and [m.hltpathname=:hltpathname]
1384 output: {hltpath:l1seed}
1387 queryHandle=schema.newQuery()
1390 if hltpathpattern
and hltpathpattern
in [
'*',
'all',
'All',
'ALL']:
1393 queryHandle.addToTableList(r)
1394 queryHandle.addToTableList(m)
1395 queryCondition=coral.AttributeList()
1396 queryCondition.extend(
'runnum',
'unsigned int')
1397 queryCondition[
'runnum'].setData(int(runnum))
1399 queryHandle.addToOutputList(m+
'.HLTPATHNAME',
'hltpathname')
1400 queryHandle.addToOutputList(m+
'.L1SEED',
'l1seed')
1401 conditionStr=r+
'.RUNNUM=:runnum and '+m+
'.HLTKEY='+r+
'.HLTKEY'
1404 conditionStr+=
' AND '+m+
'.HLTPATHNAME=:hltpathname'
1405 queryCondition.extend(
'hltpathname',
'string')
1406 queryCondition[
'hltpathname'].setData(hltpathname)
1407 queryHandle.setCondition(conditionStr,queryCondition)
1408 queryResult=coral.AttributeList()
1409 queryResult.extend(
'pname',
'string')
1410 queryResult.extend(
'l1seed',
'string')
1411 queryHandle.defineOutput(queryResult)
1412 cursor=queryHandle.execute()
1413 while cursor.next():
1414 pname=cursor.currentRow()[
'pname'].
data()
1415 l1seed=cursor.currentRow()[
'l1seed'].
data()
1416 if not result.has_key(hltpathname):
1418 if fnmatch.fnmatch(pname,hltpathpattern):
1419 result[pname]=l1seed
1421 result[pname]=l1seed
1428 def hltLSById(schema,dataid,hltpathname=None,hltpathpattern=None,withL1Pass=False,withHLTAccept=False):
1430 result (runnum, {cmslsnum:[(pathname,prescale,1lpass,hltaccept)](0)]}
1435 hltrundata=
hltRunById(schema,dataid,hltpathname=hltpathname,hltpathpattern=hltpathpattern)
1438 hltnamedict=hltrundata[3]
1440 return (hltrundata[0],{})
1444 qHandle=schema.newQuery()
1447 qHandle.addToOutputList(
'RUNNUM',
'runnum')
1448 qHandle.addToOutputList(
'CMSLSNUM',
'cmslsnum')
1449 if len(hltnamedict)!=0:
1450 qHandle.addToOutputList(
'PRESCALEBLOB',
'prescaleblob')
1452 qHandle.addToOutputList(
'HLTCOUNTBLOB',
'hltcountblob')
1454 qHandle.addToOutputList(
'HLTACCEPTBLOB',
'hltacceptblob')
1455 qConditionStr=
'DATA_ID=:dataid'
1456 qCondition=coral.AttributeList()
1457 qCondition.extend(
'dataid',
'unsigned long long')
1458 qCondition[
'dataid'].setData(dataid)
1459 qResult=coral.AttributeList()
1460 qResult.extend(
'runnum',
'unsigned int')
1461 qResult.extend(
'cmslsnum',
'unsigned int')
1462 if len(hltnamedict)!=0:
1463 qResult.extend(
'prescaleblob',
'blob')
1465 qResult.extend(
'hltcountblob',
'blob')
1467 qResult.extend(
'hltacceptblob',
'blob')
1468 qHandle.defineOutput(qResult)
1469 qHandle.setCondition(qConditionStr,qCondition)
1470 cursor=qHandle.execute()
1471 while cursor.next():
1472 runnum=cursor.currentRow()[
'runnum'].
data()
1473 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
1477 if len(hltnamedict)!=0:
1478 prescaleblob=cursor.currentRow()[
'prescaleblob'].
data()
1480 hltcountblob=cursor.currentRow()[
'hltcountblob'].
data()
1482 hltacceptblob=cursor.currentRow()[
'hltacceptblob'].
data()
1483 if not result.has_key(cmslsnum):
1504 for (hltpathidx,thispathname)
in hltnamedict:
1509 thispresc=prescales[hltpathidx]
1511 thishltcount=hltcounts[hltpathidx]
1513 thisaccept=hltaccepts[hltpathidx]
1514 thispathinfo=(thispathname,thispresc,thishltcount,thisaccept)
1515 pathinfo.append(thispathinfo)
1516 result[cmslsnum]=pathinfo
1525 return (runnum,result)
1529 output: {run:intglumi_in_fb}
1536 qHandle=schema.newQuery()
1539 qResult=coral.AttributeList()
1540 qResult.extend(
'RUNNUM',
'unsigned int')
1541 qResult.extend(
'INTGLUMI',
'float')
1542 qConditionStr=
'RUNNUM>=:minrun AND RUNNUM<=:maxrun'
1543 qCondition=coral.AttributeList()
1544 qCondition.extend(
'minrun',
'unsigned int')
1545 qCondition.extend(
'maxrun',
'unsigned int')
1546 qCondition[
'minrun'].setData(minrun)
1547 qCondition[
'maxrun'].setData(maxrun)
1548 qHandle.addToOutputList(
'RUNNUM')
1549 qHandle.addToOutputList(
'INTGLUMI')
1550 qHandle.setCondition(qConditionStr,qCondition)
1551 qHandle.defineOutput(qResult)
1552 cursor=qHandle.execute()
1553 while cursor.next():
1554 runnum=cursor.currentRow()[
'RUNNUM'].
data()
1555 intglumi=cursor.currentRow()[
'INTGLUMI'].
data()
1556 result[runnum]=intglumi
1565 output:(patternStr:correctionFac)
1567 if lumitype
not in [
'PIXEL',
'HF']:
1568 raise ValueError(
'[ERROR] unsupported lumitype '+lumitype)
1569 correctorField=
'CORRECTIONFACTOR'
1570 if lumitype==
'PIXEL':
1571 correctorField=
'PIXELCORRECTIONFACTOR'
1573 qHandle=schema.newQuery()
1576 qResult=coral.AttributeList()
1577 qResult.extend(
'FILLSCHEMEPATTERN',
'string')
1578 qResult.extend(
'CORRECTIONFACTOR',
'float')
1579 qHandle.defineOutput(qResult)
1580 qHandle.addToOutputList(
'FILLSCHEMEPATTERN')
1581 qHandle.addToOutputList(correctorField)
1582 cursor=qHandle.execute()
1583 while cursor.next():
1584 fillschemePattern=cursor.currentRow()[
'FILLSCHEMEPATTERN'].
data()
1585 afterglowfac=cursor.currentRow()[
'CORRECTIONFACTOR'].
data()
1586 result[fillschemePattern]=afterglowfac
1597 return latestrevision
1603 return latestrevision
1609 return latestrevision
1613 select max data_id of the given run. In current design, it's the most recent data of the run
1617 qHandle=schema.newQuery()
1619 qHandle.addToTableList(tablename)
1620 qHandle.addToOutputList(
'DATA_ID')
1621 qConditionStr=
'RUNNUM=:runnum '
1622 qCondition=coral.AttributeList()
1623 qCondition.extend(
'runnum',
'unsigned int')
1624 qCondition[
'runnum'].setData(runnum)
1625 qResult=coral.AttributeList()
1626 qResult.extend(
'DATA_ID',
'unsigned long long')
1627 qHandle.defineOutput(qResult)
1628 qHandle.setCondition(qConditionStr,qCondition)
1629 cursor=qHandle.execute()
1630 while cursor.next():
1631 dataid=cursor.currentRow()[
'DATA_ID'].
data()
1644 input: inputRange [run]
1645 output: {run:lumiid}
1646 select data_id,runnum from hltdata where runnum<=runmax and runnum>=:runmin
1649 if not inputRange :
return result
1650 if len(inputRange)==1:
1652 result[inputRange[0]]=trgid
1654 rmin=
min(inputRange)
1655 rmax=
max(inputRange)
1656 result=dict.fromkeys(inputRange,
None)
1657 qHandle=schema.newQuery()
1659 qHandle.addToTableList(tablename)
1660 qHandle.addToOutputList(
'DATA_ID')
1661 qHandle.addToOutputList(
'RUNNUM')
1662 qConditionStr=
'RUNNUM>=:rmin'
1663 qCondition=coral.AttributeList()
1664 qCondition.extend(
'rmin',
'unsigned int')
1665 qCondition[
'rmin'].setData(rmin)
1667 qConditionStr+=
' AND RUNNUM<=:rmax'
1668 qCondition.extend(
'rmax',
'unsigned int')
1669 qCondition[
'rmax'].setData(rmax)
1670 qResult=coral.AttributeList()
1671 qResult.extend(
'DATA_ID',
'unsigned long long')
1672 qResult.extend(
'RUNNUM',
'unsigned int')
1673 qHandle.defineOutput(qResult)
1674 qHandle.setCondition(qConditionStr,qCondition)
1675 cursor=qHandle.execute()
1676 while cursor.next():
1677 dataid=cursor.currentRow()[
'DATA_ID'].
data()
1678 runnum=cursor.currentRow()[
'RUNNUM'].
data()
1679 if result.has_key(runnum):
1680 if dataid>result[runnum]:
1681 result[runnum]=dataid
1732 get norm dataids by amodetag, egev if there are duplicates, pick max(dataid).Bypass full version lookups
1733 select data_id from luminorm where amodetag=:amodetag and egev_1=:egev1
1736 qHandle=schema.newQuery()
1741 qHandle.addToOutputList(
'DATA_ID',
'normdataid')
1742 qConditionStr=
'AMODETAG=:amodetag AND EGEV_1>=:egevmin AND EGEV_1<=:egevmax'
1743 qCondition=coral.AttributeList()
1744 qCondition.extend(
'amodetag',
'string')
1745 qCondition.extend(
'egevmin',
'unsigned int')
1746 qCondition.extend(
'egevmax',
'unsigned int')
1747 qCondition[
'amodetag'].setData(amodetag)
1748 qCondition[
'egevmin'].setData(int(egevmin))
1749 qCondition[
'egevmax'].setData(int(egevmax))
1750 qResult=coral.AttributeList()
1751 qResult.extend(
'normdataid',
'unsigned long long')
1752 qHandle.defineOutput(qResult)
1753 qHandle.setCondition(qConditionStr,qCondition)
1754 cursor=qHandle.execute()
1755 while cursor.next():
1756 normdataid=cursor.currentRow()[
'normdataid'].
data()
1757 luminormids.append(normdataid)
1762 if len(luminormids) !=0:
return max(luminormids)
1767 get norm dataids by name, if there are duplicates, pick max(dataid).Bypass full version lookups
1768 select data_id from luminorms where entry_name=:normname
1769 result luminormdataid
1772 qHandle=schema.newQuery()
1775 qHandle.addToOutputList(
'DATA_ID',
'normdataid')
1776 qConditionStr=
'ENTRY_NAME=:normname '
1777 qCondition=coral.AttributeList()
1778 qCondition.extend(
'normname',
'string')
1779 qCondition[
'normname'].setData(normname)
1780 qResult=coral.AttributeList()
1781 qResult.extend(
'normdataid',
'unsigned long long')
1782 qHandle.defineOutput(qResult)
1783 qHandle.setCondition(qConditionStr,qCondition)
1784 cursor=qHandle.execute()
1785 while cursor.next():
1786 normdataid=cursor.currentRow()[
'normdataid'].
data()
1787 luminormids.append(normdataid)
1792 if len(luminormids) !=0:
return max(luminormids)
1799 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;
1802 return [lumientryid,trgentryid,hltentryid]
1805 qHandle=schema.newQuery()
1814 qCondition=coral.AttributeList()
1815 qCondition.extend(
'runnumstr',
'string')
1816 qCondition[
'runnumstr'].setData(str(runnum))
1817 qResult=coral.AttributeList()
1818 qResult.extend(
'lumientryid',
'unsigned long long')
1819 qResult.extend(
'trgentryid',
'unsigned long long')
1820 qResult.extend(
'hltentryid',
'unsigned long long')
1821 qHandle.defineOutput(qResult)
1822 qHandle.setCondition(qConditionStr,qCondition)
1823 cursor=qHandle.execute()
1824 while cursor.next():
1825 lumientryid=cursor.currentRow()[
'lumientryid'].
data()
1826 trgentryid=cursor.currentRow()[
'trgentryid'].
data()
1827 hltentryid=cursor.currentRow()[
'hltentryid'].
data()
1828 if lumientryid
in branchfilter
and trgentryid
in branchfilter
and hltentryid
in branchfilter:
1829 result.extend([lumientryid,trgentryid,hltentryid])
1838 select l.data_id,rl.revision_id from lumidatatable l,lumirevisions rl where l.data_id=rl.data_id and l.entry_id=:entryid
1839 check revision_id is in branch
1844 if datatype==
'lumi':
1846 elif datatype==
'trg':
1848 elif dataytpe==
'hlt':
1851 raise RunTimeError(
'datatype '+datatype+
' is not supported')
1853 qHandle=schema.newQuery()
1855 qHandle.addToTableList(revmaptablename)
1856 qHandle.addToTableList(datatablename)
1857 qHandle.addToOutputList(
'l.DATA_ID',
'dataid')
1858 qHandle.addToOutputList(revmaptablename+
'.REVISION_ID',
'revisionid')
1859 qConditionStr=datatablename+
'.DATA_ID='+revmaptablename+
'.DATA_ID AND '+datatablename+
'.ENTRY_ID=:entryid'
1860 qCondition=coral.AttributeList()
1861 qCondition.extend(
'entryid',
'unsigned long long')
1862 qResult=coral.AttributeList()
1863 qResult.extend(
'dataid',
'unsigned long long')
1864 qResult.extend(
'revisionid',
'unsigned long long')
1865 qHandle.defineOutput(qResult)
1866 qHandle.setCondition(qConditionStr,qCondition)
1867 cursor=qHandle.execute()
1868 while cursor.next():
1869 dataid=cursor.currentRow()[
'dataid'].
data()
1870 revisionid=cursor.currentRow()[
'revisionid'].
data()
1871 if revisionid
in branchfilter:
1872 dataids.append(dataid)
1877 if len(dataids)!=0:
return max(dataids)
1887 branchinfo(normrevisionid,branchname)
1888 optionalnormdata {'norm_occ2':norm_occ2,'norm_et':norm_et,'norm_pu':norm_pu,'constfactor':constfactor}
1890 (revision_id,entry_id,data_id)
1894 if optionalnormdata.has_key(
'normOcc2'):
1895 norm_occ2=optionalnormdata[
'norm_occ2']
1897 if optionalnormdata.has_key(
'norm_et'):
1898 norm_et=optionalnormdata[
'norm_et']
1900 if optionalnormdata.has_key(
'norm_pu'):
1901 norm_pu=optionalnormdata[
'norm_pu']
1903 if optionalnormdata.has_key(
'constfactor'):
1904 constfactor=optionalnormdata[
'constfactor']
1907 if entry_id
is None:
1909 entryinfo=(revision_id,entry_id,normname,data_id)
1914 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'}
1915 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}
1918 return (revision_id,entry_id,data_id)
1925 branchinfo(corrrevisionid,branchname)
1926 optionalcorrdata {'a2':a2,'drift':drif}
1928 (revision_id,entry_id,data_id)
1931 if optionalcorrdata.has_key(
'a2'):
1932 a2=optionalcorrdata[
'a2']
1934 if optionalcorrdata.has_key(
'drift'):
1935 drift=optionalcorrdata[
'drift']
1938 if entry_id
is None:
1940 entryinfo=(revision_id,entry_id,corrname,data_id)
1945 tabrowDefDict={
'DATA_ID':
'unsigned long long',
'ENTRY_ID':
'unsigned long long',
'ENTRY_NAME':
'string',
'A1':
'float',
'A2':
'float',
'DRIFT':
'float'}
1946 tabrowValueDict={
'DATA_ID':data_id,
'ENTRY_ID':entry_id,
'ENTRY_NAME':corrname,
'A1':a1,
'A2':a2,
'DRIFT':drift}
1948 db.insertOneRow(nameDealer.lumicorrectionsTableName(),tabrowDefDict,tabrowValueDict)
1949 return (revision_id,entry_id,data_id)
1956 lumirundata [datasource,nominalenergy,ncollidingbunches,starttime,stoptime,nls]
1957 branchinfo (branch_id,branch_name)
1958 tableName lumiruntablename
1960 (revision_id,entry_id,data_id)
1963 datasource=lumirundata[0]
1966 starttime=coral.TimeStamp()
1967 stoptime=coral.TimeStamp()
1969 if len(lumirundata)>1:
1970 nominalenergy=lumirundata[1]
1971 ncollidingbunches=lumirundata[2]
1972 starttime=lumirundata[3]
1973 stoptime=lumirundata[4]
1976 if entry_id
is None:
1978 entryinfo=(revision_id,entry_id,str(runnumber),data_id)
1984 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'}
1985 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}
1987 db.insertOneRow(tableName,tabrowDefDict,tabrowValueDict)
1988 return (revision_id,entry_id,data_id)
1995 trgrundata [datasource(0),bitzeroname(1),bitnameclob(2)]
1996 bitnames clob, bitnames separated by ','
1998 (revision_id,entry_id,data_id)
2001 datasource=trgrundata[0]
2002 bitzeroname=trgrundata[1]
2003 bitnames=trgrundata[2]
2005 if entry_id
is None:
2007 entryinfo=(revision_id,entry_id,str(runnumber),data_id)
2012 tabrowDefDict={
'DATA_ID':
'unsigned long long',
'ENTRY_ID':
'unsigned long long',
'ENTRY_NAME':
'string',
'SOURCE':
'string',
'RUNNUM':
'unsigned int',
'BITZERONAME':
'string',
'BITNAMECLOB':
'string'}
2013 tabrowValueDict={
'DATA_ID':data_id,
'ENTRY_ID':entry_id,
'ENTRY_NAME':str(runnumber),
'SOURCE':datasource,
'RUNNUM':int(runnumber),
'BITZERONAME':bitzeroname,
'BITNAMECLOB':bitnames}
2016 return (revision_id,entry_id,data_id)
2022 hltrundata [pathnameclob(0),datasource(1)]
2024 (revision_id,entry_id,data_id)
2027 pathnames=hltrundata[0]
2028 datasource=hltrundata[1]
2029 npath=len(pathnames.split(
','))
2031 if entry_id
is None:
2033 entryinfo=(revision_id,entry_id,str(runnumber),data_id)
2038 tabrowDefDict={
'DATA_ID':
'unsigned long long',
'ENTRY_ID':
'unsigned long long',
'ENTRY_NAME':
'string',
'RUNNUM':
'unsigned int',
'SOURCE':
'string',
'NPATH':
'unsigned int',
'PATHNAMECLOB':
'string'}
2039 tabrowValueDict={
'DATA_ID':data_id,
'ENTRY_ID':entry_id,
'ENTRY_NAME':str(runnumber),
'RUNNUM':int(runnumber),
'SOURCE':datasource,
'NPATH':npath,
'PATHNAMECLOB':pathnames}
2042 return (revision_id,entry_id,data_id)
2049 runsummarydata [l1key,amodetag,egev,sequence,hltkey,fillnum,starttime,stoptime]
2052 l1key=runsummarydata[0]
2053 amodetag=runsummarydata[1]
2054 egev=runsummarydata[2]
2060 if not complementalOnly:
2061 sequence=runsummarydata[3]
2062 hltkey=runsummarydata[4]
2063 fillnum=runsummarydata[5]
2064 starttime=runsummarydata[6]
2065 stoptime=runsummarydata[7]
2067 if not complementalOnly:
2068 tabrowDefDict={
'RUNNUM':
'unsigned int',
'L1KEY':
'string',
'AMODETAG':
'string',
'EGEV':
'unsigned int',
'SEQUENCE':
'string',
'HLTKEY':
'string',
'FILLNUM':
'unsigned int',
'STARTTIME':
'time stamp',
'STOPTIME':
'time stamp'}
2069 tabrowValueDict={
'RUNNUM':int(runnumber),
'L1KEY':l1key,
'AMODETAG':amodetag,
'EGEV':int(egev),
'SEQUENCE':sequence,
'HLTKEY':hltkey,
'FILLNUM':int(fillnum),
'STARTTIME':starttime,
'STOPTIME':stoptime}
2073 setClause=
'L1KEY=:l1key,AMODETAG=:amodetag,EGEV=:egev'
2074 updateCondition=
'RUNNUM=:runnum'
2075 inputData=coral.AttributeList()
2076 inputData.extend(
'l1key',
'string')
2077 inputData.extend(
'amodetag',
'string')
2078 inputData.extend(
'egev',
'unsigned int')
2079 inputData.extend(
'runnum',
'unsigned int')
2080 inputData[
'l1key'].setData(l1key)
2081 inputData[
'amodetag'].setData(amodetag)
2082 inputData[
'egev'].setData(int(egev))
2083 inputData[
'runnum'].setData(int(runnumber))
2091 trghltmap {hltpath:l1seed}
2097 kQueryBindList=coral.AttributeList()
2098 kQueryBindList.extend(
'hltkey',
'string')
2099 kQuery=schema.newQuery()
2101 kQuery.setCondition(
'HLTKEY=:hltkey',kQueryBindList)
2102 kQueryBindList[
'hltkey'].setData(hltkey)
2103 kResult=kQuery.execute()
2104 while kResult.next():
2106 if not hltkeyExists:
2108 trghltDefDict=[(
'HLTKEY',
'string'),(
'HLTPATHNAME',
'string'),(
'L1SEED',
'string')]
2109 for hltpath,l1seed
in trghltmap.items():
2110 bulkvalues.append([(
'HLTKEY',hltkey),(
'HLTPATHNAME',hltpath),(
'L1SEED',l1seed)])
2113 nrows=len(bulkvalues)
2116 print 'error in insertTrgHltMap '
2120 insert trg per-LS data for given run and data_id, this operation can be split in transaction chuncks
2122 trglsdata {cmslsnum:[deadtime,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]}
2123 result nrows inserted
2124 if nrows==0, then this insertion failed
2126 print 'total number of trg rows ',len(trglsdata)
2127 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')]
2132 for cmslsnum,perlstrg
in trglsdata.items():
2133 deadtimecount=perlstrg[0]
2134 bitzerocount=perlstrg[1]
2135 bitzeroprescale=perlstrg[2]
2136 trgcountblob=perlstrg[3]
2137 trgprescaleblob=perlstrg[4]
2138 bulkvalues.append([(
'DATA_ID',data_id),(
'RUNNUM',runnumber),(
'CMSLSNUM',cmslsnum),(
'DEADTIMECOUNT',deadtimecount),(
'BITZEROCOUNT',bitzerocount),(
'BITZEROPRESCALE',bitzeroprescale),(
'PRESCALEBLOB',trgprescaleblob),(
'TRGCOUNTBLOB',trgcountblob)])
2142 print 'committing trg in LS chunck ',nrows
2144 session.transaction().
start(
False)
2146 session.transaction().commit()
2149 elif committedrows==len(trglsdata):
2150 print 'committing trg at the end '
2152 session.transaction().
start(
False)
2154 session.transaction().commit()
2156 print 'error in bulkInsertTrgLSData'
2161 hltlsdata {cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}
2163 print 'total number of hlt rows ',len(hltlsdata)
2164 lshltDefDict=[(
'DATA_ID',
'unsigned long long'),(
'RUNNUM',
'unsigned int'),(
'CMSLSNUM',
'unsigned int'),(
'PRESCALEBLOB',
'blob'),(
'HLTCOUNTBLOB',
'blob'),(
'HLTACCEPTBLOB',
'blob')]
2169 for cmslsnum,perlshlt
in hltlsdata.items():
2170 inputcountblob=perlshlt[0]
2171 acceptcountblob=perlshlt[1]
2172 prescaleblob=perlshlt[2]
2173 bulkvalues.append([(
'DATA_ID',data_id),(
'RUNNUM',runnumber),(
'CMSLSNUM',cmslsnum),(
'PRESCALEBLOB',prescaleblob),(
'HLTCOUNTBLOB',inputcountblob),(
'HLTACCEPTBLOB',acceptcountblob)])
2178 print 'committing hlt in LS chunck ',nrows
2180 session.transaction().
start(
False)
2182 session.transaction().commit()
2185 elif committedrows==len(hltlsdata):
2186 print 'committing hlt at the end '
2188 session.transaction().
start(
False)
2190 session.transaction().commit()
2192 print 'error in bulkInsertHltLSData'
2198 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]}
2202 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')]
2204 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')]
2205 print 'total number of lumi rows ',len(lumilsdata)
2210 for lumilsnum,perlslumi
in lumilsdata.items():
2211 cmslsnum=perlslumi[0]
2212 instlumi=perlslumi[1]
2213 instlumierror=perlslumi[2]
2214 instlumiquality=perlslumi[3]
2215 beamstatus=perlslumi[4]
2216 beamenergy=perlslumi[5]
2217 numorbit=perlslumi[6]
2218 startorbit=perlslumi[7]
2220 cmsbxindexindexblob=perlslumi[8]
2221 beam1intensity=perlslumi[9]
2222 beam2intensity=perlslumi[10]
2223 bxlumivalue_occ1=perlslumi[11]
2224 bxlumierror_occ1=perlslumi[12]
2225 bxlumiquality_occ1=perlslumi[13]
2226 bxlumivalue_occ2=perlslumi[14]
2227 bxlumierror_occ2=perlslumi[15]
2228 bxlumiquality_occ2=perlslumi[16]
2229 bxlumivalue_et=perlslumi[17]
2230 bxlumierror_et=perlslumi[18]
2231 bxlumiquality_et=perlslumi[19]
2232 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)])
2234 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)])
2238 print 'committing lumi in LS chunck ',nrows
2240 session.transaction().
start(
False)
2241 db.bulkInsert(tableName,lslumiDefDict,bulkvalues)
2242 session.transaction().commit()
2245 elif committedrows==len(lumilsdata):
2246 print 'committing lumi at the end '
2248 session.transaction().
start(
False)
2249 db.bulkInsert(tableName,lslumiDefDict,bulkvalues)
2250 session.transaction().commit()
2318 if __name__ ==
"__main__":
2319 import sessionManager
2320 import lumidbDDL,revisionDML,generateDummyData
2322 myconstr=
'oracle://devdb10/cms_xiezhen_dev'
2324 session=svc.openSession(isReadOnly=
False,cpp2sqltype=[(
'unsigned int',
'NUMBER(10)'),(
'unsigned long long',
'NUMBER(20)')])
2325 schema=session.nominalSchema()
2326 session.transaction().
start(
False)
2342 normbranchinfo=(normbranchid,
'NORM')
2343 addNormToBranch(schema,
'pp7TeV',
'PROTPHYS',6370.0,3500,{},normbranchinfo)
2346 branchinfo=(branchid,
'DATA')
2347 for runnum
in [1200,1211,1222,1233,1345]:
2353 lumirundata=[lumidummydata[0]]
2354 lumilsdata=lumidummydata[1]
2356 insertLumiLSSummary(schema,runnum,lumidataid,lumilsdata)
2358 trgrundata=[trgdata[0],trgdata[1],trgdata[2]]
2359 trglsdata=trgdata[3]
2361 insertTrgLSData(schema,runnum,trgdataid,trglsdata)
2363 hltrundata=[hltdata[0],hltdata[1]]
2364 hltlsdata=hltdata[2]
2366 insertHltLSData(schema,runnum,hltdataid,hltlsdata)
2367 session.transaction().commit()
2368 print 'test reading'
2369 session.transaction().
start(
True)
2370 print '===inspecting NORM by name==='
2374 print 'latest norm data_id for pp7TeV ',latestNorms
2376 print '===inspecting DATA branch==='
2382 print 'latest lumi data_id for run 1211 ',latestrevision
2385 print 'latest lumi data_id for run 1222 ',latestrevision
2388 print 'latest trg data_id for run 1222 ',latestrevision
2389 session.transaction().commit()
2390 print 'tagging data so far as data_orig'
2391 session.transaction().
start(
False)
2393 session.transaction().commit()
2394 session.transaction().
start(
True)
2398 session.transaction().commit()
2399 session.transaction().
start(
False)
2400 for runnum
in [1200,1222]:
2401 print 'revising lumidata for run ',runnum
2403 lumirundata=[lumidummydata[0]]
2404 lumilsdata=lumidummydata[1]
2406 insertLumiLSSummary(schema,runnum,lumidataid,lumilsdata)
2409 session.transaction().commit()
2412 print '===test reading==='
2413 session.transaction().
start(
True)
2435 print 'trg run, trgdataid ',trgdataid
2436 print trgRunById(schema,trgdataid,withblobdata=
True)
2443 session.transaction().commit()
def guessLumiDataIdByRunInBranch
def revisionsInBranchName
def pixeltagRunsTableName
def guessTrgDataIdByRunInBranch
def bulkInsertLumiLSSummary
def addTrgRunDataToBranch
const T & max(const T &a, const T &b)
def addLumiRunDataToBranch
def pixellumidataTableName
static std::string join(char **cmd)
def lumisummaryv2TableName
char data[epos_bytes_allocation]
def guesscorrIdByName
LumiDB DML API # # Author: Zhen Xie #.
def guessHltDataIdByRunInBranch
def addHLTRunDataToBranch
def latestDataRevisionOfEntry
def cmsrunsummaryTableName