CMS 3D CMS Logo

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

Functions

def main
 

Variables

string VERSION = '1.02'
 

Function Documentation

def dumpPrescale.main ( )

Definition at line 7 of file dumpPrescale.py.

References lumiQueryAPI.allruns(), python.multivaluedict.append(), lumiQueryAPI.hltBypathByrun(), lumiQueryAPI.hlttrgMappingByrun(), join(), and lumiQueryAPI.trgBybitnameByrun().

7 
8 def main():
9  parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),description="Dump Prescale info for selected hltpath and trg path",formatter_class=argparse.ArgumentDefaultsHelpFormatter)
10  parser.add_argument('-c',dest='connect',action='store',help='connect string to lumiDB,optional',default='frontier://LumiCalc/CMS_LUMI_PROD')
11  parser.add_argument('-P',dest='authpath',action='store',help='path to authentication file')
12  parser.add_argument('-r',dest='runnumber',action='store',help='run number')
13  parser.add_argument('-hltpath',dest='hltpath',action='store',required=True,help='hltpath')
14  parser.add_argument('-trgbits',dest='trgbits',action='store',help='trgbits',default='all')
15  parser.add_argument('-siteconfpath',dest='siteconfpath',action='store',help='specific path to site-local-config.xml file, optional. If path undefined, fallback to cern proxy&server')
16  parser.add_argument('--debug',dest='debug',action='store_true',help='debug')
17  args=parser.parse_args()
18  runnumber=args.runnumber
19  if args.authpath and len(args.authpath)!=0:
20  os.environ['CORAL_AUTH_PATH']=args.authpath
21  parameters = lumiQueryAPI.ParametersObject()
22  session,svc = lumiQueryAPI.setupSession (args.connect or \
23  'frontier://LumiCalc/CMS_LUMI_PROD',
24  args.siteconfpath,parameters,args.debug)
25  session.transaction().start(True)
26  schema=session.nominalSchema()
27  runlist=[]
28  if args.debug:
29  msg=coral.MessageStream('')
30  msg.setMsgVerbosity(coral.message_Level_Debug)
31  if args.runnumber:
32  runlist.append(int(args.runnumber))
33  else:
34  runlist=lumiQueryAPI.allruns(schema,True,True,True,True)
35  runlist.sort()
36  bitlist=[]
37  hltpathStr=re.sub('\s','',args.hltpath)
38  #print bitlistStr
39  if args.trgbits and args.trgbits!='all':
40  bitlistStr=args.trgbits
41  bitlistStr=bitlistStr.strip()
42  bitlistStr=re.sub('\s','',bitlistStr)
43  bitlist=bitlistStr.split(',')
44  result={}#{run:{hltpath:prescle},{trgname:prescale}}
45  trgdict={}#{run:[(trgname,trgprescale),()]}
46  hltdict={}#{run:{hltname:hltprescale}}
47  for runnum in runlist:
48  q=schema.newQuery()
49  hltdump=lumiQueryAPI.hltBypathByrun(q,runnum,hltpathStr)
50  del q
51  if len(hltdump)>0:
52  hltdict[runnum]=hltdump[1][-1]
53  else:
54  print 'run ',runnum,' hltpath ','"'+hltpathStr+'"','not found'
55  continue
56  if not args.trgbits or args.trgbits=='all':
57  q=schema.newQuery()
58  l1seeds = lumiQueryAPI.hlttrgMappingByrun(q,runnum)
59  del q
60  if len(l1seeds)==0 or not l1seeds.has_key(hltpathStr):
61  print 'hlt path',hltpathStr,'has no l1 seed'
62  continue
63  l1seed=l1seeds[hltpathStr]
64  rmQuotes=l1seed.replace('\"','')
65  rmOR=rmQuotes.replace(' OR','')
66  rmNOT=rmOR.replace(' NOT','')
67  rmAND=rmOR.replace(' AND','')
68  bitlist=rmAND.split(' ')
69  if not trgdict.has_key(runnum):
70  trgdict[runnum]=[]
71  for bitname in bitlist:
72  q=schema.newQuery()
73  trgbitdump=lumiQueryAPI.trgBybitnameByrun(q,runnum,bitname)
74  del q
75  if len(trgbitdump)>0:
76  trgprescale=trgbitdump[1][-1]
77  trgdict[runnum].append((bitname,trgprescale))
78  else:
79  print 'run ',runnum,' bit ','"'+bitname+'"',' not found'
80  continue
81  session.transaction().commit()
82  del session
83  del svc
84  if len(hltdict)<1:
85  print 'no result found for',hltpathStr
86  sys.exit(-1)
87  runs=hltdict.keys()
88  runs.sort()
89  for r in runs:
90  if not hltdict.has_key(r): continue
91  hltprescale=hltdict[r]
92  toprint=[str(r),hltpathStr,str(hltprescale)]
93  if trgdict.has_key(r):
94  trgbitsinfo=trgdict[r]
95  for trgbitinfo in trgbitsinfo:
96  trgname=trgbitinfo[0]
97  toprint.append(trgname)
98  trgprescale=trgbitinfo[1]
99  toprint.append(str(trgprescale))
100  print ' '.join(toprint)
101  #print trgdict
#print hltdict
Definition: start.py:1
def allruns
==============real api=====###
==============temporarilly here======###
Definition: lumiQueryAPI.py:22
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def hlttrgMappingByrun

Variable Documentation

string dumpPrescale.VERSION = '1.02'

Definition at line 2 of file dumpPrescale.py.