1 from __future__
import print_function
2 from builtins
import range
4 from RecoLuminosity.LumiDB
import CommonUtil,nameDealer
8 input: runnumber,calibrated instlumi,calibrated instlumierror 9 output: (uncalibrated instlumi, uncalbrated instlumierror) 11 normpp7tev=
float(6370.0)
12 normpp900gev=
float(16500.0)
13 normhi7tev=
float(2.383)
14 oldnormpp7tev=
float(6330)
15 if runnumber
in [136290,136294,136297,134721,134725]:
16 return (
float(instlumi)/normpp900gev,
float(instlumierror)/normpp900gev)
17 if runnumber >=150431
and runnumber<=153368 :
18 return (
float(instlumi)/normhi7tev,
float(instlumierror)/normhi7tev)
19 return (
float(instlumi)/normpp7tev,
float(instlumierror)/normpp7tev)
23 retrieve old lumi value, divide by norm and restore to raw value 24 select lumilsnum,cmslsnum,instlumi,instlumierror,instlumiquality,startorbit,numorbit,beamenergy,beamstatus,cmsbxindexblob,beamintensityblob_1,beamintensityblob_2 from lumisummary where runnum=:runnumber order by lumilsnum 26 select s.lumilsnum,d.bxlumivalue,d.bxlumierror,d.bxlumiquality from lumidetail d,lumisummary s where d.lumisummary_id=s.lumisummary_id and s.runnum=:runnumber and d.algoname=:algoname order by s.lumilsnum 28 output: {lumilsnum:[cmslsnum,uncalibratedinstlumi,uncalibratedinstlumierror,instlumiquality,beamstatus,beamenergy,numorbit,startorbit,cmsbxindexblob,beamintensityblob_1,beamintensityblob_2,bxlumivalue_occ1,bxlumierror_occ1,,bxlumiquality_occ1,bxlumivalue_occ2,bxlumierror_occ2,bxlumiquality_occ2,bxlumivalue_et,bxlumierror_et,bxlumiquality_et]}]} 29 dict size ~ 200mb for 1000LS 34 session.transaction().
start(
True)
35 lumischema=session.nominalSchema()
36 summaryQuery=lumischema.newQuery()
38 summaryQuery.addToOutputList(
'LUMILSNUM',
'lumilsnum')
39 summaryQuery.addToOutputList(
'CMSLSNUM',
'cmslsnum')
40 summaryQuery.addToOutputList(
'INSTLUMI',
'instlumi')
41 summaryQuery.addToOutputList(
'INSTLUMIERROR',
'instlumierror')
42 summaryQuery.addToOutputList(
'INSTLUMIQUALITY',
'instlumiquality')
43 summaryQuery.addToOutputList(
'BEAMSTATUS',
'beamstatus')
44 summaryQuery.addToOutputList(
'BEAMENERGY',
'beamenergy')
45 summaryQuery.addToOutputList(
'NUMORBIT',
'numorbit')
46 summaryQuery.addToOutputList(
'STARTORBIT',
'startorbit')
47 summaryQuery.addToOutputList(
'CMSBXINDEXBLOB',
'cmsbxindexblob')
48 summaryQuery.addToOutputList(
'BEAMINTENSITYBLOB_1',
'beamintensityblob_1')
49 summaryQuery.addToOutputList(
'BEAMINTENSITYBLOB_2',
'beamintensityblob_2')
50 summaryCondition=coral.AttributeList()
51 summaryCondition.extend(
'runnumber',
'unsigned int')
52 summaryCondition[
'runnumber'].setData(
int(runnumber))
53 summaryResult=coral.AttributeList()
54 summaryResult.extend(
'lumilsnum',
'unsigned int')
55 summaryResult.extend(
'cmslsnum',
'unsigned int')
56 summaryResult.extend(
'instlumi',
'float')
57 summaryResult.extend(
'instlumierror',
'float')
58 summaryResult.extend(
'instlumiquality',
'short')
59 summaryResult.extend(
'beamstatus',
'string')
60 summaryResult.extend(
'beamenergy',
'float')
61 summaryResult.extend(
'numorbit',
'unsigned int')
62 summaryResult.extend(
'startorbit',
'unsigned int')
63 summaryResult.extend(
'cmsbxindexblob',
'blob')
64 summaryResult.extend(
'beamintensityblob_1',
'blob')
65 summaryResult.extend(
'beamintensityblob_2',
'blob')
66 summaryQuery.defineOutput(summaryResult)
67 summaryQuery.addToOrderList(
'lumilsnum')
68 summaryQuery.setCondition(
'RUNNUM=:runnumber',summaryCondition)
69 summarycursor=summaryQuery.execute()
70 while next(summarycursor):
71 lumilsnum=summarycursor.currentRow()[
'lumilsnum'].
data()
72 cmslsnum=summarycursor.currentRow()[
'cmslsnum'].
data()
73 instlumi=summarycursor.currentRow()[
'instlumi'].
data()
74 instlumierror=summarycursor.currentRow()[
'instlumierror'].
data()
75 instlumiquality=summarycursor.currentRow()[
'instlumiquality'].
data()
76 (uncalibratedinstlumi,uncalibratedinstlumierror)=
uncalibrateLumi(runnumber,instlumi,instlumierror)
77 numorbit=summarycursor.currentRow()[
'numorbit'].
data()
78 startorbit=summarycursor.currentRow()[
'startorbit'].
data()
79 beamenergy=summarycursor.currentRow()[
'beamenergy'].
data()
80 beamstatus=summarycursor.currentRow()[
'beamstatus'].
data()
82 if not summarycursor.currentRow()[
'cmsbxindexblob'].isNull():
83 cmsbxindexblob=summarycursor.currentRow()[
'cmsbxindexblob'].
data()
84 beamintensityblob_1=
None 85 if not summarycursor.currentRow()[
'beamintensityblob_1'].isNull():
86 beamintensityblob_1=summarycursor.currentRow()[
'beamintensityblob_1'].
data()
87 beamintensityblob_2=
None 88 if not summarycursor.currentRow()[
'beamintensityblob_2'].isNull():
89 beamintensityblob_2=summarycursor.currentRow()[
'beamintensityblob_2'].
data()
90 datadict[lumilsnum]=[cmslsnum,uncalibratedinstlumi,uncalibratedinstlumierror,instlumiquality,beamstatus,beamenergy,numorbit,startorbit,cmsbxindexblob,beamintensityblob_1,beamintensityblob_2]
93 for algoname
in [
'OCC1',
'OCC2',
'ET']:
94 detailQuery=lumischema.newQuery()
97 detailQuery.addToOutputList(
's.LUMILSNUM',
'lumilsnum' )
98 detailQuery.addToOutputList(
'd.BXLUMIVALUE',
'bxlumivalue' )
99 detailQuery.addToOutputList(
'd.BXLUMIERROR',
'bxlumierror' )
100 detailQuery.addToOutputList(
'd.BXLUMIQUALITY',
'bxlumiquality' )
101 detailCondition=coral.AttributeList()
102 detailCondition.extend(
'runnumber',
'unsigned int')
103 detailCondition.extend(
'algoname',
'string')
104 detailCondition[
'runnumber'].setData(
int(runnumber))
105 detailCondition[
'algoname'].setData(algoname)
106 detailResult=coral.AttributeList()
107 detailResult.extend(
'lumilsnum',
'unsigned int')
108 detailResult.extend(
'bxlumivalue',
'blob')
109 detailResult.extend(
'bxlumierror',
'blob')
110 detailResult.extend(
'bxlumiquality',
'blob')
111 detailQuery.defineOutput(detailResult)
112 detailQuery.addToOrderList(
'lumilsnum')
113 detailQuery.setCondition(
's.RUNNUM=:runnumber AND s.LUMISUMMARY_ID=d.LUMISUMMARY_ID AND d.ALGONAME=:algoname',detailCondition)
114 detailcursor=detailQuery.execute()
115 while next(detailcursor):
116 lumilsnum=detailcursor.currentRow()[
'lumilsnum'].
data()
117 bxlumivalue=detailcursor.currentRow()[
'bxlumivalue'].
data()
118 bxlumierror=detailcursor.currentRow()[
'bxlumierror'].
data()
119 bxlumiquality=detailcursor.currentRow()[
'bxlumiquality'].
data()
120 datadict[lumilsnum].extend([bxlumivalue,bxlumierror,bxlumiquality])
122 session.transaction().commit()
128 select count(distinct pathname) from hlt where runnum=:runnum 129 select cmslsnum,pathname,inputcount,acceptcount,prescale from hlt where runnum=:runnum order by cmslsnum,pathname 130 [pathnames,databuffer] 131 databuffer: {cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]} 135 session.transaction().
start(
True)
136 lumischema=session.nominalSchema()
138 qHandle=lumischema.newQuery()
140 qHandle.addToOutputList(
'COUNT(DISTINCT PATHNAME)',
'npath')
141 qCondition=coral.AttributeList()
142 qCondition.extend(
'runnum',
'unsigned int')
143 qCondition[
'runnum'].setData(
int(runnumber))
144 qResult=coral.AttributeList()
145 qResult.extend(
'npath',
'unsigned int')
146 qHandle.defineOutput(qResult)
147 qHandle.setCondition(
'RUNNUM=:runnum',qCondition)
148 cursor=qHandle.execute()
150 npath=cursor.currentRow()[
'npath'].
data()
154 qHandle=lumischema.newQuery()
156 qHandle.addToOutputList(
'CMSLSNUM',
'cmslsnum')
157 qHandle.addToOutputList(
'PATHNAME',
'pathname')
158 qHandle.addToOutputList(
'INPUTCOUNT',
'inputcount')
159 qHandle.addToOutputList(
'ACCEPTCOUNT',
'acceptcount')
160 qHandle.addToOutputList(
'PRESCALE',
'prescale')
161 qCondition=coral.AttributeList()
162 qCondition.extend(
'runnum',
'unsigned int')
163 qCondition[
'runnum'].setData(
int(runnumber))
164 qResult=coral.AttributeList()
165 qResult.extend(
'cmslsnum',
'unsigned int')
166 qResult.extend(
'pathname',
'string')
167 qResult.extend(
'inputcount',
'unsigned int')
168 qResult.extend(
'acceptcount',
'unsigned int')
169 qResult.extend(
'prescale',
'unsigned int')
170 qHandle.defineOutput(qResult)
171 qHandle.setCondition(
'RUNNUM=:runnum',qCondition)
172 qHandle.addToOrderList(
'cmslsnum')
173 qHandle.addToOrderList(
'pathname')
174 cursor=qHandle.execute()
176 inputcountArray=array.array(
'I')
177 acceptcountArray=array.array(
'I')
178 prescaleArray=array.array(
'I')
180 pathnHLT_PixelTracksVdMames=
'' 182 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
183 pathname=cursor.currentRow()[
'pathname'].
data()
185 inputcount=cursor.currentRow()[
'inputcount'].
data()
186 acceptcount=cursor.currentRow()[
'acceptcount'].
data()
187 prescale=cursor.currentRow()[
'prescale'].
data()
188 pathnameList.append(pathname)
189 inputcountArray.append(inputcount)
190 acceptcountArray.append(acceptcount)
191 prescaleArray.append(prescale)
194 pathnames=
','.
join(pathnameList)
198 databuffer[cmslsnum]=[inputcountBlob,acceptcountBlob,prescaleBlob]
200 inputcountArray=array.array(
'I')
201 acceptcountArray=array.array(
'I')
202 prescaleArray=array.array(
'I')
205 session.transaction().commit()
207 return [pathnames,databuffer]
213 select bitnum,bitname from trg where runnum=:runnumber and cmslsnum=1 order by bitnum 214 select cmslsnum,deadtime,trgcount,prescale from trg where bitnum=:bitnum and runnum=:runnumber 216 output: [bitnames,{cmslsnum,[deadtime,bitzerocount,bitzerpoprescale,trgcountBlob,trgprescaleBlob]}] 218 session.transaction().
start(
True)
219 lumischema=session.nominalSchema()
220 qHandle=lumischema.newQuery()
222 qHandle=lumischema.newQuery()
224 qHandle.addToOutputList(
'BITNUM',
'bitnum')
225 qHandle.addToOutputList(
'BITNAME',
'bitname')
226 qCondition=coral.AttributeList()
227 qCondition.extend(
'runnum',
'unsigned int')
228 qCondition[
'runnum'].setData(
int(runnumber))
229 qCondition.extend(
'cmslsnum',
'unsigned int')
230 qCondition[
'cmslsnum'].setData(
int(1))
231 qResult=coral.AttributeList()
232 qResult.extend(
'bitnum',
'unsigned int')
233 qResult.extend(
'bitname',
'string')
234 qHandle.defineOutput(qResult)
235 qHandle.setCondition(
'RUNNUM=:runnum AND CMSLSNUM=:cmslsnum',qCondition)
236 qHandle.addToOrderList(
'BITNUM')
237 cursor=qHandle.execute()
241 bitnum=cursor.currentRow()[
'bitnum'].
data()
242 bitname=cursor.currentRow()[
'bitname'].
data()
243 bitnums.append(bitnum)
244 bitnameList.append(bitname)
246 bitnames=
','.
join(bitnameList)
249 qHandle=lumischema.newQuery()
251 qHandle.addToOutputList(
'CMSLSNUM',
'cmslsnum')
252 qHandle.addToOutputList(
'BITNUM',
'bitnum')
253 qHandle.addToOutputList(
'DEADTIME',
'deadtime')
254 qHandle.addToOutputList(
'TRGCOUNT',
'trgcount')
255 qHandle.addToOutputList(
'PRESCALE',
'prescale')
256 qCondition=coral.AttributeList()
257 qCondition.extend(
'runnum',
'unsigned int')
258 qCondition[
'runnum'].setData(
int(runnumber))
259 qResult=coral.AttributeList()
260 qResult.extend(
'cmslsnum',
'unsigned int')
261 qResult.extend(
'bitnum',
'unsigned int')
262 qResult.extend(
'deadtime',
'unsigned long long')
263 qResult.extend(
'trgcount',
'unsigned int')
264 qResult.extend(
'prescale',
'unsigned int')
265 qHandle.defineOutput(qResult)
266 qHandle.setCondition(
'RUNNUM=:runnum',qCondition)
267 qHandle.addToOrderList(
'CMSLSNUM')
268 qHandle.addToOrderList(
'BITNUM')
269 cursor=qHandle.execute()
270 trgcountArray=array.array(
'I')
271 prescaleArray=array.array(
'I')
273 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
274 bitnum=cursor.currentRow()[
'bitnum'].
data()
275 deadtime=cursor.currentRow()[
'deadtime'].
data()
276 trgcount=cursor.currentRow()[
'trgcount'].
data()
277 prescale=cursor.currentRow()[
'prescale'].
data()
278 if cmslsnum
not in databuffer:
279 databuffer[cmslsnum]=[]
280 databuffer[cmslsnum].
append(deadtime)
282 databuffer[cmslsnum].
append(trgcount)
283 databuffer[cmslsnum].
append(prescale)
284 trgcountArray.append(trgcount)
285 prescaleArray.append(prescale)
289 databuffer[cmslsnum].
append(trgcountBlob)
290 databuffer[cmslsnum].
append(prescaleBlob)
291 trgcountArray=array.array(
'I')
292 prescaleArray=array.array(
'I')
294 session.transaction().commit()
295 return [bitnames,databuffer]
307 select counts,lsnr,algobit from cms_gt_mon.gt_mon_trig_algo_view where runnr=:runnumber order by lsnr,algobit 308 select counts,lsnr,techbit from cms_gt_mon.gt_mon_trig_tech_view where runnr=:runnumber order by lsnr,techbit 309 select counts,lsnr from cms_gt_mon.gt_mon_trig_dead_view where runnr=:runnumber and deadcounter=:countername order by lsnr 310 select algo_index,alias from cms_gt.gt_run_algo_view where runnumber=:runnumber order by algo_index 311 select techtrig_index,name from cms_gt.gt_run_tech_view where runnumber=:runnumber order by techtrig_index 312 select prescale_factor_algo_000,prescale_factor_algo_001..._127 from cms_gt.gt_run_presc_algo_view where runnr=:runnumber and prescale_index=0; 313 select prescale_factor_tt_000,prescale_factor_tt_001..._63 from cms_gt.gt_run_presc_tech_view where runnr=:runnumber and prescale_index=0; 320 output: [bitnameclob,{cmslsnum:[deadtime,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]}] 321 1. select counts,lsnr from cms_gt_mon.gt_mon_trig_dead_view where runnr=:runnumber and deadcounter=:countername order by lsnr 322 2. select counts,lsnr,algobit from cms_gt_mon.gt_mon_trig_algo_view where runnr=:runnumber order by lsnr,algobit 323 3. select counts,lsnr,techbit from cms_gt_mon.gt_mon_trig_tech_view where runnr=:runnumber order by lsnr,techbit 324 4. select algo_index,alias from cms_gt.gt_run_algo_view where runnumber=:runnumber order by algo_index 325 ## not needed5. select techtrig_index,name from cms_gt.gt_run_tech_view where runnumber=:runnumber order by techtrig_index 326 5 select distinct(prescale_index) from cms_gt_mon.lumi_sections where run_number=:runnumber; 327 6. select prescale_factor_algo_000,algo.prescale_factor_algo_001..._127 from cms_gt.gt_run_presc_algo_view where prescale_index=:prescale_index and runnr=:runnumber; 328 7. select prescale_factor_tt_000,tech.prescale_factor_tt_001..._63 from cms_gt.gt_run_presc_tech_view where prescale_index=:prescale_index and runnr=:runnumber; 329 8. select lumi_section,prescale_index from cms_gt_mon.lumi_sections where run_number=:runnumber order by lumi_section 340 bitzeroprescaleDict={}
345 session.transaction().
start(
True)
346 gtmonschema=session.schema(
'CMS_GT_MON')
350 deadviewQuery=gtmonschema.newQuery()
351 deadviewQuery.addToTableList(
'GT_MON_TRIG_DEAD_VIEW')
352 deadOutput=coral.AttributeList()
353 deadOutput.extend(
'counts',
'unsigned int')
354 deadOutput.extend(
'lsnr',
'unsigned int')
355 deadviewQuery.addToOutputList(
'counts')
356 deadviewQuery.addToOutputList(
'lsnr')
357 bindVariablesDead=coral.AttributeList()
358 bindVariablesDead.extend(
'runnumber',
'int')
359 bindVariablesDead.extend(
'countername',
'string')
360 bindVariablesDead[
'runnumber'].setData(
int(runnumber))
361 bindVariablesDead[
'countername'].setData(
'DeadtimeBeamActive')
362 deadviewQuery.setCondition(
'RUNNR=:runnumber AND DEADCOUNTER=:countername',bindVariablesDead)
363 deadviewQuery.addToOrderList(
'lsnr')
364 deadviewQuery.defineOutput(deadOutput)
365 deadcursor=deadviewQuery.execute()
367 while next(deadcursor):
368 row=deadcursor.currentRow()
370 lsnr=row[
'lsnr'].
data()
372 print(
'DEADTIME alert: found hole in LS range')
373 print(
' fill deadtimebeamactive 0 for LS '+
str(s))
376 count=row[
'counts'].
data()
377 deadtimeresult[s]=count
381 session.transaction().commit()
382 raise 'requested run '+
str(runnumber )+
' does not exist for deadcounts' 386 algoviewQuery=gtmonschema.newQuery()
390 algoviewQuery.addToTableList(
'GT_MON_TRIG_ALGO_VIEW')
391 algoOutput=coral.AttributeList()
392 algoOutput.extend(
'counts',
'unsigned int')
393 algoOutput.extend(
'lsnr',
'unsigned int')
394 algoOutput.extend(
'algobit',
'unsigned int')
395 algoviewQuery.addToOutputList(
'counts')
396 algoviewQuery.addToOutputList(
'lsnr')
397 algoviewQuery.addToOutputList(
'algobit')
398 algoCondition=coral.AttributeList()
399 algoCondition.extend(
'runnumber',
'unsigned int')
400 algoCondition[
'runnumber'].setData(
int(runnumber))
401 algoviewQuery.setCondition(
'RUNNR=:runnumber',algoCondition)
402 algoviewQuery.addToOrderList(
'lsnr')
403 algoviewQuery.addToOrderList(
'algobit')
404 algoviewQuery.defineOutput(algoOutput)
406 algocursor=algoviewQuery.execute()
408 while next(algocursor):
409 row=algocursor.currentRow()
410 lsnr=row[
'lsnr'].
data()
411 counts=row[
'counts'].
data()
412 algobit=row[
'algobit'].
data()
413 mybitcount_algo.append(counts)
415 bitzerocountDict[lsnr]=counts
416 if algobit==NAlgoBit-1:
419 print(
'ALGO COUNT alert: found hole in LS range')
420 print(
' fill all algocount 0 for LS '+
str(s))
424 algocount[s]=mybitcount_algo
429 session.transaction().commit()
430 raise 'requested run '+
str(runnumber+
' does not exist for algocounts ')
434 techviewQuery=gtmonschema.newQuery()
435 techviewQuery.addToTableList(
'GT_MON_TRIG_TECH_VIEW')
439 techOutput=coral.AttributeList()
440 techOutput.extend(
'counts',
'unsigned int')
441 techOutput.extend(
'lsnr',
'unsigned int')
442 techOutput.extend(
'techbit',
'unsigned int')
443 techviewQuery.addToOutputList(
'COUNTS',
'counts')
444 techviewQuery.addToOutputList(
'LSNR',
'lsnr')
445 techviewQuery.addToOutputList(
'TECHBIT',
'techbit')
446 techCondition=coral.AttributeList()
447 techCondition.extend(
'runnumber',
'unsigned int')
448 techCondition[
'runnumber'].setData(
int(runnumber))
449 techviewQuery.setCondition(
'RUNNR=:runnumber',techCondition)
450 techviewQuery.addToOrderList(
'lsnr')
451 techviewQuery.addToOrderList(
'techbit')
452 techviewQuery.defineOutput(techOutput)
454 techcursor=techviewQuery.execute()
456 while next(techcursor):
457 row=techcursor.currentRow()
458 lsnr=row[
'lsnr'].
data()
459 counts=row[
'counts'].
data()
460 techbit=row[
'techbit'].
data()
461 mybitcount_tech.append(counts)
462 if techbit==NTechBit-1:
465 print(
'TECH COUNT alert: found hole in LS range')
466 print(
' fill all techcount 0 for LS '+
str(s))
470 techcount[s]=mybitcount_tech
475 session.transaction().commit()
476 raise 'requested run '+
str(runnumber+
' does not exist for techcounts ')
479 gtschema=session.schema(
'CMS_GT')
481 namealiasQuery=gtschema.newQuery()
486 namealiasQuery.addToTableList(
'GT_RUN_ALGO_VIEW')
487 algonameOutput=coral.AttributeList()
488 algonameOutput.extend(
'algo_index',
'unsigned int')
489 algonameOutput.extend(
'alias',
'string')
490 namealiasQuery.addToOutputList(
'algo_index')
491 namealiasQuery.addToOutputList(
'alias')
492 algonameCondition=coral.AttributeList()
493 algonameCondition.extend(
'runnumber',
'unsigned int')
494 algonameCondition[
'runnumber'].setData(
int(runnumber))
495 namealiasQuery.setCondition(
'RUNNUMBER=:runnumber',algonameCondition)
496 namealiasQuery.defineOutput(algonameOutput)
497 algonamecursor=namealiasQuery.execute()
498 while next(algonamecursor):
499 row=algonamecursor.currentRow()
500 algo_index=row[
'algo_index'].
data()
501 algo_name=row[
'alias'].
data()
502 triggernamemap[algo_index]=algo_name
532 for algoidx
in range(NAlgoBit):
533 if algoidx
in triggernamemap.keys():
534 bitnames.append(triggernamemap[algoidx])
536 bitnames.append(
'False')
540 for techidx
in range(NTechBit):
541 bitnames.append(
str(techidx))
542 bitnameclob=
','.
join(bitnames)
547 presidxQuery=gtmonschema.newQuery()
548 presidxQuery.addToTableList(
'LUMI_SECTIONS')
550 presidxBindVariable=coral.AttributeList()
551 presidxBindVariable.extend(
'runnumber',
'int')
552 presidxBindVariable[
'runnumber'].setData(
int(runnumber))
554 presidxOutput=coral.AttributeList()
555 presidxOutput.extend(
'prescale_index',
'int')
556 presidxQuery.addToOutputList(
'distinct(PRESCALE_INDEX)',
'prescale_index')
557 presidxQuery.defineOutput(presidxOutput)
558 presidxQuery.setCondition(
'RUN_NUMBER=:runnumber',presidxBindVariable)
559 presidxCursor=presidxQuery.execute()
560 while next(presidxCursor):
561 presc=presidxCursor.currentRow()[
'prescale_index'].
data()
562 prescaleidx.append(presc)
568 for prescaleindex
in prescaleidx:
569 algoprescQuery=gtschema.newQuery()
570 algoprescQuery.addToTableList(
'GT_RUN_PRESC_ALGO_VIEW')
571 algoPrescOutput=coral.AttributeList()
572 algoprescBase=
'PRESCALE_FACTOR_ALGO_' 573 for bitidx
in range(NAlgoBit):
574 algopresc=algoprescBase+
str(bitidx).zfill(3)
575 algoPrescOutput.extend(algopresc,
'unsigned int')
576 algoprescQuery.addToOutputList(algopresc)
577 PrescbindVariable=coral.AttributeList()
578 PrescbindVariable.extend(
'runnumber',
'int')
579 PrescbindVariable.extend(
'prescaleindex',
'int')
580 PrescbindVariable[
'runnumber'].setData(
int(runnumber))
581 PrescbindVariable[
'prescaleindex'].setData(prescaleindex)
582 algoprescQuery.setCondition(
'RUNNR=:runnumber AND PRESCALE_INDEX=:prescaleindex',PrescbindVariable)
583 algoprescQuery.defineOutput(algoPrescOutput)
584 algopresccursor=algoprescQuery.execute()
585 while next(algopresccursor):
586 row=algopresccursor.currentRow()
588 for bitidx
in range(NAlgoBit):
589 algopresc=algoprescBase+
str(bitidx).zfill(3)
590 algoprescale.append(row[algopresc].
data())
591 prescaleDict[prescaleindex]=algoprescale
597 for prescaleindex
in prescaleidx:
598 techprescQuery=gtschema.newQuery()
599 techprescQuery.addToTableList(
'GT_RUN_PRESC_TECH_VIEW')
600 techPrescOutput=coral.AttributeList()
601 techprescBase=
'PRESCALE_FACTOR_TT_' 602 for bitidx
in range(NTechBit):
603 techpresc=techprescBase+
str(bitidx).zfill(3)
604 techPrescOutput.extend(techpresc,
'unsigned int')
605 techprescQuery.addToOutputList(techpresc)
606 PrescbindVariable=coral.AttributeList()
607 PrescbindVariable.extend(
'runnumber',
'int')
608 PrescbindVariable.extend(
'prescaleindex',
'int')
609 PrescbindVariable[
'runnumber'].setData(
int(runnumber))
610 PrescbindVariable[
'prescaleindex'].setData(prescaleindex)
611 techprescQuery.setCondition(
'RUNNR=:runnumber AND PRESCALE_INDEX=:prescaleindex',PrescbindVariable)
612 techprescQuery.defineOutput(techPrescOutput)
613 techpresccursor=techprescQuery.execute()
614 while next(techpresccursor):
615 row=techpresccursor.currentRow()
617 for bitidx
in range(NTechBit):
618 techpresc=techprescBase+
str(bitidx).zfill(3)
619 techprescale.append(row[techpresc].
data())
620 prescaleDict[prescaleindex]+=techprescale
626 lumiprescQuery=gtmonschema.newQuery()
627 lumiprescQuery.addToTableList(
'LUMI_SECTIONS')
629 lumiprescBindVariable=coral.AttributeList()
630 lumiprescBindVariable.extend(
'runnumber',
'int')
631 lumiprescBindVariable[
'runnumber'].setData(
int(runnumber))
633 lumiprescOutput=coral.AttributeList()
634 lumiprescOutput.extend(
'lumisection',
'int')
635 lumiprescOutput.extend(
'prescale_index',
'int')
636 lumiprescQuery.addToOutputList(
'LUMI_SECTION')
637 lumiprescQuery.addToOutputList(
'PRESCALE_INDEX')
638 lumiprescQuery.defineOutput(lumiprescOutput)
639 lumiprescQuery.setCondition(
'RUN_NUMBER=:runnumber',lumiprescBindVariable)
640 lumiprescCursor=lumiprescQuery.execute()
641 while next(lumiprescCursor):
642 row=lumiprescCursor.currentRow()
643 lumisection=row[
'lumisection'].
data()
644 psindex=row[
'prescale_index'].
data()
645 bitzeroprescale=prescaleDict[psindex][0]
646 bitzeroprescaleDict[lumisection]=prescaleDict[psindex][0]
647 prescaleResult[lumisection]=prescaleDict[psindex]
651 session.transaction().commit()
655 for cmslsnum,deadcount
in deadtimeresult.items():
656 bitzerocount=bitzerocountDict[cmslsnum]
657 bitzeroprescale=bitzeroprescaleDict[cmslsnum]
658 trgcounts=array.array(
'I')
659 for acounts
in algocount[cmslsnum]:
660 trgcounts.append(acounts)
661 for tcounts
in techcount[cmslsnum]:
662 trgcounts.append(tcounts)
664 trgprescale=array.array(
'I')
665 for aprescale
in prescaleResult[cmslsnum]:
666 trgprescale.append(aprescale)
668 perlsdict[cmslsnum]=[deadcount,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]
669 result=[bitnameclob,perlsdict]
672 session.transaction().rollback()
679 output: [pathnameclob,{cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}] 680 select count(distinct PATHNAME) as npath from HLT_SUPERVISOR_LUMISECTIONS_V2 where runnr=:runnumber and lsnumber=1; 681 select l.pathname,l.lsnumber,l.l1pass,l.paccept,m.psvalue from hlt_supervisor_lumisections_v2 l,hlt_supervisor_scalar_map m where l.runnr=m.runnr and l.psindex=m.psindex and l.pathname=m.pathname and l.runnr=:runnumber order by l.lsnumber 687 session.transaction().
start(
True)
688 hltschema=session.schema(
'CMS_RUNINFO')
689 bvar=coral.AttributeList()
690 bvar.extend(
'runnumber',
'unsigned int')
691 bvar.extend(
'lsnumber',
'unsigned int')
692 bvar[
'runnumber'].setData(
int(runnumber))
693 bvar[
'lsnumber'].setData(1)
694 q1=hltschema.newQuery()
695 q1.addToTableList(
'HLT_SUPERVISOR_LUMISECTIONS_V2')
696 nls=coral.AttributeList()
697 nls.extend(
'npath',
'unsigned int')
698 q1.addToOutputList(
'count(distinct PATHNAME)',
'npath')
699 q1.setCondition(
'RUNNR=:runnumber AND LSNUMBER=:lsnumber',bvar)
703 npath=c.currentRow()[
'npath'].
data()
706 print(
'request run is empty, do nothing')
708 q=hltschema.newQuery()
709 bindVar=coral.AttributeList()
710 bindVar.extend(
'runnumber',
'unsigned int')
711 bindVar[
'runnumber'].setData(
int(runnumber))
712 q.addToTableList(
'HLT_SUPERVISOR_LUMISECTIONS_V2',
'l')
713 q.addToTableList(
'HLT_SUPERVISOR_SCALAR_MAP',
'm')
714 q.addToOutputList(
'l.LSNUMBER',
'lsnumber')
715 q.addToOutputList(
'l.PATHNAME',
'pathname')
716 q.addToOutputList(
'l.L1PASS',
'hltinput')
717 q.addToOutputList(
'l.PACCEPT',
'hltaccept')
718 q.addToOutputList(
'm.PSVALUE',
'prescale')
719 q.setCondition(
'l.RUNNR=m.RUNNR and l.PSINDEX=m.PSINDEX and l.PATHNAME=m.PATHNAME and l.RUNNR=:runnumber',bindVar)
720 q.addToOrderList(
'l.LSNUMBER')
721 q.addToOrderList(
'l.PATHNAME')
722 q.setRowCacheSize(10692)
728 hltinputs=array.array(
'I')
729 hltaccepts=array.array(
'I')
730 prescales=array.array(
'I')
732 row=cursor.currentRow()
733 cmsluminr=row[
'lsnumber'].
data()
734 hltinput=row[
'hltinput'].
data()
735 hltaccept=row[
'hltaccept'].
data()
736 prescale=row[
'prescale'].
data()
737 pathname=row[
'pathname'].
data()
740 pathnames.append(pathname)
741 if cmsluminr
not in hltdict:
742 hltdict[cmsluminr]=[]
743 hltinputs.append(hltinput)
744 hltaccepts.append(hltaccept)
745 prescales.append(prescale)
754 hltdict[cmsluminr].extend([hltinputsBlob,hltacceptsBlob,hltacceptsBlob])
756 hltinputs=array.array(
'I')
757 hltaccepts=array.array(
'I')
758 prescales=array.array(
'I')
759 pathnameclob=
','.
join(pathnames)
761 session.transaction().commit()
762 return [pathnameclob,hltdict]
769 output: [datasource,pathnameclob,{cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}] 770 select distinct(pathid) from HLT_SUPERVISOR_TRIGGERPATHS where runnnumber=:runnumber; 771 select count(*) from HLT_SUPERVISOR_LUMISECTIONS_V3 where runnumber=:runnumber;//total ls 772 select tr.runnumber,tr.lsnumber,tr.pathid,tr.l1pass,tr.paccept,ls.psindex,sm.psvalue from hlt_supervisor_triggerpaths tr,hlt_supervisor_lumisections_v3 ls,hlt_supervisor_scalar_map_v2 sm where tr.runnumber=ls.runnumber and tr.lsnumber=ls.lsnumber and sm.runnumber=tr.runnumber and sm.pathid=tr.pathid and sm.psindex=ls.psindex and tr.runnumber=:runnumber order by tr.lsnumber; 774 select pathname from cms_hlt.paths where pathid=:pathid 780 select paths.pathid,paths.name,stringparamvalues.value from stringparamvalues,paths,parameters,superidparameterassoc,modules,moduletemplates,pathmoduleassoc,configurationpathassoc,configurations where parameters.paramid=stringparamvalues.paramid and superidparameterassoc.paramid=parameters.paramid and modules.superid=superidparameterassoc.superid and moduletemplates.superid=modules.templateid and pathmoduleassoc.moduleid=modules.superid and paths.pathid=pathmoduleassoc.pathid and configurationpathassoc.pathid=paths.pathid and configurations.configid=configurationpathassoc.configid and moduletemplates.name='HLTLevel1GTSeed' and parameters.name='L1SeedsLogicalExpression' and configurations.configdescriptor=:hlt_description; 781 select paths.pathid,paths.name,stringparamvalues.value from stringparamvalues,paths,parameters,superidparameterassoc,modules,moduletemplates,pathmoduleassoc,configurationpathassoc,configurations where parameters.paramid=stringparamvalues.paramid and superidparameterassoc.paramid=parameters.paramid and modules.superid=superidparameterassoc.superid and moduletemplates.superid=modules.templateid and pathmoduleassoc.moduleid=modules.superid and paths.pathid=pathmoduleassoc.pathid and configurationpathassoc.pathid=paths.pathid and configurations.configid=configurationpathassoc.configid and moduletemplates.name='HLTLevel1GTSeed' and parameters.name='L1SeedsLogicalExpression' and configurations.configid=:hlt_numkey; 782 ##select paths.pathid from cms_hlt.paths paths,cms_hlt.configurations config where config.configdescriptor=' ' and name=:pathname 785 session.transaction().
start(
True)
786 hltconfschema=session.nominalSchema()
787 hltconfQuery=hltconfschema.newQuery()
789 hltconfQuery.addToOutputList(
'PATHS.NAME',
'hltpath')
790 hltconfQuery.addToOutputList(
'STRINGPARAMVALUES.VALUE',
'l1expression')
792 hltconfQuery.addToTableList(
'PATHS')
793 hltconfQuery.addToTableList(
'STRINGPARAMVALUES')
794 hltconfQuery.addToTableList(
'PARAMETERS')
795 hltconfQuery.addToTableList(
'SUPERIDPARAMETERASSOC')
796 hltconfQuery.addToTableList(
'MODULES')
797 hltconfQuery.addToTableList(
'MODULETEMPLATES')
798 hltconfQuery.addToTableList(
'PATHMODULEASSOC')
799 hltconfQuery.addToTableList(
'CONFIGURATIONPATHASSOC')
800 hltconfQuery.addToTableList(
'CONFIGURATIONS')
802 hltconfBindVar=coral.AttributeList()
803 hltconfBindVar.extend(
'hltseed',
'string')
804 hltconfBindVar.extend(
'l1seedexpr',
'string')
805 hltconfBindVar.extend(
'hltkey',
'string')
806 hltconfBindVar[
'hltseed'].setData(
'HLTLevel1GTSeed')
807 hltconfBindVar[
'l1seedexpr'].setData(
'L1SeedsLogicalExpression')
808 hltconfBindVar[
'hltkey'].setData(hltkey)
809 hltconfQuery.setCondition(
'PARAMETERS.PARAMID=STRINGPARAMVALUES.PARAMID AND SUPERIDPARAMETERASSOC.PARAMID=PARAMETERS.PARAMID AND MODULES.SUPERID=SUPERIDPARAMETERASSOC.SUPERID AND MODULETEMPLATES.SUPERID=MODULES.TEMPLATEID AND PATHMODULEASSOC.MODULEID=MODULES.SUPERID AND PATHS.PATHID=PATHMODULEASSOC.PATHID AND CONFIGURATIONPATHASSOC.PATHID=PATHS.PATHID AND CONFIGURATIONS.CONFIGID=CONFIGURATIONPATHASSOC.CONFIGID AND MODULETEMPLATES.NAME=:hltseed AND PARAMETERS.NAME=:l1seedexpr AND CONFIGURATIONS.CONFIGDESCRIPTOR=:hltkey',hltconfBindVar)
811 cursor=hltconfQuery.execute()
813 hltpath=cursor.currentRow()[
'hltpath'].
data()
815 l1expression=cursor.currentRow()[
'l1expression'].
data()
816 hlt2l1map[hltpath]=l1expression
818 session.transaction().commit()
823 def runsummary(session,schemaname,runnumber,complementalOnly=False):
825 x select string_value from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.TRG:TSC_KEY'; 826 x select distinct(string_value) from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.SCAL:AMODEtag' 827 x select distinct(string_value),session_id from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.SCAL:EGEV' order by SESSION_ID 829 select string_value from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.LVL0:SEQ_NAME' 830 select string_value from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.LVL0:HLT_KEY_DESCRIPTION'; 831 select string_value from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.SCAL:FILLN' and rownum<=1; 832 select time from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.LVL0:START_TIME_T'; 833 select time from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.LVL0:STOP_TIME_T'; 835 output:[l1key,amodetag,egev,sequence,hltkey,fillnum,starttime,stoptime] 837 [l1key,amodetag,egev] 839 runsessionparameterTable=
'' 850 session.transaction().
start(
True)
851 runinfoschema=session.schema(schemaname)
852 l1keyQuery=runinfoschema.newQuery()
853 l1keyQuery.addToTableList(
'RUNSESSION_PARAMETER')
854 l1keyOutput=coral.AttributeList()
855 l1keyOutput.extend(
'l1key',
'string')
856 l1keyCondition=coral.AttributeList()
857 l1keyCondition.extend(
'name',
'string')
858 l1keyCondition.extend(
'runnumber',
'unsigned int')
859 l1keyCondition[
'name'].setData(
'CMS.TRG:TSC_KEY')
860 l1keyCondition[
'runnumber'].setData(
int(runnumber))
861 l1keyQuery.addToOutputList(
'STRING_VALUE')
862 l1keyQuery.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',l1keyCondition)
863 l1keyQuery.defineOutput(l1keyOutput)
864 cursor=l1keyQuery.execute()
866 l1key=cursor.currentRow()[
'l1key'].
data()
870 amodetagQuery=runinfoschema.newQuery()
871 amodetagQuery.addToTableList(
'RUNSESSION_PARAMETER')
872 amodetagOutput=coral.AttributeList()
873 amodetagOutput.extend(
'amodetag',
'string')
874 amodetagCondition=coral.AttributeList()
875 amodetagCondition.extend(
'name',
'string')
876 amodetagCondition.extend(
'runnumber',
'unsigned int')
877 amodetagCondition[
'name'].setData(
'CMS.SCAL:AMODEtag')
878 amodetagCondition[
'runnumber'].setData(
int(runnumber))
879 amodetagQuery.addToOutputList(
'distinct(STRING_VALUE)')
880 amodetagQuery.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',amodetagCondition)
881 amodetagQuery.limitReturnedRows(1)
882 amodetagQuery.defineOutput(amodetagOutput)
883 cursor=amodetagQuery.execute()
885 amodetag=cursor.currentRow()[
'amodetag'].
data()
887 result.append(amodetag)
889 egevQuery=runinfoschema.newQuery()
890 egevQuery.addToTableList(
'RUNSESSION_PARAMETER')
891 egevOutput=coral.AttributeList()
892 egevOutput.extend(
'egev',
'string')
893 egevCondition=coral.AttributeList()
894 egevCondition.extend(
'name',
'string')
895 egevCondition.extend(
'runnumber',
'unsigned int')
896 egevCondition[
'name'].setData(
'CMS.SCAL:EGEV')
897 egevCondition[
'runnumber'].setData(
int(runnumber))
898 egevQuery.addToOutputList(
'distinct(STRING_VALUE)')
899 egevQuery.addToOutputList(
'SESSION_ID')
900 egevQuery.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',egevCondition)
901 egevQuery.defineOutput(egevOutput)
902 egevQuery.addToOrderList(
'SESSION_ID')
903 cursor=egevQuery.execute()
905 egev=cursor.currentRow()[
'egev'].
data()
909 if not complementalOnly:
910 seqQuery=runinfoschema.newQuery()
911 seqQuery.addToTableList(
'RUNSESSION_PARAMETER')
912 seqOutput=coral.AttributeList()
913 seqOutput.extend(
'seq',
'string')
914 seqCondition=coral.AttributeList()
915 seqCondition.extend(
'name',
'string')
916 seqCondition.extend(
'runnumber',
'unsigned int')
917 seqCondition[
'name'].setData(
'CMS.LVL0:SEQ_NAME')
918 seqCondition[
'runnumber'].setData(
int(runnumber))
919 seqQuery.addToOutputList(
'STRING_VALUE')
920 seqQuery.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',seqCondition)
921 seqQuery.defineOutput(seqOutput)
922 cursor=seqQuery.execute()
924 sequence=cursor.currentRow()[
'seq'].
data()
926 result.append(sequence)
928 hltkeyQuery=runinfoschema.newQuery()
929 hltkeyQuery.addToTableList(
'RUNSESSION_PARAMETER')
930 hltkeyOutput=coral.AttributeList()
931 hltkeyOutput.extend(
'hltkey',
'string')
932 hltkeyCondition=coral.AttributeList()
933 hltkeyCondition.extend(
'name',
'string')
934 hltkeyCondition.extend(
'runnumber',
'unsigned int')
935 hltkeyCondition[
'name'].setData(
'CMS.LVL0:HLT_KEY_DESCRIPTION')
936 hltkeyCondition[
'runnumber'].setData(
int(runnumber))
937 hltkeyQuery.addToOutputList(
'STRING_VALUE')
938 hltkeyQuery.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',hltkeyCondition)
940 hltkeyQuery.defineOutput(hltkeyOutput)
941 cursor=hltkeyQuery.execute()
943 hltkey=cursor.currentRow()[
'hltkey'].
data()
945 result.append(hltkey)
947 fillnumQuery=runinfoschema.newQuery()
948 fillnumQuery.addToTableList(
'RUNSESSION_PARAMETER')
949 fillnumOutput=coral.AttributeList()
950 fillnumOutput.extend(
'fillnum',
'string')
951 fillnumCondition=coral.AttributeList()
952 fillnumCondition.extend(
'name',
'string')
953 fillnumCondition.extend(
'runnumber',
'unsigned int')
954 fillnumCondition[
'name'].setData(
'CMS.SCAL:FILLN')
955 fillnumCondition[
'runnumber'].setData(
int(runnumber))
956 fillnumQuery.addToOutputList(
'STRING_VALUE')
957 fillnumQuery.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',fillnumCondition)
958 fillnumQuery.limitReturnedRows(1)
959 fillnumQuery.defineOutput(fillnumOutput)
960 cursor=fillnumQuery.execute()
962 fillnum=cursor.currentRow()[
'fillnum'].
data()
964 result.append(fillnum)
966 starttimeQuery=runinfoschema.newQuery()
967 starttimeQuery.addToTableList(
'RUNSESSION_PARAMETER')
968 starttimeOutput=coral.AttributeList()
969 starttimeOutput.extend(
'starttime',
'time stamp')
970 starttimeCondition=coral.AttributeList()
971 starttimeCondition.extend(
'name',
'string')
972 starttimeCondition.extend(
'runnumber',
'unsigned int')
973 starttimeCondition[
'name'].setData(
'CMS.LVL0:START_TIME_T')
974 starttimeCondition[
'runnumber'].setData(
int(runnumber))
975 starttimeQuery.addToOutputList(
'TIME')
976 starttimeQuery.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',starttimeCondition)
977 starttimeQuery.defineOutput(starttimeOutput)
978 cursor=starttimeQuery.execute()
980 starttime=cursor.currentRow()[
'starttime'].
data()
982 result.append(starttime)
984 stoptimeQuery=runinfoschema.newQuery()
985 stoptimeQuery.addToTableList(
'RUNSESSION_PARAMETER')
986 stoptimeOutput=coral.AttributeList()
987 stoptimeOutput.extend(
'stoptime',
'time stamp')
988 stoptimeCondition=coral.AttributeList()
989 stoptimeCondition.extend(
'name',
'string')
990 stoptimeCondition.extend(
'runnumber',
'unsigned int')
991 stoptimeCondition[
'name'].setData(
'CMS.LVL0:STOP_TIME_T')
992 stoptimeCondition[
'runnumber'].setData(
int(runnumber))
993 stoptimeQuery.addToOutputList(
'TIME')
994 stoptimeQuery.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',stoptimeCondition)
995 stoptimeQuery.defineOutput(stoptimeOutput)
996 cursor=stoptimeQuery.execute()
998 stoptime=cursor.currentRow()[
'stoptime'].
data()
1000 result.append(stoptime)
1001 session.transaction().commit()
1003 session.transaction().commit()
1008 if __name__ ==
"__main__":
1009 from RecoLuminosity.LumiDB
import sessionManager
1026 session=svc.openSession(isReadOnly=
True,cpp2sqltype=[(
'unsigned int',
'NUMBER(10)'),(
'unsigned long long',
'NUMBER(20)')])
def runsummary(session, schemaname, runnumber, complementalOnly=False)
def uncalibrateLumi(runnumber, instlumi, instlumierror)
def trgFromOldLumi(session, runnumber)
def hltFromRuninfoV3(session, runnumber)
def lumidetailTableName()
S & print(S &os, JobReport::InputFile const &f)
def lumisummaryTableName()
def hltFromOldLumi(session, runnumber)
def hltconf(session, hltkey)
def trgFromNewGT(session, runnumber)
static std::string join(char **cmd)
def hltFromRuninfoV2(session, runnumber)
def packArraytoBlob(iarray)
def uncalibratedlumiFromOldLumi(session, runnumber)
char data[epos_bytes_allocation]
def trgFromOldGT(session, runnumber)
def trgFromWBM(session, runnumber)