CMS 3D CMS Logo

lumiDBFiller.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import string, os, time,re
4 import commands
5 lumiauthpath=''
6 lumilogpath=''
7 loaderconf=''
8 
9 #def isCollisionRun(run,authpath=''):
10 # itIs = False
11 # itIsAlso = False
12 # isInAfill = False
13 # command = 'dumpRunInfo.py -c oracle://cms_omds_lb/cms_runinfo -P '+authpath+' -r '+run+' --collision-only l1key | wc'
14 # statusAndOutput = commands.getstatusoutput(command)
15 # if statusAndOutput[1].split(' ')[2] == '2': itIs = True
16 # command = 'dumpRunInfo.py -c oracle://cms_omds_lb/cms_runinfo -P '+authpath+' -r '+run+' --collision-only hltkey | wc'
17 # statusAndOutput = commands.getstatusoutput(command)
18 # if statusAndOutput[1].split(' ')[2] == '2': itIsAlso = True
19 # command = 'dumpRunInfo.py -c oracle://cms_omds_lb/cms_runinfo -P '+authpath+' -r '+run+' fill'
20 # statusAndOutput = commands.getstatusoutput(command)
21 # fillnum=statusAndOutput[1].split('\n')[1].split(' ')[1]
22 # if fillnum and fillnum != '0':
23 # isInAfill=True
24 # return itIs and itIsAlso and isInAfill
25 
26 def getRunnumberFromFileName(lumifilename):
27  runnumber=int(lumifilename.split('_')[4])
28  return runnumber
29 
30 def getRunsToBeUploaded(connectionString, dropbox, authpath='',minrun=180250):
31  #print 'authpath ',authpath
32  # get the last analyzed run
33  command = 'lumiData2.py -c ' +connectionString+' -P '+authpath+' listrun'
34  if minrun:
35  command+=' --minrun '+str(minrun)
36  statusAndOutput = commands.getstatusoutput(command)
37  rlist= eval(statusAndOutput[1])
38  if rlist:
39  lastAnalyzedRunNumber = rlist[-1]
40  print 'Last run in DB: ', lastAnalyzedRunNumber
41  else:
42  print 'No qualified run found in DB'
43  lastAnalyzedRunNumber=int(minrun)
44  # check if there are new runs to be uploaded
45  #command = 'ls -ltr '+dropbox
46  p=re.compile('^CMS_LUMI_RAW_\d\d\d\d\d\d\d\d_\d\d\d\d\d\d\d\d\d_\d\d\d\d_\d.root$')
47  files=list(filter(os.path.isfile,[os.path.join(dropbox,x) for x in os.listdir(dropbox) if p.match(x)]))
48  files.sort(key=lambda x: os.path.getmtime(os.path.join(dropbox,x)))
49  #print 'sorted files ',files
50  #print files
51  #print qualifiedfiles
52  lastRaw=files[-1]
53  lastRecordedRun = getRunnumberFromFileName(lastRaw)
54  print 'Last lumi file produced by HF: ', lastRaw +', Run: ', lastRecordedRun
55 
56  # if yes, fill a list with the runs yet to be uploaded
57  runsToBeAnalyzed = {}
58  if lastRecordedRun != lastAnalyzedRunNumber:
59  for file in files:
60  if len(file.split('_'))!=7: continue
61  thisrun=getRunnumberFromFileName(file)
62  #print 'this run ',thisrun,lastAnalyzedRunNumber
63  #if thisrun>lastAnalyzedRunNumber and isCollisionRun(str(thisrun),authpath):
64  if thisrun>lastAnalyzedRunNumber :
65  runsToBeAnalyzed[str(thisrun)] = file
66  return runsToBeAnalyzed
67 
68 import os, sys
69 from RecoLuminosity.LumiDB import argparse
70 def main():
71  parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),description="Lumi Data scan")
72  parser.add_argument('-c',dest='connect',action='store',required=True,help='connect string to lumiDB')
73  parser.add_argument('-d',dest='dropbox',action='store',required=True,help='location of the lumi root files')
74  parser.add_argument('-P',dest='authpath',action='store',required=False,help='auth path')
75  parser.add_argument('-L',dest='logpath',action='store',required=False,help='log path')
76  parser.add_argument('-f',dest='loaderconf',action='store',required=True,help='path to loder config file')
77  parser.add_argument('--minrun',dest='minrun',action='store',required=False,help='minimum run to serch')
78  args=parser.parse_args()
79  if args.authpath:
80  lumiauthpath=args.authpath
81  if args.logpath:
82  lumilogpath=args.logpath
83  loaderconf=args.loaderconf
84  runsToBeAnalyzed = getRunsToBeUploaded(args.connect,args.dropbox,lumiauthpath,minrun=args.minrun)
85 
86  runCounter=0
87  rs=sorted(runsToBeAnalyzed.keys())
88  for run in rs:
89  runCounter+=1
90  if runCounter==1: print 'List of processed runs: '
91  print 'Run: ', run, ' file: ', runsToBeAnalyzed[run]
92  logFile=open(os.path.join(lumilogpath,'loadDB_run'+run+'.log'),'w',0)
93 
94  # filling the DB
95  command = '$LOCALRT/test/$SCRAM_ARCH/cmmdLoadLumiDB -r '+run+' -L "file:'+runsToBeAnalyzed[run]+'"'+' -f '+loaderconf+' --debug'
96  statusAndOutput = commands.getstatusoutput(command)
97  logFile.write(command+'\n')
98  logFile.write(statusAndOutput[1])
99  if not statusAndOutput[0] == 0:
100  print 'ERROR while loading info onto DB for run ' + run
101  print statusAndOutput[1]
102 
103  # selectstring='"{'+run+':[]}"'
104  # command = 'lumiValidate.py -c '+args.connect+' -P '+ lumiauthpath+' -runls '+selectstring+' update'
105  # statusAndOutput = commands.getstatusoutput(command)
106  # logFile.write(command+'\n')
107  # logFile.write(statusAndOutput[1])
108  # logFile.close()
109  # if not statusAndOutput[0] == 0:
110  # print 'ERROR while applying validation flag to run '+ run
111  # print statusAndOutput[1]
112  if runCounter == 0: print 'No runs to be analyzed'
113 
114 if __name__=='__main__':
115  main()
def getRunsToBeUploaded(connectionString, dropbox, authpath='', minrun=180250)
Definition: lumiDBFiller.py:30
def getRunnumberFromFileName(lumifilename)
Definition: lumiDBFiller.py:26
Definition: main.py:1
#define str(s)
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