Functions | |
def | hltconf |
def | hltFromOldLumi |
def | hltFromRuninfoV2 |
def | hltFromRuninfoV3 |
def | runsummary |
def | trgFromNewGT |
def | trgFromOldGT |
def | trgFromOldLumi |
def | trgFromWBM |
def | uncalibratedlumiFromOldLumi |
def | uncalibrateLumi |
Variables | |
tuple | session = svc.openSession(isReadOnly=True,cpp2sqltype=[('unsigned int','NUMBER(10)'),('unsigned long long','NUMBER(20)')]) |
tuple | svc = sessionManager.sessionManager('oracle://cms_orcoff_prod/cms_lumi_prod',authpath='/afs/cern.ch/user/x/xiezhen',debugON=False) |
def queryDataSource::hltconf | ( | session, | |
hltkey | |||
) |
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; 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; ##select paths.pathid from cms_hlt.paths paths,cms_hlt.configurations config where config.configdescriptor=' ' and name=:pathname
Definition at line 776 of file queryDataSource.py.
00777 : 00778 ''' 00779 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; 00780 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; 00781 ##select paths.pathid from cms_hlt.paths paths,cms_hlt.configurations config where config.configdescriptor=' ' and name=:pathname 00782 ''' 00783 try: 00784 session.transaction().start(True) 00785 hltconfschema=session.nominalSchema() 00786 hltconfQuery=hltconfschema.newQuery() 00787 00788 hltconfQuery.addToOutputList('PATHS.NAME','hltpath') 00789 hltconfQuery.addToOutputList('STRINGPARAMVALUES.VALUE','l1expression') 00790 00791 hltconfQuery.addToTableList('PATHS') 00792 hltconfQuery.addToTableList('STRINGPARAMVALUES') 00793 hltconfQuery.addToTableList('PARAMETERS') 00794 hltconfQuery.addToTableList('SUPERIDPARAMETERASSOC') 00795 hltconfQuery.addToTableList('MODULES') 00796 hltconfQuery.addToTableList('MODULETEMPLATES') 00797 hltconfQuery.addToTableList('PATHMODULEASSOC') 00798 hltconfQuery.addToTableList('CONFIGURATIONPATHASSOC') 00799 hltconfQuery.addToTableList('CONFIGURATIONS') 00800 00801 hltconfBindVar=coral.AttributeList() 00802 hltconfBindVar.extend('hltseed','string') 00803 hltconfBindVar.extend('l1seedexpr','string') 00804 hltconfBindVar.extend('hltkey','string') 00805 hltconfBindVar['hltseed'].setData('HLTLevel1GTSeed') 00806 hltconfBindVar['l1seedexpr'].setData('L1SeedsLogicalExpression') 00807 hltconfBindVar['hltkey'].setData(hltkey) 00808 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) 00809 hlt2l1map={} 00810 cursor=hltconfQuery.execute() 00811 while cursor.next(): 00812 hltpath=cursor.currentRow()['hltpath'].data() 00813 print hltpath 00814 l1expression=cursor.currentRow()['l1expression'].data() 00815 hlt2l1map[hltpath]=l1expression 00816 del hltconfQuery 00817 session.transaction().commit() 00818 return hlt2l1map 00819 except: 00820 raise
def queryDataSource::hltFromOldLumi | ( | session, | |
runnumber | |||
) |
select count(distinct pathname) from hlt where runnum=:runnum select cmslsnum,pathname,inputcount,acceptcount,prescale from hlt where runnum=:runnum order by cmslsnum,pathname [pathnames,databuffer] databuffer: {cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}
Definition at line 124 of file queryDataSource.py.
00125 : 00126 ''' 00127 select count(distinct pathname) from hlt where runnum=:runnum 00128 select cmslsnum,pathname,inputcount,acceptcount,prescale from hlt where runnum=:runnum order by cmslsnum,pathname 00129 [pathnames,databuffer] 00130 databuffer: {cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]} 00131 ''' 00132 try: 00133 databuffer={} 00134 session.transaction().start(True) 00135 lumischema=session.nominalSchema() 00136 npath=0 00137 qHandle=lumischema.newQuery() 00138 qHandle.addToTableList( nameDealer.hltTableName() ) 00139 qHandle.addToOutputList('COUNT(DISTINCT PATHNAME)','npath') 00140 qCondition=coral.AttributeList() 00141 qCondition.extend('runnum','unsigned int') 00142 qCondition['runnum'].setData(int(runnumber)) 00143 qResult=coral.AttributeList() 00144 qResult.extend('npath','unsigned int') 00145 qHandle.defineOutput(qResult) 00146 qHandle.setCondition('RUNNUM=:runnum',qCondition) 00147 cursor=qHandle.execute() 00148 while cursor.next(): 00149 npath=cursor.currentRow()['npath'].data() 00150 del qHandle 00151 #print 'npath ',npath 00152 00153 qHandle=lumischema.newQuery() 00154 qHandle.addToTableList( nameDealer.hltTableName() ) 00155 qHandle.addToOutputList('CMSLSNUM','cmslsnum') 00156 qHandle.addToOutputList('PATHNAME','pathname') 00157 qHandle.addToOutputList('INPUTCOUNT','inputcount') 00158 qHandle.addToOutputList('ACCEPTCOUNT','acceptcount') 00159 qHandle.addToOutputList('PRESCALE','prescale') 00160 qCondition=coral.AttributeList() 00161 qCondition.extend('runnum','unsigned int') 00162 qCondition['runnum'].setData(int(runnumber)) 00163 qResult=coral.AttributeList() 00164 qResult.extend('cmslsnum','unsigned int') 00165 qResult.extend('pathname','string') 00166 qResult.extend('inputcount','unsigned int') 00167 qResult.extend('acceptcount','unsigned int') 00168 qResult.extend('prescale','unsigned int') 00169 qHandle.defineOutput(qResult) 00170 qHandle.setCondition('RUNNUM=:runnum',qCondition) 00171 qHandle.addToOrderList('cmslsnum') 00172 qHandle.addToOrderList('pathname') 00173 cursor=qHandle.execute() 00174 pathnameList=[] 00175 inputcountArray=array.array('I') 00176 acceptcountArray=array.array('I') 00177 prescaleArray=array.array('I') 00178 ipath=0 00179 pathnHLT_PixelTracksVdMames='' 00180 while cursor.next(): 00181 cmslsnum=cursor.currentRow()['cmslsnum'].data() 00182 pathname=cursor.currentRow()['pathname'].data() 00183 ipath+=1 00184 inputcount=cursor.currentRow()['inputcount'].data() 00185 acceptcount=cursor.currentRow()['acceptcount'].data() 00186 prescale=cursor.currentRow()['prescale'].data() 00187 pathnameList.append(pathname) 00188 inputcountArray.append(inputcount) 00189 acceptcountArray.append(acceptcount) 00190 prescaleArray.append(prescale) 00191 if ipath==npath: 00192 if cmslsnum==1: 00193 pathnames=','.join(pathnameList) 00194 inputcountBlob=CommonUtil.packArraytoBlob(inputcountArray) 00195 acceptcountBlob=CommonUtil.packArraytoBlob(acceptcountArray) 00196 prescaleBlob=CommonUtil.packArraytoBlob(prescaleArray) 00197 databuffer[cmslsnum]=[inputcountBlob,acceptcountBlob,prescaleBlob] 00198 pathnameList=[] 00199 inputcountArray=array.array('I') 00200 acceptcountArray=array.array('I') 00201 prescaleArray=array.array('I') 00202 ipath=0 00203 del qHandle 00204 session.transaction().commit() 00205 #print 'pathnames ',pathnames 00206 return [pathnames,databuffer] 00207 except : 00208 raise
def queryDataSource::hltFromRuninfoV2 | ( | session, | |
runnumber | |||
) |
input: output: [pathnameclob,{cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}] select count(distinct PATHNAME) as npath from HLT_SUPERVISOR_LUMISECTIONS_V2 where runnr=:runnumber and lsnumber=1; 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
Definition at line 674 of file queryDataSource.py.
00675 : 00676 ''' 00677 input: 00678 output: [pathnameclob,{cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}] 00679 select count(distinct PATHNAME) as npath from HLT_SUPERVISOR_LUMISECTIONS_V2 where runnr=:runnumber and lsnumber=1; 00680 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 00681 ''' 00682 npaths=0 00683 pathnames=[] 00684 hltdict={} 00685 try: 00686 session.transaction().start(True) 00687 hltschema=session.schema('CMS_RUNINFO') 00688 bvar=coral.AttributeList() 00689 bvar.extend('runnumber','unsigned int') 00690 bvar.extend('lsnumber','unsigned int') 00691 bvar['runnumber'].setData(int(runnumber)) 00692 bvar['lsnumber'].setData(1) 00693 q1=hltschema.newQuery() 00694 q1.addToTableList('HLT_SUPERVISOR_LUMISECTIONS_V2') 00695 nls=coral.AttributeList() 00696 nls.extend('npath','unsigned int') 00697 q1.addToOutputList('count(distinct PATHNAME)','npath') 00698 q1.setCondition('RUNNR=:runnumber AND LSNUMBER=:lsnumber',bvar) 00699 q1.defineOutput(nls) 00700 c=q1.execute() 00701 while c.next(): 00702 npath=c.currentRow()['npath'].data() 00703 del q1 00704 if npath==0: 00705 print 'request run is empty, do nothing' 00706 00707 q=hltschema.newQuery() 00708 bindVar=coral.AttributeList() 00709 bindVar.extend('runnumber','unsigned int') 00710 bindVar['runnumber'].setData(int(runnumber)) 00711 q.addToTableList('HLT_SUPERVISOR_LUMISECTIONS_V2','l') 00712 q.addToTableList('HLT_SUPERVISOR_SCALAR_MAP','m') 00713 q.addToOutputList('l.LSNUMBER','lsnumber') 00714 q.addToOutputList('l.PATHNAME','pathname') 00715 q.addToOutputList('l.L1PASS','hltinput') 00716 q.addToOutputList('l.PACCEPT','hltaccept') 00717 q.addToOutputList('m.PSVALUE','prescale') 00718 q.setCondition('l.RUNNR=m.RUNNR and l.PSINDEX=m.PSINDEX and l.PATHNAME=m.PATHNAME and l.RUNNR=:runnumber',bindVar) 00719 q.addToOrderList('l.LSNUMBER') 00720 q.addToOrderList('l.PATHNAME') 00721 q.setRowCacheSize(10692) 00722 cursor=q.execute() 00723 lastLumiSection=1 00724 currentLumiSection=0 00725 allpaths=[] 00726 ipath=0 00727 hltinputs=array.array('I') 00728 hltaccepts=array.array('I') 00729 prescales=array.array('I') 00730 while cursor.next(): 00731 row=cursor.currentRow() 00732 cmsluminr=row['lsnumber'].data() 00733 hltinput=row['hltinput'].data() 00734 hltaccept=row['hltaccept'].data() 00735 prescale=row['prescale'].data() 00736 pathname=row['pathname'].data() 00737 ipath+=1 00738 if cmsluminr==1: 00739 pathnames.append(pathname) 00740 if not hltdict.has_key(cmsluminr): 00741 hltdict[cmsluminr]=[] 00742 hltinputs.append(hltinput) 00743 hltaccepts.append(hltaccept) 00744 prescales.append(prescale) 00745 if ipath==npath: 00746 #pack 00747 #print 'packing hltinputs ',hltinputs 00748 hltinputsBlob=CommonUtil.packArraytoBlob(hltinputs) 00749 #print 'packing hltaccepts ',hltaccepts 00750 hltacceptsBlob=CommonUtil.packArraytoBlob(hltaccepts) 00751 #print 'packing prescales ',prescales 00752 prescalesBlob=CommonUtil.packArraytoBlob(prescales) 00753 hltdict[cmsluminr].extend([hltinputsBlob,hltacceptsBlob,hltacceptsBlob]) 00754 ipath=0 00755 hltinputs=array.array('I') 00756 hltaccepts=array.array('I') 00757 prescales=array.array('I') 00758 pathnameclob=','.join(pathnames) 00759 del q 00760 session.transaction().commit() 00761 return [pathnameclob,hltdict] 00762 except: 00763 raise
def queryDataSource::hltFromRuninfoV3 | ( | session, | |
runnumber | |||
) |
input: output: [datasource,pathnameclob,{cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}] select distinct(pathid) from HLT_SUPERVISOR_TRIGGERPATHS where runnnumber=:runnumber; select count(*) from HLT_SUPERVISOR_LUMISECTIONS_V3 where runnumber=:runnumber;//total ls 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; loop : select pathname from cms_hlt.paths where pathid=:pathid
Definition at line 764 of file queryDataSource.py.
00765 : 00766 ''' 00767 input: 00768 output: [datasource,pathnameclob,{cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}] 00769 select distinct(pathid) from HLT_SUPERVISOR_TRIGGERPATHS where runnnumber=:runnumber; 00770 select count(*) from HLT_SUPERVISOR_LUMISECTIONS_V3 where runnumber=:runnumber;//total ls 00771 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; 00772 loop : 00773 select pathname from cms_hlt.paths where pathid=:pathid 00774 ''' 00775 pass
def queryDataSource::runsummary | ( | session, | |
schemaname, | |||
runnumber, | |||
complementalOnly = False |
|||
) |
x select string_value from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.TRG:TSC_KEY'; x select distinct(string_value) from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.SCAL:AMODEtag' x select distinct(string_value),session_id from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.SCAL:EGEV' order by SESSION_ID select string_value from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.LVL0:SEQ_NAME' select string_value from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.LVL0:HLT_KEY_DESCRIPTION'; select string_value from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.SCAL:FILLN' and rownum<=1; select time from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.LVL0:START_TIME_T'; select time from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.LVL0:STOP_TIME_T'; input: output:[l1key,amodetag,egev,sequence,hltkey,fillnum,starttime,stoptime] if complementalOnly: [l1key,amodetag,egev]
Definition at line 821 of file queryDataSource.py.
00822 : 00823 ''' 00824 x select string_value from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.TRG:TSC_KEY'; 00825 x select distinct(string_value) from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.SCAL:AMODEtag' 00826 x select distinct(string_value),session_id from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.SCAL:EGEV' order by SESSION_ID 00827 00828 select string_value from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.LVL0:SEQ_NAME' 00829 select string_value from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.LVL0:HLT_KEY_DESCRIPTION'; 00830 select string_value from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.SCAL:FILLN' and rownum<=1; 00831 select time from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.LVL0:START_TIME_T'; 00832 select time from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.LVL0:STOP_TIME_T'; 00833 input: 00834 output:[l1key,amodetag,egev,sequence,hltkey,fillnum,starttime,stoptime] 00835 if complementalOnly: 00836 [l1key,amodetag,egev] 00837 ''' 00838 runsessionparameterTable='' 00839 result=[] 00840 l1key='' 00841 amodetag='' 00842 egev='' 00843 hltkey='' 00844 fillnum='' 00845 sequence='' 00846 starttime='' 00847 stoptime='' 00848 try: 00849 session.transaction().start(True) 00850 runinfoschema=session.schema(schemaname) 00851 l1keyQuery=runinfoschema.newQuery() 00852 l1keyQuery.addToTableList('RUNSESSION_PARAMETER') 00853 l1keyOutput=coral.AttributeList() 00854 l1keyOutput.extend('l1key','string') 00855 l1keyCondition=coral.AttributeList() 00856 l1keyCondition.extend('name','string') 00857 l1keyCondition.extend('runnumber','unsigned int') 00858 l1keyCondition['name'].setData('CMS.TRG:TSC_KEY') 00859 l1keyCondition['runnumber'].setData(int(runnumber)) 00860 l1keyQuery.addToOutputList('STRING_VALUE') 00861 l1keyQuery.setCondition('NAME=:name AND RUNNUMBER=:runnumber',l1keyCondition) 00862 l1keyQuery.defineOutput(l1keyOutput) 00863 cursor=l1keyQuery.execute() 00864 while cursor.next(): 00865 l1key=cursor.currentRow()['l1key'].data() 00866 del l1keyQuery 00867 result.append(l1key) 00868 00869 amodetagQuery=runinfoschema.newQuery() 00870 amodetagQuery.addToTableList('RUNSESSION_PARAMETER') 00871 amodetagOutput=coral.AttributeList() 00872 amodetagOutput.extend('amodetag','string') 00873 amodetagCondition=coral.AttributeList() 00874 amodetagCondition.extend('name','string') 00875 amodetagCondition.extend('runnumber','unsigned int') 00876 amodetagCondition['name'].setData('CMS.SCAL:AMODEtag') 00877 amodetagCondition['runnumber'].setData(int(runnumber)) 00878 amodetagQuery.addToOutputList('distinct(STRING_VALUE)') 00879 amodetagQuery.setCondition('NAME=:name AND RUNNUMBER=:runnumber',amodetagCondition) 00880 amodetagQuery.limitReturnedRows(1) 00881 amodetagQuery.defineOutput(amodetagOutput) 00882 cursor=amodetagQuery.execute() 00883 while cursor.next(): 00884 amodetag=cursor.currentRow()['amodetag'].data() 00885 del amodetagQuery 00886 result.append(amodetag) 00887 00888 egevQuery=runinfoschema.newQuery() 00889 egevQuery.addToTableList('RUNSESSION_PARAMETER') 00890 egevOutput=coral.AttributeList() 00891 egevOutput.extend('egev','string') 00892 egevCondition=coral.AttributeList() 00893 egevCondition.extend('name','string') 00894 egevCondition.extend('runnumber','unsigned int') 00895 egevCondition['name'].setData('CMS.SCAL:EGEV') 00896 egevCondition['runnumber'].setData(int(runnumber)) 00897 egevQuery.addToOutputList('distinct(STRING_VALUE)') 00898 egevQuery.addToOutputList('SESSION_ID') 00899 egevQuery.setCondition('NAME=:name AND RUNNUMBER=:runnumber',egevCondition) 00900 egevQuery.defineOutput(egevOutput) 00901 egevQuery.addToOrderList('SESSION_ID') 00902 cursor=egevQuery.execute() 00903 while cursor.next(): 00904 egev=cursor.currentRow()['egev'].data() 00905 del egevQuery 00906 result.append(egev) 00907 00908 if not complementalOnly: 00909 seqQuery=runinfoschema.newQuery() 00910 seqQuery.addToTableList('RUNSESSION_PARAMETER') 00911 seqOutput=coral.AttributeList() 00912 seqOutput.extend('seq','string') 00913 seqCondition=coral.AttributeList() 00914 seqCondition.extend('name','string') 00915 seqCondition.extend('runnumber','unsigned int') 00916 seqCondition['name'].setData('CMS.LVL0:SEQ_NAME') 00917 seqCondition['runnumber'].setData(int(runnumber)) 00918 seqQuery.addToOutputList('STRING_VALUE') 00919 seqQuery.setCondition('NAME=:name AND RUNNUMBER=:runnumber',seqCondition) 00920 seqQuery.defineOutput(seqOutput) 00921 cursor=seqQuery.execute() 00922 while cursor.next(): 00923 sequence=cursor.currentRow()['seq'].data() 00924 del seqQuery 00925 result.append(sequence) 00926 00927 hltkeyQuery=runinfoschema.newQuery() 00928 hltkeyQuery.addToTableList('RUNSESSION_PARAMETER') 00929 hltkeyOutput=coral.AttributeList() 00930 hltkeyOutput.extend('hltkey','string') 00931 hltkeyCondition=coral.AttributeList() 00932 hltkeyCondition.extend('name','string') 00933 hltkeyCondition.extend('runnumber','unsigned int') 00934 hltkeyCondition['name'].setData('CMS.LVL0:HLT_KEY_DESCRIPTION') 00935 hltkeyCondition['runnumber'].setData(int(runnumber)) 00936 hltkeyQuery.addToOutputList('STRING_VALUE') 00937 hltkeyQuery.setCondition('NAME=:name AND RUNNUMBER=:runnumber',hltkeyCondition) 00938 #hltkeyQuery.limitReturnedRows(1) 00939 hltkeyQuery.defineOutput(hltkeyOutput) 00940 cursor=hltkeyQuery.execute() 00941 while cursor.next(): 00942 hltkey=cursor.currentRow()['hltkey'].data() 00943 del hltkeyQuery 00944 result.append(hltkey) 00945 00946 fillnumQuery=runinfoschema.newQuery() 00947 fillnumQuery.addToTableList('RUNSESSION_PARAMETER') 00948 fillnumOutput=coral.AttributeList() 00949 fillnumOutput.extend('fillnum','string') 00950 fillnumCondition=coral.AttributeList() 00951 fillnumCondition.extend('name','string') 00952 fillnumCondition.extend('runnumber','unsigned int') 00953 fillnumCondition['name'].setData('CMS.SCAL:FILLN') 00954 fillnumCondition['runnumber'].setData(int(runnumber)) 00955 fillnumQuery.addToOutputList('STRING_VALUE') 00956 fillnumQuery.setCondition('NAME=:name AND RUNNUMBER=:runnumber',fillnumCondition) 00957 fillnumQuery.limitReturnedRows(1) 00958 fillnumQuery.defineOutput(fillnumOutput) 00959 cursor=fillnumQuery.execute() 00960 while cursor.next(): 00961 fillnum=cursor.currentRow()['fillnum'].data() 00962 del fillnumQuery 00963 result.append(fillnum) 00964 00965 starttimeQuery=runinfoschema.newQuery() 00966 starttimeQuery.addToTableList('RUNSESSION_PARAMETER') 00967 starttimeOutput=coral.AttributeList() 00968 starttimeOutput.extend('starttime','time stamp') 00969 starttimeCondition=coral.AttributeList() 00970 starttimeCondition.extend('name','string') 00971 starttimeCondition.extend('runnumber','unsigned int') 00972 starttimeCondition['name'].setData('CMS.LVL0:START_TIME_T') 00973 starttimeCondition['runnumber'].setData(int(runnumber)) 00974 starttimeQuery.addToOutputList('TIME') 00975 starttimeQuery.setCondition('NAME=:name AND RUNNUMBER=:runnumber',starttimeCondition) 00976 starttimeQuery.defineOutput(starttimeOutput) 00977 cursor=starttimeQuery.execute() 00978 while cursor.next(): 00979 starttime=cursor.currentRow()['starttime'].data() 00980 del starttimeQuery 00981 result.append(starttime) 00982 00983 stoptimeQuery=runinfoschema.newQuery() 00984 stoptimeQuery.addToTableList('RUNSESSION_PARAMETER') 00985 stoptimeOutput=coral.AttributeList() 00986 stoptimeOutput.extend('stoptime','time stamp') 00987 stoptimeCondition=coral.AttributeList() 00988 stoptimeCondition.extend('name','string') 00989 stoptimeCondition.extend('runnumber','unsigned int') 00990 stoptimeCondition['name'].setData('CMS.LVL0:STOP_TIME_T') 00991 stoptimeCondition['runnumber'].setData(int(runnumber)) 00992 stoptimeQuery.addToOutputList('TIME') 00993 stoptimeQuery.setCondition('NAME=:name AND RUNNUMBER=:runnumber',stoptimeCondition) 00994 stoptimeQuery.defineOutput(stoptimeOutput) 00995 cursor=stoptimeQuery.execute() 00996 while cursor.next(): 00997 stoptime=cursor.currentRow()['stoptime'].data() 00998 del stoptimeQuery 00999 result.append(stoptime) 01000 session.transaction().commit() 01001 else: 01002 session.transaction().commit() 01003 return result 01004 except: 01005 raise
def queryDataSource::trgFromNewGT | ( | session, | |
runnumber | |||
) |
select counts,lsnr,algobit from cms_gt_mon.gt_mon_trig_algo_view where runnr=:runnumber order by lsnr,algobit select counts,lsnr,techbit from cms_gt_mon.gt_mon_trig_tech_view where runnr=:runnumber order by lsnr,techbit select counts,lsnr from cms_gt_mon.gt_mon_trig_dead_view where runnr=:runnumber and deadcounter=:countername order by lsnr select algo_index,alias from cms_gt.gt_run_algo_view where runnumber=:runnumber order by algo_index select techtrig_index,name from cms_gt.gt_run_tech_view where runnumber=:runnumber order by techtrig_index 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; 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;
Definition at line 303 of file queryDataSource.py.
00304 : 00305 ''' 00306 select counts,lsnr,algobit from cms_gt_mon.gt_mon_trig_algo_view where runnr=:runnumber order by lsnr,algobit 00307 select counts,lsnr,techbit from cms_gt_mon.gt_mon_trig_tech_view where runnr=:runnumber order by lsnr,techbit 00308 select counts,lsnr from cms_gt_mon.gt_mon_trig_dead_view where runnr=:runnumber and deadcounter=:countername order by lsnr 00309 select algo_index,alias from cms_gt.gt_run_algo_view where runnumber=:runnumber order by algo_index 00310 select techtrig_index,name from cms_gt.gt_run_tech_view where runnumber=:runnumber order by techtrig_index 00311 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; 00312 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; 00313 ''' 00314 pass
def queryDataSource::trgFromOldGT | ( | session, | |
runnumber | |||
) |
input: runnumber output: [bitnameclob,{cmslsnum:[deadtime,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]}] 1. select counts,lsnr from cms_gt_mon.gt_mon_trig_dead_view where runnr=:runnumber and deadcounter=:countername order by lsnr 2. select counts,lsnr,algobit from cms_gt_mon.gt_mon_trig_algo_view where runnr=:runnumber order by lsnr,algobit 3. select counts,lsnr,techbit from cms_gt_mon.gt_mon_trig_tech_view where runnr=:runnumber order by lsnr,techbit 4. select algo_index,alias from cms_gt.gt_run_algo_view where runnumber=:runnumber order by algo_index ## not needed5. select techtrig_index,name from cms_gt.gt_run_tech_view where runnumber=:runnumber order by techtrig_index 5 select distinct(prescale_index) from cms_gt_mon.lumi_sections where run_number=:runnumber; 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; 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; 8. select lumi_section,prescale_index from cms_gt_mon.lumi_sections where run_number=:runnumber order by lumi_section
Definition at line 315 of file queryDataSource.py.
00316 : 00317 ''' 00318 input: runnumber 00319 output: [bitnameclob,{cmslsnum:[deadtime,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]}] 00320 1. select counts,lsnr from cms_gt_mon.gt_mon_trig_dead_view where runnr=:runnumber and deadcounter=:countername order by lsnr 00321 2. select counts,lsnr,algobit from cms_gt_mon.gt_mon_trig_algo_view where runnr=:runnumber order by lsnr,algobit 00322 3. select counts,lsnr,techbit from cms_gt_mon.gt_mon_trig_tech_view where runnr=:runnumber order by lsnr,techbit 00323 4. select algo_index,alias from cms_gt.gt_run_algo_view where runnumber=:runnumber order by algo_index 00324 ## not needed5. select techtrig_index,name from cms_gt.gt_run_tech_view where runnumber=:runnumber order by techtrig_index 00325 5 select distinct(prescale_index) from cms_gt_mon.lumi_sections where run_number=:runnumber; 00326 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; 00327 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; 00328 8. select lumi_section,prescale_index from cms_gt_mon.lumi_sections where run_number=:runnumber order by lumi_section 00329 00330 ''' 00331 result=[] 00332 deadtimeresult={}#{cmslsnum:deadtime} 00333 NAlgoBit=128 #0-127 00334 NTechBit=64 #0-63 00335 algocount={}#{cmslsnum:[algocounts]} 00336 techcount={}#{cmslsnum:[techcounts]} 00337 bitnames=[] 00338 bitzerocountDict={} 00339 bitzeroprescaleDict={} 00340 perlsdict={}#{cmslsnum:[deadtime,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]} 00341 prescaleDict={} #{prescale_index:[[algo_prescale_factors][tech_prescale_factors]]} 00342 prescaleResult={}#{lsnumber:[algo_prescale_factors,tech_prescale_factors]} 00343 try: 00344 session.transaction().start(True) 00345 gtmonschema=session.schema('CMS_GT_MON') 00346 # 00347 # select counts,lsnr from cms_gt_mon.gt_mon_trig_dead_view where runnr=:runnumber and deadcounter=:countername order by lsnr 00348 # 00349 deadviewQuery=gtmonschema.newQuery() 00350 deadviewQuery.addToTableList('GT_MON_TRIG_DEAD_VIEW') 00351 deadOutput=coral.AttributeList() 00352 deadOutput.extend('counts','unsigned int') 00353 deadOutput.extend('lsnr','unsigned int') 00354 deadviewQuery.addToOutputList('counts') 00355 deadviewQuery.addToOutputList('lsnr') 00356 bindVariablesDead=coral.AttributeList() 00357 bindVariablesDead.extend('runnumber','int') 00358 bindVariablesDead.extend('countername','string') 00359 bindVariablesDead['runnumber'].setData(int(runnumber)) 00360 bindVariablesDead['countername'].setData('DeadtimeBeamActive') 00361 deadviewQuery.setCondition('RUNNR=:runnumber AND DEADCOUNTER=:countername',bindVariablesDead) 00362 deadviewQuery.addToOrderList('lsnr') 00363 deadviewQuery.defineOutput(deadOutput) 00364 deadcursor=deadviewQuery.execute() 00365 s=0 00366 while deadcursor.next(): 00367 row=deadcursor.currentRow() 00368 s+=1 00369 lsnr=row['lsnr'].data() 00370 while s!=lsnr: 00371 print 'DEADTIME alert: found hole in LS range' 00372 print ' fill deadtimebeamactive 0 for LS '+str(s) 00373 deadtimeresult[s]=0 00374 s+=1 00375 count=row['counts'].data() 00376 deadtimeresult[s]=count 00377 if s==0: 00378 deadcursor.close() 00379 del deadviewQuery 00380 session.transaction().commit() 00381 raise 'requested run '+str(runnumber )+' does not exist for deadcounts' 00382 del deadviewQuery 00383 #print 'deadtimeresult ',deadtimeresult 00384 mybitcount_algo=[] 00385 algoviewQuery=gtmonschema.newQuery() 00386 # 00387 # select counts,lsnr,algobit from cms_gt_mon.gt_mon_trig_algo_view where runnr=:runnumber order by lsnr,algobit 00388 # 00389 algoviewQuery.addToTableList('GT_MON_TRIG_ALGO_VIEW') 00390 algoOutput=coral.AttributeList() 00391 algoOutput.extend('counts','unsigned int') 00392 algoOutput.extend('lsnr','unsigned int') 00393 algoOutput.extend('algobit','unsigned int') 00394 algoviewQuery.addToOutputList('counts') 00395 algoviewQuery.addToOutputList('lsnr') 00396 algoviewQuery.addToOutputList('algobit') 00397 algoCondition=coral.AttributeList() 00398 algoCondition.extend('runnumber','unsigned int') 00399 algoCondition['runnumber'].setData(int(runnumber)) 00400 algoviewQuery.setCondition('RUNNR=:runnumber',algoCondition) 00401 algoviewQuery.addToOrderList('lsnr') 00402 algoviewQuery.addToOrderList('algobit') 00403 algoviewQuery.defineOutput(algoOutput) 00404 00405 algocursor=algoviewQuery.execute() 00406 s=0 00407 while algocursor.next(): 00408 row=algocursor.currentRow() 00409 lsnr=row['lsnr'].data() 00410 counts=row['counts'].data() 00411 algobit=row['algobit'].data() 00412 mybitcount_algo.append(counts) 00413 if algobit==0: 00414 bitzerocountDict[lsnr]=counts 00415 if algobit==NAlgoBit-1: 00416 s+=1 00417 while s!=lsnr: 00418 print 'ALGO COUNT alert: found hole in LS range' 00419 print ' fill all algocount 0 for LS '+str(s) 00420 tmpzero=[0]*NAlgoBit 00421 algocount[s]=tmpzero 00422 s+=1 00423 algocount[s]=mybitcount_algo 00424 mybitcount_algo=[] 00425 if s==0: 00426 algocursor.close() 00427 del algoviewQuery 00428 session.transaction().commit() 00429 raise 'requested run '+str(runnumber+' does not exist for algocounts ') 00430 del algoviewQuery 00431 00432 mybitcount_tech=[] 00433 techviewQuery=gtmonschema.newQuery() 00434 techviewQuery.addToTableList('GT_MON_TRIG_TECH_VIEW') 00435 # 00436 # select counts,lsnr,techbit from cms_gt_mon.gt_mon_trig_tech_view where runnr=:runnumber order by lsnr,techbit 00437 # 00438 techOutput=coral.AttributeList() 00439 techOutput.extend('counts','unsigned int') 00440 techOutput.extend('lsnr','unsigned int') 00441 techOutput.extend('techbit','unsigned int') 00442 techviewQuery.addToOutputList('COUNTS','counts') 00443 techviewQuery.addToOutputList('LSNR','lsnr') 00444 techviewQuery.addToOutputList('TECHBIT','techbit') 00445 techCondition=coral.AttributeList() 00446 techCondition.extend('runnumber','unsigned int') 00447 techCondition['runnumber'].setData(int(runnumber)) 00448 techviewQuery.setCondition('RUNNR=:runnumber',techCondition) 00449 techviewQuery.addToOrderList('lsnr') 00450 techviewQuery.addToOrderList('techbit') 00451 techviewQuery.defineOutput(techOutput) 00452 00453 techcursor=techviewQuery.execute() 00454 s=0 00455 while techcursor.next(): 00456 row=techcursor.currentRow() 00457 lsnr=row['lsnr'].data() 00458 counts=row['counts'].data() 00459 techbit=row['techbit'].data() 00460 mybitcount_tech.append(counts) 00461 if techbit==NTechBit-1: 00462 s+=1 00463 while s!=lsnr: 00464 print 'TECH COUNT alert: found hole in LS range' 00465 print ' fill all techcount 0 for LS '+str(s) 00466 tmpzero=[0]*NTechBit 00467 techcount[s]=tmpzero 00468 s+=1 00469 techcount[s]=mybitcount_tech 00470 mybitcount_tech=[] 00471 if s==0: 00472 techcursor.close() 00473 del techviewQuery 00474 session.transaction().commit() 00475 raise 'requested run '+str(runnumber+' does not exist for techcounts ') 00476 del techviewQuery 00477 00478 gtschema=session.schema('CMS_GT') 00479 triggernamemap={} 00480 namealiasQuery=gtschema.newQuery() 00481 # 00482 # select algo_index,alias from cms_gt.gt_run_algo_view where runnumber=:runnumber 00483 # 00484 triggernamemap={} 00485 namealiasQuery.addToTableList('GT_RUN_ALGO_VIEW') 00486 algonameOutput=coral.AttributeList() 00487 algonameOutput.extend('algo_index','unsigned int') 00488 algonameOutput.extend('alias','string') 00489 namealiasQuery.addToOutputList('algo_index') 00490 namealiasQuery.addToOutputList('alias') 00491 algonameCondition=coral.AttributeList() 00492 algonameCondition.extend('runnumber','unsigned int') 00493 algonameCondition['runnumber'].setData(int(runnumber)) 00494 namealiasQuery.setCondition('RUNNUMBER=:runnumber',algonameCondition) 00495 namealiasQuery.defineOutput(algonameOutput) 00496 algonamecursor=namealiasQuery.execute() 00497 while algonamecursor.next(): 00498 row=algonamecursor.currentRow() 00499 algo_index=row['algo_index'].data() 00500 algo_name=row['alias'].data() 00501 triggernamemap[algo_index]=algo_name 00502 del namealiasQuery 00503 00504 #techtriggernamemap={} 00505 #technamealiasQuery=gtschema.newQuery() 00506 # 00507 # select techtrig_index,name from cms_gt.gt_run_tech_view where runnumber=:runnumber 00508 # 00509 # this queryis unnecessary 00510 #technamealiasQuery.addToTableList('GT_RUN_TECH_VIEW') 00511 #technameOutput=coral.AttributeList() 00512 #technameOutput.extend('techtrig_index','unsigned int') 00513 #technameOutput.extend('name','string') 00514 #technamealiasQuery.addToOutputList('techtrig_index') 00515 #technamealiasQuery.addToOutputList('name') 00516 #technameCondition=coral.AttributeList() 00517 #technameCondition.extend('runnumber','unsigned int') 00518 #technameCondition['runnumber'].setData(int(runnumber)) 00519 #technamealiasQuery.setCondition('RUNNUMBER=:runnumber',technameCondition) 00520 #technamealiasQuery.defineOutput(technameOutput) 00521 #technamecursor=technamealiasQuery.execute() 00522 #while technamecursor.next(): 00523 #row=technamecursor.currentRow() 00524 #techtrig_index=row['techtrig_index'].data() 00525 #tech_name=row['name'].data() 00526 #techtriggernamemap[techtrig_index]=tech_name 00527 #del technamealiasQuery 00528 # 00529 # reprocess Algo name result filling unallocated trigger bit with string "False" 00530 # 00531 for algoidx in range(NAlgoBit): 00532 if algoidx in triggernamemap.keys(): 00533 bitnames.append(triggernamemap[algoidx]) 00534 else: 00535 bitnames.append('False') 00536 # 00537 # reprocess Tech name 00538 # 00539 for techidx in range(NTechBit): 00540 bitnames.append(str(techidx)) 00541 bitnameclob=','.join(bitnames) 00542 # 00543 # select distinct(prescale_index) from cms_gt_mon.lumi_sections where run_number=:runnumber; 00544 # 00545 prescaleidx=[] 00546 presidxQuery=gtmonschema.newQuery() 00547 presidxQuery.addToTableList('LUMI_SECTIONS') 00548 00549 presidxBindVariable=coral.AttributeList() 00550 presidxBindVariable.extend('runnumber','int') 00551 presidxBindVariable['runnumber'].setData(int(runnumber)) 00552 00553 presidxOutput=coral.AttributeList() 00554 presidxOutput.extend('prescale_index','int') 00555 presidxQuery.addToOutputList('distinct(PRESCALE_INDEX)','prescale_index') 00556 presidxQuery.defineOutput(presidxOutput) 00557 presidxQuery.setCondition('RUN_NUMBER=:runnumber',presidxBindVariable) 00558 presidxCursor=presidxQuery.execute() 00559 while presidxCursor.next(): 00560 presc=presidxCursor.currentRow()['prescale_index'].data() 00561 prescaleidx.append(presc) 00562 #print prescaleidx 00563 del presidxQuery 00564 # 00565 # 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; 00566 # 00567 for prescaleindex in prescaleidx: 00568 algoprescQuery=gtschema.newQuery() 00569 algoprescQuery.addToTableList('GT_RUN_PRESC_ALGO_VIEW') 00570 algoPrescOutput=coral.AttributeList() 00571 algoprescBase='PRESCALE_FACTOR_ALGO_' 00572 for bitidx in range(NAlgoBit): 00573 algopresc=algoprescBase+str(bitidx).zfill(3) 00574 algoPrescOutput.extend(algopresc,'unsigned int') 00575 algoprescQuery.addToOutputList(algopresc) 00576 PrescbindVariable=coral.AttributeList() 00577 PrescbindVariable.extend('runnumber','int') 00578 PrescbindVariable.extend('prescaleindex','int') 00579 PrescbindVariable['runnumber'].setData(int(runnumber)) 00580 PrescbindVariable['prescaleindex'].setData(prescaleindex) 00581 algoprescQuery.setCondition('RUNNR=:runnumber AND PRESCALE_INDEX=:prescaleindex',PrescbindVariable) 00582 algoprescQuery.defineOutput(algoPrescOutput) 00583 algopresccursor=algoprescQuery.execute() 00584 while algopresccursor.next(): 00585 row=algopresccursor.currentRow() 00586 algoprescale=[] 00587 for bitidx in range(NAlgoBit): 00588 algopresc=algoprescBase+str(bitidx).zfill(3) 00589 algoprescale.append(row[algopresc].data()) 00590 prescaleDict[prescaleindex]=algoprescale 00591 del algoprescQuery 00592 00593 # 00594 # 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; 00595 # 00596 for prescaleindex in prescaleidx: 00597 techprescQuery=gtschema.newQuery() 00598 techprescQuery.addToTableList('GT_RUN_PRESC_TECH_VIEW') 00599 techPrescOutput=coral.AttributeList() 00600 techprescBase='PRESCALE_FACTOR_TT_' 00601 for bitidx in range(NTechBit): 00602 techpresc=techprescBase+str(bitidx).zfill(3) 00603 techPrescOutput.extend(techpresc,'unsigned int') 00604 techprescQuery.addToOutputList(techpresc) 00605 PrescbindVariable=coral.AttributeList() 00606 PrescbindVariable.extend('runnumber','int') 00607 PrescbindVariable.extend('prescaleindex','int') 00608 PrescbindVariable['runnumber'].setData(int(runnumber)) 00609 PrescbindVariable['prescaleindex'].setData(prescaleindex) 00610 techprescQuery.setCondition('RUNNR=:runnumber AND PRESCALE_INDEX=:prescaleindex',PrescbindVariable) 00611 techprescQuery.defineOutput(techPrescOutput) 00612 techpresccursor=techprescQuery.execute() 00613 while techpresccursor.next(): 00614 row=techpresccursor.currentRow() 00615 techprescale=[] 00616 for bitidx in range(NTechBit): 00617 techpresc=techprescBase+str(bitidx).zfill(3) 00618 techprescale.append(row[techpresc].data()) 00619 prescaleDict[prescaleindex]+=techprescale 00620 del techprescQuery 00621 #print prescaleDict 00622 # 00623 #select lumi_section,prescale_index from cms_gt_mon.lumi_sections where run_number=:runnumber 00624 # 00625 lumiprescQuery=gtmonschema.newQuery() 00626 lumiprescQuery.addToTableList('LUMI_SECTIONS') 00627 00628 lumiprescBindVariable=coral.AttributeList() 00629 lumiprescBindVariable.extend('runnumber','int') 00630 lumiprescBindVariable['runnumber'].setData(int(runnumber)) 00631 00632 lumiprescOutput=coral.AttributeList() 00633 lumiprescOutput.extend('lumisection','int') 00634 lumiprescOutput.extend('prescale_index','int') 00635 lumiprescQuery.addToOutputList('LUMI_SECTION') 00636 lumiprescQuery.addToOutputList('PRESCALE_INDEX') 00637 lumiprescQuery.defineOutput(lumiprescOutput) 00638 lumiprescQuery.setCondition('RUN_NUMBER=:runnumber',lumiprescBindVariable) 00639 lumiprescCursor=lumiprescQuery.execute() 00640 while lumiprescCursor.next(): 00641 row=lumiprescCursor.currentRow() 00642 lumisection=row['lumisection'].data() 00643 psindex=row['prescale_index'].data() 00644 bitzeroprescale=prescaleDict[psindex][0] 00645 bitzeroprescaleDict[lumisection]=prescaleDict[psindex][0] 00646 prescaleResult[lumisection]=prescaleDict[psindex] 00647 #print prescaleResult 00648 del lumiprescQuery 00649 #return result 00650 session.transaction().commit() 00651 # 00652 #assemble result 00653 # 00654 for cmslsnum,deadcount in deadtimeresult.items(): 00655 bitzerocount=bitzerocountDict[cmslsnum] 00656 bitzeroprescale=bitzeroprescaleDict[cmslsnum] 00657 trgcounts=array.array('I') 00658 for acounts in algocount[cmslsnum]: 00659 trgcounts.append(acounts) 00660 for tcounts in techcount[cmslsnum]: 00661 trgcounts.append(tcounts) 00662 trgcountBlob=CommonUtil.packArraytoBlob(trgcounts) 00663 trgprescale=array.array('I') 00664 for aprescale in prescaleResult[cmslsnum]: 00665 trgprescale.append(aprescale) 00666 trgprescaleBlob=CommonUtil.packArraytoBlob(trgprescale) 00667 perlsdict[cmslsnum]=[deadcount,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob] 00668 result=[bitnameclob,perlsdict] 00669 return result 00670 except: 00671 session.transaction().rollback() 00672 del session 00673 raise
def queryDataSource::trgFromOldLumi | ( | session, | |
runnumber | |||
) |
select bitnum,bitname from trg where runnum=:runnumber and cmslsnum=1 order by bitnum select cmslsnum,deadtime,trgcount,prescale from trg where bitnum=:bitnum and runnum=:runnumber input: runnumber output: [bitnames,{cmslsnum,[deadtime,bitzerocount,bitzerpoprescale,trgcountBlob,trgprescaleBlob]}]
Definition at line 209 of file queryDataSource.py.
00210 : 00211 ''' 00212 select bitnum,bitname from trg where runnum=:runnumber and cmslsnum=1 order by bitnum 00213 select cmslsnum,deadtime,trgcount,prescale from trg where bitnum=:bitnum and runnum=:runnumber 00214 input: runnumber 00215 output: [bitnames,{cmslsnum,[deadtime,bitzerocount,bitzerpoprescale,trgcountBlob,trgprescaleBlob]}] 00216 ''' 00217 session.transaction().start(True) 00218 lumischema=session.nominalSchema() 00219 qHandle=lumischema.newQuery() 00220 try: 00221 qHandle=lumischema.newQuery() 00222 qHandle.addToTableList(nameDealer.trgTableName()) 00223 qHandle.addToOutputList('BITNUM','bitnum') 00224 qHandle.addToOutputList('BITNAME','bitname') 00225 qCondition=coral.AttributeList() 00226 qCondition.extend('runnum','unsigned int') 00227 qCondition['runnum'].setData(int(runnumber)) 00228 qCondition.extend('cmslsnum','unsigned int') 00229 qCondition['cmslsnum'].setData(int(1)) 00230 qResult=coral.AttributeList() 00231 qResult.extend('bitnum','unsigned int') 00232 qResult.extend('bitname','string') 00233 qHandle.defineOutput(qResult) 00234 qHandle.setCondition('RUNNUM=:runnum AND CMSLSNUM=:cmslsnum',qCondition) 00235 qHandle.addToOrderList('BITNUM') 00236 cursor=qHandle.execute() 00237 bitnums=[] 00238 bitnameList=[] 00239 while cursor.next(): 00240 bitnum=cursor.currentRow()['bitnum'].data() 00241 bitname=cursor.currentRow()['bitname'].data() 00242 bitnums.append(bitnum) 00243 bitnameList.append(bitname) 00244 del qHandle 00245 bitnames=','.join(bitnameList) 00246 databuffer={} 00247 nbits=len(bitnums) 00248 qHandle=lumischema.newQuery() 00249 qHandle.addToTableList(nameDealer.trgTableName()) 00250 qHandle.addToOutputList('CMSLSNUM','cmslsnum') 00251 qHandle.addToOutputList('BITNUM','bitnum') 00252 qHandle.addToOutputList('DEADTIME','deadtime') 00253 qHandle.addToOutputList('TRGCOUNT','trgcount') 00254 qHandle.addToOutputList('PRESCALE','prescale') 00255 qCondition=coral.AttributeList() 00256 qCondition.extend('runnum','unsigned int') 00257 qCondition['runnum'].setData(int(runnumber)) 00258 qResult=coral.AttributeList() 00259 qResult.extend('cmslsnum','unsigned int') 00260 qResult.extend('bitnum','unsigned int') 00261 qResult.extend('deadtime','unsigned long long') 00262 qResult.extend('trgcount','unsigned int') 00263 qResult.extend('prescale','unsigned int') 00264 qHandle.defineOutput(qResult) 00265 qHandle.setCondition('RUNNUM=:runnum',qCondition) 00266 qHandle.addToOrderList('CMSLSNUM') 00267 qHandle.addToOrderList('BITNUM') 00268 cursor=qHandle.execute() 00269 trgcountArray=array.array('I') 00270 prescaleArray=array.array('I') 00271 while cursor.next(): 00272 cmslsnum=cursor.currentRow()['cmslsnum'].data() 00273 bitnum=cursor.currentRow()['bitnum'].data() 00274 deadtime=cursor.currentRow()['deadtime'].data() 00275 trgcount=cursor.currentRow()['trgcount'].data() 00276 prescale=cursor.currentRow()['prescale'].data() 00277 if not databuffer.has_key(cmslsnum): 00278 databuffer[cmslsnum]=[] 00279 databuffer[cmslsnum].append(deadtime) 00280 if bitnum==0: 00281 databuffer[cmslsnum].append(trgcount) 00282 databuffer[cmslsnum].append(prescale) 00283 trgcountArray.append(trgcount) 00284 prescaleArray.append(prescale) 00285 if bitnum==nbits-1: 00286 trgcountBlob=CommonUtil.packArraytoBlob(trgcountArray) 00287 prescaleBlob=CommonUtil.packArraytoBlob(prescaleArray) 00288 databuffer[cmslsnum].append(trgcountBlob) 00289 databuffer[cmslsnum].append(prescaleBlob) 00290 trgcountArray=array.array('I') 00291 prescaleArray=array.array('I') 00292 del qHandle 00293 session.transaction().commit() 00294 return [bitnames,databuffer] 00295 except: 00296 del qHandle 00297 raise
def queryDataSource::trgFromWBM | ( | session, | |
runnumber | |||
) |
def queryDataSource::uncalibratedlumiFromOldLumi | ( | session, | |
runnumber | |||
) |
retrieve old lumi value, divide by norm and restore to raw value select lumilsnum,cmslsnum,instlumi,instlumierror,instlumiquality,startorbit,numorbit,beamenergy,beamstatus,cmsbxindexblob,beamintensityblob_1,beamintensityblob_2 from lumisummary where runnum=:runnumber order by lumilsnum 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 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]}]} dict size ~ 200mb for 1000LS
Definition at line 19 of file queryDataSource.py.
00020 : 00021 ''' 00022 retrieve old lumi value, divide by norm and restore to raw value 00023 select lumilsnum,cmslsnum,instlumi,instlumierror,instlumiquality,startorbit,numorbit,beamenergy,beamstatus,cmsbxindexblob,beamintensityblob_1,beamintensityblob_2 from lumisummary where runnum=:runnumber order by lumilsnum 00024 00025 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 00026 00027 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]}]} 00028 dict size ~ 200mb for 1000LS 00029 ''' 00030 nTotAlgo=3 00031 try: 00032 datadict={} 00033 session.transaction().start(True) 00034 lumischema=session.nominalSchema() 00035 summaryQuery=lumischema.newQuery() 00036 summaryQuery.addToTableList( nameDealer.lumisummaryTableName() ) 00037 summaryQuery.addToOutputList( 'LUMILSNUM','lumilsnum') 00038 summaryQuery.addToOutputList( 'CMSLSNUM','cmslsnum') 00039 summaryQuery.addToOutputList( 'INSTLUMI','instlumi') 00040 summaryQuery.addToOutputList( 'INSTLUMIERROR','instlumierror') 00041 summaryQuery.addToOutputList( 'INSTLUMIQUALITY','instlumiquality') 00042 summaryQuery.addToOutputList( 'BEAMSTATUS','beamstatus') 00043 summaryQuery.addToOutputList( 'BEAMENERGY','beamenergy') 00044 summaryQuery.addToOutputList( 'NUMORBIT','numorbit') 00045 summaryQuery.addToOutputList( 'STARTORBIT','startorbit') 00046 summaryQuery.addToOutputList( 'CMSBXINDEXBLOB','cmsbxindexblob') 00047 summaryQuery.addToOutputList( 'BEAMINTENSITYBLOB_1','beamintensityblob_1') 00048 summaryQuery.addToOutputList( 'BEAMINTENSITYBLOB_2','beamintensityblob_2') 00049 summaryCondition=coral.AttributeList() 00050 summaryCondition.extend('runnumber','unsigned int') 00051 summaryCondition['runnumber'].setData(int(runnumber)) 00052 summaryResult=coral.AttributeList() 00053 summaryResult.extend('lumilsnum','unsigned int') 00054 summaryResult.extend('cmslsnum','unsigned int') 00055 summaryResult.extend('instlumi','float') 00056 summaryResult.extend('instlumierror','float') 00057 summaryResult.extend('instlumiquality','short') 00058 summaryResult.extend('beamstatus','string') 00059 summaryResult.extend('beamenergy','float') 00060 summaryResult.extend('numorbit','unsigned int') 00061 summaryResult.extend('startorbit','unsigned int') 00062 summaryResult.extend('cmsbxindexblob','blob') 00063 summaryResult.extend('beamintensityblob_1','blob') 00064 summaryResult.extend('beamintensityblob_2','blob') 00065 summaryQuery.defineOutput(summaryResult) 00066 summaryQuery.addToOrderList('lumilsnum') 00067 summaryQuery.setCondition('RUNNUM=:runnumber',summaryCondition) 00068 summarycursor=summaryQuery.execute() 00069 while summarycursor.next(): 00070 lumilsnum=summarycursor.currentRow()['lumilsnum'].data() 00071 cmslsnum=summarycursor.currentRow()['cmslsnum'].data() 00072 instlumi=summarycursor.currentRow()['instlumi'].data() 00073 instlumierror=summarycursor.currentRow()['instlumierror'].data() 00074 instlumiquality=summarycursor.currentRow()['instlumiquality'].data() 00075 (uncalibratedinstlumi,uncalibratedinstlumierror)=uncalibrateLumi(runnumber,instlumi,instlumierror) 00076 numorbit=summarycursor.currentRow()['numorbit'].data() 00077 startorbit=summarycursor.currentRow()['startorbit'].data() 00078 beamenergy=summarycursor.currentRow()['beamenergy'].data() 00079 beamstatus=summarycursor.currentRow()['beamstatus'].data() 00080 cmsbxindexblob=None 00081 if not summarycursor.currentRow()['cmsbxindexblob'].isNull(): 00082 cmsbxindexblob=summarycursor.currentRow()['cmsbxindexblob'].data() 00083 beamintensityblob_1=None 00084 if not summarycursor.currentRow()['beamintensityblob_1'].isNull(): 00085 beamintensityblob_1=summarycursor.currentRow()['beamintensityblob_1'].data() 00086 beamintensityblob_2=None 00087 if not summarycursor.currentRow()['beamintensityblob_2'].isNull(): 00088 beamintensityblob_2=summarycursor.currentRow()['beamintensityblob_2'].data() 00089 datadict[lumilsnum]=[cmslsnum,uncalibratedinstlumi,uncalibratedinstlumierror,instlumiquality,beamstatus,beamenergy,numorbit,startorbit,cmsbxindexblob,beamintensityblob_1,beamintensityblob_2] 00090 del summaryQuery 00091 #print datadict 00092 for algoname in ['OCC1','OCC2','ET']: 00093 detailQuery=lumischema.newQuery() 00094 detailQuery.addToTableList( nameDealer.lumisummaryTableName(),'s' ) 00095 detailQuery.addToTableList( nameDealer.lumidetailTableName(),'d' ) 00096 detailQuery.addToOutputList('s.LUMILSNUM','lumilsnum' ) 00097 detailQuery.addToOutputList('d.BXLUMIVALUE','bxlumivalue' ) 00098 detailQuery.addToOutputList('d.BXLUMIERROR','bxlumierror' ) 00099 detailQuery.addToOutputList('d.BXLUMIQUALITY','bxlumiquality' ) 00100 detailCondition=coral.AttributeList() 00101 detailCondition.extend('runnumber','unsigned int') 00102 detailCondition.extend('algoname','string') 00103 detailCondition['runnumber'].setData(int(runnumber)) 00104 detailCondition['algoname'].setData(algoname) 00105 detailResult=coral.AttributeList() 00106 detailResult.extend('lumilsnum','unsigned int') 00107 detailResult.extend('bxlumivalue','blob') 00108 detailResult.extend('bxlumierror','blob') 00109 detailResult.extend('bxlumiquality','blob') 00110 detailQuery.defineOutput(detailResult) 00111 detailQuery.addToOrderList('lumilsnum') 00112 detailQuery.setCondition('s.RUNNUM=:runnumber AND s.LUMISUMMARY_ID=d.LUMISUMMARY_ID AND d.ALGONAME=:algoname',detailCondition) 00113 detailcursor=detailQuery.execute() 00114 while detailcursor.next(): 00115 lumilsnum=detailcursor.currentRow()['lumilsnum'].data() 00116 bxlumivalue=detailcursor.currentRow()['bxlumivalue'].data() 00117 bxlumierror=detailcursor.currentRow()['bxlumierror'].data() 00118 bxlumiquality=detailcursor.currentRow()['bxlumiquality'].data() 00119 datadict[lumilsnum].extend([bxlumivalue,bxlumierror,bxlumiquality]) 00120 del detailQuery 00121 session.transaction().commit() 00122 return datadict 00123 except : raise
def queryDataSource::uncalibrateLumi | ( | runnumber, | |
instlumi, | |||
instlumierror | |||
) |
input: runnumber,calibrated instlumi,calibrated instlumierror output: (uncalibrated instlumi, uncalbrated instlumierror)
Definition at line 4 of file queryDataSource.py.
00005 : 00006 ''' 00007 input: runnumber,calibrated instlumi,calibrated instlumierror 00008 output: (uncalibrated instlumi, uncalbrated instlumierror) 00009 ''' 00010 normpp7tev=float(6370.0) 00011 normpp900gev=float(16500.0) 00012 normhi7tev=float(2.383) 00013 oldnormpp7tev=float(6330) 00014 if runnumber in [136290,136294,136297,134721,134725]:#900Gev pp runs 00015 return (float(instlumi)/normpp900gev,float(instlumierror)/normpp900gev) 00016 if runnumber >=150431 and runnumber<=153368 :#7TeV HI runs 00017 return (float(instlumi)/normhi7tev,float(instlumierror)/normhi7tev) 00018 return (float(instlumi)/normpp7tev,float(instlumierror)/normpp7tev)
tuple queryDataSource::session = svc.openSession(isReadOnly=True,cpp2sqltype=[('unsigned int','NUMBER(10)'),('unsigned long long','NUMBER(20)')]) |
Definition at line 1024 of file queryDataSource.py.
tuple queryDataSource::svc = sessionManager.sessionManager('oracle://cms_orcoff_prod/cms_lumi_prod',authpath='/afs/cern.ch/user/x/xiezhen',debugON=False) |
Definition at line 1023 of file queryDataSource.py.