CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
queryDataSource.py
Go to the documentation of this file.
1 import array,coral
2 from RecoLuminosity.LumiDB import CommonUtil,nameDealer
3 
4 def uncalibrateLumi(runnumber,instlumi,instlumierror):
5  '''
6  input: runnumber,calibrated instlumi,calibrated instlumierror
7  output: (uncalibrated instlumi, uncalbrated instlumierror)
8  '''
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]:#900Gev pp runs
14  return (float(instlumi)/normpp900gev,float(instlumierror)/normpp900gev)
15  if runnumber >=150431 and runnumber<=153368 :#7TeV HI runs
16  return (float(instlumi)/normhi7tev,float(instlumierror)/normhi7tev)
17  return (float(instlumi)/normpp7tev,float(instlumierror)/normpp7tev)
18 
19 def uncalibratedlumiFromOldLumi(session,runnumber):
20  '''
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
23 
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
25 
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
28  '''
29  nTotAlgo=3
30  try:
31  datadict={}
32  session.transaction().start(True)
33  lumischema=session.nominalSchema()
34  summaryQuery=lumischema.newQuery()
35  summaryQuery.addToTableList( nameDealer.lumisummaryTableName() )
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()
79  cmsbxindexblob=None
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]
89  del summaryQuery
90  #print datadict
91  for algoname in ['OCC1','OCC2','ET']:
92  detailQuery=lumischema.newQuery()
93  detailQuery.addToTableList( nameDealer.lumisummaryTableName(),'s' )
94  detailQuery.addToTableList( nameDealer.lumidetailTableName(),'d' )
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])
119  del detailQuery
120  session.transaction().commit()
121  return datadict
122  except :
123  raise
124 def hltFromOldLumi(session,runnumber):
125  '''
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]}
130  '''
131  try:
132  databuffer={}
133  session.transaction().start(True)
134  lumischema=session.nominalSchema()
135  npath=0
136  qHandle=lumischema.newQuery()
137  qHandle.addToTableList( nameDealer.hltTableName() )
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()
147  while next(cursor):
148  npath=cursor.currentRow()['npath'].data()
149  del qHandle
150  #print 'npath ',npath
151 
152  qHandle=lumischema.newQuery()
153  qHandle.addToTableList( nameDealer.hltTableName() )
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()
173  pathnameList=[]
174  inputcountArray=array.array('I')
175  acceptcountArray=array.array('I')
176  prescaleArray=array.array('I')
177  ipath=0
178  pathnHLT_PixelTracksVdMames=''
179  while next(cursor):
180  cmslsnum=cursor.currentRow()['cmslsnum'].data()
181  pathname=cursor.currentRow()['pathname'].data()
182  ipath+=1
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)
190  if ipath==npath:
191  if cmslsnum==1:
192  pathnames=','.join(pathnameList)
193  inputcountBlob=CommonUtil.packArraytoBlob(inputcountArray)
194  acceptcountBlob=CommonUtil.packArraytoBlob(acceptcountArray)
195  prescaleBlob=CommonUtil.packArraytoBlob(prescaleArray)
196  databuffer[cmslsnum]=[inputcountBlob,acceptcountBlob,prescaleBlob]
197  pathnameList=[]
198  inputcountArray=array.array('I')
199  acceptcountArray=array.array('I')
200  prescaleArray=array.array('I')
201  ipath=0
202  del qHandle
203  session.transaction().commit()
204  #print 'pathnames ',pathnames
205  return [pathnames,databuffer]
206  except :
207  raise
208 
209 def trgFromOldLumi(session,runnumber):
210  '''
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
213  input: runnumber
214  output: [bitnames,{cmslsnum,[deadtime,bitzerocount,bitzerpoprescale,trgcountBlob,trgprescaleBlob]}]
215  '''
216  session.transaction().start(True)
217  lumischema=session.nominalSchema()
218  qHandle=lumischema.newQuery()
219  try:
220  qHandle=lumischema.newQuery()
221  qHandle.addToTableList(nameDealer.trgTableName())
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()
236  bitnums=[]
237  bitnameList=[]
238  while next(cursor):
239  bitnum=cursor.currentRow()['bitnum'].data()
240  bitname=cursor.currentRow()['bitname'].data()
241  bitnums.append(bitnum)
242  bitnameList.append(bitname)
243  del qHandle
244  bitnames=','.join(bitnameList)
245  databuffer={}
246  nbits=len(bitnums)
247  qHandle=lumischema.newQuery()
248  qHandle.addToTableList(nameDealer.trgTableName())
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')
270  while next(cursor):
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)
279  if bitnum==0:
280  databuffer[cmslsnum].append(trgcount)
281  databuffer[cmslsnum].append(prescale)
282  trgcountArray.append(trgcount)
283  prescaleArray.append(prescale)
284  if bitnum==nbits-1:
285  trgcountBlob=CommonUtil.packArraytoBlob(trgcountArray)
286  prescaleBlob=CommonUtil.packArraytoBlob(prescaleArray)
287  databuffer[cmslsnum].append(trgcountBlob)
288  databuffer[cmslsnum].append(prescaleBlob)
289  trgcountArray=array.array('I')
290  prescaleArray=array.array('I')
291  del qHandle
292  session.transaction().commit()
293  return [bitnames,databuffer]
294  except:
295  del qHandle
296  raise
297 
298 def trgFromWBM(session,runnumber):
299  '''
300  '''
301  pass
302 
303 def trgFromNewGT(session,runnumber):
304  '''
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;
312  '''
313  pass
314 
315 def trgFromOldGT(session,runnumber):
316  '''
317  input: runnumber
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
328 
329  '''
330  result=[]
331  deadtimeresult={}#{cmslsnum:deadtime}
332  NAlgoBit=128 #0-127
333  NTechBit=64 #0-63
334  algocount={}#{cmslsnum:[algocounts]}
335  techcount={}#{cmslsnum:[techcounts]}
336  bitnames=[]
337  bitzerocountDict={}
338  bitzeroprescaleDict={}
339  perlsdict={}#{cmslsnum:[deadtime,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]}
340  prescaleDict={} #{prescale_index:[[algo_prescale_factors][tech_prescale_factors]]}
341  prescaleResult={}#{lsnumber:[algo_prescale_factors,tech_prescale_factors]}
342  try:
343  session.transaction().start(True)
344  gtmonschema=session.schema('CMS_GT_MON')
345  #
346  # select counts,lsnr from cms_gt_mon.gt_mon_trig_dead_view where runnr=:runnumber and deadcounter=:countername order by lsnr
347  #
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()
364  s=0
365  while next(deadcursor):
366  row=deadcursor.currentRow()
367  s+=1
368  lsnr=row['lsnr'].data()
369  while s!=lsnr:
370  print 'DEADTIME alert: found hole in LS range'
371  print ' fill deadtimebeamactive 0 for LS '+str(s)
372  deadtimeresult[s]=0
373  s+=1
374  count=row['counts'].data()
375  deadtimeresult[s]=count
376  if s==0:
377  deadcursor.close()
378  del deadviewQuery
379  session.transaction().commit()
380  raise 'requested run '+str(runnumber )+' does not exist for deadcounts'
381  del deadviewQuery
382  #print 'deadtimeresult ',deadtimeresult
383  mybitcount_algo=[]
384  algoviewQuery=gtmonschema.newQuery()
385  #
386  # select counts,lsnr,algobit from cms_gt_mon.gt_mon_trig_algo_view where runnr=:runnumber order by lsnr,algobit
387  #
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)
403 
404  algocursor=algoviewQuery.execute()
405  s=0
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)
412  if algobit==0:
413  bitzerocountDict[lsnr]=counts
414  if algobit==NAlgoBit-1:
415  s+=1
416  while s!=lsnr:
417  print 'ALGO COUNT alert: found hole in LS range'
418  print ' fill all algocount 0 for LS '+str(s)
419  tmpzero=[0]*NAlgoBit
420  algocount[s]=tmpzero
421  s+=1
422  algocount[s]=mybitcount_algo
423  mybitcount_algo=[]
424  if s==0:
425  algocursor.close()
426  del algoviewQuery
427  session.transaction().commit()
428  raise 'requested run '+str(runnumber+' does not exist for algocounts ')
429  del algoviewQuery
430 
431  mybitcount_tech=[]
432  techviewQuery=gtmonschema.newQuery()
433  techviewQuery.addToTableList('GT_MON_TRIG_TECH_VIEW')
434  #
435  # select counts,lsnr,techbit from cms_gt_mon.gt_mon_trig_tech_view where runnr=:runnumber order by lsnr,techbit
436  #
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)
451 
452  techcursor=techviewQuery.execute()
453  s=0
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:
461  s+=1
462  while s!=lsnr:
463  print 'TECH COUNT alert: found hole in LS range'
464  print ' fill all techcount 0 for LS '+str(s)
465  tmpzero=[0]*NTechBit
466  techcount[s]=tmpzero
467  s+=1
468  techcount[s]=mybitcount_tech
469  mybitcount_tech=[]
470  if s==0:
471  techcursor.close()
472  del techviewQuery
473  session.transaction().commit()
474  raise 'requested run '+str(runnumber+' does not exist for techcounts ')
475  del techviewQuery
476 
477  gtschema=session.schema('CMS_GT')
478  triggernamemap={}
479  namealiasQuery=gtschema.newQuery()
480  #
481  # select algo_index,alias from cms_gt.gt_run_algo_view where runnumber=:runnumber
482  #
483  triggernamemap={}
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
501  del namealiasQuery
502 
503  #techtriggernamemap={}
504  #technamealiasQuery=gtschema.newQuery()
505  #
506  # select techtrig_index,name from cms_gt.gt_run_tech_view where runnumber=:runnumber
507  #
508  # this queryis unnecessary
509  #technamealiasQuery.addToTableList('GT_RUN_TECH_VIEW')
510  #technameOutput=coral.AttributeList()
511  #technameOutput.extend('techtrig_index','unsigned int')
512  #technameOutput.extend('name','string')
513  #technamealiasQuery.addToOutputList('techtrig_index')
514  #technamealiasQuery.addToOutputList('name')
515  #technameCondition=coral.AttributeList()
516  #technameCondition.extend('runnumber','unsigned int')
517  #technameCondition['runnumber'].setData(int(runnumber))
518  #technamealiasQuery.setCondition('RUNNUMBER=:runnumber',technameCondition)
519  #technamealiasQuery.defineOutput(technameOutput)
520  #technamecursor=technamealiasQuery.execute()
521  #while technamecursor.next():
522  #row=technamecursor.currentRow()
523  #techtrig_index=row['techtrig_index'].data()
524  #tech_name=row['name'].data()
525  #techtriggernamemap[techtrig_index]=tech_name
526  #del technamealiasQuery
527  #
528  # reprocess Algo name result filling unallocated trigger bit with string "False"
529  #
530  for algoidx in range(NAlgoBit):
531  if algoidx in triggernamemap.keys():
532  bitnames.append(triggernamemap[algoidx])
533  else:
534  bitnames.append('False')
535  #
536  # reprocess Tech name
537  #
538  for techidx in range(NTechBit):
539  bitnames.append(str(techidx))
540  bitnameclob=','.join(bitnames)
541  #
542  # select distinct(prescale_index) from cms_gt_mon.lumi_sections where run_number=:runnumber;
543  #
544  prescaleidx=[]
545  presidxQuery=gtmonschema.newQuery()
546  presidxQuery.addToTableList('LUMI_SECTIONS')
547 
548  presidxBindVariable=coral.AttributeList()
549  presidxBindVariable.extend('runnumber','int')
550  presidxBindVariable['runnumber'].setData(int(runnumber))
551 
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)
561  #print prescaleidx
562  del presidxQuery
563  #
564  # select algo.prescale_factor_algo_000,,algo.prescale_factor_algo_001..._127 from gt_run_presc_algo_view where run_number=:runnumber and prescale_index=:prescale_index;
565  #
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()
585  algoprescale=[]
586  for bitidx in range(NAlgoBit):
587  algopresc=algoprescBase+str(bitidx).zfill(3)
588  algoprescale.append(row[algopresc].data())
589  prescaleDict[prescaleindex]=algoprescale
590  del algoprescQuery
591 
592  #
593  # select prescale_factor_tt_000,prescale_factor_tt_001..._127 from gt_run_presc_tech_view where run_number=:runnumber and prescale_index=:prescale_index;
594  #
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()
614  techprescale=[]
615  for bitidx in range(NTechBit):
616  techpresc=techprescBase+str(bitidx).zfill(3)
617  techprescale.append(row[techpresc].data())
618  prescaleDict[prescaleindex]+=techprescale
619  del techprescQuery
620  #print prescaleDict
621  #
622  #select lumi_section,prescale_index from cms_gt_mon.lumi_sections where run_number=:runnumber
623  #
624  lumiprescQuery=gtmonschema.newQuery()
625  lumiprescQuery.addToTableList('LUMI_SECTIONS')
626 
627  lumiprescBindVariable=coral.AttributeList()
628  lumiprescBindVariable.extend('runnumber','int')
629  lumiprescBindVariable['runnumber'].setData(int(runnumber))
630 
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]
646  #print prescaleResult
647  del lumiprescQuery
648  #return result
649  session.transaction().commit()
650  #
651  #assemble result
652  #
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)
661  trgcountBlob=CommonUtil.packArraytoBlob(trgcounts)
662  trgprescale=array.array('I')
663  for aprescale in prescaleResult[cmslsnum]:
664  trgprescale.append(aprescale)
665  trgprescaleBlob=CommonUtil.packArraytoBlob(trgprescale)
666  perlsdict[cmslsnum]=[deadcount,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]
667  result=[bitnameclob,perlsdict]
668  return result
669  except:
670  session.transaction().rollback()
671  del session
672  raise
673 
674 def hltFromRuninfoV2(session,runnumber):
675  '''
676  input:
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
680  '''
681  npaths=0
682  pathnames=[]
683  hltdict={}
684  try:
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)
698  q1.defineOutput(nls)
699  c=q1.execute()
700  while next(c):
701  npath=c.currentRow()['npath'].data()
702  del q1
703  if npath==0:
704  print 'request run is empty, do nothing'
705 
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)
721  cursor=q.execute()
722  lastLumiSection=1
723  currentLumiSection=0
724  allpaths=[]
725  ipath=0
726  hltinputs=array.array('I')
727  hltaccepts=array.array('I')
728  prescales=array.array('I')
729  while next(cursor):
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()
736  ipath+=1
737  if cmsluminr==1:
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)
744  if ipath==npath:
745  #pack
746  #print 'packing hltinputs ',hltinputs
747  hltinputsBlob=CommonUtil.packArraytoBlob(hltinputs)
748  #print 'packing hltaccepts ',hltaccepts
749  hltacceptsBlob=CommonUtil.packArraytoBlob(hltaccepts)
750  #print 'packing prescales ',prescales
751  prescalesBlob=CommonUtil.packArraytoBlob(prescales)
752  hltdict[cmsluminr].extend([hltinputsBlob,hltacceptsBlob,hltacceptsBlob])
753  ipath=0
754  hltinputs=array.array('I')
755  hltaccepts=array.array('I')
756  prescales=array.array('I')
757  pathnameclob=','.join(pathnames)
758  del q
759  session.transaction().commit()
760  return [pathnameclob,hltdict]
761  except:
762  raise
763 
764 def hltFromRuninfoV3(session,runnumber):
765  '''
766  input:
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;
771  loop :
772  select pathname from cms_hlt.paths where pathid=:pathid
773  '''
774  pass
775 
776 def hltconf(session,hltkey):
777  '''
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
781  '''
782  try:
783  session.transaction().start(True)
784  hltconfschema=session.nominalSchema()
785  hltconfQuery=hltconfschema.newQuery()
786 
787  hltconfQuery.addToOutputList('PATHS.NAME','hltpath')
788  hltconfQuery.addToOutputList('STRINGPARAMVALUES.VALUE','l1expression')
789 
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')
799 
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)
808  hlt2l1map={}
809  cursor=hltconfQuery.execute()
810  while next(cursor):
811  hltpath=cursor.currentRow()['hltpath'].data()
812  print hltpath
813  l1expression=cursor.currentRow()['l1expression'].data()
814  hlt2l1map[hltpath]=l1expression
815  del hltconfQuery
816  session.transaction().commit()
817  return hlt2l1map
818  except:
819  raise
820 
821 def runsummary(session,schemaname,runnumber,complementalOnly=False):
822  '''
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
826 
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';
832  input:
833  output:[l1key,amodetag,egev,sequence,hltkey,fillnum,starttime,stoptime]
834  if complementalOnly:
835  [l1key,amodetag,egev]
836  '''
837  runsessionparameterTable=''
838  result=[]
839  l1key=''
840  amodetag=''
841  egev=''
842  hltkey=''
843  fillnum=''
844  sequence=''
845  starttime=''
846  stoptime=''
847  try:
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()
863  while next(cursor):
864  l1key=cursor.currentRow()['l1key'].data()
865  del l1keyQuery
866  result.append(l1key)
867 
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()
882  while next(cursor):
883  amodetag=cursor.currentRow()['amodetag'].data()
884  del amodetagQuery
885  result.append(amodetag)
886 
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()
902  while next(cursor):
903  egev=cursor.currentRow()['egev'].data()
904  del egevQuery
905  result.append(egev)
906 
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()
921  while next(cursor):
922  sequence=cursor.currentRow()['seq'].data()
923  del seqQuery
924  result.append(sequence)
925 
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)
937  #hltkeyQuery.limitReturnedRows(1)
938  hltkeyQuery.defineOutput(hltkeyOutput)
939  cursor=hltkeyQuery.execute()
940  while next(cursor):
941  hltkey=cursor.currentRow()['hltkey'].data()
942  del hltkeyQuery
943  result.append(hltkey)
944 
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()
959  while next(cursor):
960  fillnum=cursor.currentRow()['fillnum'].data()
961  del fillnumQuery
962  result.append(fillnum)
963 
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()
977  while next(cursor):
978  starttime=cursor.currentRow()['starttime'].data()
979  del starttimeQuery
980  result.append(starttime)
981 
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()
995  while next(cursor):
996  stoptime=cursor.currentRow()['stoptime'].data()
997  del stoptimeQuery
998  result.append(stoptime)
999  session.transaction().commit()
1000  else:
1001  session.transaction().commit()
1002  return result
1003  except:
1004  raise
1005 
1006 if __name__ == "__main__":
1007  from RecoLuminosity.LumiDB import sessionManager
1008  #svc=sessionManager.sessionManager('oracle://cms_orcoff_prep/cms_lumi_dev_offline',authpath='/afs/cern.ch/user/x/xiezhen',debugON=False)
1009  #session=svc.openSession(isReadOnly=True,cpp2sqltype=[('unsigned int','NUMBER(10)'),('unsigned long long','NUMBER(20)')])
1010  #lsresult=trgFromOldLumi(session,135735)
1011  #print lsresult
1012  #lshltresult=hltFromOldLumi(session,135735)
1013  #print lshltresult
1014  #svc=sessionManager.sessionManager('oracle://cms_orcoff_prod/cms_runinfo',authpath='/afs/cern.ch/user/x/xiezhen',debugON=False)
1015  #session=svc.openSession(isReadOnly=True,cpp2sqltype=[('unsigned int','NUMBER(10)'),('unsigned long long','NUMBER(20)')])
1016  #runsummary(session,'CMS_RUNINFO',135735,complementalOnly=True)
1017  #svc=sessionManager.sessionManager('oracle://cms_orcoff_prod/cms_gt',authpath='/afs/cern.ch/user/x/xiezhen',debugON=False)
1018  #session=svc.openSession(isReadOnly=True,cpp2sqltype=[('unsigned int','NUMBER(10)'),('unsigned long long','NUMBER(20)')])
1019  #print trgFromOldGT(session,135735)
1020  #svc=sessionManager.sessionManager('oracle://cms_orcoff_prod/cms_runinfo',authpath='/afs/cern.ch/user/x/xiezhen',debugON=False)
1021  #session=svc.openSession(isReadOnly=True,cpp2sqltype=[('unsigned int','NUMBER(10)'),('unsigned long long','NUMBER(20)')])
1022  #print hltFromRuninfoV2(session,135735)
1023  svc=sessionManager.sessionManager('oracle://cms_orcoff_prod/cms_lumi_prod',authpath='/afs/cern.ch/user/x/xiezhen',debugON=False)
1024  session=svc.openSession(isReadOnly=True,cpp2sqltype=[('unsigned int','NUMBER(10)'),('unsigned long long','NUMBER(20)')])
1025  print uncalibratedlumiFromOldLumi(session,135735)
1026  del session
Definition: start.py:1
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
def lumisummaryTableName
Definition: nameDealer.py:25
def hltTableName
Definition: nameDealer.py:55
def lumidetailTableName
Definition: nameDealer.py:34
def packArraytoBlob
Definition: CommonUtil.py:220
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def trgTableName
Definition: nameDealer.py:52