test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions | Variables
queryDataSource Namespace Reference

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)
 

Function Documentation

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.

777 def hltconf(session,hltkey):
778  '''
779  select paths.pathid,paths.name,stringparamvalues.value from stringparamvalues,paths,parameters,superidparameterassoc,modules,moduletemplates,pathmoduleassoc,configurationpathassoc,configurations where parameters.paramid=stringparamvalues.paramid and superidparameterassoc.paramid=parameters.paramid and modules.superid=superidparameterassoc.superid and moduletemplates.superid=modules.templateid and pathmoduleassoc.moduleid=modules.superid and paths.pathid=pathmoduleassoc.pathid and configurationpathassoc.pathid=paths.pathid and configurations.configid=configurationpathassoc.configid and moduletemplates.name='HLTLevel1GTSeed' and parameters.name='L1SeedsLogicalExpression' and configurations.configdescriptor=:hlt_description;
780  select paths.pathid,paths.name,stringparamvalues.value from stringparamvalues,paths,parameters,superidparameterassoc,modules,moduletemplates,pathmoduleassoc,configurationpathassoc,configurations where parameters.paramid=stringparamvalues.paramid and superidparameterassoc.paramid=parameters.paramid and modules.superid=superidparameterassoc.superid and moduletemplates.superid=modules.templateid and pathmoduleassoc.moduleid=modules.superid and paths.pathid=pathmoduleassoc.pathid and configurationpathassoc.pathid=paths.pathid and configurations.configid=configurationpathassoc.configid and moduletemplates.name='HLTLevel1GTSeed' and parameters.name='L1SeedsLogicalExpression' and configurations.configid=:hlt_numkey;
781  ##select paths.pathid from cms_hlt.paths paths,cms_hlt.configurations config where config.configdescriptor=' ' and name=:pathname
782  '''
783  try:
784  session.transaction().start(True)
785  hltconfschema=session.nominalSchema()
786  hltconfQuery=hltconfschema.newQuery()
787 
788  hltconfQuery.addToOutputList('PATHS.NAME','hltpath')
789  hltconfQuery.addToOutputList('STRINGPARAMVALUES.VALUE','l1expression')
790 
791  hltconfQuery.addToTableList('PATHS')
792  hltconfQuery.addToTableList('STRINGPARAMVALUES')
793  hltconfQuery.addToTableList('PARAMETERS')
794  hltconfQuery.addToTableList('SUPERIDPARAMETERASSOC')
795  hltconfQuery.addToTableList('MODULES')
796  hltconfQuery.addToTableList('MODULETEMPLATES')
797  hltconfQuery.addToTableList('PATHMODULEASSOC')
798  hltconfQuery.addToTableList('CONFIGURATIONPATHASSOC')
799  hltconfQuery.addToTableList('CONFIGURATIONS')
800 
801  hltconfBindVar=coral.AttributeList()
802  hltconfBindVar.extend('hltseed','string')
803  hltconfBindVar.extend('l1seedexpr','string')
804  hltconfBindVar.extend('hltkey','string')
805  hltconfBindVar['hltseed'].setData('HLTLevel1GTSeed')
806  hltconfBindVar['l1seedexpr'].setData('L1SeedsLogicalExpression')
807  hltconfBindVar['hltkey'].setData(hltkey)
808  hltconfQuery.setCondition('PARAMETERS.PARAMID=STRINGPARAMVALUES.PARAMID AND SUPERIDPARAMETERASSOC.PARAMID=PARAMETERS.PARAMID AND MODULES.SUPERID=SUPERIDPARAMETERASSOC.SUPERID AND MODULETEMPLATES.SUPERID=MODULES.TEMPLATEID AND PATHMODULEASSOC.MODULEID=MODULES.SUPERID AND PATHS.PATHID=PATHMODULEASSOC.PATHID AND CONFIGURATIONPATHASSOC.PATHID=PATHS.PATHID AND CONFIGURATIONS.CONFIGID=CONFIGURATIONPATHASSOC.CONFIGID AND MODULETEMPLATES.NAME=:hltseed AND PARAMETERS.NAME=:l1seedexpr AND CONFIGURATIONS.CONFIGDESCRIPTOR=:hltkey',hltconfBindVar)
809  hlt2l1map={}
810  cursor=hltconfQuery.execute()
811  while next(cursor):
812  hltpath=cursor.currentRow()['hltpath'].data()
813  print hltpath
814  l1expression=cursor.currentRow()['l1expression'].data()
815  hlt2l1map[hltpath]=l1expression
816  del hltconfQuery
817  session.transaction().commit()
818  return hlt2l1map
819  except:
820  raise
Definition: start.py:1
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.

References AlCaHLTBitMon_QueryRunRegistry.data, nameDealer.hltTableName(), join(), GetRecoTauVFromDQM_MC_cff.next, and CommonUtil.packArraytoBlob().

125 def hltFromOldLumi(session,runnumber):
126  '''
127  select count(distinct pathname) from hlt where runnum=:runnum
128  select cmslsnum,pathname,inputcount,acceptcount,prescale from hlt where runnum=:runnum order by cmslsnum,pathname
129  [pathnames,databuffer]
130  databuffer: {cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}
131  '''
132  try:
133  databuffer={}
134  session.transaction().start(True)
135  lumischema=session.nominalSchema()
136  npath=0
137  qHandle=lumischema.newQuery()
138  qHandle.addToTableList( nameDealer.hltTableName() )
139  qHandle.addToOutputList('COUNT(DISTINCT PATHNAME)','npath')
140  qCondition=coral.AttributeList()
141  qCondition.extend('runnum','unsigned int')
142  qCondition['runnum'].setData(int(runnumber))
143  qResult=coral.AttributeList()
144  qResult.extend('npath','unsigned int')
145  qHandle.defineOutput(qResult)
146  qHandle.setCondition('RUNNUM=:runnum',qCondition)
147  cursor=qHandle.execute()
148  while next(cursor):
149  npath=cursor.currentRow()['npath'].data()
150  del qHandle
151  #print 'npath ',npath
152 
153  qHandle=lumischema.newQuery()
154  qHandle.addToTableList( nameDealer.hltTableName() )
155  qHandle.addToOutputList('CMSLSNUM','cmslsnum')
156  qHandle.addToOutputList('PATHNAME','pathname')
157  qHandle.addToOutputList('INPUTCOUNT','inputcount')
158  qHandle.addToOutputList('ACCEPTCOUNT','acceptcount')
159  qHandle.addToOutputList('PRESCALE','prescale')
160  qCondition=coral.AttributeList()
161  qCondition.extend('runnum','unsigned int')
162  qCondition['runnum'].setData(int(runnumber))
163  qResult=coral.AttributeList()
164  qResult.extend('cmslsnum','unsigned int')
165  qResult.extend('pathname','string')
166  qResult.extend('inputcount','unsigned int')
167  qResult.extend('acceptcount','unsigned int')
168  qResult.extend('prescale','unsigned int')
169  qHandle.defineOutput(qResult)
170  qHandle.setCondition('RUNNUM=:runnum',qCondition)
171  qHandle.addToOrderList('cmslsnum')
172  qHandle.addToOrderList('pathname')
173  cursor=qHandle.execute()
174  pathnameList=[]
175  inputcountArray=array.array('I')
176  acceptcountArray=array.array('I')
177  prescaleArray=array.array('I')
178  ipath=0
179  pathnHLT_PixelTracksVdMames=''
180  while next(cursor):
181  cmslsnum=cursor.currentRow()['cmslsnum'].data()
182  pathname=cursor.currentRow()['pathname'].data()
183  ipath+=1
184  inputcount=cursor.currentRow()['inputcount'].data()
185  acceptcount=cursor.currentRow()['acceptcount'].data()
186  prescale=cursor.currentRow()['prescale'].data()
187  pathnameList.append(pathname)
188  inputcountArray.append(inputcount)
189  acceptcountArray.append(acceptcount)
190  prescaleArray.append(prescale)
191  if ipath==npath:
192  if cmslsnum==1:
193  pathnames=','.join(pathnameList)
194  inputcountBlob=CommonUtil.packArraytoBlob(inputcountArray)
195  acceptcountBlob=CommonUtil.packArraytoBlob(acceptcountArray)
196  prescaleBlob=CommonUtil.packArraytoBlob(prescaleArray)
197  databuffer[cmslsnum]=[inputcountBlob,acceptcountBlob,prescaleBlob]
198  pathnameList=[]
199  inputcountArray=array.array('I')
200  acceptcountArray=array.array('I')
201  prescaleArray=array.array('I')
202  ipath=0
203  del qHandle
204  session.transaction().commit()
205  #print 'pathnames ',pathnames
206  return [pathnames,databuffer]
207  except :
208  raise
Definition: start.py:1
def hltTableName
Definition: nameDealer.py:55
def packArraytoBlob
Definition: CommonUtil.py:220
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
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.

