CMS 3D CMS Logo

Classes | Functions | Variables

lumiSumPlot Namespace Reference

Classes

class  constants

Functions

def getLumiInfoForRuns
def getLumiOrderByLS
def main

Variables

string VERSION = '1.00'

Function Documentation

def lumiSumPlot::getLumiInfoForRuns (   dbsession,
  c,
  runList,
  selectionDict,
  hltpath = '',
  beamstatus = None,
  beamenergy = None,
  beamfluctuation = 0.0 
)
input: runList[runnum], selectionDict{runnum:[ls]}
output:{runnumber:[delivered,recorded,recordedinpath] }

Definition at line 102 of file lumiSumPlot.py.

00103                                                                                                                         :
00104     '''
00105     input: runList[runnum], selectionDict{runnum:[ls]}
00106     output:{runnumber:[delivered,recorded,recordedinpath] }
00107     '''
00108     t=lumiTime.lumiTime()
00109     result={}#runnumber:[lumisumoverlumils,lumisumovercmsls-deadtimecorrected,lumisumovercmsls-deadtimecorrected*hltcorrection_hltpath]
00110     #print 'selectionDict seen ',selectionDict
00111     dbsession.transaction().start(True)
00112     for runnum in runList:
00113         totallumi=0.0
00114         delivered=0.0
00115         recorded=0.0 
00116         recordedinpath=0.0
00117         if len(selectionDict)!=0 and not selectionDict.has_key(runnum):
00118             if runnum<max(selectionDict.keys()):
00119                 result[runnum]=[0.0,0.0,0.0]
00120             continue
00121         #print 'looking for run ',runnum
00122         q=dbsession.nominalSchema().newQuery()
00123         totallumi=lumiQueryAPI.lumisumByrun(q,runnum,c.LUMIVERSION,beamstatus,beamenergy,beamfluctuation) #q1
00124         del q
00125         if not totallumi:
00126             result[runnum]=[0.0,0.0,0.0]
00127             if c.VERBOSE: print 'run ',runnum,' does not exist or has no lumi, skip'
00128             continue
00129         lumitrginfo={}
00130         hltinfo={}
00131         hlttrgmap={}
00132         q=dbsession.nominalSchema().newQuery()
00133         lumitrginfo=lumiQueryAPI.lumisummarytrgbitzeroByrun(q,runnum,c.LUMIVERSION,beamstatus,beamenergy,beamfluctuation) #q2
00134         del q
00135         if len(lumitrginfo)==0:
00136             q=dbsession.nominalSchema().newQuery()
00137             lumiinfobyrun=lumiQueryAPI.lumisummaryByrun(q,runnum,c.LUMIVERSION,beamstatus,beamenergy,beamfluctuation) #q3
00138             del q
00139             if len(lumiinfobyrun)!=0:
00140                 print 'warning request run ',runnum,' has no trigger data, calculate delivered only'
00141             for perlsdata in lumiinfobyrun:
00142                 cmslsnum=perlsdata[0]
00143                 instlumi=perlsdata[1]
00144                 norbit=perlsdata[2]
00145                 lslength=t.bunchspace_s*t.nbx*norbit
00146                 delivered=instlumi*lslength
00147                 result[runnum]=[delivered,0.0,0.0]
00148             #result[runnum]=[0.0,0.0,0.0]
00149             #if c.VERBOSE: print 'request run ',runnum,' has no trigger, skip'
00150         else:
00151             norbits=lumitrginfo.values()[0][1]
00152             lslength=t.bunchspace_s*t.nbx*norbits
00153             delivered=totallumi*lslength
00154             hlttrgmap={}
00155             trgbitinfo={}
00156             if len(hltpath)!=0 and hltpath!='all':
00157                 q=dbsession.nominalSchema().newQuery() #optional q3, initiated only if you ask for a hltpath
00158                 hlttrgmap=lumiQueryAPI.hlttrgMappingByrun(q,runnum)
00159                 del q
00160                 if hlttrgmap.has_key(hltpath):
00161                     l1bitname=hltTrgSeedMapper.findUniqueSeed(hltpath,hlttrgmap[hltpath])
00162                     q=dbsession.nominalSchema().newQuery() #optional q4, initiated only if you ask for a hltpath and it exists 
00163                     hltinfo=lumiQueryAPI.hltBypathByrun(q,runnum,hltpath)
00164                     del q
00165                     q=dbsession.nominalSchema().newQuery()
00166                     trgbitinfo=lumiQueryAPI.trgBybitnameByrun(q,runnum,l1bitname) #optional q5, initiated only if you ask for a hltpath and it has a unique l1bit
00167                     del q
00168         #done all possible queries. process result
00169             for cmslsnum,valuelist in lumitrginfo.items():
00170                 if len(selectionDict)!=0 and not (cmslsnum in selectionDict[runnum]):
00171                     #if there's a selection list but cmslsnum is not selected,skip
00172                     continue
00173                 if valuelist[5]==0:#bitzero==0 means no beam,do nothing
00174                     continue
00175                 trgprescale=valuelist[8]            
00176                 deadfrac=float(valuelist[6])/float(float(valuelist[5])*float(trgprescale))
00177                 if(deadfrac<1.0):
00178                     recorded=recorded+valuelist[0]*(1.0-deadfrac)*lslength
00179                     if hlttrgmap.has_key(hltpath) and hltinfo.has_key(cmslsnum):
00180                         hltprescale=hltinfo[cmslsnum][2]
00181                         trgprescale=trgbitinfo[cmslsnum][3]
00182                         recordedinpath=recordedinpath+valuelist[0]*(1.0-deadfrac)*lslength*hltprescale*trgprescale
00183                 else:
00184                     if deadfrac<0.0:
00185                         print 'warning deadfraction negative in run',runnum,' ls ',cmslsnum
00186                 if c.VERBOSE:
00187                     print runnum,cmslsnum,valuelist[0]*lslength,valuelist[0]*(1.0-deadfrac)*lslength,lslength,deadfrac
00188             result[runnum]=[delivered,recorded,recordedinpath]
00189     dbsession.transaction().commit()
00190     #if c.VERBOSE:
00191     #    print result
00192     return result           

