test
CMS 3D CMS Logo

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

Classes

class  constants
 

Functions

def bitzeroForRun
 
def deadcountForRun
 
def main
 

Variables

string VERSION = '1.02'
 

Function Documentation

def dumpTrg.bitzeroForRun (   dbsession,
  c,
  runnum 
)
select lsnr,counts,prescale from CMS_GT_MON.GT_MON_TRIG_ALGO_VIEW where runnr=:runnumber and algobit=:bitnum order by lsnr

Definition at line 18 of file dumpTrg.py.

References data, and GetRecoTauVFromDQM_MC_cff.next.

Referenced by main().

18 
19 def bitzeroForRun(dbsession,c,runnum):
20  '''
21  select lsnr,counts,prescale from CMS_GT_MON.GT_MON_TRIG_ALGO_VIEW where runnr=:runnumber and algobit=:bitnum order by lsnr
22  '''
23  result={}
24  try:
25  dbsession.transaction().start(True)
26  schema=dbsession.schema(c.gtmonschema)
27  if not schema:
28  raise 'cannot connect to schema',c.gtmonschema
29  if not schema.existsView(c.algoviewname):
30  raise 'non-existing view',c.algoviewname
31 
32  bitOutput=coral.AttributeList()
33  bitOutput.extend("lsnr","unsigned int")
34  bitOutput.extend("algocount","unsigned int")
35  bitBindVarList=coral.AttributeList()
36  bitBindVarList.extend("runnumber","unsigned int")
37  bitBindVarList.extend("bitnum","unsigned int")
38  bitBindVarList["runnumber"].setData(int(runnum))
39  bitBindVarList["bitnum"].setData(0)
40 
41  query=schema.newQuery()
42  query.addToTableList(c.algoviewname)
43  query.addToOutputList('LSNR','lsnr')
44  query.addToOutputList('COUNTS','algocount')
45  query.setCondition('RUNNR=:runnumber AND ALGOBIT=:bitnum',bitBindVarList)
46  query.addToOrderList('lsnr')
47  query.defineOutput(bitOutput)
48 
49  cursor=query.execute()
50  while next(cursor):
51  cmslsnum=cursor.currentRow()['lsnr'].data()
52  algocount=cursor.currentRow()['algocount'].data()
53  result[cmslsnum]=algocount
54  del query
55  dbsession.transaction().commit()
56  #print result
57  return result
58  except Exception as e:
59  print str(e)
60  dbsession.transaction().rollback()
61  del dbsession
Definition: start.py:1
def bitzeroForRun
Definition: dumpTrg.py:18
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def dumpTrg.deadcountForRun (   dbsession,
  c,
  runnum 
)
select counts,lsnr from cms_gt_mon.gt_mon_trig_dead_view where runnr=:runnumber and deadcounter=:countername order by lsnr;

Definition at line 62 of file dumpTrg.py.

References data, and GetRecoTauVFromDQM_MC_cff.next.

Referenced by main().