References AlCaHLTBitMon_QueryRunRegistry.data, join(), GetRecoTauVFromDQM_MC_cff.next, and CommonUtil.packArraytoBlob().

675 def hltFromRuninfoV2(session,runnumber):
676  '''
677  input:
678  output: [pathnameclob,{cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}]
679  select count(distinct PATHNAME) as npath from HLT_SUPERVISOR_LUMISECTIONS_V2 where runnr=:runnumber and lsnumber=1;
680  select l.pathname,l.lsnumber,l.l1pass,l.paccept,m.psvalue from hlt_supervisor_lumisections_v2 l,hlt_supervisor_scalar_map m where l.runnr=m.runnr and l.psindex=m.psindex and l.pathname=m.pathname and l.runnr=:runnumber order by l.lsnumber
681  '''
682  npaths=0
683  pathnames=[]
684  hltdict={}
685  try:
686  session.transaction().start(True)
687  hltschema=session.schema('CMS_RUNINFO')
688  bvar=coral.AttributeList()
689  bvar.extend('runnumber','unsigned int')
690  bvar.extend('lsnumber','unsigned int')
691  bvar['runnumber'].setData(int(runnumber))
692  bvar['lsnumber'].setData(1)
693  q1=hltschema.newQuery()
694  q1.addToTableList('HLT_SUPERVISOR_LUMISECTIONS_V2')
695  nls=coral.AttributeList()
696  nls.extend('npath','unsigned int')
697  q1.addToOutputList('count(distinct PATHNAME)','npath')
698  q1.setCondition('RUNNR=:runnumber AND LSNUMBER=:lsnumber',bvar)
699  q1.defineOutput(nls)
700  c=q1.execute()
701  while next(c):
702  npath=c.currentRow()['npath'].data()
703  del q1
704  if npath==0:
705  print 'request run is empty, do nothing'
706 
707  q=hltschema.newQuery()
708  bindVar=coral.AttributeList()
709  bindVar.extend('runnumber','unsigned int')
710  bindVar['runnumber'].setData(int(runnumber))
711  q.addToTableList('HLT_SUPERVISOR_LUMISECTIONS_V2','l')
712  q.addToTableList('HLT_SUPERVISOR_SCALAR_MAP','m')
713  q.addToOutputList('l.LSNUMBER','lsnumber')
714  q.addToOutputList('l.PATHNAME','pathname')
715  q.addToOutputList('l.L1PASS','hltinput')
716  q.addToOutputList('l.PACCEPT','hltaccept')
717  q.addToOutputList('m.PSVALUE','prescale')
718  q.setCondition('l.RUNNR=m.RUNNR and l.PSINDEX=m.PSINDEX and l.PATHNAME=m.PATHNAME and l.RUNNR=:runnumber',bindVar)
719  q.addToOrderList('l.LSNUMBER')
720  q.addToOrderList('l.PATHNAME')
721  q.setRowCacheSize(10692)
722  cursor=q.execute()
723  lastLumiSection=1
724  currentLumiSection=0
725  allpaths=[]
726  ipath=0
727  hltinputs=array.array('I')
728  hltaccepts=array.array('I')
729  prescales=array.array('I')
730  while next(cursor):
731  row=cursor.currentRow()
732  cmsluminr=row['lsnumber'].data()
733  hltinput=row['hltinput'].data()
734  hltaccept=row['hltaccept'].data()
735  prescale=row['prescale'].data()
736  pathname=row['pathname'].data()
737  ipath+=1
738  if cmsluminr==1:
739  pathnames.append(pathname)
740  if cmsluminr not in hltdict:
741  hltdict[cmsluminr]=[]
742  hltinputs.append(hltinput)
743  hltaccepts.append(hltaccept)
744  prescales.append(prescale)
745  if ipath==npath:
746  #pack
747  #print 'packing hltinputs ',hltinputs
748  hltinputsBlob=CommonUtil.packArraytoBlob(hltinputs)
749  #print 'packing hltaccepts ',hltaccepts
750  hltacceptsBlob=CommonUtil.packArraytoBlob(hltaccepts)
751  #print 'packing prescales ',prescales
752  prescalesBlob=CommonUtil.packArraytoBlob(prescales)
753  hltdict[cmsluminr].extend([hltinputsBlob,hltacceptsBlob,hltacceptsBlob])
754  ipath=0
755  hltinputs=array.array('I')
756  hltaccepts=array.array('I')
757  prescales=array.array('I')
758  pathnameclob=','.join(pathnames)
759  del q
760  session.transaction().commit()
761  return [pathnameclob,hltdict]
762  except:
763  raise
Definition: start.py:1
def packArraytoBlob
Definition: CommonUtil.py:220
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
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.

765 def hltFromRuninfoV3(session,runnumber):
766  '''
767  input:
768  output: [datasource,pathnameclob,{cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}]
769  select distinct(pathid) from HLT_SUPERVISOR_TRIGGERPATHS where runnnumber=:runnumber;
770  select count(*) from HLT_SUPERVISOR_LUMISECTIONS_V3 where runnumber=:runnumber;//total ls
771  select tr.runnumber,tr.lsnumber,tr.pathid,tr.l1pass,tr.paccept,ls.psindex,sm.psvalue from hlt_supervisor_triggerpaths tr,hlt_supervisor_lumisections_v3 ls,hlt_supervisor_scalar_map_v2 sm where tr.runnumber=ls.runnumber and tr.lsnumber=ls.lsnumber and sm.runnumber=tr.runnumber and sm.pathid=tr.pathid and sm.psindex=ls.psindex and tr.runnumber=:runnumber order by tr.lsnumber;
772  loop :
773  select pathname from cms_hlt.paths where pathid=:pathid
774  '''
775  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.

