2 from RecoLuminosity.LumiDB
import CommonUtil,nameDealer
6 input: runnumber,calibrated instlumi,calibrated instlumierror
7 output: (uncalibrated instlumi, uncalbrated instlumierror)
9 normpp7tev=float(6370.0)
10 normpp900gev=float(16500.0)
11 normhi7tev=float(2.383)
12 oldnormpp7tev=float(6330)
13 if runnumber
in [136290,136294,136297,134721,134725]:
14 return (float(instlumi)/normpp900gev,float(instlumierror)/normpp900gev)
15 if runnumber >=150431
and runnumber<=153368 :
16 return (float(instlumi)/normhi7tev,float(instlumierror)/normhi7tev)
17 return (float(instlumi)/normpp7tev,float(instlumierror)/normpp7tev)
21 retrieve old lumi value, divide by norm and restore to raw value
22 select lumilsnum,cmslsnum,instlumi,instlumierror,instlumiquality,startorbit,numorbit,beamenergy,beamstatus,cmsbxindexblob,beamintensityblob_1,beamintensityblob_2 from lumisummary where runnum=:runnumber order by lumilsnum
24 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
26 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]}]}
27 dict size ~ 200mb for 1000LS
32 session.transaction().
start(
True)
33 lumischema=session.nominalSchema()
34 summaryQuery=lumischema.newQuery()
36 summaryQuery.addToOutputList(
'LUMILSNUM',
'lumilsnum')
37 summaryQuery.addToOutputList(
'CMSLSNUM',
'cmslsnum')
38 summaryQuery.addToOutputList(
'INSTLUMI',
'instlumi')
39 summaryQuery.addToOutputList(
'INSTLUMIERROR',
'instlumierror')
40 summaryQuery.addToOutputList(
'INSTLUMIQUALITY',
'instlumiquality')
41 summaryQuery.addToOutputList(
'BEAMSTATUS',
'beamstatus')
42 summaryQuery.addToOutputList(
'BEAMENERGY',
'beamenergy')
43 summaryQuery.addToOutputList(
'NUMORBIT',
'numorbit')
44 summaryQuery.addToOutputList(
'STARTORBIT',
'startorbit')
45 summaryQuery.addToOutputList(
'CMSBXINDEXBLOB',
'cmsbxindexblob')
46 summaryQuery.addToOutputList(
'BEAMINTENSITYBLOB_1',
'beamintensityblob_1')
47 summaryQuery.addToOutputList(
'BEAMINTENSITYBLOB_2',
'beamintensityblob_2')
48 summaryCondition=coral.AttributeList()
49 summaryCondition.extend(
'runnumber',
'unsigned int')
50 summaryCondition[
'runnumber'].setData(int(runnumber))
51 summaryResult=coral.AttributeList()
52 summaryResult.extend(
'lumilsnum',
'unsigned int')
53 summaryResult.extend(
'cmslsnum',
'unsigned int')
54 summaryResult.extend(
'instlumi',
'float')
55 summaryResult.extend(
'instlumierror',
'float')
56 summaryResult.extend(
'instlumiquality',
'short')
57 summaryResult.extend(
'beamstatus',
'string')
58 summaryResult.extend(
'beamenergy',
'float')
59 summaryResult.extend(
'numorbit',
'unsigned int')
60 summaryResult.extend(
'startorbit',
'unsigned int')
61 summaryResult.extend(
'cmsbxindexblob',
'blob')
62 summaryResult.extend(
'beamintensityblob_1',
'blob')
63 summaryResult.extend(
'beamintensityblob_2',
'blob')
64 summaryQuery.defineOutput(summaryResult)
65 summaryQuery.addToOrderList(
'lumilsnum')
66 summaryQuery.setCondition(
'RUNNUM=:runnumber',summaryCondition)
67 summarycursor=summaryQuery.execute()
68 while next(summarycursor):
69 lumilsnum=summarycursor.currentRow()[
'lumilsnum'].
data()
70 cmslsnum=summarycursor.currentRow()[
'cmslsnum'].
data()
71 instlumi=summarycursor.currentRow()[
'instlumi'].
data()
72 instlumierror=summarycursor.currentRow()[
'instlumierror'].
data()
73 instlumiquality=summarycursor.currentRow()[
'instlumiquality'].
data()
74 (uncalibratedinstlumi,uncalibratedinstlumierror)=
uncalibrateLumi(runnumber,instlumi,instlumierror)
75 numorbit=summarycursor.currentRow()[
'numorbit'].
data()
76 startorbit=summarycursor.currentRow()[
'startorbit'].
data()
77 beamenergy=summarycursor.currentRow()[
'beamenergy'].
data()
78 beamstatus=summarycursor.currentRow()[
'beamstatus'].
data()
80 if not summarycursor.currentRow()[
'cmsbxindexblob'].isNull():
81 cmsbxindexblob=summarycursor.currentRow()[
'cmsbxindexblob'].
data()
82 beamintensityblob_1=
None
83 if not summarycursor.currentRow()[
'beamintensityblob_1'].isNull():
84 beamintensityblob_1=summarycursor.currentRow()[
'beamintensityblob_1'].
data()
85 beamintensityblob_2=
None
86 if not summarycursor.currentRow()[
'beamintensityblob_2'].isNull():
87 beamintensityblob_2=summarycursor.currentRow()[
'beamintensityblob_2'].
data()
88 datadict[lumilsnum]=[cmslsnum,uncalibratedinstlumi,uncalibratedinstlumierror,instlumiquality,beamstatus,beamenergy,numorbit,startorbit,cmsbxindexblob,beamintensityblob_1,beamintensityblob_2]
91 for algoname
in [
'OCC1',
'OCC2',
'ET']:
92 detailQuery=lumischema.newQuery()
95 detailQuery.addToOutputList(
's.LUMILSNUM',
'lumilsnum' )
96 detailQuery.addToOutputList(
'd.BXLUMIVALUE',
'bxlumivalue' )
97 detailQuery.addToOutputList(
'd.BXLUMIERROR',
'bxlumierror' )
98 detailQuery.addToOutputList(
'd.BXLUMIQUALITY',
'bxlumiquality' )
99 detailCondition=coral.AttributeList()
100 detailCondition.extend(
'runnumber',
'unsigned int')
101 detailCondition.extend(
'algoname',
'string')
102 detailCondition[
'runnumber'].setData(int(runnumber))
103 detailCondition[
'algoname'].setData(algoname)
104 detailResult=coral.AttributeList()
105 detailResult.extend(
'lumilsnum',
'unsigned int')
106 detailResult.extend(
'bxlumivalue',
'blob')
107 detailResult.extend(
'bxlumierror',
'blob')
108 detailResult.extend(
'bxlumiquality',
'blob')
109 detailQuery.defineOutput(detailResult)
110 detailQuery.addToOrderList(
'lumilsnum')
111 detailQuery.setCondition(
's.RUNNUM=:runnumber AND s.LUMISUMMARY_ID=d.LUMISUMMARY_ID AND d.ALGONAME=:algoname',detailCondition)
112 detailcursor=detailQuery.execute()
113 while next(detailcursor):
114 lumilsnum=detailcursor.currentRow()[
'lumilsnum'].
data()
115 bxlumivalue=detailcursor.currentRow()[
'bxlumivalue'].
data()
116 bxlumierror=detailcursor.currentRow()[
'bxlumierror'].
data()
117 bxlumiquality=detailcursor.currentRow()[
'bxlumiquality'].
data()
118 datadict[lumilsnum].extend([bxlumivalue,bxlumierror,bxlumiquality])
120 session.transaction().commit()
126 select count(distinct pathname) from hlt where runnum=:runnum
127 select cmslsnum,pathname,inputcount,acceptcount,prescale from hlt where runnum=:runnum order by cmslsnum,pathname
128 [pathnames,databuffer]
129 databuffer: {cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}
133 session.transaction().
start(
True)
134 lumischema=session.nominalSchema()
136 qHandle=lumischema.newQuery()
138 qHandle.addToOutputList(
'COUNT(DISTINCT PATHNAME)',
'npath')
139 qCondition=coral.AttributeList()
140 qCondition.extend(
'runnum',
'unsigned int')
141 qCondition[
'runnum'].setData(int(runnumber))
142 qResult=coral.AttributeList()
143 qResult.extend(
'npath',
'unsigned int')
144 qHandle.defineOutput(qResult)
145 qHandle.setCondition(
'RUNNUM=:runnum',qCondition)
146 cursor=qHandle.execute()
148 npath=cursor.currentRow()[
'npath'].
data()
152 qHandle=lumischema.newQuery()
154 qHandle.addToOutputList(
'CMSLSNUM',
'cmslsnum')
155 qHandle.addToOutputList(
'PATHNAME',
'pathname')
156 qHandle.addToOutputList(
'INPUTCOUNT',
'inputcount')
157 qHandle.addToOutputList(
'ACCEPTCOUNT',
'acceptcount')
158 qHandle.addToOutputList(
'PRESCALE',
'prescale')
159 qCondition=coral.AttributeList()
160 qCondition.extend(
'runnum',
'unsigned int')
161 qCondition[
'runnum'].setData(int(runnumber))
162 qResult=coral.AttributeList()
163 qResult.extend(
'cmslsnum',
'unsigned int')
164 qResult.extend(
'pathname',
'string')
165 qResult.extend(
'inputcount',
'unsigned int')
166 qResult.extend(
'acceptcount',
'unsigned int')
167 qResult.extend(
'prescale',
'unsigned int')
168 qHandle.defineOutput(qResult)
169 qHandle.setCondition(
'RUNNUM=:runnum',qCondition)
170 qHandle.addToOrderList(
'cmslsnum')
171 qHandle.addToOrderList(
'pathname')
172 cursor=qHandle.execute()
174 inputcountArray=array.array(
'I')
175 acceptcountArray=array.array(
'I')
176 prescaleArray=array.array(
'I')
178 pathnHLT_PixelTracksVdMames=
''
180 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
181 pathname=cursor.currentRow()[
'pathname'].
data()
183 inputcount=cursor.currentRow()[
'inputcount'].
data()
184 acceptcount=cursor.currentRow()[
'acceptcount'].
data()
185 prescale=cursor.currentRow()[
'prescale'].
data()
186 pathnameList.append(pathname)
187 inputcountArray.append(inputcount)
188 acceptcountArray.append(acceptcount)
189 prescaleArray.append(prescale)
192 pathnames=
','.
join(pathnameList)
196 databuffer[cmslsnum]=[inputcountBlob,acceptcountBlob,prescaleBlob]
198 inputcountArray=array.array(
'I')
199 acceptcountArray=array.array(
'I')
200 prescaleArray=array.array(
'I')
203 session.transaction().commit()
205 return [pathnames,databuffer]
211 select bitnum,bitname from trg where runnum=:runnumber and cmslsnum=1 order by bitnum
212 select cmslsnum,deadtime,trgcount,prescale from trg where bitnum=:bitnum and runnum=:runnumber
214 output: [bitnames,{cmslsnum,[deadtime,bitzerocount,bitzerpoprescale,trgcountBlob,trgprescaleBlob]}]
216 session.transaction().
start(
True)
217 lumischema=session.nominalSchema()
218 qHandle=lumischema.newQuery()
220 qHandle=lumischema.newQuery()
222 qHandle.addToOutputList(
'BITNUM',
'bitnum')
223 qHandle.addToOutputList(
'BITNAME',
'bitname')
224 qCondition=coral.AttributeList()
225 qCondition.extend(
'runnum',
'unsigned int')
226 qCondition[
'runnum'].setData(int(runnumber))
227 qCondition.extend(
'cmslsnum',
'unsigned int')
228 qCondition[
'cmslsnum'].setData(int(1))
229 qResult=coral.AttributeList()
230 qResult.extend(
'bitnum',
'unsigned int')
231 qResult.extend(
'bitname',
'string')
232 qHandle.defineOutput(qResult)
233 qHandle.setCondition(
'RUNNUM=:runnum AND CMSLSNUM=:cmslsnum',qCondition)
234 qHandle.addToOrderList(
'BITNUM')
235 cursor=qHandle.execute()
239 bitnum=cursor.currentRow()[
'bitnum'].
data()
240 bitname=cursor.currentRow()[
'bitname'].
data()
241 bitnums.append(bitnum)
242 bitnameList.append(bitname)
244 bitnames=
','.
join(bitnameList)
247 qHandle=lumischema.newQuery()
249 qHandle.addToOutputList(
'CMSLSNUM',
'cmslsnum')
250 qHandle.addToOutputList(
'BITNUM',
'bitnum')
251 qHandle.addToOutputList(
'DEADTIME',
'deadtime')
252 qHandle.addToOutputList(
'TRGCOUNT',
'trgcount')
253 qHandle.addToOutputList(
'PRESCALE',
'prescale')
254 qCondition=coral.AttributeList()
255 qCondition.extend(
'runnum',
'unsigned int')
256 qCondition[
'runnum'].setData(int(runnumber))
257 qResult=coral.AttributeList()
258 qResult.extend(
'cmslsnum',
'unsigned int')
259 qResult.extend(
'bitnum',
'unsigned int')
260 qResult.extend(
'deadtime',
'unsigned long long')
261 qResult.extend(
'trgcount',
'unsigned int')
262 qResult.extend(
'prescale',
'unsigned int')
263 qHandle.defineOutput(qResult)
264 qHandle.setCondition(
'RUNNUM=:runnum',qCondition)
265 qHandle.addToOrderList(
'CMSLSNUM')
266 qHandle.addToOrderList(
'BITNUM')
267 cursor=qHandle.execute()
268 trgcountArray=array.array(
'I')
269 prescaleArray=array.array(
'I')
271 cmslsnum=cursor.currentRow()[
'cmslsnum'].
data()
272 bitnum=cursor.currentRow()[
'bitnum'].
data()
273 deadtime=cursor.currentRow()[
'deadtime'].
data()
274 trgcount=cursor.currentRow()[
'trgcount'].
data()
275 prescale=cursor.currentRow()[
'prescale'].
data()
276 if cmslsnum
not in databuffer:
277 databuffer[cmslsnum]=[]
278 databuffer[cmslsnum].
append(deadtime)
280 databuffer[cmslsnum].
append(trgcount)
281 databuffer[cmslsnum].
append(prescale)
282 trgcountArray.append(trgcount)
283 prescaleArray.append(prescale)
287 databuffer[cmslsnum].
append(trgcountBlob)
288 databuffer[cmslsnum].
append(prescaleBlob)
289 trgcountArray=array.array(
'I')
290 prescaleArray=array.array(
'I')
292 session.transaction().commit()
293 return [bitnames,databuffer]
305 select counts,lsnr,algobit from cms_gt_mon.gt_mon_trig_algo_view where runnr=:runnumber order by lsnr,algobit
306 select counts,lsnr,techbit from cms_gt_mon.gt_mon_trig_tech_view where runnr=:runnumber order by lsnr,techbit
307 select counts,lsnr from cms_gt_mon.gt_mon_trig_dead_view where runnr=:runnumber and deadcounter=:countername order by lsnr
308 select algo_index,alias from cms_gt.gt_run_algo_view where runnumber=:runnumber order by algo_index
309 select techtrig_index,name from cms_gt.gt_run_tech_view where runnumber=:runnumber order by techtrig_index
310 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;
311 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;
318 output: [bitnameclob,{cmslsnum:[deadtime,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]}]
319 1. select counts,lsnr from cms_gt_mon.gt_mon_trig_dead_view where runnr=:runnumber and deadcounter=:countername order by lsnr
320 2. select counts,lsnr,algobit from cms_gt_mon.gt_mon_trig_algo_view where runnr=:runnumber order by lsnr,algobit
321 3. select counts,lsnr,techbit from cms_gt_mon.gt_mon_trig_tech_view where runnr=:runnumber order by lsnr,techbit
322 4. select algo_index,alias from cms_gt.gt_run_algo_view where runnumber=:runnumber order by algo_index
323 ## not needed5. select techtrig_index,name from cms_gt.gt_run_tech_view where runnumber=:runnumber order by techtrig_index
324 5 select distinct(prescale_index) from cms_gt_mon.lumi_sections where run_number=:runnumber;
325 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;
326 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;
327 8. select lumi_section,prescale_index from cms_gt_mon.lumi_sections where run_number=:runnumber order by lumi_section
338 bitzeroprescaleDict={}
343 session.transaction().
start(
True)
344 gtmonschema=session.schema(
'CMS_GT_MON')
348 deadviewQuery=gtmonschema.newQuery()
349 deadviewQuery.addToTableList(
'GT_MON_TRIG_DEAD_VIEW')
350 deadOutput=coral.AttributeList()
351 deadOutput.extend(
'counts',
'unsigned int')
352 deadOutput.extend(
'lsnr',
'unsigned int')
353 deadviewQuery.addToOutputList(
'counts')
354 deadviewQuery.addToOutputList(
'lsnr')
355 bindVariablesDead=coral.AttributeList()
356 bindVariablesDead.extend(
'runnumber',
'int')
357 bindVariablesDead.extend(
'countername',
'string')
358 bindVariablesDead[
'runnumber'].setData(int(runnumber))
359 bindVariablesDead[
'countername'].setData(
'DeadtimeBeamActive')
360 deadviewQuery.setCondition(
'RUNNR=:runnumber AND DEADCOUNTER=:countername',bindVariablesDead)
361 deadviewQuery.addToOrderList(
'lsnr')
362 deadviewQuery.defineOutput(deadOutput)
363 deadcursor=deadviewQuery.execute()
365 while next(deadcursor):
366 row=deadcursor.currentRow()
368 lsnr=row[
'lsnr'].
data()
370 print 'DEADTIME alert: found hole in LS range'
371 print ' fill deadtimebeamactive 0 for LS '+str(s)
374 count=row[
'counts'].
data()
375 deadtimeresult[s]=count
379 session.transaction().commit()
380 raise 'requested run '+str(runnumber )+
' does not exist for deadcounts'
384 algoviewQuery=gtmonschema.newQuery()
388 algoviewQuery.addToTableList(
'GT_MON_TRIG_ALGO_VIEW')
389 algoOutput=coral.AttributeList()
390 algoOutput.extend(
'counts',
'unsigned int')
391 algoOutput.extend(
'lsnr',
'unsigned int')
392 algoOutput.extend(
'algobit',
'unsigned int')
393 algoviewQuery.addToOutputList(
'counts')
394 algoviewQuery.addToOutputList(
'lsnr')
395 algoviewQuery.addToOutputList(
'algobit')
396 algoCondition=coral.AttributeList()
397 algoCondition.extend(
'runnumber',
'unsigned int')
398 algoCondition[
'runnumber'].setData(int(runnumber))
399 algoviewQuery.setCondition(
'RUNNR=:runnumber',algoCondition)
400 algoviewQuery.addToOrderList(
'lsnr')
401 algoviewQuery.addToOrderList(
'algobit')
402 algoviewQuery.defineOutput(algoOutput)
404 algocursor=algoviewQuery.execute()
406 while next(algocursor):
407 row=algocursor.currentRow()
408 lsnr=row[
'lsnr'].
data()
409 counts=row[
'counts'].
data()
410 algobit=row[
'algobit'].
data()
411 mybitcount_algo.append(counts)
413 bitzerocountDict[lsnr]=counts
414 if algobit==NAlgoBit-1:
417 print 'ALGO COUNT alert: found hole in LS range'
418 print ' fill all algocount 0 for LS '+str(s)
422 algocount[s]=mybitcount_algo
427 session.transaction().commit()
428 raise 'requested run '+str(runnumber+
' does not exist for algocounts ')
432 techviewQuery=gtmonschema.newQuery()
433 techviewQuery.addToTableList(
'GT_MON_TRIG_TECH_VIEW')
437 techOutput=coral.AttributeList()
438 techOutput.extend(
'counts',
'unsigned int')
439 techOutput.extend(
'lsnr',
'unsigned int')
440 techOutput.extend(
'techbit',
'unsigned int')
441 techviewQuery.addToOutputList(
'COUNTS',
'counts')
442 techviewQuery.addToOutputList(
'LSNR',
'lsnr')
443 techviewQuery.addToOutputList(
'TECHBIT',
'techbit')
444 techCondition=coral.AttributeList()
445 techCondition.extend(
'runnumber',
'unsigned int')
446 techCondition[
'runnumber'].setData(int(runnumber))
447 techviewQuery.setCondition(
'RUNNR=:runnumber',techCondition)
448 techviewQuery.addToOrderList(
'lsnr')
449 techviewQuery.addToOrderList(
'techbit')
450 techviewQuery.defineOutput(techOutput)
452 techcursor=techviewQuery.execute()
454 while next(techcursor):
455 row=techcursor.currentRow()
456 lsnr=row[
'lsnr'].
data()
457 counts=row[
'counts'].
data()
458 techbit=row[
'techbit'].
data()
459 mybitcount_tech.append(counts)
460 if techbit==NTechBit-1:
463 print 'TECH COUNT alert: found hole in LS range'
464 print ' fill all techcount 0 for LS '+str(s)
468 techcount[s]=mybitcount_tech
473 session.transaction().commit()
474 raise 'requested run '+str(runnumber+
' does not exist for techcounts ')
477 gtschema=session.schema(
'CMS_GT')
479 namealiasQuery=gtschema.newQuery()
484 namealiasQuery.addToTableList(
'GT_RUN_ALGO_VIEW')
485 algonameOutput=coral.AttributeList()
486 algonameOutput.extend(
'algo_index',
'unsigned int')
487 algonameOutput.extend(
'alias',
'string')
488 namealiasQuery.addToOutputList(
'algo_index')
489 namealiasQuery.addToOutputList(
'alias')
490 algonameCondition=coral.AttributeList()
491 algonameCondition.extend(
'runnumber',
'unsigned int')
492 algonameCondition[
'runnumber'].setData(int(runnumber))
493 namealiasQuery.setCondition(
'RUNNUMBER=:runnumber',algonameCondition)
494 namealiasQuery.defineOutput(algonameOutput)
495 algonamecursor=namealiasQuery.execute()
496 while next(algonamecursor):
497 row=algonamecursor.currentRow()
498 algo_index=row[
'algo_index'].
data()
499 algo_name=row[
'alias'].
data()
500 triggernamemap[algo_index]=algo_name
530 for algoidx
in range(NAlgoBit):
531 if algoidx
in triggernamemap.keys():
532 bitnames.append(triggernamemap[algoidx])
534 bitnames.append(
'False')
538 for techidx
in range(NTechBit):
539 bitnames.append(str(techidx))
540 bitnameclob=
','.
join(bitnames)
545 presidxQuery=gtmonschema.newQuery()
546 presidxQuery.addToTableList(
'LUMI_SECTIONS')
548 presidxBindVariable=coral.AttributeList()
549 presidxBindVariable.extend(
'runnumber',
'int')
550 presidxBindVariable[
'runnumber'].setData(int(runnumber))
552 presidxOutput=coral.AttributeList()
553 presidxOutput.extend(
'prescale_index',
'int')
554 presidxQuery.addToOutputList(
'distinct(PRESCALE_INDEX)',
'prescale_index')
555 presidxQuery.defineOutput(presidxOutput)
556 presidxQuery.setCondition(
'RUN_NUMBER=:runnumber',presidxBindVariable)
557 presidxCursor=presidxQuery.execute()
558 while next(presidxCursor):
559 presc=presidxCursor.currentRow()[
'prescale_index'].
data()
560 prescaleidx.append(presc)
566 for prescaleindex
in prescaleidx:
567 algoprescQuery=gtschema.newQuery()
568 algoprescQuery.addToTableList(
'GT_RUN_PRESC_ALGO_VIEW')
569 algoPrescOutput=coral.AttributeList()
570 algoprescBase=
'PRESCALE_FACTOR_ALGO_'
571 for bitidx
in range(NAlgoBit):
572 algopresc=algoprescBase+str(bitidx).zfill(3)
573 algoPrescOutput.extend(algopresc,
'unsigned int')
574 algoprescQuery.addToOutputList(algopresc)
575 PrescbindVariable=coral.AttributeList()
576 PrescbindVariable.extend(
'runnumber',
'int')
577 PrescbindVariable.extend(
'prescaleindex',
'int')
578 PrescbindVariable[
'runnumber'].setData(int(runnumber))
579 PrescbindVariable[
'prescaleindex'].setData(prescaleindex)
580 algoprescQuery.setCondition(
'RUNNR=:runnumber AND PRESCALE_INDEX=:prescaleindex',PrescbindVariable)
581 algoprescQuery.defineOutput(algoPrescOutput)
582 algopresccursor=algoprescQuery.execute()
583 while next(algopresccursor):
584 row=algopresccursor.currentRow()
586 for bitidx
in range(NAlgoBit):
587 algopresc=algoprescBase+str(bitidx).zfill(3)
588 algoprescale.append(row[algopresc].
data())
589 prescaleDict[prescaleindex]=algoprescale
595 for prescaleindex
in prescaleidx:
596 techprescQuery=gtschema.newQuery()
597 techprescQuery.addToTableList(
'GT_RUN_PRESC_TECH_VIEW')
598 techPrescOutput=coral.AttributeList()
599 techprescBase=
'PRESCALE_FACTOR_TT_'
600 for bitidx
in range(NTechBit):
601 techpresc=techprescBase+str(bitidx).zfill(3)
602 techPrescOutput.extend(techpresc,
'unsigned int')
603 techprescQuery.addToOutputList(techpresc)
604 PrescbindVariable=coral.AttributeList()
605 PrescbindVariable.extend(
'runnumber',
'int')
606 PrescbindVariable.extend(
'prescaleindex',
'int')
607 PrescbindVariable[
'runnumber'].setData(int(runnumber))
608 PrescbindVariable[
'prescaleindex'].setData(prescaleindex)
609 techprescQuery.setCondition(
'RUNNR=:runnumber AND PRESCALE_INDEX=:prescaleindex',PrescbindVariable)
610 techprescQuery.defineOutput(techPrescOutput)
611 techpresccursor=techprescQuery.execute()
612 while next(techpresccursor):
613 row=techpresccursor.currentRow()
615 for bitidx
in range(NTechBit):
616 techpresc=techprescBase+str(bitidx).zfill(3)
617 techprescale.append(row[techpresc].
data())
618 prescaleDict[prescaleindex]+=techprescale
624 lumiprescQuery=gtmonschema.newQuery()
625 lumiprescQuery.addToTableList(
'LUMI_SECTIONS')
627 lumiprescBindVariable=coral.AttributeList()
628 lumiprescBindVariable.extend(
'runnumber',
'int')
629 lumiprescBindVariable[
'runnumber'].setData(int(runnumber))
631 lumiprescOutput=coral.AttributeList()
632 lumiprescOutput.extend(
'lumisection',
'int')
633 lumiprescOutput.extend(
'prescale_index',
'int')
634 lumiprescQuery.addToOutputList(
'LUMI_SECTION')
635 lumiprescQuery.addToOutputList(
'PRESCALE_INDEX')
636 lumiprescQuery.defineOutput(lumiprescOutput)
637 lumiprescQuery.setCondition(
'RUN_NUMBER=:runnumber',lumiprescBindVariable)
638 lumiprescCursor=lumiprescQuery.execute()
639 while next(lumiprescCursor):
640 row=lumiprescCursor.currentRow()
641 lumisection=row[
'lumisection'].
data()
642 psindex=row[
'prescale_index'].
data()
643 bitzeroprescale=prescaleDict[psindex][0]
644 bitzeroprescaleDict[lumisection]=prescaleDict[psindex][0]
645 prescaleResult[lumisection]=prescaleDict[psindex]
649 session.transaction().commit()
653 for cmslsnum,deadcount
in deadtimeresult.items():
654 bitzerocount=bitzerocountDict[cmslsnum]
655 bitzeroprescale=bitzeroprescaleDict[cmslsnum]
656 trgcounts=array.array(
'I')
657 for acounts
in algocount[cmslsnum]:
658 trgcounts.append(acounts)
659 for tcounts
in techcount[cmslsnum]:
660 trgcounts.append(tcounts)
662 trgprescale=array.array(
'I')
663 for aprescale
in prescaleResult[cmslsnum]:
664 trgprescale.append(aprescale)
666 perlsdict[cmslsnum]=[deadcount,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]
667 result=[bitnameclob,perlsdict]
670 session.transaction().rollback()
677 output: [pathnameclob,{cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}]
678 select count(distinct PATHNAME) as npath from HLT_SUPERVISOR_LUMISECTIONS_V2 where runnr=:runnumber and lsnumber=1;
679 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
685 session.transaction().
start(
True)
686 hltschema=session.schema(
'CMS_RUNINFO')
687 bvar=coral.AttributeList()
688 bvar.extend(
'runnumber',
'unsigned int')
689 bvar.extend(
'lsnumber',
'unsigned int')
690 bvar[
'runnumber'].setData(int(runnumber))
691 bvar[
'lsnumber'].setData(1)
692 q1=hltschema.newQuery()
693 q1.addToTableList(
'HLT_SUPERVISOR_LUMISECTIONS_V2')
694 nls=coral.AttributeList()
695 nls.extend(
'npath',
'unsigned int')
696 q1.addToOutputList(
'count(distinct PATHNAME)',
'npath')
697 q1.setCondition(
'RUNNR=:runnumber AND LSNUMBER=:lsnumber',bvar)
701 npath=c.currentRow()[
'npath'].
data()
704 print 'request run is empty, do nothing'
706 q=hltschema.newQuery()
707 bindVar=coral.AttributeList()
708 bindVar.extend(
'runnumber',
'unsigned int')
709 bindVar[
'runnumber'].setData(int(runnumber))
710 q.addToTableList(
'HLT_SUPERVISOR_LUMISECTIONS_V2',
'l')
711 q.addToTableList(
'HLT_SUPERVISOR_SCALAR_MAP',
'm')
712 q.addToOutputList(
'l.LSNUMBER',
'lsnumber')
713 q.addToOutputList(
'l.PATHNAME',
'pathname')
714 q.addToOutputList(
'l.L1PASS',
'hltinput')
715 q.addToOutputList(
'l.PACCEPT',
'hltaccept')
716 q.addToOutputList(
'm.PSVALUE',
'prescale')
717 q.setCondition(
'l.RUNNR=m.RUNNR and l.PSINDEX=m.PSINDEX and l.PATHNAME=m.PATHNAME and l.RUNNR=:runnumber',bindVar)
718 q.addToOrderList(
'l.LSNUMBER')
719 q.addToOrderList(
'l.PATHNAME')
720 q.setRowCacheSize(10692)
726 hltinputs=array.array(
'I')
727 hltaccepts=array.array(
'I')
728 prescales=array.array(
'I')
730 row=cursor.currentRow()
731 cmsluminr=row[
'lsnumber'].
data()
732 hltinput=row[
'hltinput'].
data()
733 hltaccept=row[
'hltaccept'].
data()
734 prescale=row[
'prescale'].
data()
735 pathname=row[
'pathname'].
data()
738 pathnames.append(pathname)
739 if cmsluminr
not in hltdict:
740 hltdict[cmsluminr]=[]
741 hltinputs.append(hltinput)
742 hltaccepts.append(hltaccept)
743 prescales.append(prescale)
752 hltdict[cmsluminr].extend([hltinputsBlob,hltacceptsBlob,hltacceptsBlob])
754 hltinputs=array.array(
'I')
755 hltaccepts=array.array(
'I')
756 prescales=array.array(
'I')
757 pathnameclob=
','.
join(pathnames)
759 session.transaction().commit()
760 return [pathnameclob,hltdict]
767 output: [datasource,pathnameclob,{cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}]
768 select distinct(pathid) from HLT_SUPERVISOR_TRIGGERPATHS where runnnumber=:runnumber;
769 select count(*) from HLT_SUPERVISOR_LUMISECTIONS_V3 where runnumber=:runnumber;//total ls
770 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;
772 select pathname from cms_hlt.paths where pathid=:pathid
778 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;
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.configid=:hlt_numkey;
780 ##select paths.pathid from cms_hlt.paths paths,cms_hlt.configurations config where config.configdescriptor=' ' and name=:pathname
783 session.transaction().
start(
True)
784 hltconfschema=session.nominalSchema()
785 hltconfQuery=hltconfschema.newQuery()
787 hltconfQuery.addToOutputList(
'PATHS.NAME',
'hltpath')
788 hltconfQuery.addToOutputList(
'STRINGPARAMVALUES.VALUE',
'l1expression')
790 hltconfQuery.addToTableList(
'PATHS')
791 hltconfQuery.addToTableList(
'STRINGPARAMVALUES')
792 hltconfQuery.addToTableList(
'PARAMETERS')
793 hltconfQuery.addToTableList(
'SUPERIDPARAMETERASSOC')
794 hltconfQuery.addToTableList(
'MODULES')
795 hltconfQuery.addToTableList(
'MODULETEMPLATES')
796 hltconfQuery.addToTableList(
'PATHMODULEASSOC')
797 hltconfQuery.addToTableList(
'CONFIGURATIONPATHASSOC')
798 hltconfQuery.addToTableList(
'CONFIGURATIONS')
800 hltconfBindVar=coral.AttributeList()
801 hltconfBindVar.extend(
'hltseed',
'string')
802 hltconfBindVar.extend(
'l1seedexpr',
'string')
803 hltconfBindVar.extend(
'hltkey',
'string')
804 hltconfBindVar[
'hltseed'].setData(
'HLTLevel1GTSeed')
805 hltconfBindVar[
'l1seedexpr'].setData(
'L1SeedsLogicalExpression')
806 hltconfBindVar[
'hltkey'].setData(hltkey)
807 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)
809 cursor=hltconfQuery.execute()
811 hltpath=cursor.currentRow()[
'hltpath'].
data()
813 l1expression=cursor.currentRow()[
'l1expression'].
data()
814 hlt2l1map[hltpath]=l1expression
816 session.transaction().commit()
821 def runsummary(session,schemaname,runnumber,complementalOnly=False):
823 x select string_value from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.TRG:TSC_KEY';
824 x select distinct(string_value) from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.SCAL:AMODEtag'
825 x select distinct(string_value),session_id from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.SCAL:EGEV' order by SESSION_ID
827 select string_value from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.LVL0:SEQ_NAME'
828 select string_value from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.LVL0:HLT_KEY_DESCRIPTION';
829 select string_value from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.SCAL:FILLN' and rownum<=1;
830 select time from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.LVL0:START_TIME_T';
831 select time from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.LVL0:STOP_TIME_T';
833 output:[l1key,amodetag,egev,sequence,hltkey,fillnum,starttime,stoptime]
835 [l1key,amodetag,egev]
837 runsessionparameterTable=
''
848 session.transaction().
start(
True)
849 runinfoschema=session.schema(schemaname)
850 l1keyQuery=runinfoschema.newQuery()
851 l1keyQuery.addToTableList(
'RUNSESSION_PARAMETER')
852 l1keyOutput=coral.AttributeList()
853 l1keyOutput.extend(
'l1key',
'string')
854 l1keyCondition=coral.AttributeList()
855 l1keyCondition.extend(
'name',
'string')
856 l1keyCondition.extend(
'runnumber',
'unsigned int')
857 l1keyCondition[
'name'].setData(
'CMS.TRG:TSC_KEY')
858 l1keyCondition[
'runnumber'].setData(int(runnumber))
859 l1keyQuery.addToOutputList(
'STRING_VALUE')
860 l1keyQuery.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',l1keyCondition)
861 l1keyQuery.defineOutput(l1keyOutput)
862 cursor=l1keyQuery.execute()
864 l1key=cursor.currentRow()[
'l1key'].
data()
868 amodetagQuery=runinfoschema.newQuery()
869 amodetagQuery.addToTableList(
'RUNSESSION_PARAMETER')
870 amodetagOutput=coral.AttributeList()
871 amodetagOutput.extend(
'amodetag',
'string')
872 amodetagCondition=coral.AttributeList()
873 amodetagCondition.extend(
'name',
'string')
874 amodetagCondition.extend(
'runnumber',
'unsigned int')
875 amodetagCondition[
'name'].setData(
'CMS.SCAL:AMODEtag')
876 amodetagCondition[
'runnumber'].setData(int(runnumber))
877 amodetagQuery.addToOutputList(
'distinct(STRING_VALUE)')
878 amodetagQuery.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',amodetagCondition)
879 amodetagQuery.limitReturnedRows(1)
880 amodetagQuery.defineOutput(amodetagOutput)
881 cursor=amodetagQuery.execute()
883 amodetag=cursor.currentRow()[
'amodetag'].
data()
885 result.append(amodetag)
887 egevQuery=runinfoschema.newQuery()
888 egevQuery.addToTableList(
'RUNSESSION_PARAMETER')
889 egevOutput=coral.AttributeList()
890 egevOutput.extend(
'egev',
'string')
891 egevCondition=coral.AttributeList()
892 egevCondition.extend(
'name',
'string')
893 egevCondition.extend(
'runnumber',
'unsigned int')
894 egevCondition[
'name'].setData(
'CMS.SCAL:EGEV')
895 egevCondition[
'runnumber'].setData(int(runnumber))
896 egevQuery.addToOutputList(
'distinct(STRING_VALUE)')
897 egevQuery.addToOutputList(
'SESSION_ID')
898 egevQuery.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',egevCondition)
899 egevQuery.defineOutput(egevOutput)
900 egevQuery.addToOrderList(
'SESSION_ID')
901 cursor=egevQuery.execute()
903 egev=cursor.currentRow()[
'egev'].
data()
907 if not complementalOnly:
908 seqQuery=runinfoschema.newQuery()
909 seqQuery.addToTableList(
'RUNSESSION_PARAMETER')
910 seqOutput=coral.AttributeList()
911 seqOutput.extend(
'seq',
'string')
912 seqCondition=coral.AttributeList()
913 seqCondition.extend(
'name',
'string')
914 seqCondition.extend(
'runnumber',
'unsigned int')
915 seqCondition[
'name'].setData(
'CMS.LVL0:SEQ_NAME')
916 seqCondition[
'runnumber'].setData(int(runnumber))
917 seqQuery.addToOutputList(
'STRING_VALUE')
918 seqQuery.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',seqCondition)
919 seqQuery.defineOutput(seqOutput)
920 cursor=seqQuery.execute()
922 sequence=cursor.currentRow()[
'seq'].
data()
924 result.append(sequence)
926 hltkeyQuery=runinfoschema.newQuery()
927 hltkeyQuery.addToTableList(
'RUNSESSION_PARAMETER')
928 hltkeyOutput=coral.AttributeList()
929 hltkeyOutput.extend(
'hltkey',
'string')
930 hltkeyCondition=coral.AttributeList()
931 hltkeyCondition.extend(
'name',
'string')
932 hltkeyCondition.extend(
'runnumber',
'unsigned int')
933 hltkeyCondition[
'name'].setData(
'CMS.LVL0:HLT_KEY_DESCRIPTION')
934 hltkeyCondition[
'runnumber'].setData(int(runnumber))
935 hltkeyQuery.addToOutputList(
'STRING_VALUE')
936 hltkeyQuery.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',hltkeyCondition)
938 hltkeyQuery.defineOutput(hltkeyOutput)
939 cursor=hltkeyQuery.execute()
941 hltkey=cursor.currentRow()[
'hltkey'].
data()
943 result.append(hltkey)
945 fillnumQuery=runinfoschema.newQuery()
946 fillnumQuery.addToTableList(
'RUNSESSION_PARAMETER')
947 fillnumOutput=coral.AttributeList()
948 fillnumOutput.extend(
'fillnum',
'string')
949 fillnumCondition=coral.AttributeList()
950 fillnumCondition.extend(
'name',
'string')
951 fillnumCondition.extend(
'runnumber',
'unsigned int')
952 fillnumCondition[
'name'].setData(
'CMS.SCAL:FILLN')
953 fillnumCondition[
'runnumber'].setData(int(runnumber))
954 fillnumQuery.addToOutputList(
'STRING_VALUE')
955 fillnumQuery.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',fillnumCondition)
956 fillnumQuery.limitReturnedRows(1)
957 fillnumQuery.defineOutput(fillnumOutput)
958 cursor=fillnumQuery.execute()
960 fillnum=cursor.currentRow()[
'fillnum'].
data()
962 result.append(fillnum)
964 starttimeQuery=runinfoschema.newQuery()
965 starttimeQuery.addToTableList(
'RUNSESSION_PARAMETER')
966 starttimeOutput=coral.AttributeList()
967 starttimeOutput.extend(
'starttime',
'time stamp')
968 starttimeCondition=coral.AttributeList()
969 starttimeCondition.extend(
'name',
'string')
970 starttimeCondition.extend(
'runnumber',
'unsigned int')
971 starttimeCondition[
'name'].setData(
'CMS.LVL0:START_TIME_T')
972 starttimeCondition[
'runnumber'].setData(int(runnumber))
973 starttimeQuery.addToOutputList(
'TIME')
974 starttimeQuery.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',starttimeCondition)
975 starttimeQuery.defineOutput(starttimeOutput)
976 cursor=starttimeQuery.execute()
978 starttime=cursor.currentRow()[
'starttime'].
data()
980 result.append(starttime)
982 stoptimeQuery=runinfoschema.newQuery()
983 stoptimeQuery.addToTableList(
'RUNSESSION_PARAMETER')
984 stoptimeOutput=coral.AttributeList()
985 stoptimeOutput.extend(
'stoptime',
'time stamp')
986 stoptimeCondition=coral.AttributeList()
987 stoptimeCondition.extend(
'name',
'string')
988 stoptimeCondition.extend(
'runnumber',
'unsigned int')
989 stoptimeCondition[
'name'].setData(
'CMS.LVL0:STOP_TIME_T')
990 stoptimeCondition[
'runnumber'].setData(int(runnumber))
991 stoptimeQuery.addToOutputList(
'TIME')
992 stoptimeQuery.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',stoptimeCondition)
993 stoptimeQuery.defineOutput(stoptimeOutput)
994 cursor=stoptimeQuery.execute()
996 stoptime=cursor.currentRow()[
'stoptime'].
data()
998 result.append(stoptime)
999 session.transaction().commit()
1001 session.transaction().commit()
1006 if __name__ ==
"__main__":
1007 from RecoLuminosity.LumiDB
import sessionManager
1024 session=svc.openSession(isReadOnly=
True,cpp2sqltype=[(
'unsigned int',
'NUMBER(10)'),(
'unsigned long long',
'NUMBER(20)')])
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
def uncalibratedlumiFromOldLumi
static std::string join(char **cmd)
char data[epos_bytes_allocation]