62 
63 def deadcountForRun(dbsession,c,runnum):
64  '''
65  select counts,lsnr from cms_gt_mon.gt_mon_trig_dead_view where runnr=:runnumber and deadcounter=:countername order by lsnr;
66  '''
67  result={}
68  try:
69  dbsession.transaction().start(True)
70  schema=dbsession.schema(c.gtmonschema)
71  if not schema:
72  raise 'cannot connect to schema',c.gtmonschema
73  if not schema.existsView(c.deadviewname):
74  raise 'non-existing view',c.deadviewname
75 
76  deadOutput=coral.AttributeList()
77  deadOutput.extend("lsnr","unsigned int")
78  deadOutput.extend("deadcount","unsigned long long")
79 
80  deadBindVarList=coral.AttributeList()
81  deadBindVarList.extend("runnumber","unsigned int")
82  deadBindVarList.extend("countername","string")
83  deadBindVarList["runnumber"].setData(int(runnum))
84  deadBindVarList["countername"].setData('DeadtimeBeamActive')
85 
86  query=schema.newQuery()
87  query.addToTableList(c.deadviewname)
88  query.addToOutputList('LSNR','lsnr')
89  query.addToOutputList('COUNTS','deadcount')
90  query.setCondition('RUNNR=:runnumber AND DEADCOUNTER=:countername',deadBindVarList)
91  query.addToOrderList('lsnr')
92  query.defineOutput(deadOutput)
93 
94  cursor=query.execute()
95  while next(cursor):
96  cmslsnum=cursor.currentRow()['lsnr'].data()
97  deadcount=cursor.currentRow()['deadcount'].data()
98  result[cmslsnum]=deadcount
99  del query
100  dbsession.transaction().commit()
101  return result
102  except Exception as e:
103  print str(e)
104  dbsession.transaction().rollback()
105  del dbsession
Definition: start.py:1
def deadcountForRun
Definition: dumpTrg.py:62
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def dumpTrg.main ( )

Definition at line 106 of file dumpTrg.py.

References bitzeroForRun(), and deadcountForRun().

107 def main():
108  c=constants()
109  parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),description="Dump GT info")
110  parser.add_argument('-c',dest='connect',action='store',required=True,help='connect string to trigger DB(required)')
111  parser.add_argument('-P',dest='authpath',action='store',required=True,help='path to authentication file')
112  parser.add_argument('-r',dest='runnumber',action='store',required=True,help='run number')
113  parser.add_argument('action',choices=['deadtime','deadfraction'],help='dump deadtime beamacrive count')
114  parser.add_argument('--debug',dest='debug',action='store_true',help='debug')
115  args=parser.parse_args()
116  runnumber=args.runnumber
117  c.gtmondb=args.connect
118  if args.authpath and len(args.authpath)!=0:
119  os.environ['CORAL_AUTH_PATH']=args.authpath
120  svc=coral.ConnectionService()
121  session=svc.connect(c.gtmondb,accessMode=coral.access_ReadOnly)
122  session.typeConverter().setCppTypeForSqlType("unsigned int","NUMBER(10)")
123  session.typeConverter().setCppTypeForSqlType("unsigned long long","NUMBER(20)")
124  if args.debug:
125  msg=coral.MessageStream('')
126  msg.setMsgVerbosity(coral.message_Level_Debug)
127 
128  if args.action == 'deadtime':
129  deadresult=deadcountForRun(session,c,runnumber)
130  if deadresult and len(deadresult)!=0:
131  print 'run',runnumber
132  print 'ls deadcount'
133  for cmsls,deadcount in deadresult.items():
134  print cmsls,deadcount
135  else:
136  print 'no deadtime found for run ',runnumber
137 
138  if args.action == 'deadfraction':
139  deadresult=deadcountForRun(session,c,runnumber)
140  bitzeroresult=bitzeroForRun(session,c,runnumber)
141  if deadresult and len(deadresult)!=0:
142  print 'run',runnumber
143  print 'ls deadfraction'
144  for cmsls,deadcount in deadresult.items():
145  bitzero_count=bitzeroresult[cmsls]
146  bitzero_prescale=1.0
147  if int(runnumber)>=146315:
148  bitzero_prescale=17.0
149  if bitzero_count==0:
150  print cmsls,'no beam'
151  else:
152  print cmsls,'%.5f'%float(float(deadcount)/(float(bitzero_count)*bitzero_prescale))
153  else:
154  print 'no deadtime found for run ',runnumber
155 
156  del session
157  del svc
def deadcountForRun
Definition: dumpTrg.py:62
def main
Definition: dumpTrg.py:106
def bitzeroForRun
Definition: dumpTrg.py:18

Variable Documentation

string dumpTrg.VERSION = '1.02'

Definition at line 2 of file dumpTrg.py.