References AlCaHLTBitMon_QueryRunRegistry.data, and GetRecoTauVFromDQM_MC_cff.next.

822 def runsummary(session,schemaname,runnumber,complementalOnly=False):
823  '''
824  x select string_value from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.TRG:TSC_KEY';
825  x select distinct(string_value) from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.SCAL:AMODEtag'
826  x select distinct(string_value),session_id from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.SCAL:EGEV' order by SESSION_ID
827 
828  select string_value from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.LVL0:SEQ_NAME'
829  select string_value from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.LVL0:HLT_KEY_DESCRIPTION';
830  select string_value from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.SCAL:FILLN' and rownum<=1;
831  select time from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.LVL0:START_TIME_T';
832  select time from cms_runinfo.runsession_parameter where runnumber=:runnumber and name='CMS.LVL0:STOP_TIME_T';
833  input:
834  output:[l1key,amodetag,egev,sequence,hltkey,fillnum,starttime,stoptime]
835  if complementalOnly:
836  [l1key,amodetag,egev]
837  '''
838  runsessionparameterTable=''
839  result=[]
840  l1key=''
841  amodetag=''
842  egev=''
843  hltkey=''
844  fillnum=''
845  sequence=''
846  starttime=''
847  stoptime=''
848  try:
849  session.transaction().start(True)
850  runinfoschema=session.schema(schemaname)
851  l1keyQuery=runinfoschema.newQuery()
852  l1keyQuery.addToTableList('RUNSESSION_PARAMETER')
853  l1keyOutput=coral.AttributeList()
854  l1keyOutput.extend('l1key','string')
855  l1keyCondition=coral.AttributeList()
856  l1keyCondition.extend('name','string')
857  l1keyCondition.extend('runnumber','unsigned int')
858  l1keyCondition['name'].setData('CMS.TRG:TSC_KEY')
859  l1keyCondition['runnumber'].setData(int(runnumber))
860  l1keyQuery.addToOutputList('STRING_VALUE')
861  l1keyQuery.setCondition('NAME=:name AND RUNNUMBER=:runnumber',l1keyCondition)
862  l1keyQuery.defineOutput(l1keyOutput)
863  cursor=l1keyQuery.execute()
864  while next(cursor):
865  l1key=cursor.currentRow()['l1key'].data()
866  del l1keyQuery
867  result.append(l1key)
868 
869  amodetagQuery=runinfoschema.newQuery()
870  amodetagQuery.addToTableList('RUNSESSION_PARAMETER')
871  amodetagOutput=coral.AttributeList()
872  amodetagOutput.extend('amodetag','string')
873  amodetagCondition=coral.AttributeList()
874  amodetagCondition.extend('name','string')
875  amodetagCondition.extend('runnumber','unsigned int')
876  amodetagCondition['name'].setData('CMS.SCAL:AMODEtag')
877  amodetagCondition['runnumber'].setData(int(runnumber))
878  amodetagQuery.addToOutputList('distinct(STRING_VALUE)')
879  amodetagQuery.setCondition('NAME=:name AND RUNNUMBER=:runnumber',amodetagCondition)
880  amodetagQuery.limitReturnedRows(1)
881  amodetagQuery.defineOutput(amodetagOutput)
882  cursor=amodetagQuery.execute()
883  while next(cursor):
884  amodetag=cursor.currentRow()['amodetag'].data()
885  del amodetagQuery
886  result.append(amodetag)
887 
888  egevQuery=runinfoschema.newQuery()
889  egevQuery.addToTableList('RUNSESSION_PARAMETER')
890  egevOutput=coral.AttributeList()
891  egevOutput.extend('egev','string')
892  egevCondition=coral.AttributeList()
893  egevCondition.extend('name','string')
894  egevCondition.extend('runnumber','unsigned int')
895  egevCondition['name'].setData('CMS.SCAL:EGEV')
896  egevCondition['runnumber'].setData(int(runnumber))
897  egevQuery.addToOutputList('distinct(STRING_VALUE)')
898  egevQuery.addToOutputList('SESSION_ID')
899  egevQuery.setCondition('NAME=:name AND RUNNUMBER=:runnumber',egevCondition)
900  egevQuery.defineOutput(egevOutput)
901  egevQuery.addToOrderList('SESSION_ID')
902  cursor=egevQuery.execute()
903  while next(cursor):
904  egev=cursor.currentRow()['egev'].data()
905  del egevQuery
906  result.append(egev)
907 
908  if not complementalOnly:
909  seqQuery=runinfoschema.newQuery()
910  seqQuery.addToTableList('RUNSESSION_PARAMETER')
911  seqOutput=coral.AttributeList()
912  seqOutput.extend('seq','string')
913  seqCondition=coral.AttributeList()
914  seqCondition.extend('name','string')
915  seqCondition.extend('runnumber','unsigned int')
916  seqCondition['name'].setData('CMS.LVL0:SEQ_NAME')
917  seqCondition['runnumber'].setData(int(runnumber))
918  seqQuery.addToOutputList('STRING_VALUE')
919  seqQuery.setCondition('NAME=:name AND RUNNUMBER=:runnumber',seqCondition)
920  seqQuery.defineOutput(seqOutput)
921  cursor=seqQuery.execute()
922  while next(cursor):
923  sequence=cursor.currentRow()['seq'].data()
924  del seqQuery
925  result.append(sequence)
926 
927  hltkeyQuery=runinfoschema.newQuery()
928  hltkeyQuery.addToTableList('RUNSESSION_PARAMETER')
929  hltkeyOutput=coral.AttributeList()
930  hltkeyOutput.extend('hltkey','string')
931  hltkeyCondition=coral.AttributeList()
932  hltkeyCondition.extend('name','string')
933  hltkeyCondition.extend('runnumber','unsigned int')
934  hltkeyCondition['name'].setData('CMS.LVL0:HLT_KEY_DESCRIPTION')
935  hltkeyCondition['runnumber'].setData(int(runnumber))
936  hltkeyQuery.addToOutputList('STRING_VALUE')
937  hltkeyQuery.setCondition('NAME=:name AND RUNNUMBER=:runnumber',hltkeyCondition)
938  #hltkeyQuery.limitReturnedRows(1)
939  hltkeyQuery.defineOutput(hltkeyOutput)
940  cursor=hltkeyQuery.execute()
941  while next(cursor):
942  hltkey=cursor.currentRow()['hltkey'].data()
943  del hltkeyQuery
944  result.append(hltkey)
945 
946  fillnumQuery=runinfoschema.newQuery()
947  fillnumQuery.addToTableList('RUNSESSION_PARAMETER')
948  fillnumOutput=coral.AttributeList()
949  fillnumOutput.extend('fillnum','string')
950  fillnumCondition=coral.AttributeList()
951  fillnumCondition.extend('name','string')
952  fillnumCondition.extend('runnumber','unsigned int')
953  fillnumCondition['name'].setData('CMS.SCAL:FILLN')
954  fillnumCondition['runnumber'].setData(int(runnumber))
955  fillnumQuery.addToOutputList('STRING_VALUE')
956  fillnumQuery.setCondition('NAME=:name AND RUNNUMBER=:runnumber',fillnumCondition)
957  fillnumQuery.limitReturnedRows(1)
958  fillnumQuery.defineOutput(fillnumOutput)
959  cursor=fillnumQuery.execute()
960  while next(cursor):
961  fillnum=cursor.currentRow()['fillnum'].data()
962  del fillnumQuery
963  result.append(fillnum)
964 
965  starttimeQuery=runinfoschema.newQuery()
966  starttimeQuery.addToTableList('RUNSESSION_PARAMETER')
967  starttimeOutput=coral.AttributeList()
968  starttimeOutput.extend('starttime','time stamp')
969  starttimeCondition=coral.AttributeList()
970  starttimeCondition.extend('name','string')
971  starttimeCondition.extend('runnumber','unsigned int')
972  starttimeCondition['name'].setData('CMS.LVL0:START_TIME_T')
973  starttimeCondition['runnumber'].setData(int(runnumber))
974  starttimeQuery.addToOutputList('TIME')
975  starttimeQuery.setCondition('NAME=:name AND RUNNUMBER=:runnumber',starttimeCondition)
976  starttimeQuery.defineOutput(starttimeOutput)
977  cursor=starttimeQuery.execute()
978  while next(cursor):
979  starttime=cursor.currentRow()['starttime'].data()
980  del starttimeQuery
981  result.append(starttime)
982 
983  stoptimeQuery=runinfoschema.newQuery()
984  stoptimeQuery.addToTableList('RUNSESSION_PARAMETER')
985  stoptimeOutput=coral.AttributeList()
986  stoptimeOutput.extend('stoptime','time stamp')
987  stoptimeCondition=coral.AttributeList()
988  stoptimeCondition.extend('name','string')
989  stoptimeCondition.extend('runnumber','unsigned int')
990  stoptimeCondition['name'].setData('CMS.LVL0:STOP_TIME_T')
991  stoptimeCondition['runnumber'].setData(int(runnumber))
992  stoptimeQuery.addToOutputList('TIME')
993  stoptimeQuery.setCondition('NAME=:name AND RUNNUMBER=:runnumber',stoptimeCondition)
994  stoptimeQuery.defineOutput(stoptimeOutput)
995  cursor=stoptimeQuery.execute()
996  while next(cursor):
997  stoptime=cursor.currentRow()['stoptime'].data()
998  del stoptimeQuery
999  result.append(stoptime)
1000  session.transaction().commit()
1001  else:
1002  session.transaction().commit()
1003  return result
1004  except:
1005  raise
Definition: start.py:1
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.