def lumiSumPlot::getLumiOrderByLS (   dbsession,
  c,
  runList,
  selectionDict,
  hltpath = '',
  beamstatus = None,
  beamenergy = None,
  beamfluctuation = None 
)
input:  runList[runnum], selectionDict{runnum:[ls]}
output: [[runnumber,runstarttime,lsnum,lsstarttime,delivered,recorded,recordedinpath]]

Definition at line 16 of file lumiSumPlot.py.

00017                                                                                                                        :
00018     '''
00019     input:  runList[runnum], selectionDict{runnum:[ls]}
00020     output: [[runnumber,runstarttime,lsnum,lsstarttime,delivered,recorded,recordedinpath]]
00021     '''
00022     #print 'getLumiOrderByLS selectionDict seen ',selectionDict
00023     t=lumiTime.lumiTime()
00024     result=[]#[[runnumber,runstarttime,lsnum,lsstarttime,delivered,recorded]]
00025     dbsession.transaction().start(True)
00026     sortedresult=[]
00027     #print 'runlist ',runList
00028     for runnum in runList:
00029         delivered=0.0
00030         recorded=0.0       
00031         #print 'looking for run ',runnum
00032         q=dbsession.nominalSchema().newQuery()
00033         runsummary=lumiQueryAPI.runsummaryByrun(q,runnum)
00034         del q
00035         runstarttimeStr=runsummary[3]
00036         if len(runstarttimeStr)==0:
00037             if c.VERBOSE: print 'warning request run ',runnum,' has no runsummary, skip'
00038             continue
00039         if len(selectionDict)!=0 and not selectionDict.has_key(runnum):
00040             if runnum<max(selectionDict.keys()):
00041                 result.append([runnum,runstarttimeStr,1,t.StrToDatetime(runstarttimeStr),0.0,0.0])
00042             continue
00043         #print 'runsummary ',runsummary
00044         lumitrginfo={}
00045         q=dbsession.nominalSchema().newQuery()
00046         lumitrginfo=lumiQueryAPI.lumisummarytrgbitzeroByrun(q,runnum,c.LUMIVERSION,beamstatus,beamenergy,beamfluctuation) #q2
00047         del q
00048         #print 'lumitrginfo ',lumitrginfo
00049         if len(lumitrginfo)==0: #if no qualified cross lumi-trg found, try lumionly
00050             #result.append([runnum,runstarttimeStr,1,t.StrToDatetime(runstarttimeStr),0.0,0.0])
00051             q=dbsession.nominalSchema().newQuery()
00052             lumiinfobyrun=lumiQueryAPI.lumisummaryByrun(q,runnum,c.LUMIVERSION,beamstatus,beamenergy,beamfluctuation) #q3
00053             del q
00054             if len(lumiinfobyrun)!=0: #if lumionly has qualified data means trg has no data
00055                 print 'warning request run ',runnum,' has no trigger data, calculate delivered only'
00056                 for perlsdata in lumiinfobyrun:
00057                     cmslsnum=perlsdata[0]
00058                     instlumi=perlsdata[1]
00059                     norbit=perlsdata[2]
00060                     startorbit=perlsdata[3]
00061                     lsstarttime=t.OrbitToTime(runstarttimeStr,startorbit)
00062                     lslength=t.bunchspace_s*t.nbx*norbit
00063                     delivered=instlumi*lslength
00064                     result.append([runnum,runstarttimeStr,cmslsnum,lsstarttime,delivered,0.0])
00065             else:
00066                 #print 'run '+str(runnum)+' has no qualified data '
00067                 lsstarttime=t.OrbitToTime(runstarttimeStr,0)
00068                 result.append([runnum,runstarttimeStr,1,lsstarttime,0.0,0.0])
00069         else:
00070             norbits=lumitrginfo.values()[0][1]
00071             lslength=t.bunchspace_s*t.nbx*norbits
00072             trgbitinfo={}
00073             for cmslsnum,valuelist in lumitrginfo.items():
00074                 instlumi=valuelist[0]
00075                 startorbit=valuelist[2]
00076                 bitzero=valuelist[5]
00077                 deadcount=valuelist[6]
00078                 prescale=valuelist[-1]
00079                 lsstarttime=t.OrbitToTime(runstarttimeStr,startorbit)        
00080                 if len(selectionDict)!=0 and not (cmslsnum in selectionDict[runnum]):
00081                    #if there's a selection list but cmslsnum is not selected,set to 0
00082                    result.append([runnum,runstarttimeStr,cmslsnum,lsstarttime,0.0,0.0])
00083                    continue
00084                 delivered=instlumi*lslength
00085                 if valuelist[5]==0:#bitzero==0 means no beam,do nothing
00086                     recorded=0.0
00087                 else:
00088                     deadfrac=float(deadcount)/float(float(bitzero)*float(prescale))
00089                     if(deadfrac<1.0):
00090                         recorded=delivered*(1.0-deadfrac)
00091                 result.append([runnum,runstarttimeStr,cmslsnum,lsstarttime,delivered,recorded])
00092                 #print 'result : ',result
00093     dbsession.transaction().commit()
00094     transposedResult=CommonUtil.transposed(result)
00095     lstimes=transposedResult[3]
00096     lstimes.sort()
00097     for idx,lstime in enumerate(lstimes):
00098         sortedresult.append(result[idx])
00099     if c.VERBOSE:
00100         print sortedresult
00101     return sortedresult           

