CMS 3D CMS Logo

dumpFill.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # dump all fills into files.
4 # allfills.txt all the existing fills.
5 # fill_num.txt all the runs in the fill
6 # dumpFill -o outputdir
7 # dumpFill -f fillnum generate runlist for the given fill
8 #
9 from __future__ import print_function
10 import os,os.path,sys
11 import coral
12 from RecoLuminosity.LumiDB import argparse,sessionManager,lumiCalcAPI
13 MINFILL=1800
14 MAXFILL=9999
15 allfillname='allfills.txt'
16 
17 def tofiles(allfills,runsperfill,runtimes,outdir):
18  f=open(os.path.join(outdir,allfillname),'w')
19  for fill in allfills:
20  print('%d'%(fill), file=f)
21  f.close()
22  for fill,runs in runsperfill.items():
23  filename='fill_'+str(fill)+'.txt'
24  if len(runs)!=0:
25  f=open(os.path.join(outdir,filename),'w')
26  for run in runs:
27  print('%d,%s'%(run,runtimes[run]), file=f)
28  f.close()
29 if __name__ == '__main__':
30  parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),description = "Dump Fill",formatter_class=argparse.ArgumentDefaultsHelpFormatter)
31  # parse arguments
32  parser.add_argument('-c',dest='connect',action='store',required=False,help='connect string to lumiDB,optional',default='frontier://LumiCalc/CMS_LUMI_PROD')
33  parser.add_argument('-P',dest='authpath',action='store',help='path to authentication file,optional')
34  parser.add_argument('-o',dest='outputdir',action='store',required=False,help='output dir',default='.')
35  parser.add_argument('--amodetag',dest='amodetag',action='store',required=False,help='amodetag',default='PROTPHYS')
36  parser.add_argument('-f','--fill',
37  dest='fillnum',
38  action='store',
39  required=False,
40  help='specific fill',default=None)
41  parser.add_argument('--minfill',dest='minfill',
42  type=int,
43  action='store',
44  required=False,
45  default=MINFILL,
46  help='min fill')
47  parser.add_argument('--maxfill',dest='maxfill',
48  type=int,
49  action='store',
50  required=False,
51  default=MAXFILL,
52  help='maximum fillnumber '
53  )
54  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')
55  parser.add_argument('--debug',dest='debug',action='store_true',help='debug')
56  options=parser.parse_args()
57  if options.authpath:
58  os.environ['CORAL_AUTH_PATH'] = options.authpath
59  svc=sessionManager.sessionManager(options.connect,authpath=options.authpath,debugON=options.debug)
60  session=svc.openSession(isReadOnly=True,cpp2sqltype=[('unsigned int','NUMBER(10)'),('unsigned long long','NUMBER(20)')])
61 
62  session.transaction().start(True)
63  allfills=lumiCalcAPI.fillInRange(session.nominalSchema(),fillmin=options.minfill,fillmax=options.maxfill,amodetag=options.amodetag)
64  if len(allfills)==0:
65  print('no qualified fills found, do nothing... ')
66  exit(-1)
67  allfills.sort()
68  runsperfill={}
69  runtimes={}
70  irunlsdict={}
71  if options.fillnum:
72  if int(options.fillnum) in allfills:
73  runsperfill=lumiCalcAPI.fillrunMap(session.nominalSchema(),fillnum=int(options.fillnum))
74  allruns=runsperfill[ int(options.fillnum) ]
75  allls=[None]*len(allruns)
76  irunlsdict=dict(list(zip(allruns,allls)))
77  runresults=lumiCalcAPI.runsummary(session.nominalSchema(),irunlsdict)
78  for r in runresults:
79  runtimes[r[0]]=r[7]
80  else:
81  for fill in allfills:
82  runtimes={}
83  runsperfill=lumiCalcAPI.fillrunMap(session.nominalSchema(),fillnum=fill)
84  runs=runsperfill.values()#list of lists
85  allruns=[item for sublist in runs for item in sublist]
86  allls=[None]*len(allruns)
87  irunlsdict=dict(list(zip(allruns,allls)))
88  runresults=lumiCalcAPI.runsummary(session.nominalSchema(),irunlsdict)
89  for r in runresults:
90  runtimes[r[0]]=r[7]
91  tofiles(allfills,runsperfill,runtimes,options.outputdir)
92  session.transaction().commit()
93 
94 
Definition: start.py:1
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
def fillrunMap(schema, fillnum=None, runmin=None, runmax=None, startT=None, stopT=None, l1keyPattern=None, hltkeyPattern=None, amodetag=None)
Definition: lumiCalcAPI.py:42
def fillInRange(schema, fillmin=1000, fillmax=9999, amodetag='PROTPHYS', startT=None, stopT=None)
Definition: lumiCalcAPI.py:36
def tofiles(allfills, runsperfill, runtimes, outdir)
Definition: dumpFill.py:17
#define str(s)
def runsummary(schema, irunlsdict)
Lumi data management and calculation API # # Author: Zhen Xie #.
Definition: lumiCalcAPI.py:11
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run