304 def trgFromNewGT(session,runnumber):
305  '''
306  select counts,lsnr,algobit from cms_gt_mon.gt_mon_trig_algo_view where runnr=:runnumber order by lsnr,algobit
307  select counts,lsnr,techbit from cms_gt_mon.gt_mon_trig_tech_view where runnr=:runnumber order by lsnr,techbit
308  select counts,lsnr from cms_gt_mon.gt_mon_trig_dead_view where runnr=:runnumber and deadcounter=:countername order by lsnr
309  select algo_index,alias from cms_gt.gt_run_algo_view where runnumber=:runnumber order by algo_index
310  select techtrig_index,name from cms_gt.gt_run_tech_view where runnumber=:runnumber order by techtrig_index
311  select prescale_factor_algo_000,prescale_factor_algo_001..._127 from cms_gt.gt_run_presc_algo_view where runnr=:runnumber and prescale_index=0;
312  select prescale_factor_tt_000,prescale_factor_tt_001..._63 from cms_gt.gt_run_presc_tech_view where runnr=:runnumber and prescale_index=0;
313  '''
314  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.

316 def trgFromOldGT(session,runnumber):
317  '''
318  input: runnumber
319  output: [bitnameclob,{cmslsnum:[deadtime,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]}]
320  1. select counts,lsnr from cms_gt_mon.gt_mon_trig_dead_view where runnr=:runnumber and deadcounter=:countername order by lsnr
321  2. select counts,lsnr,algobit from cms_gt_mon.gt_mon_trig_algo_view where runnr=:runnumber order by lsnr,algobit
322  3. select counts,lsnr,techbit from cms_gt_mon.gt_mon_trig_tech_view where runnr=:runnumber order by lsnr,techbit
323  4. select algo_index,alias from cms_gt.gt_run_algo_view where runnumber=:runnumber order by algo_index
324  ## not needed5. select techtrig_index,name from cms_gt.gt_run_tech_view where runnumber=:runnumber order by techtrig_index
325  5 select distinct(prescale_index) from cms_gt_mon.lumi_sections where run_number=:runnumber;
326  6. select prescale_factor_algo_000,algo.prescale_factor_algo_001..._127 from cms_gt.gt_run_presc_algo_view where prescale_index=:prescale_index and runnr=:runnumber;
327  7. select prescale_factor_tt_000,tech.prescale_factor_tt_001..._63 from cms_gt.gt_run_presc_tech_view where prescale_index=:prescale_index and runnr=:runnumber;
328  8. select lumi_section,prescale_index from cms_gt_mon.lumi_sections where run_number=:runnumber order by lumi_section
329 
330  '''
331  result=[]
332  deadtimeresult={}#{cmslsnum:deadtime}
333  NAlgoBit=128 #0-127
334  NTechBit=64 #0-63
335  algocount={}#{cmslsnum:[algocounts]}
336  techcount={}#{cmslsnum:[techcounts]}
337  bitnames=[]
338  bitzerocountDict={}
339  bitzeroprescaleDict={}
340  perlsdict={}#{cmslsnum:[deadtime,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]}
341  prescaleDict={} #{prescale_index:[[algo_prescale_factors][tech_prescale_factors]]}
342  prescaleResult={}#{lsnumber:[algo_prescale_factors,tech_prescale_factors]}
343  try:
344  session.transaction().start(True)
345  gtmonschema=session.schema('CMS_GT_MON')
346  #
347  # select counts,lsnr from cms_gt_mon.gt_mon_trig_dead_view where runnr=:runnumber and deadcounter=:countername order by lsnr
348  #
349  deadviewQuery=gtmonschema.newQuery()
350  deadviewQuery.addToTableList('GT_MON_TRIG_DEAD_VIEW')
351  deadOutput=coral.AttributeList()
352  deadOutput.extend('counts','unsigned int')
353  deadOutput.extend('lsnr','unsigned int')
354  deadviewQuery.addToOutputList('counts')
355  deadviewQuery.addToOutputList('lsnr')
356  bindVariablesDead=coral.AttributeList()
357  bindVariablesDead.extend('runnumber','int')
358  bindVariablesDead.extend('countername','string')
359  bindVariablesDead['runnumber'].setData(int(runnumber))
360  bindVariablesDead['countername'].setData('DeadtimeBeamActive')
361  deadviewQuery.setCondition('RUNNR=:runnumber AND DEADCOUNTER=:countername',bindVariablesDead)
362  deadviewQuery.addToOrderList('lsnr')
363  deadviewQuery.defineOutput(deadOutput)
364  deadcursor=deadviewQuery.execute()
365  s=0
366  while next(deadcursor):
367  row=deadcursor.currentRow()
368  s+=1
369  lsnr=row['lsnr'].data()
370  while s!=lsnr:
371  print 'DEADTIME alert: found hole in LS range'
372  print ' fill deadtimebeamactive 0 for LS '+str(s)
373  deadtimeresult[s]=0
374  s+=1
375  count=row['counts'].data()
376  deadtimeresult[s]=count
377  if s==0:
378  deadcursor.close()
379  del deadviewQuery
380  session.transaction().commit()
381  raise 'requested run '+str(runnumber )+' does not exist for deadcounts'
382  del deadviewQuery
383  #print 'deadtimeresult ',deadtimeresult
384  mybitcount_algo=[]
385  algoviewQuery=gtmonschema.newQuery()
386  #
387  # select counts,lsnr,algobit from cms_gt_mon.gt_mon_trig_algo_view where runnr=:runnumber order by lsnr,algobit
388  #
389  algoviewQuery.addToTableList('GT_MON_TRIG_ALGO_VIEW')
390  algoOutput=coral.AttributeList()
391  algoOutput.extend('counts','unsigned int')
392  algoOutput.extend('lsnr','unsigned int')
393  algoOutput.extend('algobit','unsigned int')
394  algoviewQuery.addToOutputList('counts')
395  algoviewQuery.addToOutputList('lsnr')
396  algoviewQuery.addToOutputList('algobit')
397  algoCondition=coral.AttributeList()
398  algoCondition.extend('runnumber','unsigned int')
399  algoCondition['runnumber'].setData(int(runnumber))
400  algoviewQuery.setCondition('RUNNR=:runnumber',algoCondition)
401  algoviewQuery.addToOrderList('lsnr')
402  algoviewQuery.addToOrderList('algobit')
403  algoviewQuery.defineOutput(algoOutput)
404 
405  algocursor=algoviewQuery.execute()
406  s=0
407  while next(algocursor):
408  row=algocursor.currentRow()
409  lsnr=row['lsnr'].data()
410  counts=row['counts'].data()
411  algobit=row['algobit'].data()
412  mybitcount_algo.append(counts)
413  if algobit==0:
414  bitzerocountDict[lsnr]=counts
415  if algobit==NAlgoBit-1:
416  s+=1
417  while s!=lsnr:
418  print 'ALGO COUNT alert: found hole in LS range'
419  print ' fill all algocount 0 for LS '+str(s)
420  tmpzero=[0]*NAlgoBit
421  algocount[s]=tmpzero
422  s+=1
423  algocount[s]=mybitcount_algo
424  mybitcount_algo=[]
425  if s==0:
426  algocursor.close()
427  del algoviewQuery
428  session.transaction().commit()
429  raise 'requested run '+str(runnumber+' does not exist for algocounts ')
430  del algoviewQuery
431 
432  mybitcount_tech=[]
433  techviewQuery=gtmonschema.newQuery()
434  techviewQuery.addToTableList('GT_MON_TRIG_TECH_VIEW')
435  #
436  # select counts,lsnr,techbit from cms_gt_mon.gt_mon_trig_tech_view where runnr=:runnumber order by lsnr,techbit
437  #
438  techOutput=coral.AttributeList()
439  techOutput.extend('counts','unsigned int')
440  techOutput.extend('lsnr','unsigned int')
441  techOutput.extend('techbit','unsigned int')
442  techviewQuery.addToOutputList('COUNTS','counts')
443  techviewQuery.addToOutputList('LSNR','lsnr')
444  techviewQuery.addToOutputList('TECHBIT','techbit')
445  techCondition=coral.AttributeList()
446  techCondition.extend('runnumber','unsigned int')
447  techCondition['runnumber'].setData(int(runnumber))
448  techviewQuery.setCondition('RUNNR=:runnumber',techCondition)
449  techviewQuery.addToOrderList('lsnr')
450  techviewQuery.addToOrderList('techbit')
451  techviewQuery.defineOutput(techOutput)
452 
453  techcursor=techviewQuery.execute()
454  s=0
455  while next(techcursor):
456  row=techcursor.currentRow()
457  lsnr=row['lsnr'].data()
458  counts=row['counts'].data()
459  techbit=row['techbit'].data()
460  mybitcount_tech.append(counts)
461  if techbit==NTechBit-1:
462  s+=1
463  while s!=lsnr:
464  print 'TECH COUNT alert: found hole in LS range'
465  print ' fill all techcount 0 for LS '+str(s)
466  tmpzero=[0]*NTechBit
467  techcount[s]=tmpzero
468  s+=1
469  techcount[s]=mybitcount_tech
470  mybitcount_tech=[]
471  if s==0:
472  techcursor.close()
473  del techviewQuery
474  session.transaction().commit()
475  raise 'requested run '+str(runnumber+' does not exist for techcounts ')
476  del techviewQuery
477 
478  gtschema=session.schema('CMS_GT')
479  triggernamemap={}
480  namealiasQuery=gtschema.newQuery()
481  #
482  # select algo_index,alias from cms_gt.gt_run_algo_view where runnumber=:runnumber
483  #
484  triggernamemap={}
485  namealiasQuery.addToTableList('GT_RUN_ALGO_VIEW')
486  algonameOutput=coral.AttributeList()
487  algonameOutput.extend('algo_index','unsigned int')
488  algonameOutput.extend('alias','string')
489  namealiasQuery.addToOutputList('algo_index')
490  namealiasQuery.addToOutputList('alias')
491  algonameCondition=coral.AttributeList()
492  algonameCondition.extend('runnumber','unsigned int')
493  algonameCondition['runnumber'].setData(int(runnumber))
494  namealiasQuery.setCondition('RUNNUMBER=:runnumber',algonameCondition)
495  namealiasQuery.defineOutput(algonameOutput)
496  algonamecursor=namealiasQuery.execute()
497  while next(algonamecursor):
498  row=algonamecursor.currentRow()
499  algo_index=row['algo_index'].data()
500  algo_name=row['alias'].data()
501  triggernamemap[algo_index]=algo_name
502  del namealiasQuery
503 
504  #techtriggernamemap={}
505  #technamealiasQuery=gtschema.newQuery()
506  #
507  # select techtrig_index,name from cms_gt.gt_run_tech_view where runnumber=:runnumber
508  #
509  # this queryis unnecessary
510  #technamealiasQuery.addToTableList('GT_RUN_TECH_VIEW')
511  #technameOutput=coral.AttributeList()
512  #technameOutput.extend('techtrig_index','unsigned int')
513  #technameOutput.extend('name','string')
514  #technamealiasQuery.addToOutputList('techtrig_index')
515  #technamealiasQuery.addToOutputList('name')
516  #technameCondition=coral.AttributeList()
517  #technameCondition.extend('runnumber','unsigned int')
518  #technameCondition['runnumber'].setData(int(runnumber))
519  #technamealiasQuery.setCondition('RUNNUMBER=:runnumber',technameCondition)
520  #technamealiasQuery.defineOutput(technameOutput)
521  #technamecursor=technamealiasQuery.execute()
522  #while technamecursor.next():
523  #row=technamecursor.currentRow()
524  #techtrig_index=row['techtrig_index'].data()
525  #tech_name=row['name'].data()
526  #techtriggernamemap[techtrig_index]=tech_name
527  #del technamealiasQuery
528  #
529  # reprocess Algo name result filling unallocated trigger bit with string "False"
530  #
531  for algoidx in range(NAlgoBit):
532  if algoidx in triggernamemap.keys():
533  bitnames.append(triggernamemap[algoidx])
534  else:
535  bitnames.append('False')
536  #
537  # reprocess Tech name
538  #
539  for techidx in range(NTechBit):
540  bitnames.append(str(techidx))
541  bitnameclob=','.join(bitnames)
542  #
543  # select distinct(prescale_index) from cms_gt_mon.lumi_sections where run_number=:runnumber;
544  #
545  prescaleidx=[]
546  presidxQuery=gtmonschema.newQuery()
547  presidxQuery.addToTableList('LUMI_SECTIONS')
548 
549  presidxBindVariable=coral.AttributeList()
550  presidxBindVariable.extend('runnumber','int')
551  presidxBindVariable['runnumber'].setData(int(runnumber))
552 
553  presidxOutput=coral.AttributeList()
554  presidxOutput.extend('prescale_index','int')
555  presidxQuery.addToOutputList('distinct(PRESCALE_INDEX)','prescale_index')
556  presidxQuery.defineOutput(presidxOutput)
557  presidxQuery.setCondition('RUN_NUMBER=:runnumber',presidxBindVariable)
558  presidxCursor=presidxQuery.execute()
559  while next(presidxCursor):
560  presc=presidxCursor.currentRow()['prescale_index'].data()
561  prescaleidx.append(presc)
562  #print prescaleidx
563  del presidxQuery
564  #
565  # 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;
566  #
567  for prescaleindex in prescaleidx:
568  algoprescQuery=gtschema.newQuery()
569  algoprescQuery.addToTableList('GT_RUN_PRESC_ALGO_VIEW')
570  algoPrescOutput=coral.AttributeList()
571  algoprescBase='PRESCALE_FACTOR_ALGO_'
572  for bitidx in range(NAlgoBit):
573  algopresc=algoprescBase+str(bitidx).zfill(3)
574  algoPrescOutput.extend(algopresc,'unsigned int')
575  algoprescQuery.addToOutputList(algopresc)
576  PrescbindVariable=coral.AttributeList()
577  PrescbindVariable.extend('runnumber','int')
578  PrescbindVariable.extend('prescaleindex','int')
579  PrescbindVariable['runnumber'].setData(int(runnumber))
580  PrescbindVariable['prescaleindex'].setData(prescaleindex)
581  algoprescQuery.setCondition('RUNNR=:runnumber AND PRESCALE_INDEX=:prescaleindex',PrescbindVariable)
582  algoprescQuery.defineOutput(algoPrescOutput)
583  algopresccursor=algoprescQuery.execute()
584  while next(algopresccursor):
585  row=algopresccursor.currentRow()
586  algoprescale=[]
587  for bitidx in range(NAlgoBit):
588  algopresc=algoprescBase+str(bitidx).zfill(3)
589  algoprescale.append(row[algopresc].data())
590  prescaleDict[prescaleindex]=algoprescale
591  del algoprescQuery
592 
593  #
594  # 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;
595  #
596  for prescaleindex in prescaleidx:
597  techprescQuery=gtschema.newQuery()
598  techprescQuery.addToTableList('GT_RUN_PRESC_TECH_VIEW')
599  techPrescOutput=coral.AttributeList()
600  techprescBase='PRESCALE_FACTOR_TT_'
601  for bitidx in range(NTechBit):
602  techpresc=techprescBase+str(bitidx).zfill(3)
603  techPrescOutput.extend(techpresc,'unsigned int')
604  techprescQuery.addToOutputList(techpresc)
605  PrescbindVariable=coral.AttributeList()
606  PrescbindVariable.extend('runnumber','int')
607  PrescbindVariable.extend('prescaleindex','int')
608  PrescbindVariable['runnumber'].setData(int(runnumber))
609  PrescbindVariable['prescaleindex'].setData(prescaleindex)
610  techprescQuery.setCondition('RUNNR=:runnumber AND PRESCALE_INDEX=:prescaleindex',PrescbindVariable)
611  techprescQuery.defineOutput(techPrescOutput)
612  techpresccursor=techprescQuery.execute()
613  while next(techpresccursor):
614  row=techpresccursor.currentRow()
615  techprescale=[]
616  for bitidx in range(NTechBit):
617  techpresc=techprescBase+str(bitidx).zfill(3)
618  techprescale.append(row[techpresc].data())
619  prescaleDict[prescaleindex]+=techprescale
620  del techprescQuery
621  #print prescaleDict
622  #
623  #select lumi_section,prescale_index from cms_gt_mon.lumi_sections where run_number=:runnumber
624  #
625  lumiprescQuery=gtmonschema.newQuery()
626  lumiprescQuery.addToTableList('LUMI_SECTIONS')
627 
628  lumiprescBindVariable=coral.AttributeList()
629  lumiprescBindVariable.extend('runnumber','int')
630  lumiprescBindVariable['runnumber'].setData(int(runnumber))
631 
632  lumiprescOutput=coral.AttributeList()
633  lumiprescOutput.extend('lumisection','int')
634  lumiprescOutput.extend('prescale_index','int')
635  lumiprescQuery.addToOutputList('LUMI_SECTION')
636  lumiprescQuery.addToOutputList('PRESCALE_INDEX')
637  lumiprescQuery.defineOutput(lumiprescOutput)
638  lumiprescQuery.setCondition('RUN_NUMBER=:runnumber',lumiprescBindVariable)
639  lumiprescCursor=lumiprescQuery.execute()
640  while next(lumiprescCursor):
641  row=lumiprescCursor.currentRow()
642  lumisection=row['lumisection'].data()
643  psindex=row['prescale_index'].data()
644  bitzeroprescale=prescaleDict[psindex][0]
645  bitzeroprescaleDict[lumisection]=prescaleDict[psindex][0]
646  prescaleResult[lumisection]=prescaleDict[psindex]
647  #print prescaleResult
648  del lumiprescQuery
649  #return result
650  session.transaction().commit()
651  #
652  #assemble result
653  #
654  for cmslsnum,deadcount in deadtimeresult.items():
655  bitzerocount=bitzerocountDict[cmslsnum]
656  bitzeroprescale=bitzeroprescaleDict[cmslsnum]
657  trgcounts=array.array('I')
658  for acounts in algocount[cmslsnum]:
659  trgcounts.append(acounts)
660  for tcounts in techcount[cmslsnum]:
661  trgcounts.append(tcounts)
662  trgcountBlob=CommonUtil.packArraytoBlob(trgcounts)
663  trgprescale=array.array('I')
664  for aprescale in prescaleResult[cmslsnum]:
665  trgprescale.append(aprescale)
666  trgprescaleBlob=CommonUtil.packArraytoBlob(trgprescale)
667  perlsdict[cmslsnum]=[deadcount,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]
668  result=[bitnameclob,perlsdict]
669  return result
670  except:
671  session.transaction().rollback()
672  del session
673  raise
Definition: start.py:1
def packArraytoBlob
Definition: CommonUtil.py:220
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
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.

