00001
00002
00003
00004
00005
00006
00007
00008
00009 import os,os.path,sys,datetime,time,csv,re
00010 from RecoLuminosity.LumiDB import argparse,lumiTime,matplotRender,sessionManager,lumiParameters,RegexValidator,revisionDML,lumiCalcAPI,normDML
00011 import matplotlib
00012 from matplotlib.figure import Figure
00013
00014 def parseInputFiles(inputfilename):
00015 '''
00016 output ({run:[cmsls,cmsls,...]},[[resultlines]])
00017 '''
00018 selectedrunlsInDB={}
00019 resultlines=[]
00020 p=inputFilesetParser.inputFilesetParser(inputfilename)
00021 runlsbyfile=p.runsandls()
00022 selectedProcessedRuns=p.selectedRunsWithresult()
00023 selectedNonProcessedRuns=p.selectedRunsWithoutresult()
00024 resultlines=p.resultlines()
00025 for runinfile in selectedNonProcessedRuns:
00026 selectedrunlsInDB[runinfile]=runlsbyfile[runinfile]
00027 return (selectedrunlsInDB,resultlines)
00028
00029
00030
00031
00032
00033
00034
00035
00036 if __name__=='__main__':
00037 referenceLabel='Delivered'
00038 labels=['Delivered','Recorded']
00039 allowedActions = ['run','time','fill','perday','instpeakperday']
00040 beamChoices=['PROTPHYS','IONPHYS','PAPHYS']
00041 allowedscales=['linear','log','both']
00042 beamModeChoices = [ "stable", "quiet", "either"]
00043 amodetagChoices = [ "PROTPHYS","IONPHYS",'PAPHYS' ]
00044 actiontofilebasemap={'time':'lumivstime','run':'lumivsrun','fill':'lumivsfill','perday':'lumiperday','instpeakperday':'lumipeak'}
00045
00046
00047
00048 currentdir=os.getcwd()
00049 rcparamfile='.lumiplotrc'
00050 mplrcdir=matplotlib.get_configdir()
00051 mpllumiconfig=os.path.join(mplrcdir,rcparamfile)
00052 locallumiconfig=os.path.join(currentdir,rcparamfile)
00053 figureparams={'sizex':7.5,'sizey':5.7,'dpi':135}
00054 if os.path.exists(locallumiconfig):
00055 import ConfigParser
00056 try:
00057 config=ConfigParser.RawConfigParser()
00058 config.read(locallumiconfig)
00059 figureparams['sizex']=config.getfloat('sizex')
00060 figureparams['sizey']=config.getfloat('sizey')
00061 figureparams['dpi']=config.getint('dpi')
00062 except ConfigParser.NoOptionError:
00063 pass
00064 elif os.path.exists(mpllumiconfig):
00065 import ConfigParser
00066 try:
00067 config=ConfigParser.RawConfigParser()
00068 config.read(mpllumiconfig)
00069 figureparams['sizex']=config.getfloat('sizex')
00070 figureparams['sizey']=config.getfloat('sizey')
00071 figureparams['dpi']=config.getint('dpi')
00072 except ConfigParser.NoOptionError:
00073 pass
00074
00075
00076
00077
00078
00079
00080 parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),
00081 description="Plot luminosity as function of the time variable of choice",
00082 formatter_class=argparse.ArgumentDefaultsHelpFormatter)
00083 parser.add_argument('-c',
00084 dest='connect',
00085 action='store',
00086 help='connect string to lumiDB',
00087 default='frontier://LumiCalc/CMS_LUMI_PROD')
00088 parser.add_argument('-P',
00089 dest='authpath',
00090 action='store',
00091 help='path to authentication file')
00092 parser.add_argument('--datatag',
00093 dest='datatag',
00094 action='store',
00095 default=None,
00096 help='data tag')
00097 parser.add_argument('--normtag',
00098 dest='normtag',
00099 action='store',
00100 default=None,
00101 help='norm tag')
00102
00103
00104
00105 parser.add_argument('-i',
00106 dest='inputfile',
00107 action='store',
00108 help='run/ls selection file')
00109
00110
00111
00112 parser.add_argument('--hltpath',
00113 dest='hltpath',
00114 action='store',
00115 default=None,
00116 required=False,
00117 help='specific hltpath or hltpath pattern to calculate the effectived luminosity (optional)')
00118
00119
00120
00121 parser.add_argument('-b',
00122 dest='beamstatus',
00123 action='store',
00124 help='selection criteria beam status')
00125
00126
00127
00128 parser.add_argument('-f','--fill',
00129 dest='fillnum',
00130 action='store',
00131 type=int,
00132 help='specific fill',
00133 default=None)
00134 parser.add_argument('--amodetag',
00135 dest='amodetag',
00136 action='store',
00137 help='accelerator mode')
00138 parser.add_argument('--beamenergy',
00139 dest='beamenergy',
00140 action='store',
00141 type=float,
00142 default=3500,
00143 help='beamenergy (in GeV) selection criteria')
00144 parser.add_argument('--beamfluctuation',
00145 dest='beamfluctuation',
00146 action='store',
00147 type=float,
00148 default=0.2,
00149 help='allowed fraction of beamenergy to fluctuate')
00150 parser.add_argument('--begin',
00151 dest='begintime',
00152 action='store',
00153 default='03/01/10 00:00:00',
00154 type=RegexValidator.RegexValidator("^\d\d/\d\d/\d\d \d\d:\d\d:\d\d$","must be form mm/dd/yy hh:mm:ss"),
00155 help='min run start time,mm/dd/yy hh:mm:ss')
00156 parser.add_argument('--end',
00157 dest='endtime',
00158 action='store',
00159 type=RegexValidator.RegexValidator("^\d\d/\d\d/\d\d \d\d:\d\d:\d\d$","must be form mm/dd/yy hh:mm:ss"),
00160 help='max run start time,mm/dd/yy hh:mm:ss')
00161
00162
00163
00164 parser.add_argument('--siteconfpath',
00165 dest='siteconfpath',
00166 action='store',
00167 help='specific path to site-local-config.xml file, default to $CMS_PATH/SITECONF/local/JobConfig, if path undefined, fallback to cern proxy&server')
00168
00169
00170
00171
00172 parser.add_argument('--inplotdata',
00173 dest='inplot',
00174 action='store',
00175 help='existing base plot(s) in text format')
00176 parser.add_argument('--outplotdata',
00177 dest='outplot',
00178 action='store',
00179 help='output plot. By default, a text dump of the plot is produced.')
00180
00181 parser.add_argument('--with-annotation',
00182 dest='withannotation',
00183 action='store_true',
00184 help='annotate boundary run numbers')
00185 parser.add_argument('--interactive',
00186 dest='interactive',
00187 action='store_true',
00188 help='graphical mode to draw plot in a QT pannel.')
00189 parser.add_argument('--without-textoutput',
00190 dest='withoutTextoutput',
00191 action='store_true',
00192 help='not to write out text output file')
00193 parser.add_argument('--without-png',
00194 dest='withoutpng',
00195 action='store_true',
00196 help='do not produce')
00197 parser.add_argument('--yscale',
00198 dest='yscale',
00199 action='store',
00200 default='linear',
00201 help='y_scale[linear,log,both]')
00202 parser.add_argument('--lastpointfromdb',
00203 dest='lastpointfromdb',
00204 action='store_true',
00205 help='the last point in the plot is always recaculated from current values in LumiDB')
00206
00207
00208 parser.add_argument('--without-correction',
00209 dest='withoutNorm',
00210 action='store_true',
00211 help='without any correction/calibration')
00212
00213
00214 parser.add_argument('--verbose',
00215 dest='verbose',
00216 action='store_true',
00217 help='verbose mode, print result also to screen')
00218 parser.add_argument('--debug',
00219 dest='debug',
00220 action='store_true',
00221 help='debug')
00222 parser.add_argument('action',
00223 choices=allowedActions,
00224 help='type of plots')
00225 options=parser.parse_args()
00226 if options.yscale=='both' and options.interactive:
00227 print '--interactive mode can draw either yscale log or linear at a time'
00228 exit(0)
00229 outplotfilename = options.outplot
00230 if not outplotfilename:
00231 outplotfilename=actiontofilebasemap[options.action]
00232 outtextfilename = outplotfilename+'.csv'
00233 if options.withoutTextoutput:
00234 outtextfilename=None
00235 lumip=lumiParameters.ParametersObject()
00236 svc=sessionManager.sessionManager(options.connect,
00237 authpath=options.authpath,
00238 siteconfpath=options.siteconfpath,
00239 debugON=options.debug)
00240 session=svc.openSession(isReadOnly=True,cpp2sqltype=[('unsigned int','NUMBER(10)'),('unsigned long long','NUMBER(20)')])
00241 lslength=lumip.lslengthsec()
00242 begtime=options.begintime
00243 endtime=options.endtime
00244 lut=lumiTime.lumiTime()
00245 if not endtime:
00246 endtime=lut.DatetimeToStr(datetime.datetime.utcnow(),customfm='%m/%d/%y %H:%M:%S')
00247 pbeammode=None
00248 if options.beamstatus=='stable':
00249 pbeammode='STABLE BEAMS'
00250 resultlines=[]
00251 inplots=[]
00252
00253
00254
00255 inplot=options.inplot
00256 if inplot:
00257 inplots=inplot.split('+')
00258 for ip in inplots:
00259 f=open(ip,'r')
00260 reader=csv.reader(f,delimiter=',')
00261 for row in reader:
00262 if '#' in row[0]:continue
00263 resultlines.append(row)
00264
00265
00266
00267 irunlsdict={}
00268 rruns=[]
00269 reqTrg=False
00270 reqHlt=False
00271 if options.hltpath:
00272 reqHlt=True
00273 fillrunMap={}
00274 lastDrawnRun=None
00275 maxDrawnDay=None
00276 lastDrawnFill=None
00277 newFirstDay=None
00278 newFirstRun=None
00279 newFirstFill=None
00280 session.transaction().start(True)
00281 if options.action=='perday' or options.action=='instpeakperday':
00282 maxDrawnDay=int(lut.StrToDatetime(begtime,customfm='%m/%d/%y %H:%M:%S').date().toordinal())
00283 if resultlines:
00284 for drawnDay in [ int(t[0]) for t in resultlines]:
00285 if drawnDay>maxDrawnDay:
00286 maxDrawnDay=drawnDay
00287 newFirstDay=maxDrawnDay
00288 midnight=datetime.time()
00289 begT=datetime.datetime.combine(datetime.date.fromordinal(newFirstDay),midnight)
00290 begTStr=lut.DatetimeToStr(begT,customfm='%m/%d/%y %H:%M:%S')
00291
00292 runlist=lumiCalcAPI.runList(session.nominalSchema(),options.fillnum,runmin=None,runmax=None,startT=begTStr,stopT=endtime,l1keyPattern=None,hltkeyPattern=None,amodetag=options.amodetag,nominalEnergy=options.beamenergy,energyFlut=options.beamfluctuation,requiretrg=reqTrg,requirehlt=reqHlt)
00293 if options.action=='run' or options.action=='time':
00294 lastDrawnRun=132000
00295 if resultlines:
00296 lastDrawnRun=max([int(t[0]) for t in resultlines])
00297 newFirstRun=lastDrawnRun+1
00298 if options.lastpointfromdb:
00299 newFirstRun=lastDrawnRun
00300 runlist=lumiCalcAPI.runList(session.nominalSchema(),options.fillnum,runmin=newFirstRun,runmax=None,startT=begtime,stopT=endtime,l1keyPattern=None,hltkeyPattern=None,amodetag=options.amodetag,nominalEnergy=options.beamenergy,energyFlut=options.beamfluctuation,requiretrg=reqTrg,requirehlt=reqHlt)
00301 if options.action=='fill':
00302 lastDrawnFill=1000
00303 lastDrawnRun=132000
00304 if resultlines:
00305 lastDrawnFill=max([int(t[0]) for t in resultlines])
00306 lastDrawnRun=min([int(t[1]) for t in resultlines if int(t[0])==lastDrawnFill])
00307 newFirstRun=lastDrawnRun+1
00308 if options.lastpointfromdb:
00309 newFirstRun=lastDrawnRun
00310 runlist=lumiCalcAPI.runList(session.nominalSchema(),runmin=newFirstRun,runmax=None,startT=begtime,stopT=endtime,l1keyPattern=None,hltkeyPattern=None,amodetag=options.amodetag,nominalEnergy=options.beamenergy,energyFlut=options.beamfluctuation,requiretrg=reqTrg,requirehlt=reqHlt)
00311 fillrunMap=lumiCalcAPI.fillrunMap(session.nominalSchema(),runmin=newFirstRun,runmax=None,startT=begtime,stopT=endtime)
00312
00313 if options.inputfile:
00314 (irunlsdict,iresults)=parseInputFiles(options.inputfile)
00315
00316 if options.fillnum or options.begin or options.end or options.amodetag or options.beamenergy:
00317 rruns=[val for val in runlist if val in irunlsdict.keys()]
00318 for selectedrun in irunlsdict.keys():
00319 if selectedrun not in rruns:
00320 del irunlsdict[selectedrun]
00321 else:
00322 rruns=irunlsdict.keys()
00323 else:
00324 for run in runlist:
00325 irunlsdict[run]=None
00326 rruns=irunlsdict.keys()
00327
00328 if options.verbose:
00329 print '[INFO] runs from db: ',irunlsdict
00330 if lastDrawnRun:
00331 print '[INFO] last run in old plot: ',lastDrawnRun
00332 print '[INFO] first run from DB in fresh plot: ',newFirstRun
00333 if maxDrawnDay:
00334 print '[INFO] last day in old plot: ',maxDrawnDay
00335 print '[INFO] first day from DB in fresh plot: ',newFirstDay
00336
00337 if len(rruns)==0:
00338 if len(resultlines)!=0:
00339 print '[INFO] drawing all from old plot data'
00340 else:
00341 print '[INFO] found no old nor new data, do nothing'
00342 exit(0)
00343
00344 GrunsummaryData=lumiCalcAPI.runsummaryMap(session.nominalSchema(),irunlsdict)
00345
00346
00347
00348 datatagname=options.datatag
00349 if not datatagname:
00350 (datatagid,datatagname)=revisionDML.currentDataTag(session.nominalSchema())
00351 dataidmap=revisionDML.dataIdsByTagId(session.nominalSchema(),datatagid,runlist=rruns,withcomment=False)
00352
00353 else:
00354 dataidmap=revisionDML.dataIdsByTagName(session.nominalSchema(),datatagname,runlist=rruns,withcomment=False)
00355
00356
00357
00358 normname='NONE'
00359 normid=0
00360 normvalueDict={}
00361 if not options.withoutNorm:
00362 normname=options.normtag
00363 if not normname:
00364 normmap=normDML.normIdByType(session.nominalSchema(),lumitype='HF',defaultonly=True)
00365 if len(normmap):
00366 normname=normmap.keys()[0]
00367 normid=normmap[normname]
00368 else:
00369 normid=normDML.normIdByName(session.nominalSchema(),normname)
00370 if not normid:
00371 raise RuntimeError('[ERROR] cannot resolve norm/correction')
00372 sys.exit(-1)
00373 normvalueDict=normDML.normValueById(session.nominalSchema(),normid)
00374
00375 fig=Figure(figsize=(figureparams['sizex'],figureparams['sizey']),dpi=figureparams['dpi'])
00376 m=matplotRender.matplotRender(fig)
00377 logfig=Figure(figsize=(figureparams['sizex'],figureparams['sizey']),dpi=figureparams['dpi'])
00378 mlog=matplotRender.matplotRender(logfig)
00379
00380 if not options.hltpath:
00381 lumibyls=lumiCalcAPI.lumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=pbeammode,normmap=normvalueDict,lumitype='HF')
00382 else:
00383 referenceLabel='Recorded'
00384 hltname=options.hltpath
00385 hltpat=None
00386 if hltname=='*' or hltname=='all':
00387 hltname=None
00388 elif 1 in [c in hltname for c in '*?[]']:
00389 hltpat=hltname
00390 hltname=None
00391 lumibyls=lumiCalcAPI.effectiveLumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=pbeammode,normmap=normvalueDict,hltpathname=hltname,hltpathpattern=hltpat)
00392 session.transaction().commit()
00393 rawdata={}
00394
00395
00396
00397 if options.action=='run':
00398 for run in sorted(lumibyls):
00399 rundata=lumibyls[run]
00400 if not options.hltpath:
00401 if len(rundata)!=0:
00402 rawdata.setdefault('Delivered',[]).append((run,sum([t[5] for t in rundata if t[5]])))
00403 rawdata.setdefault('Recorded',[]).append((run,sum([t[6] for t in rundata if t[6]])))
00404 else:
00405 labels=['Recorded']
00406 if len(rundata)!=0:
00407 pathdict={}
00408 rawdata.setdefault('Recorded',[]).append((run,sum([t[6] for t in rundata if t[6]])))
00409 for perlsdata in rundata:
00410 effdict=perlsdata[8]
00411 pathnames=effdict.keys()
00412 for thispath in pathnames:
00413 pathdict.setdefault(thispath,[]).append(effdict[thispath][3])
00414 for thispath in pathdict.keys():
00415 labels.append(thispath)
00416 rawdata.setdefault(thispath,[]).append((run,sum([t for t in pathdict[thispath] if t])))
00417 if options.yscale=='linear':
00418 m.plotSumX_Run(rawdata,resultlines,textoutput=outtextfilename,yscale='linear',referenceLabel=referenceLabel,labels=labels)
00419 elif options.yscale=='log':
00420 m.plotSumX_Run(rawdata,resultlines,textoutput=outtextfilename,yscale='log',referenceLabel=referenceLabel,labels=labels)
00421 else:
00422 m.plotSumX_Run(rawdata,resultlines,textoutput=outtextfilename,yscale='linear',referenceLabel=referenceLabel,labels=labels)
00423 m.plotSumX_Run(rawdata,resultlines,textoutput=outtextfilename,yscale='log',referenceLabel=referenceLabel,labels=labels)
00424 if options.action=='fill':
00425 for fill in sorted(fillrunMap):
00426 for run in fillrunMap[fill]:
00427 if not lumibyls.has_key(run): continue
00428 rundata=lumibyls[run]
00429 if not options.hltpath:
00430 if len(rundata)!=0:
00431 rawdata.setdefault('Delivered',[]).append((fill,run,sum([t[5] for t in rundata if t[5]])))
00432 rawdata.setdefault('Recorded',[]).append((fill,run,sum([t[6] for t in rundata if t[6]])))
00433 else:
00434 labels=['Recorded']
00435 if len(rundata)!=0:
00436 pathdict={}
00437 rawdata.setdefault('Recorded',[]).append((fill,run,sum([t[6] for t in rundata if t[6]])))
00438 for perlsdata in rundata:
00439 effdict=perlsdata[8]
00440 pathnames=effdict.keys()
00441 for thispath in pathnames:
00442 pathdict.setdefault(thispath,[]).append(effdict[thispath][3])
00443 for thispath in pathdict.keys():
00444 labels.append(thispath)
00445 rawdata.setdefault(thispath,[]).append((fill,run,sum([t for t in pathdict[thispath] if t])))
00446 if options.yscale=='linear':
00447 m.plotSumX_Fill(rawdata,resultlines,textoutput=outtextfilename,yscale='linear',referenceLabel=referenceLabel)
00448 elif options.yscale=='log':
00449 m.plotSumX_Fill(rawdata,resultlines,textoutput=outtextfilename,yscale='log',referenceLabel=referenceLabel)
00450 else:
00451 m.plotSumX_Fill(rawdata,resultlines,textoutput=outtextfilename,yscale='linear',referenceLabel=referenceLabel)
00452 m.plotSumX_Fill(rawdata,resultlines,textoutput=outtextfilename,yscale='log',referenceLabel=referenceLabel)
00453 if options.action=='time':
00454 for run in sorted(lumibyls):
00455 rundata=lumibyls[run]
00456 if not options.hltpath:
00457 if len(rundata)!=0:
00458 rawdata.setdefault('Delivered',[]).append((run,rundata[0][2],rundata[-1][2],sum([t[5] for t in rundata if t[5]])))
00459 rawdata.setdefault('Recorded',[]).append((run,rundata[0][2],rundata[-1][2],sum([t[6] for t in rundata if t[6]])))
00460 else:
00461 labels=['Recorded']
00462 if len(rundata)!=0:
00463 pathdict={}
00464 rawdata.setdefault('Recorded',[]).append((run,rundata[0][2],rundata[-1][2],sum([t[6] for t in rundata if t[6]])))
00465 for perlsdata in rundata:
00466 effdict=perlsdata[8]
00467 pathnames=effdict.keys()
00468 for thispath in pathnames:
00469 pathdict.setdefault(thispath,[]).append(effdict[thispath][3])
00470 for thispath in pathdict.keys():
00471 labels.append(thispath)
00472 rawdata.setdefault(thispath,[]).append((run,rundata[0][2],rundata[-1][2],sum([t for t in pathdict[thispath] if t])))
00473 if options.yscale=='linear':
00474 m.plotSumX_Time(rawdata,resultlines,minTime=begtime,maxTime=endtime,textoutput=outtextfilename,yscale='linear',referenceLabel=referenceLabel)
00475 elif options.yscale=='log':
00476 mlog.plotSumX_Time(rawdata,resultlines,minTime=begtime,maxTime=endtime,textoutput=outtextfilename,yscale='log',referenceLabel=referenceLabel)
00477 else:
00478 m.plotSumX_Time(rawdata,resultlines,minTime=begtime,maxTime=endtime,textoutput=outtextfilename,yscale='linear',referenceLabel=referenceLabel)
00479 mlog.plotSumX_Time(rawdata,resultlines,minTime=begtime,maxTime=endtime,textoutput=outtextfilename,yscale='log',referenceLabel=referenceLabel)
00480 if options.action=='perday':
00481 daydict={}
00482 for run in sorted(lumibyls):
00483 rundata=lumibyls[run]
00484 for lsdata in rundata:
00485 lumilsnum=lsdata[0]
00486 lsTS=lsdata[2]
00487 dellum=lsdata[5]
00488 reclum=lsdata[6]
00489 daynumber=lsTS.date().toordinal()
00490 daydict.setdefault(daynumber,[]).append((run,lumilsnum,dellum,reclum))
00491 for day in sorted(daydict):
00492 daydata=daydict[day]
00493 daybeg=str(daydata[0][0])+':'+str(daydata[0][1])
00494 dayend=str(daydata[-1][0])+':'+str(daydata[-1][1])
00495 daydel=sum([t[2] for t in daydata if t[2]])
00496 dayrec=sum([t[3] for t in daydata if t[3]])
00497 rawdata.setdefault('Delivered',[]).append((day,daybeg,dayend,daydel))
00498 rawdata.setdefault('Recorded',[]).append((day,daybeg,dayend,dayrec))
00499
00500 if options.yscale=='linear':
00501 m.plotPerdayX_Time(rawdata,resultlines,minTime=begtime,maxTime=endtime,textoutput=outtextfilename,yscale='linear',referenceLabel=referenceLabel)
00502 elif options.yscale=='log':
00503 mlog.plotPerdayX_Time(rawdata,resultlines,minTime=begtime,maxTime=endtime,textoutput=outtextfilename,yscale='log',referenceLabel=referenceLabel)
00504 else:
00505 m.plotPerdayX_Time(rawdata,resultlines,minTime=begtime,maxTime=endtime,textoutput=outtextfilename,yscale='linear',referenceLabel=referenceLabel)
00506 mlog.plotPerdayX_Time(rawdata,resultlines,minTime=begtime,maxTime=endtime,textoutput=outtextfilename,yscale='log',referenceLabel=referenceLabel)
00507 if options.action=='instpeakperday':
00508 daydict={}
00509 for run in sorted(lumibyls):
00510 rundata=lumibyls[run]
00511 for lsdata in rundata:
00512 lumilsnum=lsdata[0]
00513 lsTS=lsdata[2]
00514 instlum=lsdata[5]/lslength
00515 daynumber=lsTS.date().toordinal()
00516 daydict.setdefault(daynumber,[]).append((run,lumilsnum,instlum))
00517 for day in sorted(daydict):
00518 daydata=daydict[day]
00519 daymax_val=0.0
00520 daymax_run=0
00521 daymax_ls=0
00522 for datatp in daydata:
00523 if datatp[2]>daymax_val:
00524 daymax_val=datatp[2]
00525 daymax_run=datatp[0]
00526 daymax_ls=datatp[1]
00527 rawdata.setdefault('Delivered',[]).append((day,daymax_run,daymax_ls,daymax_val))
00528 if options.yscale=='linear':
00529 m.plotPeakPerday_Time(rawdata,resultlines,minTime=begtime,maxTime=endtime,textoutput=outtextfilename,yscale='linear',referenceLabel=referenceLabel)
00530 elif options.yscale=='log':
00531 mlog.plotPeakPerday_Time(rawdata,resultlines,minTime=begtime,maxTime=endtime,textoutput=outtextfilename,yscale='log',referenceLabel=referenceLabel)
00532 else:
00533 m.plotPeakPerday_Time(rawdata,resultlines,minTime=begtime,maxTime=endtime,textoutput=outtextfilename,yscale='linear',referenceLabel=referenceLabel)
00534 mlog.plotPeakPerday_Time(rawdata,resultlines,minTime=begtime,maxTime=endtime,textoutput=outtextfilename,yscale='log',referenceLabel=referenceLabel)
00535 if options.action=='inst':
00536 thisfillnumber=fillrunMap.keys()[0]
00537 starttime=0
00538 stoptime=0
00539 rawxdata=[]
00540 rawydata={}
00541 for run,rundata in lumibyls.items():
00542 rundata.sort()
00543 totlumils=0
00544 totcmsls=0
00545 starttime=rundata[0][2]
00546 stoptime=rundata[-1][2]
00547 for lsdata in rundata:
00548 lumilsnum=lsdata[0]
00549 totlumils+=1
00550 cmslsnum=lsdata[1]
00551 if cmslsnum!=0:
00552 totcmsls+=1
00553 lsTS=lsdata[2]
00554 dellumi=lsdata[5]
00555 reclumi=lsdata[6]
00556 rawydata.setdefault('Delivered',[]).append(dellumi)
00557 rawydata.setdefault('Recorded',[]).append(reclumi)
00558 rawxdata=[run,thisfillnumber,starttime,stoptime,totlumils,totcmsls]
00559 m.plotInst_RunLS(rawxdata,rawydata,textoutput=None)
00560
00561 if options.yscale=='linear':
00562 if options.interactive:
00563 m.drawInteractive()
00564 exit(0)
00565 else:
00566 if not options.withoutpng:
00567 m.drawPNG(outplotfilename+'.png')
00568 exit(0)
00569 elif options.yscale=='log':
00570 if options.interactive:
00571 mlog.drawInteractive()
00572 exit(0)
00573 else:
00574 if not options.withoutpng:
00575 mlog.drawPNG(outplotfilename+'_log.png')
00576 exit(0)
00577 else:
00578 if options.interactive:
00579 print 'cannot draw both log and linear from interactive'
00580 exit(0)
00581 if not options.withoutpng:
00582 m.drawPNG(outplotfilename+'.png')
00583 mlog.drawPNG(outplotfilename+'_log.png')
00584 exit(0)
00585