CMS 3D CMS Logo

Functions | Variables

lumiDBFiller Namespace Reference

Functions

def getRunnumberFromFileName
def getRunsToBeUploaded
def main

Variables

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

Function Documentation

def lumiDBFiller::getRunnumberFromFileName (   lumifilename)

Definition at line 26 of file lumiDBFiller.py.

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

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

Definition at line 30 of file lumiDBFiller.py.

00031                                                                              :
00032     #print 'authpath ',authpath
00033     # get the last analyzed run
00034     command = 'lumiData2.py -c ' +connectionString+' -P '+authpath+' listrun'
00035     if minrun:
00036         command+=' --minrun '+str(minrun)
00037     statusAndOutput = commands.getstatusoutput(command)
00038     rlist= eval(statusAndOutput[1])
00039     if rlist:
00040         lastAnalyzedRunNumber = rlist[-1]
00041         print 'Last run in DB: ', lastAnalyzedRunNumber
00042     else:
00043         print 'No qualified run found in DB'
00044         lastAnalyzedRunNumber=int(minrun)
00045     # check if there are new runs to be uploaded
00046     #command = 'ls -ltr '+dropbox
00047     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$')
00048     files=filter(os.path.isfile,[os.path.join(dropbox,x) for x in os.listdir(dropbox) if p.match(x)])
00049     files.sort(key=lambda x: os.path.getmtime(os.path.join(dropbox,x)))
00050     #print 'sorted files ',files
00051     #print files
00052     #print qualifiedfiles
00053     lastRaw=files[-1]
00054     lastRecordedRun = getRunnumberFromFileName(lastRaw)
00055     print 'Last lumi file produced by HF: ', lastRaw +', Run: ', lastRecordedRun 
00056         
00057     # if yes, fill a list with the runs yet to be uploaded
00058     runsToBeAnalyzed = {}
00059     if lastRecordedRun != lastAnalyzedRunNumber:
00060         for file in files:
00061             if len(file.split('_'))!=7: continue
00062             thisrun=getRunnumberFromFileName(file)
00063             #print 'this run ',thisrun,lastAnalyzedRunNumber
00064             #if  thisrun>lastAnalyzedRunNumber and isCollisionRun(str(thisrun),authpath):
00065             if thisrun>lastAnalyzedRunNumber :
00066                 runsToBeAnalyzed[str(thisrun)] = file
00067     return runsToBeAnalyzed

def lumiDBFiller::main ( )

Definition at line 70 of file lumiDBFiller.py.

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