def lumiQueryAPI::allfills | ( | queryHandle, | |
filtercrazy = True |
|||
) |
select distinct fillnum from cmsrunsummary there are crazy fill numbers. we assume they are not valid runs
Definition at line 1020 of file lumiQueryAPI.py.
01021 : 01022 '''select distinct fillnum from cmsrunsummary 01023 there are crazy fill numbers. we assume they are not valid runs 01024 ''' 01025 result=[] 01026 queryHandle.addToTableList(nameDealer.cmsrunsummaryTableName()) 01027 queryHandle.addToOutputList('distinct FILLNUM','fillnum') 01028 01029 if filtercrazy: 01030 queryCondition='FILLNUM>:zero and FILLNUM<:crazybig' 01031 queryBind=coral.AttributeList() 01032 queryBind.extend('zero','unsigned int') 01033 queryBind.extend('crazybig','unsigned int') 01034 queryBind['zero'].setData(int(0)) 01035 queryBind['crazybig'].setData(int(29701)) 01036 queryHandle.setCondition(queryCondition,queryBind) 01037 queryResult=coral.AttributeList() 01038 queryResult.extend('fillnum','unsigned int') 01039 queryHandle.defineOutput(queryResult) 01040 cursor=queryHandle.execute() 01041 while cursor.next(): 01042 result.append(cursor.currentRow()['fillnum'].data()) 01043 result.sort() return result
def lumiQueryAPI::allruns | ( | schemaHandle, | |
requireRunsummary = True , |
|||
requireLumisummary = False , |
|||
requireTrg = False , |
|||
requireHlt = False |
|||
) |
==============real api=====###
find all runs in the DB. By default requires cmsrunsummary table contain the run. The condition can be loosed in situation where db loading failed on certain data portions.
Definition at line 902 of file lumiQueryAPI.py.
00903 : 00904 ''' 00905 find all runs in the DB. By default requires cmsrunsummary table contain the run. The condition can be loosed in situation where db loading failed on certain data portions. 00906 ''' 00907 if not requireRunsummary and not requireLumiummary and not requireTrg and not requireHlt: 00908 print 'must require at least one table' 00909 raise 00910 runresult=[] 00911 runlist=[] 00912 numdups=0 00913 if requireRunsummary: 00914 numdups=numdups+1 00915 queryHandle=schemaHandle.newQuery() 00916 queryHandle.addToTableList(nameDealer.cmsrunsummaryTableName()) 00917 queryHandle.addToOutputList("RUNNUM","run") 00918 #queryBind=coral.AttributeList() 00919 result=coral.AttributeList() 00920 result.extend("run","unsigned int") 00921 queryHandle.defineOutput(result) 00922 cursor=queryHandle.execute() 00923 while cursor.next(): 00924 r=cursor.currentRow()['run'].data() 00925 runlist.append(r) 00926 del queryHandle 00927 if requireLumisummary: 00928 numdups=numdups+1 00929 queryHandle=schemaHandle.newQuery() 00930 queryHandle.addToTableList(nameDealer.lumisummaryTableName()) 00931 queryHandle.addToOutputList("distinct RUNNUM","run") 00932 #queryBind=coral.AttributeList() 00933 result=coral.AttributeList() 00934 result.extend("run","unsigned int") 00935 queryHandle.defineOutput(result) 00936 cursor=queryHandle.execute() 00937 while cursor.next(): 00938 r=cursor.currentRow()['run'].data() 00939 runlist.append(r) 00940 del queryHandle 00941 if requireTrg: 00942 numdups=numdups+1 00943 queryHandle=schemaHandle.newQuery() 00944 queryHandle.addToTableList(nameDealer.trgTableName()) 00945 queryHandle.addToOutputList("distinct RUNNUM","run") 00946 #queryBind=coral.AttributeList() 00947 result=coral.AttributeList() 00948 result.extend("run","unsigned int") 00949 queryHandle.defineOutput(result) 00950 cursor=queryHandle.execute() 00951 while cursor.next(): 00952 r=cursor.currentRow()['run'].data() 00953 runlist.append(r) 00954 del queryHandle 00955 if requireHlt: 00956 numdups=numdups+1 00957 queryHandle=schemaHandle.newQuery() 00958 queryHandle.addToTableList(nameDealer.hltTableName()) 00959 queryHandle.addToOutputList("distinct RUNNUM","run") 00960 #queryBind=coral.AttributeList() 00961 result=coral.AttributeList() 00962 result.extend("run","unsigned int") 00963 queryHandle.defineOutput(result) 00964 cursor=queryHandle.execute() 00965 while cursor.next(): 00966 r=cursor.currentRow()['run'].data() 00967 runlist.append(r) 00968 del queryHandle 00969 dupresult=CommonUtil.count_dups(runlist) 00970 for dup in dupresult: 00971 if dup[1]==numdups: 00972 runresult.append(dup[0]) 00973 runresult.sort() 00974 return runresult
def lumiQueryAPI::beamIntensityForRun | ( | query, | |
parameters, | |||
runnum | |||
) |
select CMSBXINDEXBLOB,BEAMINTENSITYBLOB_1,BEAMINTENSITYBLOB_2 from LUMISUMMARY where runnum=146315 and LUMIVERSION='0001' output : result {startorbit: [(bxidx,beam1intensity,beam2intensity)]}
Definition at line 1437 of file lumiQueryAPI.py.
01438 : 01439 ''' 01440 select CMSBXINDEXBLOB,BEAMINTENSITYBLOB_1,BEAMINTENSITYBLOB_2 from LUMISUMMARY where runnum=146315 and LUMIVERSION='0001' 01441 01442 output : result {startorbit: [(bxidx,beam1intensity,beam2intensity)]} 01443 ''' 01444 result={} #{startorbit:[(bxidx,occlumi,occlumierr,beam1intensity,beam2intensity)]} 01445 01446 lumisummaryOutput=coral.AttributeList() 01447 lumisummaryOutput.extend('cmslsnum','unsigned int') 01448 lumisummaryOutput.extend('startorbit','unsigned int') 01449 lumisummaryOutput.extend('bxindexblob','blob'); 01450 lumisummaryOutput.extend('beamintensityblob1','blob'); 01451 lumisummaryOutput.extend('beamintensityblob2','blob'); 01452 condition=coral.AttributeList() 01453 condition.extend('runnum','unsigned int') 01454 condition.extend('lumiversion','string') 01455 condition['runnum'].setData(int(runnum)) 01456 condition['lumiversion'].setData(parameters.lumiversion) 01457 01458 query.addToTableList(parameters.lumisummaryname) 01459 query.addToOutputList('CMSLSNUM','cmslsnum') 01460 query.addToOutputList('STARTORBIT','startorbit') 01461 query.addToOutputList('CMSBXINDEXBLOB','bxindexblob') 01462 query.addToOutputList('BEAMINTENSITYBLOB_1','beamintensityblob1') 01463 query.addToOutputList('BEAMINTENSITYBLOB_2','beamintensityblob2') 01464 query.setCondition('RUNNUM=:runnum AND LUMIVERSION=:lumiversion',condition) 01465 query.defineOutput(lumisummaryOutput) 01466 cursor=query.execute() 01467 while cursor.next(): 01468 #cmslsnum=cursor.currentRow()['cmslsnum'].data() 01469 startorbit=cursor.currentRow()['startorbit'].data() 01470 if not cursor.currentRow()["bxindexblob"].isNull(): 01471 bxindexblob=cursor.currentRow()['bxindexblob'].data() 01472 beamintensityblob1=cursor.currentRow()['beamintensityblob1'].data() 01473 beamintensityblob2=cursor.currentRow()['beamintensityblob2'].data() 01474 if bxindexblob.readline() is not None and beamintensityblob1.readline() is not None and beamintensityblob2.readline() is not None: 01475 bxidx=array.array('h') 01476 bxidx.fromstring(bxindexblob.readline()) 01477 bb1=array.array('f') 01478 bb1.fromstring(beamintensityblob1.readline()) 01479 bb2=array.array('f') 01480 bb2.fromstring(beamintensityblob2.readline()) 01481 for index,bxidxvalue in enumerate(bxidx): 01482 if not result.has_key(startorbit): 01483 result[startorbit]=[] 01484 b1intensity=bb1[index] 01485 b2intensity=bb2[index] 01486 result[startorbit].append((bxidxvalue,b1intensity,b2intensity)) 01487 return result
def lumiQueryAPI::calculateEffective | ( | trgtable, | |
totalrecorded | |||
) |
input: trgtable{hltpath:[l1seed, hltprescale, l1prescale]}, totalrecorded (float) output:{hltpath, recorded}
Definition at line 430 of file lumiQueryAPI.py.
00431 : 00432 """ 00433 input: trgtable{hltpath:[l1seed, hltprescale, l1prescale]}, totalrecorded (float) 00434 output:{hltpath, recorded} 00435 """ 00436 #print 'inputtrgtable', trgtable 00437 result = {} 00438 for hltpath, data in trgtable.items(): 00439 if len (data) == 3: 00440 result[hltpath] = totalrecorded/ (data[1]*data[2]) 00441 else: 00442 result[hltpath] = 0.0 00443 return result 00444
def lumiQueryAPI::calculateTotalRecorded | ( | deadtable | ) |
input: {lsnum:[deadtime, instlumi, bit_0, norbits,prescale]} output: recordedLumi
Definition at line 395 of file lumiQueryAPI.py.
00396 : 00397 """ 00398 input: {lsnum:[deadtime, instlumi, bit_0, norbits,prescale]} 00399 output: recordedLumi 00400 """ 00401 recordedLumi = 0.0 00402 for myls, d in deadtable.items(): 00403 instLumi = d[1] 00404 #deadfrac = float (d[0])/float (d[2]*3564) 00405 #print myls, float (d[2]) 00406 if float (d[2]) == 0.0: 00407 deadfrac = 1.0 00408 else: 00409 deadfrac = float (d[0])/(float (d[2])*float (d[-1])) 00410 lstime = lslengthsec (d[3], 3564) 00411 recordedLumi += instLumi* (1.0-deadfrac)*lstime 00412 return recordedLumi 00413
def lumiQueryAPI::calibratedDetailForRunLimitresult | ( | query, | |
parameters, | |||
runnum, | |||
algoname = 'OCC1' |
|||
) |
select s.cmslsnum,d.bxlumivalue,d.bxlumierror,d.bxlumiquality,d.algoname from LUMIDETAIL d,LUMISUMMARY s where s.runnum=133885 and d.algoname='OCC1' and s.lumisummary_id=d.lumisummary_id order by s.startorbit,s.cmslsnum result={(startorbit,cmslsnum):[(lumivalue,lumierr),]}
Definition at line 1488 of file lumiQueryAPI.py.
01489 : 01490 '''select 01491 s.cmslsnum,d.bxlumivalue,d.bxlumierror,d.bxlumiquality,d.algoname from LUMIDETAIL d,LUMISUMMARY s where s.runnum=133885 and d.algoname='OCC1' and s.lumisummary_id=d.lumisummary_id order by s.startorbit,s.cmslsnum 01492 result={(startorbit,cmslsnum):[(lumivalue,lumierr),]} 01493 ''' 01494 result={} 01495 detailOutput=coral.AttributeList() 01496 detailOutput.extend('cmslsnum','unsigned int') 01497 detailOutput.extend('startorbit','unsigned int') 01498 detailOutput.extend('bxlumivalue','blob') 01499 detailOutput.extend('bxlumierror','blob') 01500 detailCondition=coral.AttributeList() 01501 detailCondition.extend('runnum','unsigned int') 01502 detailCondition.extend('algoname','string') 01503 detailCondition['runnum'].setData(runnum) 01504 detailCondition['algoname'].setData(algoname) 01505 01506 query.addToTableList(parameters.lumisummaryname,'s') 01507 query.addToTableList(parameters.lumidetailname,'d') 01508 query.addToOutputList('s.CMSLSNUM','cmslsnum') 01509 query.addToOutputList('s.STARTORBIT','startorbit') 01510 query.addToOutputList('d.BXLUMIVALUE','bxlumivalue') 01511 query.addToOutputList('d.BXLUMIERROR','bxlumierror') 01512 query.addToOutputList('d.BXLUMIQUALITY','bxlumiquality') 01513 query.setCondition('s.RUNNUM=:runnum and d.ALGONAME=:algoname and s.LUMISUMMARY_ID=d.LUMISUMMARY_ID',detailCondition) 01514 query.defineOutput(detailOutput) 01515 cursor=query.execute() 01516 while cursor.next(): 01517 cmslsnum=cursor.currentRow()['cmslsnum'].data() 01518 bxlumivalue=cursor.currentRow()['bxlumivalue'].data() 01519 bxlumierror=cursor.currentRow()['bxlumierror'].data() 01520 startorbit=cursor.currentRow()['startorbit'].data() 01521 01522 bxlumivalueArray=array.array('f') 01523 bxlumivalueArray.fromstring(bxlumivalue.readline()) 01524 bxlumierrorArray=array.array('f') 01525 bxlumierrorArray.fromstring(bxlumierror.readline()) 01526 xingLum=[] 01527 #apply selection criteria 01528 maxlumi=max(bxlumivalueArray)*parameters.normFactor 01529 for index,lum in enumerate(bxlumivalueArray): 01530 lum *= parameters.normFactor 01531 lumierror = bxlumierrorArray[index]*parameters.normFactor 01532 if lum<max(parameters.xingMinLum,maxlumi*0.2): 01533 continue 01534 xingLum.append( (index,lum,lumierror) ) 01535 if len(xingLum)!=0: 01536 result[(startorbit,cmslsnum)]=xingLum 01537 return result
def lumiQueryAPI::deliveredLumiForRange | ( | dbsession, | |
parameters, | |||
inputRange | |||
) |
Takes either single run as a string or dictionary of run ranges
Definition at line 82 of file lumiQueryAPI.py.
00083 : 00084 '''Takes either single run as a string or dictionary of run ranges''' 00085 lumidata = [] 00086 # is this a single string? 00087 if isinstance (inputRange, str): 00088 lumidata.append( deliveredLumiForRun (dbsession, parameters, inputRange) ) 00089 else: 00090 # if not, it's one of these dictionary things 00091 for run in sorted( inputRange.runs() ): 00092 if parameters.verbose: 00093 print "run", run 00094 lumidata.append( deliveredLumiForRun (dbsession, parameters, run) ) 00095 #print lumidata 00096 return lumidata 00097
def lumiQueryAPI::deliveredLumiForRun | ( | dbsession, | |
parameters, | |||
runnum | |||
) |
select sum (INSTLUMI), count (INSTLUMI) from lumisummary where runnum = 124025 and lumiversion = '0001'; select INSTLUMI,NUMORBIT from lumisummary where runnum = 124025 and lumiversion = '0001' query result unit E27cm^-2 (= 1 / mb)
Definition at line 143 of file lumiQueryAPI.py.
00143 : 00144 """ 00145 select sum (INSTLUMI), count (INSTLUMI) from lumisummary where runnum = 124025 and lumiversion = '0001'; 00146 select INSTLUMI,NUMORBIT from lumisummary where runnum = 124025 and lumiversion = '0001' 00147 query result unit E27cm^-2 (= 1 / mb)""" 00148 #if parameters.verbose: 00149 # print 'deliveredLumiForRun : norm : ', parameters.norm, ' : run : ', runnum 00150 #output ['run', 'totalls', 'delivered', 'beammode'] 00151 delivered = 0.0 00152 totalls = 0 00153 try: 00154 conditionstring="RUNNUM = :runnum AND LUMIVERSION = :lumiversion" 00155 dbsession.transaction().start (True) 00156 schema = dbsession.nominalSchema() 00157 query = schema.tableHandle (nameDealer.lumisummaryTableName()).newQuery() 00158 #query.addToOutputList ("sum (INSTLUMI)", "totallumi") 00159 #query.addToOutputList ("count (INSTLUMI)", "totalls") 00160 query.addToOutputList("INSTLUMI",'instlumi') 00161 query.addToOutputList ("NUMORBIT", "norbits") 00162 queryBind = coral.AttributeList() 00163 queryBind.extend ("runnum", "unsigned int") 00164 queryBind.extend ("lumiversion", "string") 00165 queryBind["runnum"].setData (int (runnum)) 00166 queryBind["lumiversion"].setData (parameters.lumiversion) 00167 #print parameters.beammode 00168 if len(parameters.beammode)!=0: 00169 conditionstring=conditionstring+' and BEAMSTATUS=:beamstatus' 00170 queryBind.extend('beamstatus','string') 00171 queryBind['beamstatus'].setData(parameters.beammode) 00172 result = coral.AttributeList() 00173 result.extend ("instlumi", "float") 00174 result.extend ("norbits", "unsigned int") 00175 query.defineOutput (result) 00176 query.setCondition (conditionstring,queryBind) 00177 #query.limitReturnedRows (1) 00178 #query.groupBy ('NUMORBIT') 00179 cursor = query.execute() 00180 while cursor.next(): 00181 instlumi = cursor.currentRow()['instlumi'].data() 00182 norbits = cursor.currentRow()['norbits'].data() 00183 00184 if instlumi is not None and norbits is not None: 00185 lstime = lslengthsec(norbits, parameters.NBX) 00186 delivered=delivered+instlumi*parameters.norm*lstime 00187 totalls+=1 00188 del query 00189 dbsession.transaction().commit() 00190 lumidata = [] 00191 if delivered == 0.0: 00192 lumidata = [str (runnum), 'N/A', 'N/A', 'N/A'] 00193 else: 00194 lumidata = [str (runnum), str (totalls), '%.3f'%delivered, parameters.beammode] 00195 return lumidata 00196 except Exception, e: 00197 print str (e) 00198 dbsession.transaction().rollback() 00199 del dbsession 00200
def lumiQueryAPI::dumpData | ( | lumidata, | |
filename | |||
) |
input params: lumidata [{'fieldname':value}] filename csvname
Definition at line 386 of file lumiQueryAPI.py.
Referenced by HcalDbXml::dumpObject(), and CastorDbXml::dumpObject().
def lumiQueryAPI::dumpOverview | ( | delivered, | |
recorded, | |||
hltpath = '' |
|||
) |
Definition at line 736 of file lumiQueryAPI.py.
00737 : 00738 #toprowlabels = ['run', 'delivered', 'recorded', 'hltpath'] 00739 datatable = [] 00740 for runidx, deliveredrowdata in enumerate (delivered): 00741 rowdata = [] 00742 rowdata += [deliveredrowdata[0], deliveredrowdata[2]] 00743 if deliveredrowdata[1] == 'N/A': #run does not exist 00744 rowdata += ['N/A', 'N/A'] 00745 datatable.append (rowdata) 00746 continue 00747 recordedLumi = calculateTotalRecorded (recorded[runidx][2]) 00748 lumiinPaths = calculateEffective (recorded[runidx][1], recordedLumi) 00749 if hltpath != '' and hltpath != 'all': 00750 if lumiinPaths.has_key (hltpath): 00751 rowdata += [recordedLumi, lumiinPaths[hltpath]] 00752 else: 00753 rowdata += [recordedLumi, 'N/A'] 00754 else: 00755 rowdata += [recordedLumi, recordedLumi] 00756 datatable.append (rowdata) 00757 return datatable 00758
def lumiQueryAPI::dumpPerLSLumi | ( | lumidata | ) |
Definition at line 499 of file lumiQueryAPI.py.
00500 : 00501 datatodump = [] 00502 for perrundata in lumidata: 00503 runnumber = perrundata[0] 00504 deadtable = perrundata[2] 00505 lumiresult = lsBylsLumi (deadtable) 00506 for lsnum, dataperls in lumiresult.items(): 00507 rowdata = [] 00508 if len (dataperls) == 0: 00509 rowdata += [str (runnumber), str (lsnum), 'N/A', 'N/A'] 00510 else: 00511 rowdata += [str (runnumber), str (lsnum), dataperls[0], dataperls[1]] 00512 if len (dataperls) > 2: 00513 rowdata.extend ( flatten (dataperls[2:]) ) 00514 datatodump.append (rowdata) 00515 return datatodump 00516
def lumiQueryAPI::dumpRecordedLumi | ( | lumidata, | |
hltpath = '' |
|||
) |
Definition at line 626 of file lumiQueryAPI.py.
00627 : 00628 #labels = ['Run', 'HLT path', 'Recorded'] 00629 datatodump = [] 00630 for dataperRun in lumidata: 00631 runnum = dataperRun[0] 00632 if len (dataperRun[1]) == 0: 00633 rowdata = [] 00634 rowdata += [str (runnum)]+2*['N/A'] 00635 datatodump.append (rowdata) 00636 continue 00637 perlsdata = dataperRun[2] 00638 recordedLumi = 0.0 00639 #norbits = perlsdata.values()[0][3] 00640 recordedLumi = calculateTotalRecorded (perlsdata) 00641 trgdict = dataperRun[1] 00642 effective = calculateEffective (trgdict, recordedLumi) 00643 if trgdict.has_key (hltpath) and effective.has_key (hltpath): 00644 rowdata = [] 00645 l1bit = trgdict[hltpath][0] 00646 if len (trgdict[hltpath]) != 3: 00647 rowdata += [str (runnum), hltpath, 'N/A'] 00648 else: 00649 hltprescale = trgdict[hltpath][1] 00650 l1prescale = trgdict[hltpath][2] 00651 rowdata += [str (runnum), hltpath, effective[hltpath]] 00652 datatodump.append (rowdata) 00653 continue 00654 00655 for trg, trgdata in trgdict.items(): 00656 #print trg, trgdata 00657 rowdata = [] 00658 rowdata += [str (runnum)] 00659 l1bit = trgdata[0] 00660 if len (trgdata) == 3: 00661 rowdata += [trg, effective[trg]] 00662 else: 00663 rowdata += [trg, 'N/A'] 00664 datatodump.append (rowdata) 00665 return datatodump 00666
def lumiQueryAPI::filterDeadtable | ( | inTable, | |
lslist | |||
) |
Definition at line 368 of file lumiQueryAPI.py.
00369 : 00370 result = {} 00371 if lslist is None: 00372 return inTable 00373 if len (lslist) == 0: #if request no ls, then return nothing 00374 return result 00375 for existingLS in inTable.keys(): 00376 if existingLS in lslist: 00377 result[existingLS] = inTable[existingLS] 00378 return result 00379
def lumiQueryAPI::flatten | ( | obj | ) |
Given nested lists or tuples, returns a single flattened list
Definition at line 843 of file lumiQueryAPI.py.
00844 : 00845 '''Given nested lists or tuples, returns a single flattened list''' 00846 result = [] 00847 for piece in obj: 00848 if hasattr (piece, '__iter__') and not isinstance (piece, basestring): 00849 result.extend( flatten (piece) ) 00850 else: 00851 result.append (piece) 00852 return result 00853
def lumiQueryAPI::getDeadfractions | ( | deadtable | ) |
inputtable: {lsnum:[deadtime, instlumi, bit_0, norbits,bit_0_prescale]} output: {lsnum:deadfraction}
Definition at line 445 of file lumiQueryAPI.py.
00446 : 00447 """ 00448 inputtable: {lsnum:[deadtime, instlumi, bit_0, norbits,bit_0_prescale]} 00449 output: {lsnum:deadfraction} 00450 """ 00451 result = {} 00452 for myls, d in deadtable.items(): 00453 #deadfrac = float (d[0])/ (float (d[2])*float (3564)) 00454 if float (d[2]) == 0.0: ##no beam 00455 deadfrac = -1.0 00456 else: 00457 deadfrac = float (d[0])/ (float (d[2])*float(d[-1])) 00458 result[myls] = deadfrac 00459 return result
def lumiQueryAPI::hltAllpathByrun | ( | queryHandle, | |
runnum | |||
) |
select cmslsnum,inputcount,acceptcount,prescale,pathname from hlt where runnum=:runnum this can be changed to blob query later output: {cmslsnum:{pathname:[inputcount,acceptcount,prescale]}}
Definition at line 1397 of file lumiQueryAPI.py.
01398 : 01399 ''' 01400 select cmslsnum,inputcount,acceptcount,prescale,pathname from hlt where runnum=:runnum 01401 this can be changed to blob query later 01402 output: {cmslsnum:{pathname:[inputcount,acceptcount,prescale]}} 01403 ''' 01404 result={} 01405 queryHandle.addToTableList(nameDealer.hltTableName()) 01406 queryCondition=coral.AttributeList() 01407 queryCondition.extend('runnum','unsigned int') 01408 queryCondition['runnum'].setData(int(runnum)) 01409 queryHandle.addToOutputList('CMSLSNUM','cmslsnum') 01410 queryHandle.addToOutputList('INPUTCOUNT','inputcount') 01411 queryHandle.addToOutputList('ACCEPTCOUNT','acceptcount') 01412 queryHandle.addToOutputList('PRESCALE','prescale') 01413 queryHandle.addToOutputList('PATHNAME','pathname') 01414 queryHandle.setCondition('RUNNUM=:runnum',queryCondition) 01415 queryResult=coral.AttributeList() 01416 queryResult.extend('cmslsnum','unsigned int') 01417 queryResult.extend('inputcount','unsigned int') 01418 queryResult.extend('acceptcount','unsigned int') 01419 queryResult.extend('prescale','unsigned int') 01420 queryResult.extend('pathname','string') 01421 queryHandle.defineOutput(queryResult) 01422 cursor=queryHandle.execute() 01423 while cursor.next(): 01424 cmslsnum=cursor.currentRow()['cmslsnum'].data() 01425 inputcount=cursor.currentRow()['inputcount'].data() 01426 acceptcount=cursor.currentRow()['acceptcount'].data() 01427 prescale=cursor.currentRow()['prescale'].data() 01428 pathname=cursor.currentRow()['pathname'].data() 01429 if not result.has_key(cmslsnum): 01430 dataperLS={} 01431 dataperLS[pathname]=[inputcount,acceptcount,prescale] 01432 result[cmslsnum]=dataperLS 01433 else: 01434 result[cmslsnum][pathname]=[inputcount,acceptcount,prescale] 01435 return result 01436
def lumiQueryAPI::hltBypathByrun | ( | queryHandle, | |
runnum, | |||
hltpath | |||
) |
select cmslsnum,inputcount,acceptcount,prescale from hlt where runnum=:runnum and pathname=:pathname output: {cmslsnum:[inputcount,acceptcount,prescale]}
Definition at line 1364 of file lumiQueryAPI.py.
01365 : 01366 ''' 01367 select cmslsnum,inputcount,acceptcount,prescale from hlt where runnum=:runnum and pathname=:pathname 01368 output: {cmslsnum:[inputcount,acceptcount,prescale]} 01369 ''' 01370 result={} 01371 queryHandle.addToTableList(nameDealer.hltTableName()) 01372 queryCondition=coral.AttributeList() 01373 queryCondition.extend('runnum','unsigned int') 01374 queryCondition.extend('pathname','string') 01375 queryCondition['runnum'].setData(int(runnum)) 01376 queryCondition['pathname'].setData(hltpath) 01377 queryHandle.addToOutputList('CMSLSNUM','cmslsnum') 01378 queryHandle.addToOutputList('INPUTCOUNT','inputcount') 01379 queryHandle.addToOutputList('ACCEPTCOUNT','acceptcount') 01380 queryHandle.addToOutputList('PRESCALE','prescale') 01381 queryHandle.setCondition('RUNNUM=:runnum and PATHNAME=:pathname',queryCondition) 01382 queryResult=coral.AttributeList() 01383 queryResult.extend('cmslsnum','unsigned int') 01384 queryResult.extend('inputcount','unsigned int') 01385 queryResult.extend('acceptcount','unsigned int') 01386 queryResult.extend('prescale','unsigned int') 01387 queryHandle.defineOutput(queryResult) 01388 cursor=queryHandle.execute() 01389 while cursor.next(): 01390 cmslsnum=cursor.currentRow()['cmslsnum'].data() 01391 inputcount=cursor.currentRow()['inputcount'].data() 01392 acceptcount=cursor.currentRow()['acceptcount'].data() 01393 prescale=cursor.currentRow()['prescale'].data() 01394 if not result.has_key(cmslsnum): 01395 result[cmslsnum]=[inputcount,acceptcount,prescale] 01396 return result
def lumiQueryAPI::hlttrgMappingByrun | ( | queryHandle, | |
runnum | |||
) |
select m.hltpathname,m.l1seed from cmsrunsummary r,trghltmap m where r.runnum=:runnum and m.hltkey=r.hltkey output: {hltpath:l1seed}
Definition at line 1620 of file lumiQueryAPI.py.
01621 : 01622 ''' 01623 select m.hltpathname,m.l1seed from cmsrunsummary r,trghltmap m where r.runnum=:runnum and m.hltkey=r.hltkey 01624 output: {hltpath:l1seed} 01625 ''' 01626 result={} 01627 queryHandle.addToTableList(nameDealer.cmsrunsummaryTableName(),'r') 01628 queryHandle.addToTableList(nameDealer.trghltMapTableName(),'m') 01629 queryCondition=coral.AttributeList() 01630 queryCondition.extend('runnum','unsigned int') 01631 queryCondition['runnum'].setData(int(runnum)) 01632 queryHandle.addToOutputList('m.HLTPATHNAME','hltpathname') 01633 queryHandle.addToOutputList('m.L1SEED','l1seed') 01634 queryHandle.setCondition('r.RUNNUM=:runnum and m.HLTKEY=r.HLTKEY',queryCondition) 01635 queryResult=coral.AttributeList() 01636 queryResult.extend('hltpathname','string') 01637 queryResult.extend('l1seed','string') 01638 queryHandle.defineOutput(queryResult) 01639 cursor=queryHandle.execute() 01640 while cursor.next(): 01641 hltpathname=cursor.currentRow()['hltpathname'].data() 01642 l1seed=cursor.currentRow()['l1seed'].data() 01643 if not result.has_key(hltpathname): 01644 result[hltpathname]=l1seed 01645 return result
def lumiQueryAPI::lsBylsLumi | ( | deadtable | ) |
input: {lsnum:[deadtime, instlumi, bit_0, norbits,prescale...]} output: {lsnum:[instlumi, recordedlumi...]}
Definition at line 60 of file lumiQueryAPI.py.
00061 : 00062 """ 00063 input: {lsnum:[deadtime, instlumi, bit_0, norbits,prescale...]} 00064 output: {lsnum:[instlumi, recordedlumi...]} 00065 """ 00066 result = {} 00067 for myls, deadArray in deadtable.items(): 00068 lstime = lslengthsec (deadArray[3], 3564) 00069 instlumi = deadArray[1] * lstime 00070 if float( deadArray[2] ) == 0.0: 00071 deadfrac = 1.0 00072 else: 00073 deadfrac = float (deadArray[0]) / (float (deadArray[2])*float(deadArray[4])) 00074 recordedLumi = instlumi * (1.0 - deadfrac) 00075 myLsList = [instlumi, recordedLumi] 00076 #print myls,instlumi,recordedLumi,lstime,deadfrac 00077 if len (deadArray) > 5: 00078 myLsList.extend (deadArray[5:]) 00079 result[myls] = myLsList 00080 return result 00081
def lumiQueryAPI::lslengthsec | ( | numorbit, | |
numbx | |||
) |
Definition at line 55 of file lumiQueryAPI.py.
def lumiQueryAPI::lumidetailAllalgosByrun | ( | queryHandle, | |
runnum | |||
) |
select s.cmslsnum,d.bxlumivalue,d.bxlumierror,d.bxlumiquality,d.algoname,s.startorbit from LUMIDETAIL d,LUMISUMMARY s where s.runnum=:runnumber and s.lumisummary_id=d.lumisummary_id order by s.startorbit,d.algoname output: {algoname:{cmslsnum:[bxlumivalue,bxlumierror,bxlumiquality,startorbit]}}
Definition at line 1576 of file lumiQueryAPI.py.
01577 : 01578 ''' 01579 select s.cmslsnum,d.bxlumivalue,d.bxlumierror,d.bxlumiquality,d.algoname,s.startorbit from LUMIDETAIL d,LUMISUMMARY s where s.runnum=:runnumber and s.lumisummary_id=d.lumisummary_id order by s.startorbit,d.algoname 01580 output: {algoname:{cmslsnum:[bxlumivalue,bxlumierror,bxlumiquality,startorbit]}} 01581 ''' 01582 result={} 01583 queryHandle.addToTableList(nameDealer.lumidetailTableName(),'d') 01584 queryHandle.addToTableList(nameDealer.lumisummaryTableName(),'s') 01585 queryCondition=coral.AttributeList() 01586 queryCondition.extend('runnum','unsigned int') 01587 queryCondition['runnum'].setData(int(runnum)) 01588 queryHandle.addToOutputList('s.CMSLSNUM','cmslsnum') 01589 queryHandle.addToOutputList('d.BXLUMIVALUE','bxlumivalue') 01590 queryHandle.addToOutputList('d.BXLUMIERROR','bxlumierror') 01591 queryHandle.addToOutputList('d.BXLUMIQUALITY','bxlumiquality') 01592 queryHandle.addToOutputList('d.ALGONAME','algoname') 01593 queryHandle.addToOutputList('s.STARTORBIT','startorbit') 01594 queryHandle.setCondition('s.RUNNUM=:runnum and s.LUMISUMMARY_ID=d.LUMISUMMARY_ID',queryCondition) 01595 queryResult=coral.AttributeList() 01596 queryResult.extend('cmslsnum','unsigned int') 01597 queryResult.extend('bxlumivalue','blob') 01598 queryResult.extend('bxlumierror','blob') 01599 queryResult.extend('bxlumiquality','blob') 01600 queryResult.extend('algoname','string') 01601 queryResult.extend('startorbit','unsigned int') 01602 queryHandle.addToOrderList('startorbit') 01603 queryHandle.addToOrderList('algoname') 01604 queryHandle.defineOutput(queryResult) 01605 cursor=queryHandle.execute() 01606 while cursor.next(): 01607 cmslsnum=cursor.currentRow()['cmslsnum'].data() 01608 bxlumivalue=cursor.currentRow()['bxlumivalue'].data() 01609 bxlumierror=cursor.currentRow()['bxlumierror'].data() 01610 bxlumiquality=cursor.currentRow()['bxlumiquality'].data() 01611 algoname=cursor.currentRow()['algoname'].data() 01612 startorbit=cursor.currentRow()['startorbit'].data() 01613 if not result.has_key(algoname): 01614 dataPerAlgo={} 01615 dataPerAlgo[cmslsnum]=[bxlumivalue,bxlumierror,bxlumiquality,startorbit] 01616 result[algoname]=dataPerAlgo 01617 else: 01618 result[algoname][cmslsnum]=[bxlumivalue,bxlumierror,bxlumiquality,startorbit] 01619 return result
def lumiQueryAPI::lumidetailByrunByAlgo | ( | queryHandle, | |
runnum, | |||
algoname = 'OCC1' |
|||
) |
select s.cmslsnum,d.bxlumivalue,d.bxlumierror,d.bxlumiquality,s.startorbit from LUMIDETAIL d,LUMISUMMARY s where s.runnum=:runnum and d.algoname=:algoname and s.lumisummary_id=d.lumisummary_id order by s.startorbit output: [[cmslsnum,bxlumivalue,bxlumierror,bxlumiquality,startorbit]] since the output is ordered by time, it has to be in seq list format
Definition at line 1538 of file lumiQueryAPI.py.
01539 : 01540 ''' 01541 select s.cmslsnum,d.bxlumivalue,d.bxlumierror,d.bxlumiquality,s.startorbit from LUMIDETAIL d,LUMISUMMARY s where s.runnum=:runnum and d.algoname=:algoname and s.lumisummary_id=d.lumisummary_id order by s.startorbit 01542 output: [[cmslsnum,bxlumivalue,bxlumierror,bxlumiquality,startorbit]] 01543 since the output is ordered by time, it has to be in seq list format 01544 ''' 01545 result=[] 01546 queryHandle.addToTableList(nameDealer.lumidetailTableName(),'d') 01547 queryHandle.addToTableList(nameDealer.lumisummaryTableName(),'s') 01548 queryCondition=coral.AttributeList() 01549 queryCondition.extend('runnum','unsigned int') 01550 queryCondition.extend('algoname','string') 01551 queryCondition['runnum'].setData(int(runnum)) 01552 queryCondition['algoname'].setData(algoname) 01553 queryHandle.addToOutputList('s.CMSLSNUM','cmslsnum') 01554 queryHandle.addToOutputList('d.BXLUMIVALUE','bxlumivalue') 01555 queryHandle.addToOutputList('d.BXLUMIERROR','bxlumierror') 01556 queryHandle.addToOutputList('d.BXLUMIQUALITY','bxlumiquality') 01557 queryHandle.addToOutputList('s.STARTORBIT','startorbit') 01558 queryHandle.setCondition('s.runnum=:runnum and d.algoname=:algoname and s.lumisummary_id=d.lumisummary_id',queryCondition) 01559 queryResult=coral.AttributeList() 01560 queryResult.extend('cmslsnum','unsigned int') 01561 queryResult.extend('bxlumivalue','blob') 01562 queryResult.extend('bxlumierror','blob') 01563 queryResult.extend('bxlumiquality','blob') 01564 queryResult.extend('startorbit','unsigned int') 01565 queryHandle.addToOrderList('s.STARTORBIT') 01566 queryHandle.defineOutput(queryResult) 01567 cursor=queryHandle.execute() 01568 while cursor.next(): 01569 cmslsnum=cursor.currentRow()['cmslsnum'].data() 01570 bxlumivalue=cursor.currentRow()['bxlumivalue'].data() 01571 bxlumierror=cursor.currentRow()['bxlumierror'].data() 01572 bxlumiquality=cursor.currentRow()['bxlumiquality'].data() 01573 startorbit=cursor.currentRow()['startorbit'].data() 01574 result.append([cmslsnum,bxlumivalue,bxlumierror,bxlumiquality,startorbit]) 01575 return result
def lumiQueryAPI::lumisumByrun | ( | queryHandle, | |
runnum, | |||
lumiversion, | |||
beamstatus = None , |
|||
beamenergy = None , |
|||
beamenergyfluctuation = 0.09 |
|||
) |
beamenergy unit : GeV beamenergyfluctuation : fraction allowed to fluctuate around beamenergy value select sum(instlumi) from lumisummary where runnum=:runnum and lumiversion=:lumiversion output: float totallumi Note: the output is the raw result, need to apply LS length in time(sec)
Definition at line 1137 of file lumiQueryAPI.py.
01138 : 01139 ''' 01140 beamenergy unit : GeV 01141 beamenergyfluctuation : fraction allowed to fluctuate around beamenergy value 01142 select sum(instlumi) from lumisummary where runnum=:runnum and lumiversion=:lumiversion 01143 output: float totallumi 01144 Note: the output is the raw result, need to apply LS length in time(sec) 01145 ''' 01146 result=0.0 01147 queryHandle.addToTableList(nameDealer.lumisummaryTableName()) 01148 queryCondition=coral.AttributeList() 01149 queryCondition.extend('runnum','unsigned int') 01150 queryCondition.extend('lumiversion','string') 01151 01152 queryCondition['runnum'].setData(int(runnum)) 01153 queryCondition['lumiversion'].setData(lumiversion) 01154 queryHandle.addToOutputList('sum(INSTLUMI)','lumitotal') 01155 conditionstring='RUNNUM=:runnum and LUMIVERSION=:lumiversion' 01156 if beamstatus and len(beamstatus)!=0: 01157 conditionstring=conditionstring+' and BEAMSTATUS=:beamstatus' 01158 queryCondition.extend('beamstatus','string') 01159 queryCondition['beamstatus'].setData(beamstatus) 01160 if beamenergy and beamenergy!=0.0: 01161 minBeamenergy=float(beamenergy*(1.0-beamenergyfluctuation)) 01162 maxBeamenergy=float(beamenergy*(1.0+beamenergyfluctuation)) 01163 conditionstring=conditionstring+' and BEAMENERGY>:minBeamenergy and BEAMENERGY<:maxBeamenergy' 01164 queryCondition.extend('minBeamenergy','float') 01165 queryCondition.extend('maxBeamenergy','float') 01166 queryCondition['minBeamenergy'].setData(float(minBeamenergy)) 01167 queryCondition['maxBeamenergy'].setData(float(maxBeamenergy)) 01168 queryHandle.setCondition(conditionstring,queryCondition) 01169 queryResult=coral.AttributeList() 01170 queryResult.extend('lumitotal','float') 01171 queryHandle.defineOutput(queryResult) 01172 cursor=queryHandle.execute() 01173 while cursor.next(): 01174 result=cursor.currentRow()['lumitotal'].data() 01175 return result
def lumiQueryAPI::lumisummaryByrun | ( | queryHandle, | |
runnum, | |||
lumiversion, | |||
beamstatus = None , |
|||
beamenergy = None , |
|||
beamenergyfluctuation = 0.09 |
|||
) |
one can impose beamstatus, beamenergy selections at the SQL query level or process them later from the general result select cmslsnum,instlumi,numorbit,startorbit,beamstatus,beamenery from lumisummary where runnum=:runnum and lumiversion=:lumiversion order by startorbit; output: [[cmslsnum,instlumi,numorbit,startorbit,beamstatus,beamenergy,cmsalive]] Note: the non-cmsalive LS are included in the result
Definition at line 1080 of file lumiQueryAPI.py.
01081 : 01082 ''' 01083 one can impose beamstatus, beamenergy selections at the SQL query level or process them later from the general result 01084 select cmslsnum,instlumi,numorbit,startorbit,beamstatus,beamenery from lumisummary where runnum=:runnum and lumiversion=:lumiversion order by startorbit; 01085 output: [[cmslsnum,instlumi,numorbit,startorbit,beamstatus,beamenergy,cmsalive]] 01086 Note: the non-cmsalive LS are included in the result 01087 ''' 01088 result=[] 01089 queryHandle.addToTableList(nameDealer.lumisummaryTableName()) 01090 queryCondition=coral.AttributeList() 01091 queryCondition.extend('runnum','unsigned int') 01092 queryCondition.extend('lumiversion','string') 01093 conditionstring='RUNNUM=:runnum and LUMIVERSION=:lumiversion' 01094 queryCondition['runnum'].setData(int(runnum)) 01095 queryCondition['lumiversion'].setData(lumiversion) 01096 queryHandle.addToOutputList('CMSLSNUM','cmslsnum') 01097 queryHandle.addToOutputList('INSTLUMI','instlumi') 01098 queryHandle.addToOutputList('NUMORBIT','numorbit') 01099 queryHandle.addToOutputList('STARTORBIT','startorbit') 01100 queryHandle.addToOutputList('BEAMSTATUS','beamstatus') 01101 queryHandle.addToOutputList('BEAMENERGY','beamenergy') 01102 queryHandle.addToOutputList('CMSALIVE','cmsalive') 01103 if beamstatus and len(beamstatus)!=0: 01104 conditionstring=conditionstring+' and BEAMSTATUS=:beamstatus' 01105 queryCondition.extend('beamstatus','string') 01106 queryCondition['beamstatus'].setData(beamstatus) 01107 if beamenergy: 01108 minBeamenergy=float(beamenergy*(1.0-beamenergyfluctuation)) 01109 maxBeamenergy=float(beamenergy*(1.0+beamenergyfluctuation)) 01110 conditionstring=conditionstring+' and BEAMENERGY>:minBeamenergy and BEAMENERGY<:maxBeamenergy' 01111 queryCondition.extend('minBeamenergy','float') 01112 queryCondition.extend('maxBeamenergy','float') 01113 queryCondition['minBeamenergy'].setData(float(minBeamenergy)) 01114 queryCondition['maxBeamenergy'].setData(float(maxBeamenergy)) 01115 queryResult=coral.AttributeList() 01116 queryResult.extend('cmslsnum','unsigned int') 01117 queryResult.extend('instlumi','float') 01118 queryResult.extend('numorbit','unsigned int') 01119 queryResult.extend('startorbit','unsigned int') 01120 queryResult.extend('beamstatus','string') 01121 queryResult.extend('beamenergy','float') 01122 queryResult.extend('cmsalive','unsigned int') 01123 queryHandle.defineOutput(queryResult) 01124 queryHandle.setCondition(conditionstring,queryCondition) 01125 queryHandle.addToOrderList('startorbit') 01126 cursor=queryHandle.execute() 01127 while cursor.next(): 01128 cmslsnum=cursor.currentRow()['cmslsnum'].data() 01129 instlumi=cursor.currentRow()['instlumi'].data() 01130 numorbit=cursor.currentRow()['numorbit'].data() 01131 startorbit=cursor.currentRow()['startorbit'].data() 01132 beamstatus=cursor.currentRow()['beamstatus'].data() 01133 beamenergy=cursor.currentRow()['beamenergy'].data() 01134 cmsalive=cursor.currentRow()['cmsalive'].data() 01135 result.append([cmslsnum,instlumi,numorbit,startorbit,beamstatus,beamenergy,cmsalive]) 01136 return result
def lumiQueryAPI::lumisummarytrgbitzeroByrun | ( | queryHandle, | |
runnum, | |||
lumiversion, | |||
beamstatus = None , |
|||
beamenergy = None , |
|||
beamenergyfluctuation = 0.09 |
|||
) |
select l.cmslsnum,l.instlumi,l.numorbit,l.startorbit,l.beamstatus,l.beamenery,t.trgcount,t.deadtime,t.bitname,t.prescale from trg t,lumisummary l where t.bitnum=:bitnum and l.runnum=:runnum and l.lumiversion=:lumiversion and l.runnum=t.runnum and t.cmslsnum=l.cmslsnum; Everything you ever need to know about bitzero and avg luminosity. Since we do not know if joint query is better of sperate, support both. output: {cmslsnum:[instlumi,numorbit,startorbit,beamstatus,beamenergy,bitzerocount,deadtime,bitname,prescale]} Note: only cmsalive LS are included in the result. Therefore, this function cannot be used for calculating delivered!
Definition at line 1212 of file lumiQueryAPI.py.
01213 : 01214 ''' 01215 select l.cmslsnum,l.instlumi,l.numorbit,l.startorbit,l.beamstatus,l.beamenery,t.trgcount,t.deadtime,t.bitname,t.prescale from trg t,lumisummary l where t.bitnum=:bitnum and l.runnum=:runnum and l.lumiversion=:lumiversion and l.runnum=t.runnum and t.cmslsnum=l.cmslsnum; 01216 Everything you ever need to know about bitzero and avg luminosity. Since we do not know if joint query is better of sperate, support both. 01217 output: {cmslsnum:[instlumi,numorbit,startorbit,beamstatus,beamenergy,bitzerocount,deadtime,bitname,prescale]} 01218 Note: only cmsalive LS are included in the result. Therefore, this function cannot be used for calculating delivered! 01219 ''' 01220 result={} 01221 queryHandle.addToTableList(nameDealer.trgTableName(),'t') 01222 queryHandle.addToTableList(nameDealer.lumisummaryTableName(),'l') 01223 queryCondition=coral.AttributeList() 01224 queryCondition.extend('bitnum','unsigned int') 01225 queryCondition.extend('runnum','unsigned int') 01226 queryCondition.extend('lumiversion','string') 01227 queryCondition['bitnum'].setData(int(0)) 01228 queryCondition['runnum'].setData(int(runnum)) 01229 queryCondition['lumiversion'].setData(lumiversion) 01230 01231 queryHandle.addToOutputList('l.CMSLSNUM','cmslsnum') 01232 queryHandle.addToOutputList('l.INSTLUMI','instlumi') 01233 queryHandle.addToOutputList('l.NUMORBIT','numorbit') 01234 queryHandle.addToOutputList('l.STARTORBIT','startorbit') 01235 queryHandle.addToOutputList('l.BEAMSTATUS','beamstatus') 01236 queryHandle.addToOutputList('l.BEAMENERGY','beamenergy') 01237 queryHandle.addToOutputList('t.TRGCOUNT','trgcount') 01238 queryHandle.addToOutputList('t.DEADTIME','deadtime') 01239 queryHandle.addToOutputList('t.BITNAME','bitname') 01240 queryHandle.addToOutputList('t.PRESCALE','prescale') 01241 conditionstring='t.BITNUM=:bitnum and l.RUNNUM=:runnum and l.LUMIVERSION=:lumiversion and l.RUNNUM=t.RUNNUM and t.CMSLSNUM=l.CMSLSNUM' 01242 if beamstatus and len(beamstatus)!=0: 01243 conditionstring=conditionstring+' and l.BEAMSTATUS=:beamstatus' 01244 queryCondition.extend('beamstatus','string') 01245 queryCondition['beamstatus'].setData(beamstatus) 01246 if beamenergy and beamenergy!=0.0: 01247 minBeamenergy=float(beamenergy*(1-beamenergyfluctuation)) 01248 maxBeamenergy=float(beamenergy*(1+beamenergyfluctuation)) 01249 conditionstring=conditionstring+' and l.BEAMENERGY>:minBeamenergy and l.BEAMENERGY<:maxBeamenergy' 01250 queryCondition.extend('minBeamenergy','float') 01251 queryCondition.extend('maxBeamenergy','float') 01252 queryCondition['minBeamenergy'].setData(float(minBeamenergy)) 01253 queryCondition['maxBeamenergy'].setData(float(maxBeamenergy)) 01254 queryHandle.setCondition(conditionstring,queryCondition) 01255 queryResult=coral.AttributeList() 01256 queryResult.extend('cmslsnum','unsigned int') 01257 queryResult.extend('instlumi','float') 01258 queryResult.extend('numorbit','unsigned int') 01259 queryResult.extend('startorbit','unsigned int') 01260 queryResult.extend('beamstatus','string') 01261 queryResult.extend('beamenergy','float') 01262 queryResult.extend('trgcount','unsigned int') 01263 queryResult.extend('deadtime','unsigned int') 01264 queryResult.extend('bitname','string') 01265 queryResult.extend('prescale','unsigned int') 01266 queryHandle.defineOutput(queryResult) 01267 cursor=queryHandle.execute() 01268 while cursor.next(): 01269 cmslsnum=cursor.currentRow()['cmslsnum'].data() 01270 instlumi=cursor.currentRow()['instlumi'].data() 01271 numorbit=cursor.currentRow()['numorbit'].data() 01272 startorbit=cursor.currentRow()['startorbit'].data() 01273 beamstatus=cursor.currentRow()['beamstatus'].data() 01274 beamenergy=cursor.currentRow()['beamenergy'].data() 01275 trgcount=cursor.currentRow()['trgcount'].data() 01276 deadtime=cursor.currentRow()['deadtime'].data() 01277 bitname=cursor.currentRow()['bitname'].data() 01278 prescale=cursor.currentRow()['prescale'].data() 01279 if not result.has_key(cmslsnum): 01280 result[cmslsnum]=[instlumi,numorbit,startorbit,beamstatus,beamenergy,trgcount,deadtime,bitname,prescale] 01281 return result
def lumiQueryAPI::mergeXingLumi | ( | triplet, | |
xingLumiDict | |||
) |
Given general xing information and a xingLumiDict, the xing luminosity information is merged with the general information
Definition at line 854 of file lumiQueryAPI.py.
00855 : 00856 '''Given general xing information and a xingLumiDict, the xing 00857 luminosity information is merged with the general information''' 00858 runNumber = triplet[0] 00859 deadTable = triplet[2] 00860 for lumi, lumiList in deadTable.iteritems(): 00861 key = ( int(runNumber), int(lumi) ) 00862 xingLumiValues = xingLumiDict.get (key) 00863 if xingLumiValues: 00864 lumiList.append( flatten (xingLumiValues) ) 00865
def lumiQueryAPI::printDeliveredLumi | ( | lumidata, | |
mode | |||
) |
Definition at line 380 of file lumiQueryAPI.py.
00381 : 00382 labels = [ ('Run', 'Delivered LS', 'Delivered'+u' (/\u03bcb)'.encode ('utf-8'), 'Beam Mode')] 00383 print tablePrinter.indent (labels+lumidata, hasHeader = True, separateRows = False, 00384 prefix = '| ', postfix = ' |', justify = 'right', 00385 delim = ' | ', wrapfunc = lambda x: wrap_onspace (x, 20) )
def lumiQueryAPI::printOverviewData | ( | delivered, | |
recorded, | |||
hltpath = '' |
|||
) |
Definition at line 667 of file lumiQueryAPI.py.
00668 : 00669 if len (hltpath) == 0 or hltpath == 'all': 00670 toprowlabels = [ ('Run', 'Delivered LS', 'Delivered'+u' (/\u03bcb)'.encode ('utf-8'), 'Selected LS', 'Recorded'+u' (/\u03bcb)'.encode ('utf-8') )] 00671 lastrowlabels = [ ('Delivered LS', 'Delivered'+u' (/\u03bcb)'.encode ('utf-8'), 'Selected LS', 'Recorded'+u' (/\u03bcb)'.encode ('utf-8') ) ] 00672 else: 00673 toprowlabels = [ ('Run', 'Delivered LS', 'Delivered'+u' (/\u03bcb)'.encode ('utf-8'), 'Selected LS', 'Recorded'+u' (/\u03bcb)'.encode ('utf-8'), 'Effective'+u' (/\u03bcb) '.encode ('utf-8')+hltpath )] 00674 lastrowlabels = [ ('Delivered LS', 'Delivered'+u' (/\u03bcb)'.encode ('utf-8'), 'Selected LS', 'Recorded'+u' (/\u03bcb)'.encode ('utf-8'), 'Effective '+u' (/\u03bcb) '.encode ('utf-8')+hltpath)] 00675 datatable = [] 00676 totaldata = [] 00677 totalDeliveredLS = 0 00678 totalSelectedLS = 0 00679 totalDelivered = 0.0 00680 totalRecorded = 0.0 00681 totalRecordedInPath = 0.0 00682 totaltable = [] 00683 for runidx, deliveredrowdata in enumerate (delivered): 00684 rowdata = [] 00685 rowdata += [deliveredrowdata[0], deliveredrowdata[1], deliveredrowdata[2]] 00686 if deliveredrowdata[1] == 'N/A': #run does not exist 00687 if hltpath != '' and hltpath != 'all': 00688 rowdata += ['N/A', 'N/A', 'N/A'] 00689 else: 00690 rowdata += ['N/A', 'N/A'] 00691 datatable.append (rowdata) 00692 continue 00693 totalDeliveredLS += int (deliveredrowdata[1]) 00694 totalDelivered += float (deliveredrowdata[2]) 00695 selectedls = recorded[runidx][2].keys() 00696 #print 'runidx ', runidx, deliveredrowdata 00697 #print 'selectedls ', selectedls 00698 if len (selectedls) == 0: 00699 selectedlsStr = '[]' 00700 recordedLumi = 0 00701 if hltpath != '' and hltpath != 'all': 00702 rowdata += [selectedlsStr, 'N/A', 'N/A'] 00703 else: 00704 rowdata += [selectedlsStr, 'N/A'] 00705 else: 00706 selectedlsStr = splitlistToRangeString (selectedls) 00707 recordedLumi = calculateTotalRecorded (recorded[runidx][2]) 00708 lumiinPaths = calculateEffective (recorded[runidx][1], recordedLumi) 00709 if hltpath != '' and hltpath != 'all': 00710 if lumiinPaths.has_key (hltpath): 00711 rowdata += [selectedlsStr, '%.3f'% (recordedLumi), '%.3f'% (lumiinPaths[hltpath])] 00712 totalRecordedInPath += lumiinPaths[hltpath] 00713 else: 00714 rowdata += [selectedlsStr, '%.3f'% (recordedLumi), 'N/A'] 00715 else: 00716 #rowdata += [selectedlsStr, '%.3f'% (recordedLumi), '%.3f'% (recordedLumi)] 00717 rowdata += [selectedlsStr, '%.3f'% (recordedLumi)] 00718 totalSelectedLS += len (selectedls) 00719 totalRecorded += recordedLumi 00720 datatable.append (rowdata) 00721 00722 if hltpath != '' and hltpath != 'all': 00723 totaltable = [[str (totalDeliveredLS), '%.3f'% (totalDelivered), str (totalSelectedLS), 00724 '%.3f'% (totalRecorded), '%.3f'% (totalRecordedInPath)]] 00725 else: 00726 totaltable = [[str (totalDeliveredLS), '%.3f'% (totalDelivered), str (totalSelectedLS), 00727 '%.3f'% (totalRecorded)]] 00728 print tablePrinter.indent (toprowlabels+datatable, hasHeader = True, separateRows = False, prefix = '| ', 00729 postfix = ' |', justify = 'right', delim = ' | ', 00730 wrapfunc = lambda x: wrap_onspace (x, 20)) 00731 print ' == = Total : ' 00732 print tablePrinter.indent (lastrowlabels+totaltable, hasHeader = True, separateRows = False, prefix = '| ', 00733 postfix = ' |', justify = 'right', delim = ' | ', 00734 wrapfunc = lambda x: wrap_onspace (x, 20)) 00735
def lumiQueryAPI::printPerLSLumi | ( | lumidata, | |
isVerbose = False |
|||
) |
input lumidata [['runnumber', 'trgtable{}', 'deadtable{}']] deadtable {lsnum:[deadtime, instlumi, bit_0, norbits,prescale]}
Definition at line 460 of file lumiQueryAPI.py.
00461 : 00462 ''' 00463 input lumidata [['runnumber', 'trgtable{}', 'deadtable{}']] 00464 deadtable {lsnum:[deadtime, instlumi, bit_0, norbits,prescale]} 00465 ''' 00466 datatoprint = [] 00467 totalrow = [] 00468 labels = [ ('Run', 'LS', 'Delivered', 'Recorded'+u' (/\u03bcb)'.encode ('utf-8'))] 00469 lastrowlabels = [ ('Selected LS', 'Delivered'+u' (/\u03bcb)'.encode ('utf-8'), 'Recorded'+u' (/\u03bcb)'.encode ('utf-8'))] 00470 totalDeliveredLS = 0 00471 totalSelectedLS = 0 00472 totalDelivered = 0.0 00473 totalRecorded = 0.0 00474 00475 for perrundata in lumidata: 00476 runnumber = perrundata[0] 00477 deadtable = perrundata[2] 00478 lumiresult = lsBylsLumi (deadtable) 00479 totalSelectedLS = totalSelectedLS+len (deadtable) 00480 for lsnum, dataperls in lumiresult.items(): 00481 rowdata = [] 00482 if len (dataperls) == 0: 00483 rowdata += [str (runnumber), str (lsnum), 'N/A', 'N/A'] 00484 else: 00485 rowdata += [str (runnumber), str (lsnum), '%.3f' % (dataperls[0]), '%.3f' % (dataperls[1])] 00486 totalDelivered = totalDelivered+dataperls[0] 00487 totalRecorded = totalRecorded+dataperls[1] 00488 datatoprint.append (rowdata) 00489 totalrow.append ([str (totalSelectedLS), '%.3f'% (totalDelivered), '%.3f'% (totalRecorded)]) 00490 print ' == = ' 00491 print tablePrinter.indent (labels+datatoprint, hasHeader = True, separateRows = False, prefix = '| ', 00492 postfix = ' |', justify = 'right', delim = ' | ', 00493 wrapfunc = lambda x: wrap_onspace_strict (x, 22)) 00494 print ' == = Total : ' 00495 print tablePrinter.indent (lastrowlabels+totalrow, hasHeader = True, separateRows = False, prefix = '| ', 00496 postfix = ' |', justify = 'right', delim = ' | ', 00497 wrapfunc = lambda x: wrap_onspace (x, 20)) 00498
def lumiQueryAPI::printRecordedLumi | ( | lumidata, | |
isVerbose = False , |
|||
hltpath = '' |
|||
) |
Definition at line 517 of file lumiQueryAPI.py.
00518 : 00519 datatoprint = [] 00520 totalrow = [] 00521 labels = [ ('Run', 'HLT path', 'Recorded'+u' (/\u03bcb)'.encode ('utf-8'))] 00522 lastrowlabels = [ ('Selected LS', 'Recorded'+u' (/\u03bcb)'.encode ('utf-8'))] 00523 if len (hltpath) != 0 and hltpath != 'all': 00524 lastrowlabels = [ ('Selected LS', 'Recorded'+u' (/\u03bcb)'.encode ('utf-8'), 00525 'Effective '+u' (/\u03bcb) '.encode ('utf-8')+hltpath)] 00526 if isVerbose: 00527 labels = [ ('Run', 'HLT-path', 'L1-bit', 'L1-presc', 'HLT-presc', 'Recorded'+u' (/\u03bcb)'.encode ('utf-8'))] 00528 totalSelectedLS = 0 00529 totalRecorded = 0.0 00530 totalRecordedInPath = 0.0 00531 00532 for dataperRun in lumidata: 00533 runnum = dataperRun[0] 00534 if len (dataperRun[1]) == 0: 00535 rowdata = [] 00536 rowdata += [str (runnum)]+2*['N/A'] 00537 datatoprint.append (rowdata) 00538 continue 00539 perlsdata = dataperRun[2] 00540 totalSelectedLS = totalSelectedLS+len (perlsdata) 00541 recordedLumi = 0.0 00542 #norbits = perlsdata.values()[0][3] 00543 recordedLumi = calculateTotalRecorded (perlsdata) 00544 totalRecorded = totalRecorded+recordedLumi 00545 trgdict = dataperRun[1] 00546 effective = calculateEffective (trgdict, recordedLumi) 00547 if trgdict.has_key (hltpath) and effective.has_key (hltpath): 00548 rowdata = [] 00549 l1bit = trgdict[hltpath][0] 00550 if len (trgdict[hltpath]) != 3: 00551 if not isVerbose: 00552 rowdata += [str (runnum), hltpath, 'N/A'] 00553 else: 00554 rowdata += [str (runnum), hltpath, l1bit, 'N/A', 'N/A', 'N/A'] 00555 else: 00556 if not isVerbose: 00557 rowdata += [str (runnum), hltpath, '%.3f'% (effective[hltpath])] 00558 else: 00559 hltprescale = trgdict[hltpath][1] 00560 l1prescale = trgdict[hltpath][2] 00561 rowdata += [str (runnum), hltpath, l1bit, str (l1prescale), str (hltprescale), 00562 '%.3f'% (effective[hltpath])] 00563 totalRecordedInPath = totalRecordedInPath+effective[hltpath] 00564 datatoprint.append (rowdata) 00565 continue 00566 00567 for trg, trgdata in trgdict.items(): 00568 #print trg, trgdata 00569 rowdata = [] 00570 if trg == trgdict.keys()[0]: 00571 rowdata += [str (runnum)] 00572 else: 00573 rowdata += [''] 00574 l1bit = trgdata[0] 00575 if len (trgdata) == 3: 00576 if not isVerbose: 00577 rowdata += [trg, '%.3f'% (effective[trg])] 00578 else: 00579 hltprescale = trgdata[1] 00580 l1prescale = trgdata[2] 00581 rowdata += [trg, l1bit, str (l1prescale), str (hltprescale), '%.3f'% (effective[trg])] 00582 else: 00583 if not isVerbose: 00584 rowdata += [trg, 'N/A'] 00585 else: 00586 rowdata += [trg, l1bit, 'N/A', 'N/A', '%.3f'% (effective[trg])] 00587 datatoprint.append (rowdata) 00588 #print datatoprint 00589 print ' == = ' 00590 print tablePrinter.indent (labels+datatoprint, hasHeader = True, separateRows = False, prefix = '| ', 00591 postfix = ' |', justify = 'right', delim = ' | ', 00592 wrapfunc = lambda x: wrap_onspace_strict (x, 22)) 00593 00594 if len (hltpath) != 0 and hltpath != 'all': 00595 totalrow.append ([str (totalSelectedLS), '%.3f'% (totalRecorded), '%.3f'% (totalRecordedInPath)]) 00596 else: 00597 totalrow.append ([str (totalSelectedLS), '%.3f'% (totalRecorded)]) 00598 print ' == = Total : ' 00599 print tablePrinter.indent (lastrowlabels+totalrow, hasHeader = True, separateRows = False, prefix = '| ', 00600 postfix = ' |', justify = 'right', delim = ' | ', 00601 wrapfunc = lambda x: wrap_onspace (x, 20)) 00602 if isVerbose: 00603 deadtoprint = [] 00604 deadtimelabels = [ ('Run', 'Lumi section : Dead fraction')] 00605 00606 for dataperRun in lumidata: 00607 runnum = dataperRun[0] 00608 if len (dataperRun[1]) == 0: 00609 deadtoprint.append ([str (runnum), 'N/A']) 00610 continue 00611 perlsdata = dataperRun[2] 00612 #print 'perlsdata 2 : ', perlsdata 00613 deadT = getDeadfractions (perlsdata) 00614 t = '' 00615 for myls, de in deadT.items(): 00616 if de<0: 00617 t += str (myls)+':nobeam ' 00618 else: 00619 t += str (myls)+':'+'%.5f'% (de)+' ' 00620 deadtoprint.append ([str (runnum), t]) 00621 print ' == = ' 00622 print tablePrinter.indent (deadtimelabels+deadtoprint, hasHeader = True, separateRows = True, prefix = '| ', 00623 postfix = ' |', justify = 'right', delim = ' | ', 00624 wrapfunc = lambda x: wrap_onspace (x, 80)) 00625
def lumiQueryAPI::recordedLumiForRange | ( | dbsession, | |
parameters, | |||
inputRange | |||
) |
Takes either single run as a string or dictionary of run ranges
Definition at line 98 of file lumiQueryAPI.py.
00099 : 00100 '''Takes either single run as a string or dictionary of run ranges''' 00101 lumidata = [] 00102 # is this a single string? 00103 if isinstance (inputRange, str): 00104 lumiDataPiece = recordedLumiForRun (dbsession, parameters, inputRange) 00105 if parameters.lumiXing: 00106 # get the xing information for the run 00107 xingLumiDict = xingLuminosityForRun (dbsession, inputRange, 00108 parameters) 00109 mergeXingLumi (lumiDataPiece, xingLumiDict) 00110 lumidata.append (lumiDataPiece) 00111 00112 else: 00113 # we want to collapse the lists so that every run is considered once. 00114 runLsDict = {} 00115 maxLumiSectionDict = {} 00116 for (run, lslist) in sorted (inputRange.runsandls().items() ): 00117 if(len(lslist)!=0): 00118 maxLumiSectionDict[run] = max ( max (lslist), 00119 maxLumiSectionDict.get(run,0) ) 00120 runLsDict.setdefault (run, []).append (lslist) 00121 for run, metaLsList in sorted (runLsDict.iteritems()): 00122 if parameters.verbose: 00123 print "run", run 00124 runLumiData = [] 00125 for lslist in metaLsList: 00126 runLumiData.append( recordedLumiForRun (dbsession, parameters, 00127 run, lslist) ) 00128 if parameters.lumiXing: 00129 # get the xing information once for the whole run 00130 xingLumiDict = xingLuminosityForRun (dbsession, run, 00131 parameters, 00132 maxLumiSection = \ 00133 maxLumiSectionDict[run]) 00134 # merge it with every piece of lumi data for this run 00135 for lumiDataPiece in runLumiData: 00136 mergeXingLumi (lumiDataPiece, xingLumiDict) 00137 lumidata.append (lumiDataPiece) 00138 else: 00139 lumidata.extend( runLumiData ) 00140 return lumidata 00141 00142
def lumiQueryAPI::recordedLumiForRun | ( | dbsession, | |
parameters, | |||
runnum, | |||
lslist = None |
|||
) |
lslist = [] means take none in the db lslist = None means to take all in the db output: ['runnumber', 'trgtable{}', 'deadtable{}']
Definition at line 201 of file lumiQueryAPI.py.
00202 : 00203 """ 00204 lslist = [] means take none in the db 00205 lslist = None means to take all in the db 00206 output: ['runnumber', 'trgtable{}', 'deadtable{}'] 00207 """ 00208 recorded = 0.0 00209 lumidata = [] #[runnumber, trgtable, deadtable] 00210 trgtable = {} #{hltpath:[l1seed, hltprescale, l1prescale]} 00211 deadtable = {} #{lsnum:[deadtime, instlumi, bit_0, norbits,bitzero_prescale]} 00212 lumidata.append (runnum) 00213 lumidata.append (trgtable) 00214 lumidata.append (deadtable) 00215 collectedseeds = [] #[ (hltpath, l1seed)] 00216 conditionstring='trghltmap.HLTKEY = cmsrunsummary.HLTKEY AND cmsrunsummary.RUNNUM = :runnumber' 00217 try: 00218 dbsession.transaction().start (True) 00219 schema = dbsession.nominalSchema() 00220 query = schema.newQuery() 00221 query.addToTableList (nameDealer.cmsrunsummaryTableName(), 'cmsrunsummary') 00222 query.addToTableList (nameDealer.trghltMapTableName(), 'trghltmap')#small table first 00223 queryCondition = coral.AttributeList() 00224 queryCondition.extend ("runnumber", "unsigned int") 00225 queryCondition["runnumber"].setData (int (runnum)) 00226 query.setCondition (conditionstring,queryCondition) 00227 query.addToOutputList ("trghltmap.HLTPATHNAME", "hltpathname") 00228 query.addToOutputList ("trghltmap.L1SEED", "l1seed") 00229 result = coral.AttributeList() 00230 result.extend ("hltpathname", "string") 00231 result.extend ("l1seed", "string") 00232 query.defineOutput (result) 00233 cursor = query.execute() 00234 while cursor.next(): 00235 hltpathname = cursor.currentRow()["hltpathname"].data() 00236 l1seed = cursor.currentRow()["l1seed"].data() 00237 collectedseeds.append ( (hltpathname, l1seed)) 00238 #print 'collectedseeds ', collectedseeds 00239 del query 00240 dbsession.transaction().commit() 00241 #loop over hltpath 00242 for (hname, sname) in collectedseeds: 00243 l1bitname = hltTrgSeedMapper.findUniqueSeed (hname, sname) 00244 #print 'found unque seed ', hname, l1bitname 00245 if l1bitname: 00246 lumidata[1][hname] = [] 00247 lumidata[1][hname].append (l1bitname.replace ('\"', '')) 00248 dbsession.transaction().start (True) 00249 schema = dbsession.nominalSchema() 00250 hltprescQuery = schema.tableHandle (nameDealer.hltTableName()).newQuery() 00251 hltprescQuery.addToOutputList ("PATHNAME", "hltpath") 00252 hltprescQuery.addToOutputList ("PRESCALE", "hltprescale") 00253 hltprescCondition = coral.AttributeList() 00254 hltprescCondition.extend ('runnumber', 'unsigned int') 00255 hltprescCondition.extend ('cmslsnum', 'unsigned int') 00256 hltprescCondition.extend ('inf', 'unsigned int') 00257 hltprescResult = coral.AttributeList() 00258 hltprescResult.extend ('hltpath', 'string') 00259 hltprescResult.extend ('hltprescale', 'unsigned int') 00260 hltprescQuery.defineOutput (hltprescResult) 00261 hltprescCondition['runnumber'].setData (int (runnum)) 00262 hltprescCondition['cmslsnum'].setData (1) 00263 hltprescCondition['inf'].setData (0) 00264 hltprescQuery.setCondition ("RUNNUM = :runnumber and CMSLSNUM = :cmslsnum and PRESCALE != :inf", 00265 hltprescCondition) 00266 cursor = hltprescQuery.execute() 00267 while cursor.next(): 00268 hltpath = cursor.currentRow()['hltpath'].data() 00269 hltprescale = cursor.currentRow()['hltprescale'].data() 00270 if lumidata[1].has_key (hltpath): 00271 lumidata[1][hltpath].append (hltprescale) 00272 00273 cursor.close() 00274 del hltprescQuery 00275 dbsession.transaction().commit() 00276 dbsession.transaction().start (True) 00277 schema = dbsession.nominalSchema() 00278 query = schema.newQuery() 00279 query.addToTableList (nameDealer.trgTableName(), 'trg') 00280 query.addToTableList (nameDealer.lumisummaryTableName(), 'lumisummary')#small table first--right-most 00281 queryCondition = coral.AttributeList() 00282 queryCondition.extend ("runnumber", "unsigned int") 00283 queryCondition.extend ("lumiversion", "string") 00284 queryCondition["runnumber"].setData (int (runnum)) 00285 queryCondition["lumiversion"].setData (parameters.lumiversion) 00286 conditionstring='lumisummary.RUNNUM =:runnumber and lumisummary.LUMIVERSION =:lumiversion AND lumisummary.CMSLSNUM=trg.CMSLSNUM and lumisummary.RUNNUM=trg.RUNNUM' 00287 if len(parameters.beammode)!=0: 00288 conditionstring=conditionstring+' and lumisummary.BEAMSTATUS=:beamstatus' 00289 queryCondition.extend('beamstatus','string') 00290 queryCondition['beamstatus'].setData(parameters.beammode) 00291 query.setCondition(conditionstring,queryCondition) 00292 query.addToOutputList ("lumisummary.CMSLSNUM", "cmsls") 00293 query.addToOutputList ("lumisummary.INSTLUMI", "instlumi") 00294 query.addToOutputList ("lumisummary.NUMORBIT", "norbits") 00295 query.addToOutputList ("trg.TRGCOUNT", "trgcount") 00296 query.addToOutputList ("trg.BITNAME", "bitname") 00297 query.addToOutputList ("trg.DEADTIME", "trgdeadtime") 00298 query.addToOutputList ("trg.PRESCALE", "trgprescale") 00299 query.addToOutputList ("trg.BITNUM", "trgbitnum") 00300 00301 result = coral.AttributeList() 00302 result.extend ("cmsls", "unsigned int") 00303 result.extend ("instlumi", "float") 00304 result.extend ("norbits", "unsigned int") 00305 result.extend ("trgcount", "unsigned int") 00306 result.extend ("bitname", "string") 00307 result.extend ("trgdeadtime", "unsigned long long") 00308 result.extend ("trgprescale", "unsigned int") 00309 result.extend ("trgbitnum", "unsigned int") 00310 trgprescalemap = {} 00311 query.defineOutput (result) 00312 cursor = query.execute() 00313 while cursor.next(): 00314 cmsls = cursor.currentRow()["cmsls"].data() 00315 instlumi = cursor.currentRow()["instlumi"].data()*parameters.norm 00316 norbits = cursor.currentRow()["norbits"].data() 00317 trgcount = cursor.currentRow()["trgcount"].data() 00318 trgbitname = cursor.currentRow()["bitname"].data() 00319 trgdeadtime = cursor.currentRow()["trgdeadtime"].data() 00320 trgprescale = cursor.currentRow()["trgprescale"].data() 00321 trgbitnum = cursor.currentRow()["trgbitnum"].data() 00322 if cmsls == 1: 00323 if not trgprescalemap.has_key (trgbitname): 00324 trgprescalemap[trgbitname] = trgprescale 00325 if trgbitnum == 0: 00326 if not deadtable.has_key (cmsls): 00327 deadtable[cmsls] = [] 00328 deadtable[cmsls].append (trgdeadtime) 00329 deadtable[cmsls].append (instlumi) 00330 deadtable[cmsls].append (trgcount) 00331 deadtable[cmsls].append (norbits) 00332 deadtable[cmsls].append (trgprescale) 00333 cursor.close() 00334 del query 00335 dbsession.transaction().commit() 00336 00337 # 00338 #consolidate results 00339 # 00340 #trgtable 00341 #print 'trgprescalemap', trgprescalemap 00342 #print lumidata[1] 00343 for hpath, trgdataseq in lumidata[1].items(): 00344 bitn = trgdataseq[0] 00345 if trgprescalemap.has_key (bitn) and len (trgdataseq) == 2: 00346 lumidata[1][hpath].append (trgprescalemap[bitn]) 00347 #filter selected cmsls 00348 lumidata[2] = filterDeadtable (deadtable, lslist) 00349 #print 'lslist ',lslist 00350 if not parameters.noWarnings: 00351 if len(lumidata[2])!=0: 00352 for lumi, deaddata in lumidata[2].items(): 00353 if deaddata[1] == 0.0 and deaddata[2]!=0 and deaddata[0]!=0: 00354 print '[Warning] : run %s :ls %d has 0 instlumi but trigger has data' % (runnum, lumi) 00355 if (deaddata[2] == 0 or deaddata[0] == 0) and deaddata[1]!=0.0: 00356 print '[Warning] : run %s :ls %d has 0 dead counts or 0 zerobias bit counts, but inst!=0' % (runnum, lumi) 00357 #print 'lumidata[2] ', lumidata[2] 00358 except Exception, e: 00359 print str (e) 00360 dbsession.transaction().rollback() 00361 del dbsession 00362 #print 'before return lumidata ', lumidata 00363 ## if parameters.lumiXing: 00364 ## xingLumiDict = xingLuminosityForRun (dbsession, runnum, parameters) 00365 ## mergeXingLumi (lumidata, xingLumiDict) 00366 return lumidata 00367
def lumiQueryAPI::runsByfillrange | ( | queryHandle, | |
minFill, | |||
maxFill | |||
) |
find all runs in the fill range inclusive select runnum,fillnum from cmsrunsummary where fillnum>=:minFill and fillnum<=:maxFill output: fillDict={fillnum:[runlist]}
Definition at line 1646 of file lumiQueryAPI.py.
01647 : 01648 ''' 01649 find all runs in the fill range inclusive 01650 select runnum,fillnum from cmsrunsummary where fillnum>=:minFill and fillnum<=:maxFill 01651 output: fillDict={fillnum:[runlist]} 01652 ''' 01653 result={} 01654 queryHandle.addToTableList(nameDealer.cmsrunsummaryTableName()) 01655 queryCondition=coral.AttributeList() 01656 queryCondition.extend('minFill','unsigned int') 01657 queryCondition.extend('maxFill','unsigned int') 01658 queryCondition['minFill'].setData(int(minFill)) 01659 queryCondition['maxFill'].setData(int(maxFill)) 01660 queryHandle.addToOutputList('RUNNUM','runnum') 01661 queryHandle.addToOutputList('FILLNUM','fillnum') 01662 queryHandle.setCondition('FILLNUM>=:minFill and FILLNUM<=:maxFill',queryCondition) 01663 queryResult=coral.AttributeList() 01664 queryResult.extend('runnum','unsigned int') 01665 queryResult.extend('fillnum','unsigned int') 01666 queryHandle.defineOutput(queryResult) 01667 cursor=queryHandle.execute() 01668 while cursor.next(): 01669 runnum=cursor.currentRow()['runnum'].data() 01670 fillnum=cursor.currentRow()['fillnum'].data() 01671 if not result.has_key(fillnum): 01672 result[fillnum]=[runnum] 01673 else: 01674 result[fillnum].append(runnum) 01675 return result
def lumiQueryAPI::runsByTimerange | ( | queryHandle, | |
minTime, | |||
maxTime | |||
) |
find all runs in the time range inclusive the selected run must have started after minTime and finished by maxTime select runnum,to_char(startTime),to_char(stopTime) from cmsrunsummary where startTime>=timestamp(minTime) and stopTime<=timestamp(maxTime); input: minTime,maxTime in python obj datetime.datetime output: {runnum:[starttime,stoptime]} return in python obj datetime.datetime
Definition at line 1676 of file lumiQueryAPI.py.
01677 : 01678 ''' 01679 find all runs in the time range inclusive 01680 the selected run must have started after minTime and finished by maxTime 01681 select runnum,to_char(startTime),to_char(stopTime) from cmsrunsummary where startTime>=timestamp(minTime) and stopTime<=timestamp(maxTime); 01682 input: minTime,maxTime in python obj datetime.datetime 01683 output: {runnum:[starttime,stoptime]} return in python obj datetime.datetime 01684 ''' 01685 t=lumiTime.lumiTime() 01686 result={} 01687 coralminTime=coral.TimeStamp(minTime.year,minTime.month,minTime.day,minTime.hour,minTime.minute,minTime.second,0) 01688 coralmaxTime=coral.TimeStamp(maxTime.year,maxTime.month,maxTime.day,maxTime.hour,maxTime.minute,maxTime.second,0) 01689 queryHandle.addToTableList(nameDealer.cmsrunsummaryTableName()) 01690 queryCondition=coral.AttributeList() 01691 queryCondition.extend('minTime','time stamp') 01692 queryCondition.extend('maxTime','time stamp') 01693 queryCondition['minTime'].setData(coralminTime) 01694 queryCondition['maxTime'].setData(coralmaxTime) 01695 queryHandle.addToOutputList('RUNNUM','runnum') 01696 queryHandle.addToOutputList('TO_CHAR(STARTTIME,\''+t.coraltimefm+'\')','starttime') 01697 queryHandle.addToOutputList('TO_CHAR(STOPTIME,\''+t.coraltimefm+'\')','stoptime') 01698 queryHandle.setCondition('STARTTIME>=:minTime and STOPTIME<=:maxTime',queryCondition) 01699 queryResult=coral.AttributeList() 01700 queryResult.extend('runnum','unsigned int') 01701 queryResult.extend('starttime','string') 01702 queryResult.extend('stoptime','string') 01703 queryHandle.defineOutput(queryResult) 01704 cursor=queryHandle.execute() 01705 while cursor.next(): 01706 runnum=cursor.currentRow()['runnum'].data() 01707 starttimeStr=cursor.currentRow()['starttime'].data() 01708 stoptimeStr=cursor.currentRow()['stoptime'].data() 01709 if not result.has_key(runnum): 01710 result[runnum]=[t.StrToDatetime(starttimeStr),t.StrToDatetime(stoptimeStr)] 01711 return result
def lumiQueryAPI::runsummaryByrun | ( | queryHandle, | |
runnum | |||
) |
select fillnum,sequence,hltkey,to_char(starttime),to_char(stoptime) from cmsrunsummary where runnum=:runnum output: [fillnum,sequence,hltkey,starttime,stoptime]
Definition at line 1044 of file lumiQueryAPI.py.
01045 : 01046 ''' 01047 select fillnum,sequence,hltkey,to_char(starttime),to_char(stoptime) from cmsrunsummary where runnum=:runnum 01048 output: [fillnum,sequence,hltkey,starttime,stoptime] 01049 ''' 01050 t=lumiTime.lumiTime() 01051 result=[] 01052 queryHandle.addToTableList(nameDealer.cmsrunsummaryTableName()) 01053 queryCondition=coral.AttributeList() 01054 queryCondition.extend('runnum','unsigned int') 01055 queryCondition['runnum'].setData(int(runnum)) 01056 queryHandle.addToOutputList('FILLNUM','fillnum') 01057 queryHandle.addToOutputList('SEQUENCE','sequence') 01058 queryHandle.addToOutputList('HLTKEY','hltkey') 01059 queryHandle.addToOutputList('to_char(STARTTIME,\''+t.coraltimefm+'\')','starttime') 01060 queryHandle.addToOutputList('to_char(STOPTIME,\''+t.coraltimefm+'\')','stoptime') 01061 queryHandle.setCondition('RUNNUM=:runnum',queryCondition) 01062 queryResult=coral.AttributeList() 01063 queryResult.extend('fillnum','unsigned int') 01064 queryResult.extend('sequence','string') 01065 queryResult.extend('hltkey','string') 01066 queryResult.extend('starttime','string') 01067 queryResult.extend('stoptime','string') 01068 queryHandle.defineOutput(queryResult) 01069 cursor=queryHandle.execute() 01070 while cursor.next(): 01071 result.append(cursor.currentRow()['fillnum'].data()) 01072 result.append(cursor.currentRow()['sequence'].data()) 01073 result.append(cursor.currentRow()['hltkey'].data()) 01074 result.append(cursor.currentRow()['starttime'].data()) 01075 result.append(cursor.currentRow()['stoptime'].data()) 01076 #if len(result)!=5: 01077 # print 'wrong runsummary result' 01078 # raise 01079 return result
def lumiQueryAPI::setupSession | ( | connectString, | |
siteconfpath, | |||
parameters, | |||
debug = False |
|||
) |
returns database session
Definition at line 866 of file lumiQueryAPI.py.
00867 : 00868 '''returns database session''' 00869 connectparser = connectstrParser.connectstrParser (connectString) 00870 connectparser.parse() 00871 usedefaultfrontierconfig = False 00872 cacheconfigpath = '' 00873 if connectparser.needsitelocalinfo(): 00874 if not siteconfpath: 00875 cacheconfigpath = os.environ['CMS_PATH'] 00876 if cacheconfigpath: 00877 cacheconfigpath = os.path.join (cacheconfigpath, 'SITECONF', 'local', 'JobConfig', 'site-local-config.xml') 00878 else: 00879 usedefaultfrontierconfig = True 00880 else: 00881 cacheconfigpath = siteconfpath 00882 cacheconfigpath = os.path.join (cacheconfigpath, 'site-local-config.xml') 00883 ccp = cacheconfigParser.cacheconfigParser() 00884 if usedefaultfrontierconfig: 00885 ccp.parseString (parameters.defaultfrontierConfigString) 00886 else: 00887 ccp.parse (cacheconfigpath) 00888 connectString = connectparser.fullfrontierStr (connectparser.schemaname(), ccp.parameterdict()) 00889 svc = coral.ConnectionService() 00890 if debug : 00891 msg = coral.MessageStream ('') 00892 msg.setMsgVerbosity (coral.message_Level_Debug) 00893 parameters.verbose = True 00894 session = svc.connect (connectString, accessMode = coral.access_ReadOnly) 00895 session.typeConverter().setCppTypeForSqlType ("unsigned int", "NUMBER (10)") 00896 session.typeConverter().setCppTypeForSqlType ("unsigned long long", "NUMBER (20)") 00897 return session, svc 00898 00899
def lumiQueryAPI::splitlistToRangeString | ( | inPut | ) |
Definition at line 414 of file lumiQueryAPI.py.
00415 : 00416 result = [] 00417 first = inPut[0] 00418 last = inPut[0] 00419 result.append ([inPut[0]]) 00420 counter = 0 00421 for i in inPut[1:]: 00422 if i == last+1: 00423 result[counter].append (i) 00424 else: 00425 counter += 1 00426 result.append ([i]) 00427 last = i 00428 return ', '.join (['['+str (min (x))+'-'+str (max (x))+']' for x in result]) 00429
def lumiQueryAPI::trgAllbitsByrun | ( | queryHandle, | |
runnum | |||
) |
all you ever want to know about trigger select cmslsnum,trgcount,deadtime,bitnum,bitname,prescale from trg where runnum=:runnum order by bitnum,cmslsnum this can be changed to blob query later output: {cmslsnum:{bitname:[bitnum,trgcount,deadtime,prescale]}}
Definition at line 1318 of file lumiQueryAPI.py.
01319 : 01320 ''' 01321 all you ever want to know about trigger 01322 select cmslsnum,trgcount,deadtime,bitnum,bitname,prescale from trg where runnum=:runnum order by bitnum,cmslsnum 01323 this can be changed to blob query later 01324 output: {cmslsnum:{bitname:[bitnum,trgcount,deadtime,prescale]}} 01325 ''' 01326 result={} 01327 queryHandle.addToTableList(nameDealer.trgTableName()) 01328 queryCondition=coral.AttributeList() 01329 queryCondition.extend('runnum','unsigned int') 01330 queryCondition['runnum'].setData(int(runnum)) 01331 queryHandle.addToOutputList('cmslsnum') 01332 queryHandle.addToOutputList('trgcount') 01333 queryHandle.addToOutputList('deadtime') 01334 queryHandle.addToOutputList('bitnum') 01335 queryHandle.addToOutputList('bitname') 01336 queryHandle.addToOutputList('prescale') 01337 queryHandle.setCondition('runnum=:runnum',queryCondition) 01338 queryResult=coral.AttributeList() 01339 queryResult.extend('cmslsnum','unsigned int') 01340 queryResult.extend('trgcount','unsigned int') 01341 queryResult.extend('deadtime','unsigned long long') 01342 queryResult.extend('bitnum','unsigned int') 01343 queryResult.extend('bitname','string') 01344 queryResult.extend('prescale','unsigned int') 01345 queryHandle.defineOutput(queryResult) 01346 queryHandle.addToOrderList('bitnum') 01347 queryHandle.addToOrderList('cmslsnum') 01348 cursor=queryHandle.execute() 01349 while cursor.next(): 01350 cmslsnum=cursor.currentRow()['cmslsnum'].data() 01351 trgcount=cursor.currentRow()['trgcount'].data() 01352 deadtime=cursor.currentRow()['deadtime'].data() 01353 bitnum=cursor.currentRow()['bitnum'].data() 01354 bitname=cursor.currentRow()['bitname'].data() 01355 prescale=cursor.currentRow()['prescale'].data() 01356 if not result.has_key(cmslsnum): 01357 dataperLS={} 01358 dataperLS[bitname]=[bitnum,trgcount,deadtime,prescale] 01359 result[cmslsnum]=dataperLS 01360 else: 01361 result[cmslsnum][bitname]=[bitnum,trgcount,deadtime,prescale] 01362 return result 01363
def lumiQueryAPI::trgbitzeroByrun | ( | queryHandle, | |
runnum | |||
) |
select cmslsnum,trgcount,deadtime,bitname,prescale from trg where runnum=:runnum and bitnum=0; output: {cmslsnum:[trgcount,deadtime,bitname,prescale]}
Definition at line 1176 of file lumiQueryAPI.py.
01177 : 01178 ''' 01179 select cmslsnum,trgcount,deadtime,bitname,prescale from trg where runnum=:runnum and bitnum=0; 01180 output: {cmslsnum:[trgcount,deadtime,bitname,prescale]} 01181 ''' 01182 result={} 01183 queryHandle.addToTableList(nameDealer.trgTableName()) 01184 queryCondition=coral.AttributeList() 01185 queryCondition.extend('runnum','unsigned int') 01186 queryCondition.extend('bitnum','unsigned int') 01187 queryCondition['runnum'].setData(int(runnum)) 01188 queryCondition['bitnum'].setData(int(0)) 01189 queryHandle.addToOutputList('CMSLSNUM','cmslsnum') 01190 queryHandle.addToOutputList('TRGCOUNT','trgcount') 01191 queryHandle.addToOutputList('DEADTIME','deadtime') 01192 queryHandle.addToOutputList('BITNAME','bitname') 01193 queryHandle.addToOutputList('PRESCALE','prescale') 01194 queryHandle.setCondition('RUNNUM=:runnum and BITNUM=:bitnum',queryCondition) 01195 queryResult=coral.AttributeList() 01196 queryResult.extend('cmslsnum','unsigned int') 01197 queryResult.extend('trgcount','unsigned int') 01198 queryResult.extend('deadtime','unsigned int') 01199 queryResult.extend('bitname','string') 01200 queryResult.extend('prescale','unsigned int') 01201 queryHandle.defineOutput(queryResult) 01202 cursor=queryHandle.execute() 01203 while cursor.next(): 01204 cmslsnum=cursor.currentRow()['cmslsnum'].data() 01205 trgcount=cursor.currentRow()['trgcount'].data() 01206 deadtime=cursor.currentRow()['deadtime'].data() 01207 bitname=cursor.currentRow()['bitname'].data() 01208 prescale=cursor.currentRow()['prescale'].data() 01209 if not result.has_key(cmslsnum): 01210 result[cmslsnum]=[trgcount,deadtime,bitname,prescale] 01211 return result
def lumiQueryAPI::trgBybitnameByrun | ( | queryHandle, | |
runnum, | |||
bitname | |||
) |
select cmslsnum,trgcount,deadtime,bitnum,prescale from trg where runnum=:runnum and bitname=:bitname; output: {cmslsnum:[trgcount,deadtime,bitnum,prescale]}
Definition at line 1282 of file lumiQueryAPI.py.
01283 : 01284 ''' 01285 select cmslsnum,trgcount,deadtime,bitnum,prescale from trg where runnum=:runnum and bitname=:bitname; 01286 output: {cmslsnum:[trgcount,deadtime,bitnum,prescale]} 01287 ''' 01288 result={} 01289 queryHandle.addToTableList(nameDealer.trgTableName()) 01290 queryCondition=coral.AttributeList() 01291 queryCondition.extend('runnum','unsigned int') 01292 queryCondition.extend('bitname','string') 01293 queryCondition['runnum'].setData(int(runnum)) 01294 queryCondition['bitname'].setData(bitname) 01295 queryHandle.addToOutputList('CMSLSNUM','cmslsnum') 01296 queryHandle.addToOutputList('TRGCOUNT','trgcount') 01297 queryHandle.addToOutputList('DEADTIME','deadtime') 01298 queryHandle.addToOutputList('BITNUM','bitnum') 01299 queryHandle.addToOutputList('PRESCALE','prescale') 01300 queryHandle.setCondition('RUNNUM=:runnum and BITNAME=:bitname',queryCondition) 01301 queryResult=coral.AttributeList() 01302 queryResult.extend('cmslsnum','unsigned int') 01303 queryResult.extend('trgcount','unsigned int') 01304 queryResult.extend('deadtime','unsigned long long') 01305 queryResult.extend('bitnum','unsigned int') 01306 queryResult.extend('prescale','unsigned int') 01307 queryHandle.defineOutput(queryResult) 01308 cursor=queryHandle.execute() 01309 while cursor.next(): 01310 cmslsnum=cursor.currentRow()['cmslsnum'].data() 01311 trgcount=cursor.currentRow()['trgcount'].data() 01312 deadtime=cursor.currentRow()['deadtime'].data() 01313 bitnum=cursor.currentRow()['bitnum'].data() 01314 prescale=cursor.currentRow()['prescale'].data() 01315 if not result.has_key(cmslsnum): 01316 result[cmslsnum]=[trgcount,deadtime,bitnum,prescale] 01317 return result
def lumiQueryAPI::validation | ( | queryHandle, | |
run = None , |
|||
cmsls = None |
|||
) |
retrieve validation data per run or all input: run. if not run, retrive all; if cmslsnum selection list pesent, filter out unselected result output: {run:[[cmslsnum,status,comment]]}
Definition at line 975 of file lumiQueryAPI.py.
00976 : 00977 '''retrieve validation data per run or all 00978 input: run. if not run, retrive all; if cmslsnum selection list pesent, filter out unselected result 00979 output: {run:[[cmslsnum,status,comment]]} 00980 ''' 00981 result={} 00982 queryHandle.addToTableList(nameDealer.lumivalidationTableName()) 00983 queryHandle.addToOutputList('RUNNUM','runnum') 00984 queryHandle.addToOutputList('CMSLSNUM','cmslsnum') 00985 queryHandle.addToOutputList('FLAG','flag') 00986 queryHandle.addToOutputList('COMMENT','comment') 00987 if run: 00988 queryCondition='RUNNUM=:runnum' 00989 queryBind=coral.AttributeList() 00990 queryBind.extend('runnum','unsigned int') 00991 queryBind['runnum'].setData(run) 00992 queryHandle.setCondition(queryCondition,queryBind) 00993 queryResult=coral.AttributeList() 00994 queryResult.extend('runnum','unsigned int') 00995 queryResult.extend('cmslsnum','unsigned int') 00996 queryResult.extend('flag','string') 00997 queryResult.extend('comment','string') 00998 queryHandle.defineOutput(queryResult) 00999 cursor=queryHandle.execute() 01000 while cursor.next(): 01001 runnum=cursor.currentRow()['runnum'].data() 01002 if not result.has_key(runnum): 01003 result[runnum]=[] 01004 cmslsnum=cursor.currentRow()['cmslsnum'].data() 01005 flag=cursor.currentRow()['flag'].data() 01006 comment=cursor.currentRow()['comment'].data() 01007 result[runnum].append([cmslsnum,flag,comment]) 01008 if run and cmsls and len(cmsls)!=0: 01009 selectedresult={} 01010 for runnum,perrundata in result.items(): 01011 for lsdata in perrundata: 01012 if lsdata[0] not in cmsls: 01013 continue 01014 if not selectedresult.has_key(runnum): 01015 selectedresult[runnum]=[] 01016 selectedresult[runnum].append(lsdata) 01017 return selectedresult 01018 else: 01019 return result
def lumiQueryAPI::xingLuminosityForRun | ( | dbsession, | |
runnum, | |||
parameters, | |||
lumiXingDict = {} , |
|||
maxLumiSection = None |
|||
) |
Given a run number and a minimum xing luminosity value, returns a dictionary (keyed by (run, lumi section)) where the value is a list of tuples of (xingID, xingLum). - For all xing luminosities, simply set minLumValue to 0. - If you want one dictionary for several runs, pass it in to "lumiXingDict" select s.cmslsnum, d.bxlumivalue, d.bxlumierror, d.bxlumiquality, d.algoname from LUMIDETAIL d, LUMISUMMARY s where s.runnum = 133885 and d.algoname = 'OCC1' and s.lumisummary_id = d.lumisummary_id order by s.startorbit, s.cmslsnum
Definition at line 759 of file lumiQueryAPI.py.
00759 {}, 00760 maxLumiSection = None): 00761 '''Given a run number and a minimum xing luminosity value, 00762 returns a dictionary (keyed by (run, lumi section)) where the 00763 value is a list of tuples of (xingID, xingLum). 00764 00765 - For all xing luminosities, simply set minLumValue to 0. 00766 00767 - If you want one dictionary for several runs, pass it in to 00768 "lumiXingDict" 00769 00770 00771 select 00772 s.cmslsnum, d.bxlumivalue, d.bxlumierror, d.bxlumiquality, d.algoname from LUMIDETAIL d, LUMISUMMARY s where s.runnum = 133885 and d.algoname = 'OCC1' and s.lumisummary_id = d.lumisummary_id order by s.startorbit, s.cmslsnum 00773 ''' 00774 try: 00775 runnum = int (runnum) 00776 dbsession.transaction().start (True) 00777 schema = dbsession.schema (parameters.lumischema) 00778 if not schema: 00779 raise 'cannot connect to schema ', parameters.lumischema 00780 detailOutput = coral.AttributeList() 00781 detailOutput.extend ('startorbit', 'unsigned int') 00782 detailOutput.extend ('cmslsnum', 'unsigned int') 00783 detailOutput.extend ('bxlumivalue', 'blob') 00784 detailOutput.extend ('bxlumierror', 'blob') 00785 detailOutput.extend ('bxlumiquality', 'blob') 00786 detailOutput.extend ('algoname', 'string') 00787 detailCondition = coral.AttributeList() 00788 detailCondition.extend ('runnum', 'unsigned int') 00789 detailCondition.extend ('algoname', 'string') 00790 detailCondition['runnum'].setData (runnum) 00791 detailCondition['algoname'].setData ('OCC1') 00792 query = schema.newQuery() 00793 query.addToTableList(nameDealer.lumisummaryTableName(), 's') 00794 query.addToTableList(nameDealer.lumidetailTableName(), 'd') 00795 query.addToOutputList ('s.STARTORBIT', 'startorbit') 00796 query.addToOutputList ('s.CMSLSNUM', 'cmslsnum') 00797 query.addToOutputList ('d.BXLUMIVALUE', 'bxlumivalue') 00798 query.addToOutputList ('d.BXLUMIERROR', 'bxlumierror') 00799 query.addToOutputList ('d.BXLUMIQUALITY', 'bxlumiquality') 00800 query.addToOutputList ('d.ALGONAME', 'algoname') 00801 query.setCondition ('s.RUNNUM =:runnum and d.ALGONAME =:algoname and s.LUMISUMMARY_ID=d.LUMISUMMARY_ID',detailCondition) 00802 query.addToOrderList ('s.CMSLSNUM') 00803 query.defineOutput (detailOutput) 00804 cursor = query.execute() 00805 count = 0 00806 while cursor.next(): 00807 ## ## Note: If you are going to break out of this loop early, 00808 ## ## make sure you call cursor.close(): 00809 ## 00810 ## if count > 20 : 00811 ## cursor.close() 00812 ## break 00813 ## count += 1 00814 cmslsnum = cursor.currentRow()['cmslsnum'].data() 00815 algoname = cursor.currentRow()['algoname'].data() 00816 bxlumivalue = cursor.currentRow()['bxlumivalue'].data() 00817 startorbit = cursor.currentRow()['startorbit'].data() 00818 00819 if maxLumiSection and maxLumiSection < cmslsnum: 00820 cursor.close() 00821 break 00822 00823 xingArray = array.array ('f') 00824 xingArray.fromstring( bxlumivalue.readline() ) 00825 numPrinted = 0 00826 xingLum = [] 00827 for index, lum in enumerate (xingArray): 00828 lum *= parameters.normFactor 00829 if lum < parameters.xingMinLum: 00830 continue 00831 xingLum.append( (index, lum) ) 00832 lumiXingDict[ (runnum, cmslsnum) ] = xingLum 00833 del query 00834 dbsession.transaction().commit() 00835 return lumiXingDict 00836 except Exception, e: 00837 print str (e) 00838 print "whoops" 00839 dbsession.transaction().rollback() 00840 del dbsession 00841 00842
tuple lumiQueryAPI::allfills = allfills(q) |
Definition at line 1782 of file lumiQueryAPI.py.
tuple lumiQueryAPI::allruns = allruns(schema,requireLumisummary=True,requireTrg=True,requireHlt=True) |
Definition at line 1724 of file lumiQueryAPI.py.
string lumiQueryAPI::connectstr = 'oracle://cms_orcoff_prod/cms_lumi_prod' |
Definition at line 1718 of file lumiQueryAPI.py.
tuple lumiQueryAPI::msg = coral.MessageStream('') |
Definition at line 1713 of file lumiQueryAPI.py.
tuple lumiQueryAPI::q = schema.newQuery() |
Definition at line 1781 of file lumiQueryAPI.py.
Referenced by PhotonValidator::analyze(), JetAnaPythia< Jet >::analyze(), L1TdeCSCTF::analyze(), TrackParameterAnalyzer::analyze(), HLTScalers::analyze(), CaloRecHitMetaCollection::at(), AlignmentTrackSelector::basicCuts(), PhysicsTools::AtomicId::build(), CandCombinerBase< OutputCollection, CandPtr >::combine(), AnalyticalCurvilinearJacobian::computeFullJacobian(), VVIObjDetails::cosint(), TtFullLepKinSolver::cubic(), TwoBodyDecayModel::curvilinearToCartesianJacobian(), PhysicsTools::VarProcessor::deriv(), lhef::domToLines(), EEQuadrant(), lhef::LHEReader::XMLHandler::endElement(), ConfigurationDBHandler::endElement(), LMFSeqDat::fetchByRunNumber(), TrackAnalyzer::fillHistosForState(), PrimaryVertexAnalyzer4PU::fillTrackHistos(), edm::Guid::fromString(), edm::ParameterSet::fromString(), GammaFunctionGenerator::gammaFrac(), lumi::idDealer::generateNextIDForTable(), TiXmlBase::GetEntity(), lumi::idDealer::getIDforTable(), MonitorElement::getQReport(), PrimaryVertexAnalyzer4PU::getSimTrkParameters(), pftools::CaloEllipse::getTheta(), L1MuGMTSortRankUnit::getVeryLowQualityLevel(), gen::Herwig6Instance::give(), ConversionFastHelix::helixStateAtVertex(), FastHelix::helixStateAtVertex(), GflashTrajectory::initializeTrajectory(), SeedFromConsecutiveHitsStraightLineCreator::initialKinematic(), RoadSearchTrackCandidateMakerAlgorithm::initialTrajectory(), JacobianCartesianToCurvilinear::JacobianCartesianToCurvilinear(), JacobianCartesianToLocal::JacobianCartesianToLocal(), JacobianCurvilinearToCartesian::JacobianCurvilinearToCartesian(), JacobianCurvilinearToLocal::JacobianCurvilinearToLocal(), JacobianLocalToCartesian::JacobianLocalToCartesian(), JacobianLocalToCurvilinear::JacobianLocalToCurvilinear(), JetBProbabilityComputer::jetProbability(), reco::TrackProbabilityTagInfo::jetProbability(), JetProbabilityComputer::jetProbability(), SteppingHelixPropagator::makeAtomStep(), match(), L1MuGMTMerger::merge_rank(), MergeRootfile(), NtpProducer< C >::NtpProducer(), edm::Guid::operator=(), edm::Guid::operator==(), HcalPacker::pack(), trigger::TriggerObject::particle(), RawParticle::PDGcharge(), CastorNominalCoderTemplate::process(), HcalNominalCoderTemplate::process(), HcalBeamMonitor::processEvent(), L3MuonCandidateProducer::produce(), L2MuonCandidateProducer::produce(), TtSemiEvtSolutionMaker::produce(), TtHadEvtSolutionMaker::produce(), NtpProducer< C >::produce(), L3MuonCandidateProducerFromMuons::produce(), Herwig6Hadronizer::pythiaStatusCode(), reco::TrackBase::quality(), reco::Conversion::quality(), GSUtilities::quantile(), RealQuadEquation::RealQuadEquation(), HcalCableMapper::record(), L1MuDTEtaProcessor::runEtaTrackFinder(), CustomPDGParser::s_charge(), MuScleFit::selGlobalMuon(), MuScleFitMuonSelector::selGlobalMuon(), BPhysicsOniaDQM::selGlobalMuon(), RawParticle::setCharge(), ObjectValidator::setEBRecHitCollection(), ObjectValidator::setEcalChannelStatus(), ObjectValidator::setEcalSeverityLevelAlgo(), ObjectValidator::setEERecHitCollection(), ObjectValidator::setHcalChannelQuality(), ObjectValidator::setHcalSeverityLevelComputer(), CSCCorrelatedLCTDigi::setQuality(), pat::HardEventHypothesis::setQuality(), reco::Conversion::setQuality(), reco::TrackBase::setQuality(), GenEventInfoProduct::setScales(), VVIObjDetails::sincosint(), VVIObjDetails::sinint(), HelixExtrapolatorToLine2Order::solve3rdOrder(), L1MuGMTSortRankUnit::sort_rank(), L1MuGMTLFMergeRankEtaQLUT::SpecificLookup(), L1MuGMTLFSortRankPtQLUT::SpecificLookup(), L1MuGMTLFMergeRankPtQLUT::SpecificLookup(), L1MuGMTLFSortRankEtaQLUT::SpecificLookup(), L1MuGMTLFMergeRankEtaQLUT::SpecificLookup_flag(), L1MuGMTLFMergeRankEtaQLUT::SpecificLookup_rank_etaq(), L1MuGMTLFSortRankEtaQLUT::SpecificLookup_rank_etaq(), L1MuGMTLFSortRankPtQLUT::SpecificLookup_rank_ptq(), L1MuGMTLFMergeRankPtQLUT::SpecificLookup_rank_ptq(), L1MuGMTLFSortRankEtaQLUT::SpecificLookup_vlq(), PhysicsTools::split(), ConversionFastHelix::straightLineStateAtVertex(), FastHelix::straightLineStateAtVertex(), TiXmlBase::StringEqual(), edm::service::ELoutput::summarization(), edm::ELlog4cplus::summarization(), edm::service::ELfwkJobReport::summarization(), L1MuGMTLFMergeRankEtaQLUT::TheLookupFunction(), L1MuGMTLFSortRankPtQLUT::TheLookupFunction(), L1MuonPixelTrackFitter::valInversePt(), SiStripClusterInfo::variance(), VVIObj::VVIObj(), and DCULVRVoltagesDat::writeArrayDB().
tuple lumiQueryAPI::schema = session.nominalSchema() |
Definition at line 1723 of file lumiQueryAPI.py.
tuple lumiQueryAPI::session = svc.connect(connectstr,accessMode=coral.access_ReadOnly) |
Definition at line 1719 of file lumiQueryAPI.py.
tuple lumiQueryAPI::svc = coral.ConnectionService() |
Definition at line 1717 of file lumiQueryAPI.py.