References bitset_utilities.append(), AlCaHLTBitMon_QueryRunRegistry.data, join(), GetRecoTauVFromDQM_MC_cff.next, CommonUtil.packArraytoBlob(), and nameDealer.trgTableName().

210 def trgFromOldLumi(session,runnumber):
211  '''
212  select bitnum,bitname from trg where runnum=:runnumber and cmslsnum=1 order by bitnum
213  select cmslsnum,deadtime,trgcount,prescale from trg where bitnum=:bitnum and runnum=:runnumber
214  input: runnumber
215  output: [bitnames,{cmslsnum,[deadtime,bitzerocount,bitzerpoprescale,trgcountBlob,trgprescaleBlob]}]
216  '''
217  session.transaction().start(True)
218  lumischema=session.nominalSchema()
219  qHandle=lumischema.newQuery()
220  try:
221  qHandle=lumischema.newQuery()
222  qHandle.addToTableList(nameDealer.trgTableName())
223  qHandle.addToOutputList('BITNUM','bitnum')
224  qHandle.addToOutputList('BITNAME','bitname')
225  qCondition=coral.AttributeList()
226  qCondition.extend('runnum','unsigned int')
227  qCondition['runnum'].setData(int(runnumber))
228  qCondition.extend('cmslsnum','unsigned int')
229  qCondition['cmslsnum'].setData(int(1))
230  qResult=coral.AttributeList()
231  qResult.extend('bitnum','unsigned int')
232  qResult.extend('bitname','string')
233  qHandle.defineOutput(qResult)
234  qHandle.setCondition('RUNNUM=:runnum AND CMSLSNUM=:cmslsnum',qCondition)
235  qHandle.addToOrderList('BITNUM')
236  cursor=qHandle.execute()
237  bitnums=[]
238  bitnameList=[]
239  while next(cursor):
240  bitnum=cursor.currentRow()['bitnum'].data()
241  bitname=cursor.currentRow()['bitname'].data()
242  bitnums.append(bitnum)
243  bitnameList.append(bitname)
244  del qHandle
245  bitnames=','.join(bitnameList)
246  databuffer={}
247  nbits=len(bitnums)
248  qHandle=lumischema.newQuery()
249  qHandle.addToTableList(nameDealer.trgTableName())
250  qHandle.addToOutputList('CMSLSNUM','cmslsnum')
251  qHandle.addToOutputList('BITNUM','bitnum')
252  qHandle.addToOutputList('DEADTIME','deadtime')
253  qHandle.addToOutputList('TRGCOUNT','trgcount')
254  qHandle.addToOutputList('PRESCALE','prescale')
255  qCondition=coral.AttributeList()
256  qCondition.extend('runnum','unsigned int')
257  qCondition['runnum'].setData(int(runnumber))
258  qResult=coral.AttributeList()
259  qResult.extend('cmslsnum','unsigned int')
260  qResult.extend('bitnum','unsigned int')
261  qResult.extend('deadtime','unsigned long long')
262  qResult.extend('trgcount','unsigned int')
263  qResult.extend('prescale','unsigned int')
264  qHandle.defineOutput(qResult)
265  qHandle.setCondition('RUNNUM=:runnum',qCondition)
266  qHandle.addToOrderList('CMSLSNUM')
267  qHandle.addToOrderList('BITNUM')
268  cursor=qHandle.execute()
269  trgcountArray=array.array('I')
270  prescaleArray=array.array('I')
271  while next(cursor):
272  cmslsnum=cursor.currentRow()['cmslsnum'].data()
273  bitnum=cursor.currentRow()['bitnum'].data()
274  deadtime=cursor.currentRow()['deadtime'].data()
275  trgcount=cursor.currentRow()['trgcount'].data()
276  prescale=cursor.currentRow()['prescale'].data()
277  if cmslsnum not in databuffer:
278  databuffer[cmslsnum]=[]
279  databuffer[cmslsnum].append(deadtime)
280  if bitnum==0:
281  databuffer[cmslsnum].append(trgcount)
282  databuffer[cmslsnum].append(prescale)
283  trgcountArray.append(trgcount)
284  prescaleArray.append(prescale)
285  if bitnum==nbits-1:
286  trgcountBlob=CommonUtil.packArraytoBlob(trgcountArray)
287  prescaleBlob=CommonUtil.packArraytoBlob(prescaleArray)
288  databuffer[cmslsnum].append(trgcountBlob)
289  databuffer[cmslsnum].append(prescaleBlob)
290  trgcountArray=array.array('I')
291  prescaleArray=array.array('I')
292  del qHandle
293  session.transaction().commit()
294  return [bitnames,databuffer]
295  except:
296  del qHandle
297  raise
Definition: start.py:1
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
def packArraytoBlob
Definition: CommonUtil.py:220
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def trgTableName
Definition: nameDealer.py:52
def queryDataSource.trgFromWBM (   session,
  runnumber 
)
 

