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 isCollisionRun
 
def main
 

Variables

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

Function Documentation

def lumiDBFiller.getRunnumberFromFileName (   lumifilename)

Definition at line 25 of file lumiDBFiller.py.

Referenced by getRunsToBeUploaded().

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

Definition at line 29 of file lumiDBFiller.py.

References align_tpl.filter, getRunnumberFromFileName(), and isCollisionRun().

Referenced by main().

29 
30 def getRunsToBeUploaded(connectionString, dropbox, authpath=''):
31  #print 'authpath ',authpath
32  # get the last analyzed run
33  command = 'lumiData.py -c ' +connectionString+' -P '+authpath+' --raw listrun'
34  statusAndOutput = commands.getstatusoutput(command)
35  lastAnalyzedRunNumber = eval(statusAndOutput[1])[-1][0]
36  print 'Last run in DB: ', lastAnalyzedRunNumber
37 
38  # check if there are new runs to be uploaded
39  #command = 'ls -ltr '+dropbox
40  files=filter(os.path.isfile,[os.path.join(dropbox,x) for x in os.listdir(dropbox)])
41  #print files
42  files.sort(key=lambda x: os.path.getmtime(os.path.join(dropbox,x)))
43  #print 'sorted files ',files
44  lastRaw = files[-1]
45  lastRecordedRun = getRunnumberFromFileName(lastRaw)
46 
47  print 'Last lumi file produced: ', lastRaw +', Run: ', lastRecordedRun
48 
49  # if yes, fill a list with the runs yet to be uploaded
50  runsToBeAnalyzed = {}
51  if lastRecordedRun != lastAnalyzedRunNumber:
52  for file in files:
53  if len(file.split('_'))!=7: continue
54  thisrun=getRunnumberFromFileName(file)
55  #print 'this run ',thisrun
56  if thisrun>lastAnalyzedRunNumber and isCollisionRun(str(thisrun),authpath):
57  runsToBeAnalyzed[str(thisrun)] = file
58  return runsToBeAnalyzed
def isCollisionRun
Definition: lumiDBFiller.py:8
def getRunsToBeUploaded
Definition: lumiDBFiller.py:29
tuple filter
USE THIS FOR SKIMMED TRACKS process.p = cms.Path(process.hltLevel1GTSeed*process.skimming*process.offlineBeamSpot*process.TrackRefitter2) OTHERWISE USE THIS.
Definition: align_tpl.py:86
def getRunnumberFromFileName
Definition: lumiDBFiller.py:25
def lumiDBFiller.isCollisionRun (   run,
  authpath = '' 
)

Definition at line 8 of file lumiDBFiller.py.

References split.

Referenced by getRunsToBeUploaded().

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
def isCollisionRun
Definition: lumiDBFiller.py:8
double split
Definition: MVATrainer.cc:139
def lumiDBFiller.main ( )

Definition at line 61 of file lumiDBFiller.py.

References getRunsToBeUploaded().

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

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.