def lumiSumPlot::main ( )

Definition at line 193 of file lumiSumPlot.py.

00194           :
00195     allowedscales=['linear','log','both']
00196     c=constants()
00197     parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),description="Plot integrated luminosity as function of the time variable of choice",formatter_class=argparse.ArgumentDefaultsHelpFormatter)
00198     # add required arguments
00199     parser.add_argument('-c',dest='connect',action='store',required=True,help='connect string to lumiDB')
00200     # add optional arguments
00201     parser.add_argument('-P',dest='authpath',action='store',help='path to authentication file')
00202     parser.add_argument('-n',dest='normfactor',action='store',help='normalization factor (optional, default to 1.0)')
00203     parser.add_argument('-i',dest='inputfile',action='store',help='lumi range selection file (optional)')
00204     parser.add_argument('-o',dest='outputfile',action='store',help='csv outputfile name (optional)')
00205     parser.add_argument('-lumiversion',dest='lumiversion',default='0001',action='store',required=False,help='lumi data version')
00206     parser.add_argument('-begin',dest='begin',action='store',help='begin value of x-axi (required)')
00207     parser.add_argument('-end',dest='end',action='store',help='end value of x-axi (optional). Default to the maximum exists DB')
00208     parser.add_argument('-beamenergy',dest='beamenergy',action='store',type=float,required=False,help='beamenergy (in GeV) selection criteria,e.g. 3.5e3')
00209     parser.add_argument('-beamfluctuation',dest='beamfluctuation',action='store',type=float,required=False,help='allowed fraction of beamenergy to fluctuate, e.g. 0.1')
00210     parser.add_argument('-beamstatus',dest='beamstatus',action='store',required=False,help='selection criteria beam status,e.g. STABLE BEAMS')
00211     parser.add_argument('-yscale',dest='yscale',action='store',required=False,default='linear',help='y_scale')
00212     parser.add_argument('-hltpath',dest='hltpath',action='store',help='specific hltpath to calculate the recorded luminosity. If specified aoverlays the recorded luminosity for the hltpath on the plot')
00213     parser.add_argument('-batch',dest='batch',action='store',help='graphical mode to produce PNG file. Specify graphical file here. Default to lumiSum.png')
00214     parser.add_argument('--annotateboundary',dest='annotateboundary',action='store_true',help='annotate boundary run numbers')
00215     parser.add_argument('--interactive',dest='interactive',action='store_true',help='graphical mode to draw plot in a TK pannel.')
00216     parser.add_argument('-timeformat',dest='timeformat',action='store',help='specific python timeformat string (optional).  Default mm/dd/yy hh:min:ss.00')
00217     parser.add_argument('-siteconfpath',dest='siteconfpath',action='store',help='specific path to site-local-config.xml file, default to $CMS_PATH/SITECONF/local/JobConfig, if path undefined, fallback to cern proxy&server')
00218     parser.add_argument('action',choices=['run','fill','time','perday'],help='x-axis data type of choice')
00219     #graphical mode options
00220     parser.add_argument('--verbose',dest='verbose',action='store_true',help='verbose mode, print result also to screen')
00221     parser.add_argument('--debug',dest='debug',action='store_true',help='debug')
00222     # parse arguments
00223     batchmode=True
00224     args=parser.parse_args()
00225     connectstring=args.connect
00226     begvalue=args.begin
00227     endvalue=args.end
00228     beamstatus=args.beamstatus
00229     beamenergy=args.beamenergy
00230     beamfluctuation=args.beamfluctuation
00231     xaxitype='run'
00232     connectparser=connectstrParser.connectstrParser(connectstring)
00233     connectparser.parse()
00234     usedefaultfrontierconfig=False
00235     cacheconfigpath=''
00236     if connectparser.needsitelocalinfo():
00237         if not args.siteconfpath:
00238             cacheconfigpath=os.environ['CMS_PATH']
00239             if cacheconfigpath:
00240                 cacheconfigpath=os.path.join(cacheconfigpath,'SITECONF','local','JobConfig','site-local-config.xml')
00241             else:
00242                 usedefaultfrontierconfig=True
00243         else:
00244             cacheconfigpath=args.siteconfpath
00245             cacheconfigpath=os.path.join(cacheconfigpath,'site-local-config.xml')
00246         p=cacheconfigParser.cacheconfigParser()
00247         if usedefaultfrontierconfig:
00248             p.parseString(c.defaultfrontierConfigString)
00249         else:
00250             p.parse(cacheconfigpath)
00251         connectstring=connectparser.fullfrontierStr(connectparser.schemaname(),p.parameterdict())
00252     #print 'connectstring',connectstring
00253     runnumber=0
00254     svc = coral.ConnectionService()
00255     hltpath=''
00256     if args.hltpath:
00257         hltpath=args.hltpath
00258     if args.debug :
00259         msg=coral.MessageStream('')
00260         msg.setMsgVerbosity(coral.message_Level_Debug)
00261     ifilename=''
00262     ofilename='integratedlumi.png'
00263     timeformat=''
00264     if args.authpath and len(args.authpath)!=0:
00265         os.environ['CORAL_AUTH_PATH']=args.authpath
00266     if args.normfactor:
00267         c.NORM=float(args.normfactor)
00268     if args.lumiversion:
00269         c.LUMIVERSION=args.lumiversion
00270     if args.verbose:
00271         c.VERBOSE=True
00272     if args.inputfile:
00273         ifilename=args.inputfile
00274     if args.batch:
00275         opicname=args.batch
00276     if args.outputfile:
00277         ofilename=args.outputfile
00278     if args.timeformat:
00279         timeformat=args.timeformat
00280     session=svc.connect(connectstring,accessMode=coral.access_Update)
00281     session.typeConverter().setCppTypeForSqlType("unsigned int","NUMBER(10)")
00282     session.typeConverter().setCppTypeForSqlType("unsigned long long","NUMBER(20)")
00283     inputfilecontent=''
00284     fileparsingResult=''
00285     runList=[]
00286     runDict={}
00287     fillDict={}
00288     selectionDict={}
00289     minTime=''
00290     maxTime=''
00291 
00292     #if len(ifilename)!=0 :
00293     #    f=open(ifilename,'r')
00294     #    inputfilecontent=f.read()
00295     #    sparser=selectionParser.selectionParser(inputfilecontent)
00296     #    runsandls=sparser.runsandls()
00297     #    keylist=runsandls.keys()
00298     #    keylist.sort()
00299     #    for run in keylist:
00300     #        if selectionDict.has_key(run):
00301     #            lslist=runsandls[run]
00302     #            lslist.sort()
00303     #            selectionDict[run]=lslist
00304     if len(ifilename)!=0:
00305         ifparser=inputFilesetParser.inputFilesetParser(ifilename)
00306         runsandls=ifparser.runsandls()
00307         keylist=runsandls.keys()
00308         keylist.sort()
00309         for run in keylist:
00310             if not selectionDict.has_key(run):
00311                 lslist=runsandls[run]
00312                 lslist.sort()
00313                 selectionDict[run]=lslist
00314     if args.action == 'run':
00315         if not args.end:
00316             session.transaction().start(True)
00317             schema=session.nominalSchema()
00318             lastrun=max(lumiQueryAPI.allruns(schema,requireRunsummary=True,requireLumisummary=True,requireTrg=True,requireHlt=True))
00319             session.transaction().commit()
00320         else:
00321             lastrun=int(args.end)
00322         for r in range(int(args.begin),lastrun+1):
00323             runList.append(r)
00324     elif args.action == 'fill':
00325         session.transaction().start(True)
00326         maxfill=None
00327         if not args.end:
00328             qHandle=session.nominalSchema().newQuery()
00329             maxfill=max(lumiQueryAPI.allfills(qHandle,filtercrazy=True))
00330             del qHandle
00331         else:
00332             maxfill=int(args.end)
00333         qHandle=session.nominalSchema().newQuery()
00334         fillDict=lumiQueryAPI.runsByfillrange(qHandle,int(args.begin),maxfill)
00335         del qHandle
00336         session.transaction().commit()
00337         #print 'fillDict ',fillDict
00338         for fill in range(int(args.begin),maxfill+1):
00339             if fillDict.has_key(fill): #fill exists
00340                 for run in fillDict[fill]:
00341                     runList.append(run)
00342     elif args.action == 'time' or args.action == 'perday':
00343         session.transaction().start(True)
00344         t=lumiTime.lumiTime()
00345         minTime=t.StrToDatetime(args.begin,timeformat)
00346         if not args.end:
00347             maxTime=datetime.datetime.utcnow() #to now
00348         else:
00349             maxTime=t.StrToDatetime(args.end,timeformat)
00350         #print minTime,maxTime
00351         qHandle=session.nominalSchema().newQuery()
00352         runDict=lumiQueryAPI.runsByTimerange(qHandle,minTime,maxTime)#xrawdata
00353         session.transaction().commit()
00354         runList=runDict.keys()
00355         del qHandle
00356         #print runDict
00357     else:
00358         print 'unsupported action ',args.action
00359         exit
00360     runList.sort()
00361     #print 'runList ',runList
00362     #print 'runDict ', runDict
00363     
00364     fig=Figure(figsize=(6,4.5),dpi=100)
00365     m=matplotRender.matplotRender(fig)
00366     
00367     logfig=Figure(figsize=(6.8,4.5),dpi=100)
00368     mlog=matplotRender.matplotRender(logfig)
00369     
00370     if args.action == 'run':
00371         result={}        
00372         result=getLumiInfoForRuns(session,c,runList,selectionDict,hltpath,beamstatus=beamstatus,beamenergy=beamenergy,beamfluctuation=beamfluctuation)
00373         xdata=[]
00374         ydata={}
00375         ydata['Delivered']=[]
00376         ydata['Recorded']=[]
00377         keylist=result.keys()
00378         keylist.sort() #must be sorted in order
00379         if args.outputfile:
00380             reporter=csvReporter.csvReporter(ofilename)
00381             fieldnames=['run','delivered','recorded']
00382             reporter.writeRow(fieldnames)
00383         for run in keylist:
00384             xdata.append(run)
00385             delivered=result[run][0]
00386             recorded=result[run][1]
00387             ydata['Delivered'].append(delivered)
00388             ydata['Recorded'].append(recorded)
00389             if args.outputfile and (delivered!=0 or recorded!=0):
00390                 reporter.writeRow([run,result[run][0],result[run][1]])                
00391         m.plotSumX_Run(xdata,ydata,yscale='linear')
00392         mlog.plotSumX_Run(xdata,ydata,yscale='log')
00393     elif args.action == 'fill':        
00394         lumiDict={}
00395         lumiDict=getLumiInfoForRuns(session,c,runList,selectionDict,hltpath,beamstatus=beamstatus,beamenergy=beamenergy,beamfluctuation=beamfluctuation)
00396         xdata=[]
00397         ydata={}
00398         ydata['Delivered']=[]
00399         ydata['Recorded']=[]
00400         #keylist=lumiDict.keys()
00401         #keylist.sort()
00402         if args.outputfile:
00403             reporter=csvReporter.csvReporter(ofilename)
00404             fieldnames=['fill','run','delivered','recorded']
00405             reporter.writeRow(fieldnames)
00406         fills=fillDict.keys()
00407         fills.sort()
00408         for fill in fills:
00409             runs=fillDict[fill]
00410             runs.sort()
00411             for run in runs:
00412                 xdata.append(run)
00413                 ydata['Delivered'].append(lumiDict[run][0])
00414                 ydata['Recorded'].append(lumiDict[run][1])
00415                 if args.outputfile :
00416                     reporter.writeRow([fill,run,lumiDict[run][0],lumiDict[run][1]])   
00417         #print 'input fillDict ',len(fillDict.keys()),fillDict
00418         m.plotSumX_Fill(xdata,ydata,fillDict,yscale='linear')
00419         mlog.plotSumX_Fill(xdata,ydata,fillDict,yscale='log')
00420     elif args.action == 'time' : 
00421         lumiDict={}
00422         lumiDict=getLumiInfoForRuns(session,c,runList,selectionDict,hltpath,beamstatus=beamstatus,beamenergy=beamenergy,beamfluctuation=beamfluctuation)
00423         #lumiDict=getLumiInfoForRuns(session,c,runList,selectionDict,hltpath,beamstatus='STABLE BEAMS')
00424         xdata={}#{run:[starttime,stoptime]}
00425         ydata={}
00426         ydata['Delivered']=[]
00427         ydata['Recorded']=[]
00428         keylist=lumiDict.keys()
00429         keylist.sort()
00430         if args.outputfile:
00431             reporter=csvReporter.csvReporter(ofilename)
00432             fieldnames=['run','starttime','stoptime','delivered','recorded']
00433             reporter.writeRow(fieldnames)
00434         for run in keylist:
00435             ydata['Delivered'].append(lumiDict[run][0])
00436             ydata['Recorded'].append(lumiDict[run][1])
00437             starttime=runDict[run][0]
00438             stoptime=runDict[run][1]
00439             xdata[run]=[starttime,stoptime]
00440             if args.outputfile :
00441                 reporter.writeRow([run,starttime,stoptime,lumiDict[run][0],lumiDict[run][1]])
00442         m.plotSumX_Time(xdata,ydata,minTime,maxTime,hltpath=hltpath,annotateBoundaryRunnum=args.annotateboundary,yscale='linear')
00443         mlog.plotSumX_Time(xdata,ydata,minTime,maxTime,hltpath=hltpath,annotateBoundaryRunnum=args.annotateboundary,yscale='log')
00444     elif args.action == 'perday':
00445         daydict={}#{day:[[run,cmslsnum,lsstarttime,delivered,recorded]]}
00446         lumibyls=getLumiOrderByLS(session,c,runList,selectionDict,hltpath,beamstatus=beamstatus,beamenergy=beamenergy,beamfluctuation=beamfluctuation)
00447         #print 'lumibyls ',lumibyls
00448         #lumibyls [[runnumber,runstarttime,lsnum,lsstarttime,delivered,recorded,recordedinpath]]
00449         if args.outputfile:
00450             reporter=csvReporter.csvReporter(ofilename)
00451             fieldnames=['day','begrunls','endrunls','delivered','recorded']
00452             reporter.writeRow(fieldnames)
00453         beginfo=[lumibyls[0][3],str(lumibyls[0][0])+':'+str(lumibyls[0][2])]
00454         endinfo=[lumibyls[-1][3],str(lumibyls[-1][0])+':'+str(lumibyls[-1][2])]
00455         for perlsdata in lumibyls:
00456             lsstarttime=perlsdata[3]
00457             delivered=perlsdata[4]
00458             recorded=perlsdata[5]
00459             day=lsstarttime.toordinal()
00460             if not daydict.has_key(day):
00461                 daydict[day]=[]
00462             daydict[day].append([delivered,recorded])
00463         days=daydict.keys()
00464         days.sort()
00465         daymin=days[0]
00466         daymax=days[-1]
00467         #alldays=range(daymin,daymax+1)
00468         resultbyday={}
00469         resultbyday['Delivered']=[]
00470         resultbyday['Recorded']=[]
00471         #for day in days:
00472         #print 'day min ',daymin
00473         #print 'day max ',daymax
00474         for day in range(daymin,daymax+1):
00475             if not daydict.has_key(day):
00476                 delivered=0.0
00477                 recorded=0.0
00478             else:
00479                 daydata=daydict[day]
00480                 mytransposed=CommonUtil.transposed(daydata,defaultval=0.0)
00481                 delivered=sum(mytransposed[0])
00482                 recorded=sum(mytransposed[1])
00483             resultbyday['Delivered'].append(delivered)
00484             resultbyday['Recorded'].append(recorded)
00485             if args.outputfile:
00486                 reporter.writeRow([day,beginfo[1],endinfo[1],delivered,recorded])
00487         #print 'beginfo ',beginfo
00488         #print 'endinfo ',endinfo
00489         #print resultbyday
00490         m.plotPerdayX_Time( range(daymin,daymax+1) ,resultbyday,minTime,maxTime,boundaryInfo=[beginfo,endinfo],annotateBoundaryRunnum=args.annotateboundary,yscale='linear')
00491         mlog.plotPerdayX_Time( range(daymin,daymax+1),resultbyday,minTime,maxTime,boundaryInfo=[beginfo,endinfo],annotateBoundaryRunnum=args.annotateboundary,yscale='log')
00492     else:
00493         raise Exception,'must specify the type of x-axi'
00494 
00495     del session
00496     del svc
00497 
00498     if args.batch and args.yscale=='linear':
00499         m.drawPNG(args.batch)
00500     elif args.batch and args.yscale=='log':
00501         mlog.drawPNG(args.batch)
00502     elif args.batch and args.yscale=='both':
00503         m.drawPNG(args.batch)
00504         basename,extension=os.path.splitext(args.batch)
00505         logfilename=basename+'_log'+extension        
00506         mlog.drawPNG(logfilename)
00507     else:
00508         raise Exception('unsupported yscale for batch mode : '+args.yscale)
00509     if not args.interactive:
00510         return
00511     if args.interactive is True and args.yscale=='linear':
00512         m.drawInteractive()
00513     elif args.interactive is True and args.yscale=='log':
00514         mlog.drawInteractive()
00515     else:
        raise Exception('unsupported yscale for interactive mode : '+args.yscale)

Variable Documentation

string lumiSumPlot::VERSION = '1.00'

Definition at line 2 of file lumiSumPlot.py.