Definition at line 298 of file queryDataSource.py.

299 def trgFromWBM(session,runnumber):
300  '''
301  '''
302  pass
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.

References AlCaHLTBitMon_QueryRunRegistry.data, nameDealer.lumidetailTableName(), nameDealer.lumisummaryTableName(), GetRecoTauVFromDQM_MC_cff.next, and uncalibrateLumi().

19 
20 def uncalibratedlumiFromOldLumi(session,runnumber):
21  '''
22  retrieve old lumi value, divide by norm and restore to raw value
23  select lumilsnum,cmslsnum,instlumi,instlumierror,instlumiquality,startorbit,numorbit,beamenergy,beamstatus,cmsbxindexblob,beamintensityblob_1,beamintensityblob_2 from lumisummary where runnum=:runnumber order by lumilsnum
24 
25  select s.lumilsnum,d.bxlumivalue,d.bxlumierror,d.bxlumiquality from lumidetail d,lumisummary s where d.lumisummary_id=s.lumisummary_id and s.runnum=:runnumber and d.algoname=:algoname order by s.lumilsnum
26 
27  output: {lumilsnum:[cmslsnum,uncalibratedinstlumi,uncalibratedinstlumierror,instlumiquality,beamstatus,beamenergy,numorbit,startorbit,cmsbxindexblob,beamintensityblob_1,beamintensityblob_2,bxlumivalue_occ1,bxlumierror_occ1,,bxlumiquality_occ1,bxlumivalue_occ2,bxlumierror_occ2,bxlumiquality_occ2,bxlumivalue_et,bxlumierror_et,bxlumiquality_et]}]}
28  dict size ~ 200mb for 1000LS
29  '''
30  nTotAlgo=3
31  try:
32  datadict={}
33  session.transaction().start(True)
34  lumischema=session.nominalSchema()
35  summaryQuery=lumischema.newQuery()
36  summaryQuery.addToTableList( nameDealer.lumisummaryTableName() )
37  summaryQuery.addToOutputList( 'LUMILSNUM','lumilsnum')
38  summaryQuery.addToOutputList( 'CMSLSNUM','cmslsnum')
39  summaryQuery.addToOutputList( 'INSTLUMI','instlumi')
40  summaryQuery.addToOutputList( 'INSTLUMIERROR','instlumierror')
41  summaryQuery.addToOutputList( 'INSTLUMIQUALITY','instlumiquality')
42  summaryQuery.addToOutputList( 'BEAMSTATUS','beamstatus')
43  summaryQuery.addToOutputList( 'BEAMENERGY','beamenergy')
44  summaryQuery.addToOutputList( 'NUMORBIT','numorbit')
45  summaryQuery.addToOutputList( 'STARTORBIT','startorbit')
46  summaryQuery.addToOutputList( 'CMSBXINDEXBLOB','cmsbxindexblob')
47  summaryQuery.addToOutputList( 'BEAMINTENSITYBLOB_1','beamintensityblob_1')
48  summaryQuery.addToOutputList( 'BEAMINTENSITYBLOB_2','beamintensityblob_2')
49  summaryCondition=coral.AttributeList()
50  summaryCondition.extend('runnumber','unsigned int')
51  summaryCondition['runnumber'].setData(int(runnumber))
52  summaryResult=coral.AttributeList()
53  summaryResult.extend('lumilsnum','unsigned int')
54  summaryResult.extend('cmslsnum','unsigned int')
55  summaryResult.extend('instlumi','float')
56  summaryResult.extend('instlumierror','float')
57  summaryResult.extend('instlumiquality','short')
58  summaryResult.extend('beamstatus','string')
59  summaryResult.extend('beamenergy','float')
60  summaryResult.extend('numorbit','unsigned int')
61  summaryResult.extend('startorbit','unsigned int')
62  summaryResult.extend('cmsbxindexblob','blob')
63  summaryResult.extend('beamintensityblob_1','blob')
64  summaryResult.extend('beamintensityblob_2','blob')
65  summaryQuery.defineOutput(summaryResult)
66  summaryQuery.addToOrderList('lumilsnum')
67  summaryQuery.setCondition('RUNNUM=:runnumber',summaryCondition)
68  summarycursor=summaryQuery.execute()
69  while next(summarycursor):
70  lumilsnum=summarycursor.currentRow()['lumilsnum'].data()
71  cmslsnum=summarycursor.currentRow()['cmslsnum'].data()
72  instlumi=summarycursor.currentRow()['instlumi'].data()
73  instlumierror=summarycursor.currentRow()['instlumierror'].data()
74  instlumiquality=summarycursor.currentRow()['instlumiquality'].data()
75  (uncalibratedinstlumi,uncalibratedinstlumierror)=uncalibrateLumi(runnumber,instlumi,instlumierror)
76  numorbit=summarycursor.currentRow()['numorbit'].data()
77  startorbit=summarycursor.currentRow()['startorbit'].data()
78  beamenergy=summarycursor.currentRow()['beamenergy'].data()
79  beamstatus=summarycursor.currentRow()['beamstatus'].data()
80  cmsbxindexblob=None
81  if not summarycursor.currentRow()['cmsbxindexblob'].isNull():
82  cmsbxindexblob=summarycursor.currentRow()['cmsbxindexblob'].data()
83  beamintensityblob_1=None
84  if not summarycursor.currentRow()['beamintensityblob_1'].isNull():
85  beamintensityblob_1=summarycursor.currentRow()['beamintensityblob_1'].data()
86  beamintensityblob_2=None
87  if not summarycursor.currentRow()['beamintensityblob_2'].isNull():
88  beamintensityblob_2=summarycursor.currentRow()['beamintensityblob_2'].data()
89  datadict[lumilsnum]=[cmslsnum,uncalibratedinstlumi,uncalibratedinstlumierror,instlumiquality,beamstatus,beamenergy,numorbit,startorbit,cmsbxindexblob,beamintensityblob_1,beamintensityblob_2]
90  del summaryQuery
91  #print datadict
92  for algoname in ['OCC1','OCC2','ET']:
93  detailQuery=lumischema.newQuery()
94  detailQuery.addToTableList( nameDealer.lumisummaryTableName(),'s' )
95  detailQuery.addToTableList( nameDealer.lumidetailTableName(),'d' )
96  detailQuery.addToOutputList('s.LUMILSNUM','lumilsnum' )
97  detailQuery.addToOutputList('d.BXLUMIVALUE','bxlumivalue' )
98  detailQuery.addToOutputList('d.BXLUMIERROR','bxlumierror' )
99  detailQuery.addToOutputList('d.BXLUMIQUALITY','bxlumiquality' )
100  detailCondition=coral.AttributeList()
101  detailCondition.extend('runnumber','unsigned int')
102  detailCondition.extend('algoname','string')
103  detailCondition['runnumber'].setData(int(runnumber))
104  detailCondition['algoname'].setData(algoname)
105  detailResult=coral.AttributeList()
106  detailResult.extend('lumilsnum','unsigned int')
107  detailResult.extend('bxlumivalue','blob')
108  detailResult.extend('bxlumierror','blob')
109  detailResult.extend('bxlumiquality','blob')
110  detailQuery.defineOutput(detailResult)
111  detailQuery.addToOrderList('lumilsnum')
112  detailQuery.setCondition('s.RUNNUM=:runnumber AND s.LUMISUMMARY_ID=d.LUMISUMMARY_ID AND d.ALGONAME=:algoname',detailCondition)
113  detailcursor=detailQuery.execute()
114  while next(detailcursor):
115  lumilsnum=detailcursor.currentRow()['lumilsnum'].data()
116  bxlumivalue=detailcursor.currentRow()['bxlumivalue'].data()
117  bxlumierror=detailcursor.currentRow()['bxlumierror'].data()
118  bxlumiquality=detailcursor.currentRow()['bxlumiquality'].data()
119  datadict[lumilsnum].extend([bxlumivalue,bxlumierror,bxlumiquality])
120  del detailQuery
121  session.transaction().commit()
122  return datadict
123  except :
raise
Definition: start.py:1
def uncalibratedlumiFromOldLumi
def lumisummaryTableName
Definition: nameDealer.py:25
def lumidetailTableName
Definition: nameDealer.py:34
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.

Referenced by uncalibratedlumiFromOldLumi().

4 
5 def uncalibrateLumi(runnumber,instlumi,instlumierror):
6  '''
7  input: runnumber,calibrated instlumi,calibrated instlumierror
8  output: (uncalibrated instlumi, uncalbrated instlumierror)
9  '''
10  normpp7tev=float(6370.0)
11  normpp900gev=float(16500.0)
12  normhi7tev=float(2.383)
13  oldnormpp7tev=float(6330)
14  if runnumber in [136290,136294,136297,134721,134725]:#900Gev pp runs
15  return (float(instlumi)/normpp900gev,float(instlumierror)/normpp900gev)
16  if runnumber >=150431 and runnumber<=153368 :#7TeV HI runs
17  return (float(instlumi)/normhi7tev,float(instlumierror)/normhi7tev)
18  return (float(instlumi)/normpp7tev,float(instlumierror)/normpp7tev)

Variable Documentation

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.