CMS 3D CMS Logo

Functions | Variables

lumiDBFiller Namespace Reference

Functions

def getRunnumberFromFileName
def getRunsToBeUploaded
def isCollisionRun
def main

Variables

string loaderconf = ''
string lumiauthpath = ''
string lumilogpath = ''

Function Documentation

def lumiDBFiller::getRunnumberFromFileName (   lumifilename)

Definition at line 25 of file lumiDBFiller.py.

00026                                           :
00027     runnumber=int(lumifilename.split('_')[4])
00028     return runnumber

def lumiDBFiller::getRunsToBeUploaded (   connectionString,
  dropbox,
  authpath = '' 
)

Definition at line 29 of file lumiDBFiller.py.

00030                                                                :
00031     #print 'authpath ',authpath
00032     # get the last analyzed run
00033     command = 'lumiData.py -c ' +connectionString+' -P '+authpath+' --raw listrun'
00034     statusAndOutput = commands.getstatusoutput(command)
00035     lastAnalyzedRunNumber = eval(statusAndOutput[1])[-1][0]
00036     print 'Last run in DB: ', lastAnalyzedRunNumber
00037 
00038     # check if there are new runs to be uploaded
00039     #command = 'ls -ltr '+dropbox
00040     files=filter(os.path.isfile,[os.path.join(dropbox,x) for x in os.listdir(dropbox)])
00041     #print files
00042     files.sort(key=lambda x: os.path.getmtime(os.path.join(dropbox,x)))
00043     #print 'sorted files ',files
00044     lastRaw = files[-1]
00045     lastRecordedRun = getRunnumberFromFileName(lastRaw)
00046 
00047     print 'Last lumi file produced: ', lastRaw +', Run: ', lastRecordedRun 
00048         
00049     # if yes, fill a list with the runs yet to be uploaded
00050     runsToBeAnalyzed = {}
00051     if lastRecordedRun != lastAnalyzedRunNumber:
00052         for file in files:
00053             if len(file.split('_'))!=7: continue
00054             thisrun=getRunnumberFromFileName(file)
00055             #print 'this run ',thisrun
00056             if  thisrun>lastAnalyzedRunNumber and isCollisionRun(str(thisrun),authpath): 
00057                     runsToBeAnalyzed[str(thisrun)] = file
00058     return runsToBeAnalyzed

def lumiDBFiller::isCollisionRun (   run,
  authpath = '' 
)

Definition at line 8 of file lumiDBFiller.py.

00009                                    :
00010     itIs = False
00011     itIsAlso = False
00012     isInAfill = False
00013     command = 'dumpRunInfo.py -c oracle://cms_omds_lb/cms_runinfo -P '+authpath+' -r '+run+' --collision-only l1key | wc'
00014     statusAndOutput = commands.getstatusoutput(command)
00015     if statusAndOutput[1].split('   ')[2] == '2': itIs = True
00016     command = 'dumpRunInfo.py -c oracle://cms_omds_lb/cms_runinfo -P '+authpath+' -r '+run+' --collision-only hltkey | wc'
00017     statusAndOutput = commands.getstatusoutput(command)
00018     if statusAndOutput[1].split('   ')[2] == '2': itIsAlso = True
00019     command = 'dumpRunInfo.py -c oracle://cms_omds_lb/cms_runinfo -P '+authpath+' -r '+run+' fill'
00020     statusAndOutput = commands.getstatusoutput(command)
00021     fillnum=statusAndOutput[1].split('\n')[1].split(' ')[1]
00022     if fillnum and fillnum != '0':
00023         isInAfill=True
00024     return itIs and itIsAlso and isInAfill

def lumiDBFiller::main ( )

Definition at line 61 of file lumiDBFiller.py.

00062           :
00063     parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),description="Lumi Data scan")
00064     parser.add_argument('-c',dest='connect',action='store',required=True,help='connect string to lumiDB')
00065     parser.add_argument('-d',dest='dropbox',action='store',required=True,help='location of the lumi root files')
00066     parser.add_argument('-P',dest='authpath',action='store',required=False,help='auth path')
00067     parser.add_argument('-L',dest='logpath',action='store',required=False,help='log path')
00068     parser.add_argument('-f',dest='loaderconf',action='store',required=True,help='path to loder config file')
00069     args=parser.parse_args()
00070     if args.authpath:
00071         lumiauthpath=args.authpath
00072     if args.logpath:
00073         lumilogpath=args.logpath
00074     loaderconf=args.loaderconf
00075     runsToBeAnalyzed = getRunsToBeUploaded(args.connect, args.dropbox,lumiauthpath) 
00076 
00077     runCounter=0
00078     rs=runsToBeAnalyzed.keys()
00079     rs.sort()
00080     for run in rs:
00081         runCounter+=1
00082         if runCounter==1: print 'List of processed runs: '
00083         print 'Run: ', run, ' file: ', runsToBeAnalyzed[run]
00084         logFile=open(os.path.join(lumilogpath,'loadDB_run'+run+'.log'),'w',0)
00085 
00086         # filling the DB
00087         command = '$LOCALRT/test/$SCRAM_ARCH/cmmdLoadLumiDB -r '+run+' -L "file:'+runsToBeAnalyzed[run]+'"'+' -f '+loaderconf+' --debug'
00088         statusAndOutput = commands.getstatusoutput(command)
00089         logFile.write(command+'\n')
00090         logFile.write(statusAndOutput[1])
00091         if not statusAndOutput[0] == 0:
00092             print 'ERROR while loading info onto DB for run ' + run
00093             print statusAndOutput[1]
00094             
00095         selectstring='"{'+run+':[]}"'
00096         command = 'lumiValidate.py -c '+args.connect+' -P '+ lumiauthpath+' -runls '+selectstring+' update' 
00097         statusAndOutput = commands.getstatusoutput(command)
00098         logFile.write(command+'\n')
00099         logFile.write(statusAndOutput[1])
00100         logFile.close()
00101         if not statusAndOutput[0] == 0:
00102             print 'ERROR while applying normalization to run '+ run
00103             print statusAndOutput[1]
00104 
00105     if runCounter == 0: print 'No runs to be analyzed'


Variable Documentation

Definition at line 7 of file lumiDBFiller.py.

Definition at line 5 of file lumiDBFiller.py.

Definition at line 6 of file lumiDBFiller.py.