1 from __future__
import print_function
3 from RecoLuminosity.LumiDB
import CommonUtil,nameDealer
7 input: runnumber,calibrated instlumi,calibrated instlumierror 8 output: (uncalibrated instlumi, uncalbrated instlumierror) 10 normpp7tev=
float(6370.0)
11 normpp900gev=
float(16500.0)
12 normhi7tev=
float(2.383)
13 oldnormpp7tev=
float(6330)
14 if runnumber
in [136290,136294,136297,134721,134725]:
15 return (
float(instlumi)/normpp900gev,
float(instlumierror)/normpp900gev)
16 if runnumber >=150431
and runnumber<=153368 :
17 return (
float(instlumi)/normhi7tev,
float(instlumierror)/normhi7tev)
18 return (
float(instlumi)/normpp7tev,
float(instlumierror)/normpp7tev)
22 retrieve old lumi value, divide by norm and restore to raw value 23 select lumilsnum,cmslsnum,instlumi,instlumierror,instlumiquality,startorbit,numorbit,beamenergy,beamstatus,cmsbxindexblob,beamintensityblob_1,beamintensityblob_2 from lumisummary where runnum=:runnumber order by lumilsnum 25 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 27 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]}]} 28 dict size ~ 200mb for 1000LS 33 session.transaction().
start(
True)
34 lumischema=session.nominalSchema()
35 summaryQuery=lumischema.newQuery()
37 summaryQuery.addToOutputList(
'LUMILSNUM',
'lumilsnum')
38 summaryQuery.addToOutputList(
'CMSLSNUM',
'cmslsnum')
39 summaryQuery.addToOutputList(
'INSTLUMI',
'instlumi')
40 summaryQuery.addToOutputList(
'INSTLUMIERROR',
'instlumierror')
41 summaryQuery.addToOutputList(
'INSTLUMIQUALITY',
'instlumiquality')
42 summaryQuery.addToOutputList(
'BEAMSTATUS',
'beamstatus')
43 summaryQuery.addToOutputList(
'BEAMENERGY',
'beamenergy')
44 summaryQuery.addToOutputList(
'NUMORBIT',
'numorbit')
45 summaryQuery.addToOutputList(
'STARTORBIT',
'startorbit')
46 summaryQuery.addToOutputList(
'CMSBXINDEXBLOB',
'cmsbxindexblob')
47 summaryQuery.addToOutputList(
'BEAMINTENSITYBLOB_1',
'beamintensityblob_1')
48 summaryQuery.addToOutputList(
'BEAMINTENSITYBLOB_2',
'beamintensityblob_2')
49 summaryCondition=coral.AttributeList()
50 summaryCondition.extend(
'runnumber',
'unsigned int')
51 summaryCondition[
'runnumber'].setData(
int(runnumber))
52 summaryResult=coral.AttributeList()
53 summaryResult.extend(
'lumilsnum',
'unsigned int')
54 summaryResult.extend(
'cmslsnum',
'unsigned int')
55 summaryResult.extend(
'instlumi',
'float')
56 summaryResult.extend(
'instlumierror',
'float')
57 summaryResult.extend(
'instlumiquality',
'short')
58 summaryResult.extend(
'beamstatus',
'string')
59 summaryResult.extend(
'beamenergy',
'float')
60 summaryResult.extend(
'numorbit',
'unsigned int')
61 summaryResult.extend(
'startorbit',
'unsigned int')
62 summaryResult.extend(
'cmsbxindexblob',
'blob')
63 summaryResult.extend(
'beamintensityblob_1',
'blob')
64 summaryResult.extend(
'beamintensityblob_2',
'blob')
65 summaryQuery.defineOutput(summaryResult)
66 summaryQuery.addToOrderList(
'lumilsnum')
67 summaryQuery.setCondition(
'RUNNUM=:runnumber',summaryCondition)
68 summarycursor=summaryQuery.execute()
69 while next(summarycursor):
70 lumilsnum=summarycursor.currentRow()[
'lumilsnum'].
data()
71 cmslsnum=summarycursor.currentRow()[
'cmslsnum'].
data()
72 instlumi=summarycursor.currentRow()[
'instlumi'].
data()
73 instlumierror=summarycursor.currentRow()[
'instlumierror'].
data()
74 instlumiquality=summarycursor.currentRow()[
'instlumiquality'].
data()
75 (uncalibratedinstlumi,uncalibratedinstlumierror)=
uncalibrateLumi(runnumber,instlumi,instlumierror)
76 numorbit=summarycursor.currentRow()[
'numorbit'].
data()
77 startorbit=summarycursor.currentRow()[
'startorbit'].
data()
78 beamenergy=summarycursor.currentRow()[
'beamenergy'].
data()
79 beamstatus=summarycursor.currentRow()[
'beamstatus'].
data()
81 if not summarycursor.currentRow()[
'cmsbxindexblob'].isNull():
82 cmsbxindexblob=summarycursor.currentRow()[
'cmsbxindexblob'].
data()
83 beamintensityblob_1=
None 84 if not summarycursor.currentRow()[
'beamintensityblob_1'].isNull():
85 beamintensityblob_1=summarycursor.currentRow()[
'beamintensityblob_1'].
data()
86 beamintensityblob_2=
None 87 if not summarycursor.currentRow()[
'beamintensityblob_2'].isNull():
88 beamintensityblob_2=summarycursor.currentRow()[
'beamintensityblob_2'].
data()
89 datadict[lumilsnum]=[cmslsnum,uncalibratedinstlumi,uncalibratedinstlumierror,instlumiquality,beamstatus,beamenergy,numorbit,startorbit,cmsbxindexblob,beamintensityblob_1,beamintensityblob_2]
92 for algoname
in [
'OCC1',
'OCC2',
'ET']:
93 detailQuery=lumischema.newQuery()
96 detailQuery.addToOutputList(
's.LUMILSNUM',
'lumilsnum' )
97 detailQuery.addToOutputList(
'd.BXLUMIVALUE',
'bxlumivalue' )
98 detailQuery.addToOutputList(
'd.BXLUMIERROR',
'bxlumierror' )
99 detailQuery.addToOutputList(
'd.BXLUMIQUALITY',
'bxlumiquality' )
100 detailCondition=coral.AttributeList()
101 detailCondition.extend(
'runnumber',
'unsigned int')
102 detailCondition.extend(
'algoname',
'string')
103 detailCondition[
'runnumber'].setData(
int(runnumber))
104 detailCondition[
'algoname'].setData(algoname)
105 detailResult=coral.AttributeList()
106 detailResult.extend(
'lumilsnum',
'unsigned int')
107 detailResult.extend(
'bxlumivalue',
'blob')
108 detailResult.extend(
'bxlumierror',
'blob')
109 detailResult.extend(
'bxlumiquality',
'blob')
110 detailQuery.defineOutput(detailResult)
111 detailQuery.addToOrderList(
'lumilsnum')
112 detailQuery.setCondition(
's.RUNNUM=:runnumber AND s.LUMISUMMARY_ID=d.LUMISUMMARY_ID AND d.ALGONAME=:algoname',detailCondition)
113 detailcursor=detailQuery.execute()
114 while next(detailcursor):
115 lumilsnum=detailcursor.currentRow()[
'lumilsnum'].
data()
116 bxlumivalue=detailcursor.currentRow()[
'bxlumivalue'].
data()
117 bxlumierror=detailcursor.currentRow()[
'bxlumierror'].
data()
118 bxlumiquality=detailcursor.currentRow()[
'bxlumiquality'].
data()
119 datadict[lumilsnum].extend([bxlumivalue,bxlumierror,bxlumiquality])
121 session.transaction().commit()
127 select count(distinct pathname) from hlt where runnum=:runnum 128 select cmslsnum,pathname,inputcount,acceptcount,prescale from hlt where runnum=:runnum order by cmslsnum,pathname 129 [pathnames,databuffer] 130 databuffer: {cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]} 134 session.transaction().
start(
True)
135 lumischema=session.nominalSchema()
137 qHandle=lumischema.newQuery()
139 qHandle.addToOutputList(
'COUNT(DISTINCT PATHNAME)',
'npath')
140 qCondition=coral.AttributeList()
141 qCondition.extend(
'runnum',
'unsigned int')
142 qCondition[
'runnum'].setData(
int(runnumber))
143 qResult=coral.AttributeList()
144 qResult.extend(
'npath',
'unsigned int')
145 qHandle.defineOutput(qResult)
146 qHandle.setCondition(
'RUNNUM=:runnum',qCondition)
147 cursor=qHandle.execute()
149 npath=cursor.currentRow()[
'npath'].
data()
153 qHandle=lumischema.newQuery()
155 qHandle.addToOutputList(
'CMSLSNUM',
'cmslsnum')
156 qHandle.addToOutputList(
'PATHNAME',
'pathname')
157 qHandle.addToOutputList(
'INPUTCOUNT',
'inputcount')
158 qHandle.addToOutputList(
'ACCEPTCOUNT',
'acceptcount')
159 qHandle.addToOutputList(
'PRESCALE',
'prescale')
160 qCondition=coral.AttributeList()
161 qCondition.extend(
'runnum',
'unsigned int')
162 qCondition[
'runnum'].setData(
int(runnumber))
163 qResult=coral.AttributeList()
164 qResult.extend(
'cmslsnum',
'unsigned int')
165 qResult.extend(
'pathname',
'string')
166 qResult.extend(
'inputcount',
'unsigned int')
167 qResult.extend(
'acceptcount',
'unsigned int')
168 qResult.extend(
'prescale',
'unsigned int')
169 qHandle.defineOutput(qResult)
170 qHandle.setCondition(
'RUNNUM=:runnum',qCondition)
171 qHandle.addToOrderList(
'cmslsnum')
172 qHandle.addToOrderList(
'pathname')
173 cursor=qHandle.execute()
175 inputcountArray=array.array(
'I')
176 acceptcountArray=array.array(
'I')
177 prescaleArray=array.array(
'I')
179 pathnHLT_PixelTracksVdMames=
'' 181 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
182 pathname=cursor.currentRow()[
'pathname'].
data()
184 inputcount=cursor.currentRow()[
'inputcount'].
data()
185 acceptcount=cursor.currentRow()[
'acceptcount'].
data()
186 prescale=cursor.currentRow()[
'prescale'].
data()
187 pathnameList.append(pathname)
188 inputcountArray.append(inputcount)
189 acceptcountArray.append(acceptcount)
190 prescaleArray.append(prescale)
193 pathnames=
','.
join(pathnameList)
197 databuffer[cmslsnum]=[inputcountBlob,acceptcountBlob,prescaleBlob]
199 inputcountArray=array.array(
'I')
200 acceptcountArray=array.array(
'I')
201 prescaleArray=array.array(
'I')
204 session.transaction().commit()
206 return [pathnames,databuffer]
212 select bitnum,bitname from trg where runnum=:runnumber and cmslsnum=1 order by bitnum 213 select cmslsnum,deadtime,trgcount,prescale from trg where bitnum=:bitnum and runnum=:runnumber 215 output: [bitnames,{cmslsnum,[deadtime,bitzerocount,bitzerpoprescale,trgcountBlob,trgprescaleBlob]}] 217 session.transaction().
start(
True)
218 lumischema=session.nominalSchema()
219 qHandle=lumischema.newQuery()
221 qHandle=lumischema.newQuery()
223 qHandle.addToOutputList(
'BITNUM',
'bitnum')
224 qHandle.addToOutputList(
'BITNAME',
'bitname')
225 qCondition=coral.AttributeList()
226 qCondition.extend(
'runnum',
'unsigned int')
227 qCondition[
'runnum'].setData(
int(runnumber))
228 qCondition.extend(
'cmslsnum',
'unsigned int')
229 qCondition[
'cmslsnum'].setData(
int(1))
230 qResult=coral.AttributeList()
231 qResult.extend(
'bitnum',
'unsigned int')
232 qResult.extend(
'bitname',
'string')
233 qHandle.defineOutput(qResult)
234 qHandle.setCondition(
'RUNNUM=:runnum AND CMSLSNUM=:cmslsnum',qCondition)
235 qHandle.addToOrderList(
'BITNUM')
236 cursor=qHandle.execute()
240 bitnum=cursor.currentRow()[
'bitnum'].
data()
241 bitname=cursor.currentRow()[
'bitname'].
data()
242 bitnums.append(bitnum)
243 bitnameList.append(bitname)
245 bitnames=
','.
join(bitnameList)
248 qHandle=lumischema.newQuery()
250 qHandle.addToOutputList(
'CMSLSNUM',
'cmslsnum')
251 qHandle.addToOutputList(
'BITNUM',
'bitnum')
252 qHandle.addToOutputList(
'DEADTIME',
'deadtime')
253 qHandle.addToOutputList(
'TRGCOUNT',
'trgcount')
254 qHandle.addToOutputList(
'PRESCALE',
'prescale')
255 qCondition=coral.AttributeList()
256 qCondition.extend(
'runnum',
'unsigned int')
257 qCondition[
'runnum'].setData(
int(runnumber))
258 qResult=coral.AttributeList()
259 qResult.extend(
'cmslsnum',
'unsigned int')
260 qResult.extend(
'bitnum',
'unsigned int')
261 qResult.extend(
'deadtime',
'unsigned long long')
262 qResult.extend(
'trgcount',
'unsigned int')
263 qResult.extend(
'prescale',
'unsigned int')
264 qHandle.defineOutput(qResult)
265 qHandle.setCondition(
'RUNNUM=:runnum',qCondition)
266 qHandle.addToOrderList(
'CMSLSNUM')
267 qHandle.addToOrderList(
'BITNUM')
268 cursor=qHandle.execute()
269 trgcountArray=array.array(
'I')
270 prescaleArray=array.array(
'I')
272 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
273 bitnum=cursor.currentRow()[
'bitnum'].
data()
274 deadtime=cursor.currentRow()[
'deadtime'].
data()
275 trgcount=cursor.currentRow()[
'trgcount'].
data()
276 prescale=cursor.currentRow()[
'prescale'].
data()
277 if cmslsnum
not in databuffer:
278 databuffer[cmslsnum]=[]
279 databuffer[cmslsnum].
append(deadtime)
281 databuffer[cmslsnum].
append(trgcount)
282 databuffer[cmslsnum].
append(prescale)
283 trgcountArray.append(trgcount)
284 prescaleArray.append(prescale)
288 databuffer[cmslsnum].
append(trgcountBlob)
289 databuffer[cmslsnum].
append(prescaleBlob)
290 trgcountArray=array.array(
'I')
291 prescaleArray=array.array(
'I')
293 session.transaction().commit()
294 return [bitnames,databuffer]
306 select counts,lsnr,algobit from cms_gt_mon.gt_mon_trig_algo_view where runnr=:runnumber order by lsnr,algobit 307 select counts,lsnr,techbit from cms_gt_mon.gt_mon_trig_tech_view where runnr=:runnumber order by lsnr,techbit 308 select counts,lsnr from cms_gt_mon.gt_mon_trig_dead_view where runnr=:runnumber and deadcounter=:countername order by lsnr 309 select algo_index,alias from cms_gt.gt_run_algo_view where runnumber=:runnumber order by algo_index 310 select techtrig_index,name from cms_gt.gt_run_tech_view where runnumber=:runnumber order by techtrig_index 311 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; 312 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; 319 output: [bitnameclob,{cmslsnum:[deadtime,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]}] 320 1. select counts,lsnr from cms_gt_mon.gt_mon_trig_dead_view where runnr=:runnumber and deadcounter=:countername order by lsnr 321 2. select counts,lsnr,algobit from cms_gt_mon.gt_mon_trig_algo_view where runnr=:runnumber order by lsnr,algobit 322 3. select counts,lsnr,techbit from cms_gt_mon.gt_mon_trig_tech_view where runnr=:runnumber order by lsnr,techbit 323 4. select algo_index,alias from cms_gt.gt_run_algo_view where runnumber=:runnumber order by algo_index 324 ## not needed5. select techtrig_index,name from cms_gt.gt_run_tech_view where runnumber=:runnumber order by techtrig_index 325 5 select distinct(prescale_index) from cms_gt_mon.lumi_sections where run_number=:runnumber; 326 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; 327 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; 328 8. select lumi_section,prescale_index from cms_gt_mon.lumi_sections where run_number=:runnumber order by lumi_section 339 bitzeroprescaleDict={}
344 session.transaction().
start(
True)
345 gtmonschema=session.schema(
'CMS_GT_MON')
349 deadviewQuery=gtmonschema.newQuery()
350 deadviewQuery.addToTableList(
'GT_MON_TRIG_DEAD_VIEW')
351 deadOutput=coral.AttributeList()
352 deadOutput.extend(
'counts',
'unsigned int')
353 deadOutput.extend(
'lsnr',
'unsigned int')
354 deadviewQuery.addToOutputList(
'counts')
355 deadviewQuery.addToOutputList(
'lsnr')
356 bindVariablesDead=coral.AttributeList()
357 bindVariablesDead.extend(
'runnumber',
'int')
358 bindVariablesDead.extend(
'countername',
'string')
359 bindVariablesDead[
'runnumber'].setData(
int(runnumber))
360 bindVariablesDead[
'countername'].setData(
'DeadtimeBeamActive')
361 deadviewQuery.setCondition(
'RUNNR=:runnumber AND DEADCOUNTER=:countername',bindVariablesDead)
362 deadviewQuery.addToOrderList(
'lsnr')
363 deadviewQuery.defineOutput(deadOutput)
364 deadcursor=deadviewQuery.execute()
366 while next(deadcursor):
367 row=deadcursor.currentRow()
369 lsnr=row[
'lsnr'].
data()
371 print(
'DEADTIME alert: found hole in LS range')
372 print(
' fill deadtimebeamactive 0 for LS '+
str(s))
375 count=row[
'counts'].
data()
376 deadtimeresult[s]=count
380 session.transaction().commit()
381 raise 'requested run '+
str(runnumber )+
' does not exist for deadcounts' 385 algoviewQuery=gtmonschema.newQuery()
389 algoviewQuery.addToTableList(
'GT_MON_TRIG_ALGO_VIEW')
390 algoOutput=coral.AttributeList()
391 algoOutput.extend(
'counts',
'unsigned int')
392 algoOutput.extend(
'lsnr',
'unsigned int')
393 algoOutput.extend(
'algobit',
'unsigned int')
394 algoviewQuery.addToOutputList(
'counts')
395 algoviewQuery.addToOutputList(
'lsnr')
396 algoviewQuery.addToOutputList(
'algobit')
397 algoCondition=coral.AttributeList()
398 algoCondition.extend(
'runnumber',
'unsigned int')
399 algoCondition[
'runnumber'].setData(
int(runnumber))
400 algoviewQuery.setCondition(
'RUNNR=:runnumber',algoCondition)
401 algoviewQuery.addToOrderList(
'lsnr')
402 algoviewQuery.addToOrderList(
'algobit')
403 algoviewQuery.defineOutput(algoOutput)
405 algocursor=algoviewQuery.execute()
407 while next(algocursor):
408 row=algocursor.currentRow()
409 lsnr=row[
'lsnr'].
data()
410 counts=row[
'counts'].
data()
411 algobit=row[
'algobit'].
data()
412 mybitcount_algo.append(counts)
414 bitzerocountDict[lsnr]=counts
415 if algobit==NAlgoBit-1:
418 print(
'ALGO COUNT alert: found hole in LS range')
419 print(
' fill all algocount 0 for LS '+
str(s))
423 algocount[s]=mybitcount_algo
428 session.transaction().commit()
429 raise 'requested run '+
str(runnumber+
' does not exist for algocounts ')
433 techviewQuery=gtmonschema.newQuery()
434 techviewQuery.addToTableList(
'GT_MON_TRIG_TECH_VIEW')
438 techOutput=coral.AttributeList()
439 techOutput.extend(
'counts',
'unsigned int')
440 techOutput.extend(
'lsnr',
'unsigned int')
441 techOutput.extend(
'techbit',
'unsigned int')
442 techviewQuery.addToOutputList(
'COUNTS',
'counts')
443 techviewQuery.addToOutputList(
'LSNR',
'lsnr')
444 techviewQuery.addToOutputList(
'TECHBIT',
'techbit')
445 techCondition=coral.AttributeList()
446 techCondition.extend(
'runnumber',
'unsigned int')
447 techCondition[
'runnumber'].setData(
int(runnumber))
448 techviewQuery.setCondition(
'RUNNR=:runnumber',techCondition)
449 techviewQuery.addToOrderList(
'lsnr')
450 techviewQuery.addToOrderList(
'techbit')
451 techviewQuery.defineOutput(techOutput)
453 techcursor=techviewQuery.execute()
455 while next(techcursor):
456 row=techcursor.currentRow()
457 lsnr=row[
'lsnr'].
data()
458 counts=row[
'counts'].
data()
459 techbit=row[
'techbit'].
data()
460 mybitcount_tech.append(counts)
461 if techbit==NTechBit-1:
464 print(
'TECH COUNT alert: found hole in LS range')
465 print(
' fill all techcount 0 for LS '+
str(s))
469 techcount[s]=mybitcount_tech
474 session.transaction().commit()
475 raise 'requested run '+
str(runnumber+
' does not exist for techcounts ')
478 gtschema=session.schema(
'CMS_GT')
480 namealiasQuery=gtschema.newQuery()
485 namealiasQuery.addToTableList(
'GT_RUN_ALGO_VIEW')
486 algonameOutput=coral.AttributeList()
487 algonameOutput.extend(
'algo_index',
'unsigned int')
488 algonameOutput.extend(
'alias',
'string')
489 namealiasQuery.addToOutputList(
'algo_index')
490 namealiasQuery.addToOutputList(
'alias')
491 algonameCondition=coral.AttributeList()
492 algonameCondition.extend(
'runnumber',
'unsigned int')
493 algonameCondition[
'runnumber'].setData(
int(runnumber))
494 namealiasQuery.setCondition(
'RUNNUMBER=:runnumber',algonameCondition)
495 namealiasQuery.defineOutput(algonameOutput)
496 algonamecursor=namealiasQuery.execute()
497 while next(algonamecursor):
498 row=algonamecursor.currentRow()
499 algo_index=row[
'algo_index'].
data()
500 algo_name=row[
'alias'].
data()
501 triggernamemap[algo_index]=algo_name
531 for algoidx
in range(NAlgoBit):
532 if algoidx
in triggernamemap.keys():
533 bitnames.append(triggernamemap[algoidx])
535 bitnames.append(
'False')
539 for techidx
in range(NTechBit):
540 bitnames.append(
str(techidx))
541 bitnameclob=
','.
join(bitnames)
546 presidxQuery=gtmonschema.newQuery()
547 presidxQuery.addToTableList(
'LUMI_SECTIONS')
549 presidxBindVariable=coral.AttributeList()
550 presidxBindVariable.extend(
'runnumber',
'int')
551 presidxBindVariable[
'runnumber'].setData(
int(runnumber))
553 presidxOutput=coral.AttributeList()
554 presidxOutput.extend(
'prescale_index',
'int')
555 presidxQuery.addToOutputList(
'distinct(PRESCALE_INDEX)',
'prescale_index')
556 presidxQuery.defineOutput(presidxOutput)
557 presidxQuery.setCondition(
'RUN_NUMBER=:runnumber',presidxBindVariable)
558 presidxCursor=presidxQuery.execute()
559 while next(presidxCursor):
560 presc=presidxCursor.currentRow()[
'prescale_index'].
data()
561 prescaleidx.append(presc)
567 for prescaleindex
in prescaleidx:
568 algoprescQuery=gtschema.newQuery()
569 algoprescQuery.addToTableList(
'GT_RUN_PRESC_ALGO_VIEW')
570 algoPrescOutput=coral.AttributeList()
571 algoprescBase=
'PRESCALE_FACTOR_ALGO_' 572 for bitidx
in range(NAlgoBit):
573 algopresc=algoprescBase+
str(bitidx).zfill(3)
574 algoPrescOutput.extend(algopresc,
'unsigned int')
575 algoprescQuery.addToOutputList(algopresc)
576 PrescbindVariable=coral.AttributeList()
577 PrescbindVariable.extend(
'runnumber',
'int')
578 PrescbindVariable.extend(
'prescaleindex',
'int')
579 PrescbindVariable[
'runnumber'].setData(
int(runnumber))
580 PrescbindVariable[
'prescaleindex'].setData(prescaleindex)
581 algoprescQuery.setCondition(
'RUNNR=:runnumber AND PRESCALE_INDEX=:prescaleindex',PrescbindVariable)
582 algoprescQuery.defineOutput(algoPrescOutput)
583 algopresccursor=algoprescQuery.execute()
584 while next(algopresccursor):
585 row=algopresccursor.currentRow()
587 for bitidx
in range(NAlgoBit):
588 algopresc=algoprescBase+
str(bitidx).zfill(3)
589 algoprescale.append(row[algopresc].
data())
590 prescaleDict[prescaleindex]=algoprescale
596 for prescaleindex
in prescaleidx:
597 techprescQuery=gtschema.newQuery()
598 techprescQuery.addToTableList(
'GT_RUN_PRESC_TECH_VIEW')
599 techPrescOutput=coral.AttributeList()
600 techprescBase=
'PRESCALE_FACTOR_TT_' 601 for bitidx
in range(NTechBit):
602 techpresc=techprescBase+
str(bitidx).zfill(3)
603 techPrescOutput.extend(techpresc,
'unsigned int')
604 techprescQuery.addToOutputList(techpresc)
605 PrescbindVariable=coral.AttributeList()
606 PrescbindVariable.extend(
'runnumber',
'int')
607 PrescbindVariable.extend(
'prescaleindex',
'int')
608 PrescbindVariable[
'runnumber'].setData(
int(runnumber))
609 PrescbindVariable[
'prescaleindex'].setData(prescaleindex)
610 techprescQuery.setCondition(
'RUNNR=:runnumber AND PRESCALE_INDEX=:prescaleindex',PrescbindVariable)
611 techprescQuery.defineOutput(techPrescOutput)
612 techpresccursor=techprescQuery.execute()
613 while next(techpresccursor):
614 row=techpresccursor.currentRow()
616 for bitidx
in range(NTechBit):
617 techpresc=techprescBase+
str(bitidx).zfill(3)
618 techprescale.append(row[techpresc].
data())
619 prescaleDict[prescaleindex]+=techprescale
625 lumiprescQuery=gtmonschema.newQuery()
626 lumiprescQuery.addToTableList(
'LUMI_SECTIONS')
628 lumiprescBindVariable=coral.AttributeList()
629 lumiprescBindVariable.extend(
'runnumber',
'int')
630 lumiprescBindVariable[
'runnumber'].setData(
int(runnumber))
632 lumiprescOutput=coral.AttributeList()
633 lumiprescOutput.extend(
'lumisection',
'int')
634 lumiprescOutput.extend(
'prescale_index',
'int')
635 lumiprescQuery.addToOutputList(
'LUMI_SECTION')
636 lumiprescQuery.addToOutputList(
'PRESCALE_INDEX')
637 lumiprescQuery.defineOutput(lumiprescOutput)
638 lumiprescQuery.setCondition(
'RUN_NUMBER=:runnumber',lumiprescBindVariable)
639 lumiprescCursor=lumiprescQuery.execute()
640 while next(lumiprescCursor):
641 row=lumiprescCursor.currentRow()
642 lumisection=row[
'lumisection'].
data()
643 psindex=row[
'prescale_index'].
data()
644 bitzeroprescale=prescaleDict[psindex][0]
645 bitzeroprescaleDict[lumisection]=prescaleDict[psindex][0]
646 prescaleResult[lumisection]=prescaleDict[psindex]
650 session.transaction().commit()
654 for cmslsnum,deadcount
in deadtimeresult.items():
655 bitzerocount=bitzerocountDict[cmslsnum]
656 bitzeroprescale=bitzeroprescaleDict[cmslsnum]
657 trgcounts=array.array(
'I')
658 for acounts
in algocount[cmslsnum]:
659 trgcounts.append(acounts)
660 for tcounts
in techcount[cmslsnum]:
661 trgcounts.append(tcounts)
663 trgprescale=array.array(
'I')
664 for aprescale
in prescaleResult[cmslsnum]:
665 trgprescale.append(aprescale)
667 perlsdict[cmslsnum]=[deadcount,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]
668 result=[bitnameclob,perlsdict]
671 session.transaction().rollback()
678 output: [pathnameclob,{cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}] 679 select count(distinct PATHNAME) as npath from HLT_SUPERVISOR_LUMISECTIONS_V2 where runnr=:runnumber and lsnumber=1; 680 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 686 session.transaction().
start(
True)
687 hltschema=session.schema(
'CMS_RUNINFO')
688 bvar=coral.AttributeList()
689 bvar.extend(
'runnumber',
'unsigned int')
690 bvar.extend(
'lsnumber',
'unsigned int')
691 bvar[
'runnumber'].setData(
int(runnumber))
692 bvar[
'lsnumber'].setData(1)
693 q1=hltschema.newQuery()
694 q1.addToTableList(
'HLT_SUPERVISOR_LUMISECTIONS_V2')
695 nls=coral.AttributeList()
696 nls.extend(
'npath',
'unsigned int')
697 q1.addToOutputList(
'count(distinct PATHNAME)',
'npath')
698 q1.setCondition(
'RUNNR=:runnumber AND LSNUMBER=:lsnumber',bvar)
702 npath=c.currentRow()[
'npath'].
data()
705 print(
'request run is empty, do nothing')
707 q=hltschema.newQuery()
708 bindVar=coral.AttributeList()
709 bindVar.extend(
'runnumber',
'unsigned int')
710 bindVar[
'runnumber'].setData(
int(runnumber))
711 q.addToTableList(
'HLT_SUPERVISOR_LUMISECTIONS_V2',
'l')
712 q.addToTableList(
'HLT_SUPERVISOR_SCALAR_MAP',
'm')
713 q.addToOutputList(
'l.LSNUMBER',
'lsnumber')
714 q.addToOutputList(
'l.PATHNAME',
'pathname')
715 q.addToOutputList(
'l.L1PASS',
'hltinput')
716 q.addToOutputList(
'l.PACCEPT',
'hltaccept')
717 q.addToOutputList(
'm.PSVALUE',
'prescale')
718 q.setCondition(
'l.RUNNR=m.RUNNR and l.PSINDEX=m.PSINDEX and l.PATHNAME=m.PATHNAME and l.RUNNR=:runnumber',bindVar)
719 q.addToOrderList(
'l.LSNUMBER')
720 q.addToOrderList(
'l.PATHNAME')
721 q.setRowCacheSize(10692)
727 hltinputs=array.array(
'I')
728 hltaccepts=array.array(
'I')
729 prescales=array.array(
'I')
731 row=cursor.currentRow()
732 cmsluminr=row[
'lsnumber'].
data()
733 hltinput=row[
'hltinput'].
data()
734 hltaccept=row[
'hltaccept'].
data()
735 prescale=row[
'prescale'].
data()
736 pathname=row[
'pathname'].
data()
739 pathnames.append(pathname)
740 if cmsluminr
not in hltdict:
741 hltdict[cmsluminr]=[]
742 hltinputs.append(hltinput)
743 hltaccepts.append(hltaccept)
744 prescales.append(prescale)
753 hltdict[cmsluminr].extend([hltinputsBlob,hltacceptsBlob,hltacceptsBlob])
755 hltinputs=array.array(
'I')
756 hltaccepts=array.array(
'I')
757 prescales=array.array(
'I')
758 pathnameclob=
','.
join(pathnames)
760 session.transaction().commit()
761 return [pathnameclob,hltdict]
768 output: [datasource,pathnameclob,{cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}] 769 select distinct(pathid) from HLT_SUPERVISOR_TRIGGERPATHS where runnnumber=:runnumber; 770 select count(*) from HLT_SUPERVISOR_LUMISECTIONS_V3 where runnumber=:runnumber;//total ls 771 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; 773 select pathname from cms_hlt.paths where pathid=:pathid 779 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; 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.configid=:hlt_numkey; 781 ##select paths.pathid from cms_hlt.paths paths,cms_hlt.configurations config where config.configdescriptor=' ' and name=:pathname 784 session.transaction().
start(
True)
785 hltconfschema=session.nominalSchema()
786 hltconfQuery=hltconfschema.newQuery()
788 hltconfQuery.addToOutputList(
'PATHS.NAME',
'hltpath')
789 hltconfQuery.addToOutputList(
'STRINGPARAMVALUES.VALUE',
'l1expression')
791 hltconfQuery.addToTableList(
'PATHS')
792 hltconfQuery.addToTableList(
'STRINGPARAMVALUES')
793 hltconfQuery.addToTableList(
'PARAMETERS')
794 hltconfQuery.addToTableList(
'SUPERIDPARAMETERASSOC')
795 hltconfQuery.addToTableList(
'MODULES')
796 hltconfQuery.addToTableList(
'MODULETEMPLATES')
797 hltconfQuery.addToTableList(
'PATHMODULEASSOC')
798 hltconfQuery.addToTableList(
'CONFIGURATIONPATHASSOC')
799 hltconfQuery.addToTableList(
'CONFIGURATIONS')
801 hltconfBindVar=coral.AttributeList()
802 hltconfBindVar.extend(
'hltseed',
'string')
803 hltconfBindVar.extend(
'l1seedexpr',
'string')
804 hltconfBindVar.extend(
'hltkey',
'string')
805 hltconfBindVar[
'hltseed'].setData(
'HLTLevel1GTSeed')
806 hltconfBindVar[
'l1seedexpr'].setData(
'L1SeedsLogicalExpression')
807 hltconfBindVar[
'hltkey'].setData(hltkey)
808 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)
810 cursor=hltconfQuery.execute()
812 hltpath=cursor.currentRow()[
'hltpath'].
data()
814 l1expression=cursor.currentRow()[
'l1expression'].
data()
815 hlt2l1map[hltpath]=l1expression
817 session.transaction().commit()
822 def runsummary(session,schemaname,runnumber,complementalOnly=False):
824 x select string_value from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.TRG:TSC_KEY'; 825 x select distinct(string_value) from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.SCAL:AMODEtag' 826 x select distinct(string_value),session_id from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.SCAL:EGEV' order by SESSION_ID 828 select string_value from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.LVL0:SEQ_NAME' 829 select string_value from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.LVL0:HLT_KEY_DESCRIPTION'; 830 select string_value from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.SCAL:FILLN' and rownum<=1; 831 select time from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.LVL0:START_TIME_T'; 832 select time from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.LVL0:STOP_TIME_T'; 834 output:[l1key,amodetag,egev,sequence,hltkey,fillnum,starttime,stoptime] 836 [l1key,amodetag,egev] 838 runsessionparameterTable=
'' 849 session.transaction().
start(
True)
850 runinfoschema=session.schema(schemaname)
851 l1keyQuery=runinfoschema.newQuery()
852 l1keyQuery.addToTableList(
'RUNSESSION_PARAMETER')
853 l1keyOutput=coral.AttributeList()
854 l1keyOutput.extend(
'l1key',
'string')
855 l1keyCondition=coral.AttributeList()
856 l1keyCondition.extend(
'name',
'string')
857 l1keyCondition.extend(
'runnumber',
'unsigned int')
858 l1keyCondition[
'name'].setData(
'CMS.TRG:TSC_KEY')
859 l1keyCondition[
'runnumber'].setData(
int(runnumber))
860 l1keyQuery.addToOutputList(
'STRING_VALUE')
861 l1keyQuery.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',l1keyCondition)
862 l1keyQuery.defineOutput(l1keyOutput)
863 cursor=l1keyQuery.execute()
865 l1key=cursor.currentRow()[
'l1key'].
data()
869 amodetagQuery=runinfoschema.newQuery()
870 amodetagQuery.addToTableList(
'RUNSESSION_PARAMETER')
871 amodetagOutput=coral.AttributeList()
872 amodetagOutput.extend(
'amodetag',
'string')
873 amodetagCondition=coral.AttributeList()
874 amodetagCondition.extend(
'name',
'string')
875 amodetagCondition.extend(
'runnumber',
'unsigned int')
876 amodetagCondition[
'name'].setData(
'CMS.SCAL:AMODEtag')
877 amodetagCondition[
'runnumber'].setData(
int(runnumber))
878 amodetagQuery.addToOutputList(
'distinct(STRING_VALUE)')
879 amodetagQuery.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',amodetagCondition)
880 amodetagQuery.limitReturnedRows(1)
881 amodetagQuery.defineOutput(amodetagOutput)
882 cursor=amodetagQuery.execute()
884 amodetag=cursor.currentRow()[
'amodetag'].
data()
886 result.append(amodetag)
888 egevQuery=runinfoschema.newQuery()
889 egevQuery.addToTableList(
'RUNSESSION_PARAMETER')
890 egevOutput=coral.AttributeList()
891 egevOutput.extend(
'egev',
'string')
892 egevCondition=coral.AttributeList()
893 egevCondition.extend(
'name',
'string')
894 egevCondition.extend(
'runnumber',
'unsigned int')
895 egevCondition[
'name'].setData(
'CMS.SCAL:EGEV')
896 egevCondition[
'runnumber'].setData(
int(runnumber))
897 egevQuery.addToOutputList(
'distinct(STRING_VALUE)')
898 egevQuery.addToOutputList(
'SESSION_ID')
899 egevQuery.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',egevCondition)
900 egevQuery.defineOutput(egevOutput)
901 egevQuery.addToOrderList(
'SESSION_ID')
902 cursor=egevQuery.execute()
904 egev=cursor.currentRow()[
'egev'].
data()
908 if not complementalOnly:
909 seqQuery=runinfoschema.newQuery()
910 seqQuery.addToTableList(
'RUNSESSION_PARAMETER')
911 seqOutput=coral.AttributeList()
912 seqOutput.extend(
'seq',
'string')
913 seqCondition=coral.AttributeList()
914 seqCondition.extend(
'name',
'string')
915 seqCondition.extend(
'runnumber',
'unsigned int')
916 seqCondition[
'name'].setData(
'CMS.LVL0:SEQ_NAME')
917 seqCondition[
'runnumber'].setData(
int(runnumber))
918 seqQuery.addToOutputList(
'STRING_VALUE')
919 seqQuery.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',seqCondition)
920 seqQuery.defineOutput(seqOutput)
921 cursor=seqQuery.execute()
923 sequence=cursor.currentRow()[
'seq'].
data()
925 result.append(sequence)
927 hltkeyQuery=runinfoschema.newQuery()
928 hltkeyQuery.addToTableList(
'RUNSESSION_PARAMETER')
929 hltkeyOutput=coral.AttributeList()
930 hltkeyOutput.extend(
'hltkey',
'string')
931 hltkeyCondition=coral.AttributeList()
932 hltkeyCondition.extend(
'name',
'string')
933 hltkeyCondition.extend(
'runnumber',
'unsigned int')
934 hltkeyCondition[
'name'].setData(
'CMS.LVL0:HLT_KEY_DESCRIPTION')
935 hltkeyCondition[
'runnumber'].setData(
int(runnumber))
936 hltkeyQuery.addToOutputList(
'STRING_VALUE')
937 hltkeyQuery.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',hltkeyCondition)
939 hltkeyQuery.defineOutput(hltkeyOutput)
940 cursor=hltkeyQuery.execute()
942 hltkey=cursor.currentRow()[
'hltkey'].
data()
944 result.append(hltkey)
946 fillnumQuery=runinfoschema.newQuery()
947 fillnumQuery.addToTableList(
'RUNSESSION_PARAMETER')
948 fillnumOutput=coral.AttributeList()
949 fillnumOutput.extend(
'fillnum',
'string')
950 fillnumCondition=coral.AttributeList()
951 fillnumCondition.extend(
'name',
'string')
952 fillnumCondition.extend(
'runnumber',
'unsigned int')
953 fillnumCondition[
'name'].setData(
'CMS.SCAL:FILLN')
954 fillnumCondition[
'runnumber'].setData(
int(runnumber))
955 fillnumQuery.addToOutputList(
'STRING_VALUE')
956 fillnumQuery.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',fillnumCondition)
957 fillnumQuery.limitReturnedRows(1)
958 fillnumQuery.defineOutput(fillnumOutput)
959 cursor=fillnumQuery.execute()
961 fillnum=cursor.currentRow()[
'fillnum'].
data()
963 result.append(fillnum)
965 starttimeQuery=runinfoschema.newQuery()
966 starttimeQuery.addToTableList(
'RUNSESSION_PARAMETER')
967 starttimeOutput=coral.AttributeList()
968 starttimeOutput.extend(
'starttime',
'time stamp')
969 starttimeCondition=coral.AttributeList()
970 starttimeCondition.extend(
'name',
'string')
971 starttimeCondition.extend(
'runnumber',
'unsigned int')
972 starttimeCondition[
'name'].setData(
'CMS.LVL0:START_TIME_T')
973 starttimeCondition[
'runnumber'].setData(
int(runnumber))
974 starttimeQuery.addToOutputList(
'TIME')
975 starttimeQuery.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',starttimeCondition)
976 starttimeQuery.defineOutput(starttimeOutput)
977 cursor=starttimeQuery.execute()
979 starttime=cursor.currentRow()[
'starttime'].
data()
981 result.append(starttime)
983 stoptimeQuery=runinfoschema.newQuery()
984 stoptimeQuery.addToTableList(
'RUNSESSION_PARAMETER')
985 stoptimeOutput=coral.AttributeList()
986 stoptimeOutput.extend(
'stoptime',
'time stamp')
987 stoptimeCondition=coral.AttributeList()
988 stoptimeCondition.extend(
'name',
'string')
989 stoptimeCondition.extend(
'runnumber',
'unsigned int')
990 stoptimeCondition[
'name'].setData(
'CMS.LVL0:STOP_TIME_T')
991 stoptimeCondition[
'runnumber'].setData(
int(runnumber))
992 stoptimeQuery.addToOutputList(
'TIME')
993 stoptimeQuery.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',stoptimeCondition)
994 stoptimeQuery.defineOutput(stoptimeOutput)
995 cursor=stoptimeQuery.execute()
997 stoptime=cursor.currentRow()[
'stoptime'].
data()
999 result.append(stoptime)
1000 session.transaction().commit()
1002 session.transaction().commit()
1007 if __name__ ==
"__main__":
1008 from RecoLuminosity.LumiDB
import sessionManager
1025 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)