CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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.

Referenced by getRunsToBeUploaded().

26 
27 def getRunnumberFromFileName(lumifilename):
28  runnumber=int(lumifilename.split('_')[4])
29  return runnumber
def getRunnumberFromFileName
Definition: lumiDBFiller.py:26
def lumiDBFiller.getRunsToBeUploaded (   connectionString,
  dropbox,
  authpath = '',
  minrun = 180250 
)

Definition at line 30 of file lumiDBFiller.py.

References alcazmumu_cfi.filter, and getRunnumberFromFileName().

Referenced by main().

30 
31 def getRunsToBeUploaded(connectionString, dropbox, authpath='',minrun=180250):
32  #print 'authpath ',authpath
33  # get the last analyzed run
34  command = 'lumiData2.py -c ' +connectionString+' -P '+authpath+' listrun'
35  if minrun:
36  command+=' --minrun '+str(minrun)
37  statusAndOutput = commands.getstatusoutput(command)
38  rlist= eval(statusAndOutput[1])
39  if rlist:
40  lastAnalyzedRunNumber = rlist[-1]
41  print 'Last run in DB: ', lastAnalyzedRunNumber
42  else:
43  print 'No qualified run found in DB'
44  lastAnalyzedRunNumber=int(minrun)
45  # check if there are new runs to be uploaded
46  #command = 'ls -ltr '+dropbox
47  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$')
48  files=filter(os.path.isfile,[os.path.join(dropbox,x) for x in os.listdir(dropbox) if p.match(x)])
49  files.sort(key=lambda x: os.path.getmtime(os.path.join(dropbox,x)))
50  #print 'sorted files ',files
51  #print files
52  #print qualifiedfiles
53  lastRaw=files[-1]
54  lastRecordedRun = getRunnumberFromFileName(lastRaw)
55  print 'Last lumi file produced by HF: ', lastRaw +', Run: ', lastRecordedRun
56 
57  # if yes, fill a list with the runs yet to be uploaded
58  runsToBeAnalyzed = {}
59  if lastRecordedRun != lastAnalyzedRunNumber:
60  for file in files:
61  if len(file.split('_'))!=7: continue
62  thisrun=getRunnumberFromFileName(file)
63  #print 'this run ',thisrun,lastAnalyzedRunNumber
64  #if thisrun>lastAnalyzedRunNumber and isCollisionRun(str(thisrun),authpath):
65  if thisrun>lastAnalyzedRunNumber :
66  runsToBeAnalyzed[str(thisrun)] = file
67  return runsToBeAnalyzed
def getRunsToBeUploaded
Definition: lumiDBFiller.py:30
def getRunnumberFromFileName
Definition: lumiDBFiller.py:26
def lumiDBFiller.main ( )

Definition at line 70 of file lumiDBFiller.py.

References getRunsToBeUploaded().

70 
71 def main():
72  parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),description="Lumi Data scan")
73  parser.add_argument('-c',dest='connect',action='store',required=True,help='connect string to lumiDB')
74  parser.add_argument('-d',dest='dropbox',action='store',required=True,help='location of the lumi root files')
75  parser.add_argument('-P',dest='authpath',action='store',required=False,help='auth path')
76  parser.add_argument('-L',dest='logpath',action='store',required=False,help='log path')
77  parser.add_argument('-f',dest='loaderconf',action='store',required=True,help='path to loder config file')
78  parser.add_argument('--minrun',dest='minrun',action='store',required=False,help='minimum run to serch')
79  args=parser.parse_args()
80  if args.authpath:
81  lumiauthpath=args.authpath
82  if args.logpath:
83  lumilogpath=args.logpath
84  loaderconf=args.loaderconf
85  runsToBeAnalyzed = getRunsToBeUploaded(args.connect,args.dropbox,lumiauthpath,minrun=args.minrun)
86 
87  runCounter=0
88  rs=runsToBeAnalyzed.keys()
89  rs.sort()
90  for run in rs:
91  runCounter+=1
92  if runCounter==1: print 'List of processed runs: '
93  print 'Run: ', run, ' file: ', runsToBeAnalyzed[run]
94  logFile=open(os.path.join(lumilogpath,'loadDB_run'+run+'.log'),'w',0)
95 
96  # filling the DB
97  command = '$LOCALRT/test/$SCRAM_ARCH/cmmdLoadLumiDB -r '+run+' -L "file:'+runsToBeAnalyzed[run]+'"'+' -f '+loaderconf+' --debug'
98  statusAndOutput = commands.getstatusoutput(command)
99  logFile.write(command+'\n')
100  logFile.write(statusAndOutput[1])
101  if not statusAndOutput[0] == 0:
102  print 'ERROR while loading info onto DB for run ' + run
103  print statusAndOutput[1]
104 
105  # selectstring='"{'+run+':[]}"'
106  # command = 'lumiValidate.py -c '+args.connect+' -P '+ lumiauthpath+' -runls '+selectstring+' update'
107  # statusAndOutput = commands.getstatusoutput(command)
108  # logFile.write(command+'\n')
109  # logFile.write(statusAndOutput[1])
110  # logFile.close()
111  # if not statusAndOutput[0] == 0:
112  # print 'ERROR while applying validation flag to run '+ run
113  # print statusAndOutput[1]
114  if runCounter == 0: print 'No runs to be analyzed'
def getRunsToBeUploaded
Definition: lumiDBFiller.py:30

Variable Documentation

string lumiDBFiller.loaderconf = ''

Definition at line 7 of file lumiDBFiller.py.

string lumiDBFiller.lumiauthpath = ''

Definition at line 5 of file lumiDBFiller.py.

string lumiDBFiller.lumilogpath = ''

Definition at line 6 of file lumiDBFiller.py.