CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
lumiPlot.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #########################################################################
3 # Command to produce plots with selected conditions and styles #
4 # output #
5 # #
6 # Author: Zhen Xie #
7 #########################################################################
8 #
9 import os,os.path,sys,datetime,time,csv,re
10 from RecoLuminosity.LumiDB import argparse,lumiTime,matplotRender,sessionManager,lumiParameters,RegexValidator,revisionDML,lumiCalcAPI,normDML
11 import matplotlib
12 from matplotlib.figure import Figure
13 
14 def parseInputFiles(inputfilename):
15  '''
16  output ({run:[cmsls,cmsls,...]},[[resultlines]])
17  '''
18  selectedrunlsInDB={}
19  resultlines=[]
21  runlsbyfile=p.runsandls()
22  selectedProcessedRuns=p.selectedRunsWithresult()
23  selectedNonProcessedRuns=p.selectedRunsWithoutresult()
24  resultlines=p.resultlines()
25  for runinfile in selectedNonProcessedRuns:
26  selectedrunlsInDB[runinfile]=runlsbyfile[runinfile]
27  return (selectedrunlsInDB,resultlines)
28 ##############################
29 ## ######################## ##
30 ## ## ################## ## ##
31 ## ## ## Main Program ## ## ##
32 ## ## ################## ## ##
33 ## ######################## ##
34 ##############################
35 
36 if __name__=='__main__':
37  referenceLabel='Delivered'#from which label,lumi unit should be calculated
38  labels=['Delivered','Recorded']#default label order
39  allowedActions = ['run','time','fill','perday','instpeakperday']
40  beamChoices=['PROTPHYS','IONPHYS','PAPHYS']
41  allowedscales=['linear','log','both']
42  beamModeChoices = [ "stable", "quiet", "either"]
43  amodetagChoices = [ "PROTPHYS","IONPHYS",'PAPHYS' ]
44  actiontofilebasemap={'time':'lumivstime','run':'lumivsrun','fill':'lumivsfill','perday':'lumiperday','instpeakperday':'lumipeak'}
45  #############################################################
46  # parse figure configuration if found
47  #############################################################
48  currentdir=os.getcwd()
49  rcparamfile='.lumiplotrc'
50  mplrcdir=matplotlib.get_configdir()
51  mpllumiconfig=os.path.join(mplrcdir,rcparamfile)
52  locallumiconfig=os.path.join(currentdir,rcparamfile)
53  figureparams={'sizex':7.5,'sizey':5.7,'dpi':135}
54  if os.path.exists(locallumiconfig):
55  import ConfigParser
56  try:
57  config=ConfigParser.RawConfigParser()
58  config.read(locallumiconfig)
59  figureparams['sizex']=config.getfloat('sizex')
60  figureparams['sizey']=config.getfloat('sizey')
61  figureparams['dpi']=config.getint('dpi')
62  except ConfigParser.NoOptionError:
63  pass
64  elif os.path.exists(mpllumiconfig):
65  import ConfigParser
66  try:
67  config=ConfigParser.RawConfigParser()
68  config.read(mpllumiconfig)
69  figureparams['sizex']=config.getfloat('sizex')
70  figureparams['sizey']=config.getfloat('sizey')
71  figureparams['dpi']=config.getint('dpi')
72  except ConfigParser.NoOptionError:
73  pass
74  ###############################
75  # parse arguments
76  ###############################
77  #
78  # basic arguments
79  #
80  parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),
81  description="Plot luminosity as function of the time variable of choice",
83  parser.add_argument('-c',
84  dest='connect',
85  action='store',
86  help='connect string to lumiDB',
87  default='frontier://LumiCalc/CMS_LUMI_PROD')
88  parser.add_argument('-P',
89  dest='authpath',
90  action='store',
91  help='path to authentication file')
92  parser.add_argument('--datatag',
93  dest='datatag',
94  action='store',
95  default=None,
96  help='data tag')
97  parser.add_argument('--normtag',
98  dest='normtag',
99  action='store',
100  default=None,
101  help='norm tag')
102  #
103  #optional arg to select exact run and ls
104  #
105  parser.add_argument('-i',
106  dest='inputfile',
107  action='store',
108  help='run/ls selection file')
109  #
110  #optional arg to select exact hltpath or pattern
111  #
112  parser.add_argument('--hltpath',
113  dest='hltpath',
114  action='store',
115  default=None,
116  required=False,
117  help='specific hltpath or hltpath pattern to calculate the effectived luminosity (optional)')
118  #
119  #optional args to filter run/ls
120  #
121  parser.add_argument('-b',
122  dest='beamstatus',
123  action='store',
124  help='selection criteria beam status')
125  #
126  #optional args to filter *runs*, they do not select on LS level.
127  #
128  parser.add_argument('-f','--fill',
129  dest='fillnum',
130  action='store',
131  type=int,
132  help='specific fill',
133  default=None)
134  parser.add_argument('--amodetag',
135  dest='amodetag',
136  action='store',
137  help='accelerator mode')
138  parser.add_argument('--beamenergy',
139  dest='beamenergy',
140  action='store',
141  type=float,
142  default=3500,
143  help='beamenergy (in GeV) selection criteria')
144  parser.add_argument('--beamfluctuation',
145  dest='beamfluctuation',
146  action='store',
147  type=float,
148  default=0.2,
149  help='allowed fraction of beamenergy to fluctuate')
150  parser.add_argument('--begin',
151  dest='begintime',
152  action='store',
153  default='03/01/10 00:00:00',
154  type=RegexValidator.RegexValidator("^\d\d/\d\d/\d\d \d\d:\d\d:\d\d$","must be form mm/dd/yy hh:mm:ss"),
155  help='min run start time,mm/dd/yy hh:mm:ss')
156  parser.add_argument('--end',
157  dest='endtime',
158  action='store',
159  type=RegexValidator.RegexValidator("^\d\d/\d\d/\d\d \d\d:\d\d:\d\d$","must be form mm/dd/yy hh:mm:ss"),
160  help='max run start time,mm/dd/yy hh:mm:ss')
161  #
162  #frontier config options
163  #
164  parser.add_argument('--siteconfpath',
165  dest='siteconfpath',
166  action='store',
167  help='specific path to site-local-config.xml file, default to $CMS_PATH/SITECONF/local/JobConfig, if path undefined, fallback to cern proxy&server')
168  #
169  #plot options
170  #
171  ####input/output file names
172  parser.add_argument('--inplotdata',
173  dest='inplot',
174  action='store',
175  help='existing base plot(s) in text format')
176  parser.add_argument('--outplotdata',
177  dest='outplot',
178  action='store',
179  help='output plot. By default, a text dump of the plot is produced.')
180  ####graphic switches
181  parser.add_argument('--with-annotation',
182  dest='withannotation',
183  action='store_true',
184  help='annotate boundary run numbers')
185  parser.add_argument('--interactive',
186  dest='interactive',
187  action='store_true',
188  help='graphical mode to draw plot in a QT pannel.')
189  parser.add_argument('--without-textoutput',
190  dest='withoutTextoutput',
191  action='store_true',
192  help='not to write out text output file')
193  parser.add_argument('--without-png',
194  dest='withoutpng',
195  action='store_true',
196  help='do not produce')
197  parser.add_argument('--yscale',
198  dest='yscale',
199  action='store',
200  default='linear',
201  help='y_scale[linear,log,both]')
202  parser.add_argument('--lastpointfromdb',
203  dest='lastpointfromdb',
204  action='store_true',
205  help='the last point in the plot is always recaculated from current values in LumiDB')
206 
207  ####correction switches
208  parser.add_argument('--without-correction',
209  dest='withoutNorm',
210  action='store_true',
211  help='without any correction/calibration')
212 
213  ###general switches
214  parser.add_argument('--verbose',
215  dest='verbose',
216  action='store_true',
217  help='verbose mode, print result also to screen')
218  parser.add_argument('--debug',
219  dest='debug',
220  action='store_true',
221  help='debug')
222  parser.add_argument('action',
223  choices=allowedActions,
224  help='type of plots')
225  options=parser.parse_args()
226  if options.yscale=='both' and options.interactive:
227  print '--interactive mode can draw either yscale log or linear at a time'
228  exit(0)
229  outplotfilename = options.outplot
230  if not outplotfilename:
231  outplotfilename=actiontofilebasemap[options.action]
232  outtextfilename = outplotfilename+'.csv'
233  if options.withoutTextoutput:
234  outtextfilename=None
236  svc=sessionManager.sessionManager(options.connect,
237  authpath=options.authpath,
238  siteconfpath=options.siteconfpath,
239  debugON=options.debug)
240  session=svc.openSession(isReadOnly=True,cpp2sqltype=[('unsigned int','NUMBER(10)'),('unsigned long long','NUMBER(20)')])
241  lslength=lumip.lslengthsec()
242  begtime=options.begintime
243  endtime=options.endtime
245  if not endtime:
246  endtime=lut.DatetimeToStr(datetime.datetime.utcnow(),customfm='%m/%d/%y %H:%M:%S')
247  pbeammode=None
248  if options.beamstatus=='stable':
249  pbeammode='STABLE BEAMS'
250  resultlines=[]
251  inplots=[]
252  #######################################################################
253  ##process old plot csv files,if any, skipping #commentlines
254  #######################################################################
255  inplot=options.inplot
256  if inplot:
257  inplots=inplot.split('+')
258  for ip in inplots:
259  f=open(ip,'r')
260  reader=csv.reader(f,delimiter=',')
261  for row in reader:
262  if '#' in row[0]:continue
263  resultlines.append(row)
264  #####################################
265  ##find runs need to read from DB
266  #####################################
267  irunlsdict={}#either from -i or from other selection options
268  rruns=[]
269  reqTrg=False
270  reqHlt=False
271  if options.hltpath:
272  reqHlt=True
273  fillrunMap={}
274  lastDrawnRun=None
275  maxDrawnDay=None
276  lastDrawnFill=None
277  newFirstDay=None
278  newFirstRun=None
279  newFirstFill=None
280  session.transaction().start(True)
281  if options.action=='perday' or options.action=='instpeakperday':
282  maxDrawnDay=int(lut.StrToDatetime(begtime,customfm='%m/%d/%y %H:%M:%S').date().toordinal()) #default maxDrawnDay is begtime
283  if resultlines: #if there's old result lines
284  for drawnDay in [ int(t[0]) for t in resultlines]:
285  if drawnDay>maxDrawnDay: #all required days are already drawn
286  maxDrawnDay=drawnDay
287  newFirstDay=maxDrawnDay
288  midnight=datetime.time()
289  begT=datetime.datetime.combine(datetime.date.fromordinal(newFirstDay),midnight)
290  begTStr=lut.DatetimeToStr(begT,customfm='%m/%d/%y %H:%M:%S')
291  #find runs not in old plot
292  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)
293  if options.action=='run' or options.action=='time':
294  lastDrawnRun=132000
295  if resultlines:#if there's old plot, start to count runs only after that
296  lastDrawnRun=max([int(t[0]) for t in resultlines])
297  newFirstRun=lastDrawnRun+1
298  if options.lastpointfromdb:
299  newFirstRun=lastDrawnRun
300  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)
301  if options.action=='fill':
302  lastDrawnFill=1000
303  lastDrawnRun=132000
304  if resultlines:
305  lastDrawnFill=max([int(t[0]) for t in resultlines])
306  lastDrawnRun=min([int(t[1]) for t in resultlines if int(t[0])==lastDrawnFill])
307  newFirstRun=lastDrawnRun+1
308  if options.lastpointfromdb:
309  newFirstRun=lastDrawnRun
310  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)
311  fillrunMap=lumiCalcAPI.fillrunMap(session.nominalSchema(),runmin=newFirstRun,runmax=None,startT=begtime,stopT=endtime)
312 
313  if options.inputfile:
314  (irunlsdict,iresults)=parseInputFiles(options.inputfile)
315  #apply further filter only if specified
316  if options.fillnum or options.begin or options.end or options.amodetag or options.beamenergy:
317  rruns=[val for val in runlist if val in irunlsdict.keys()]
318  for selectedrun in irunlsdict.keys():#if there's further filter on the runlist,clean input dict
319  if selectedrun not in rruns:
320  del irunlsdict[selectedrun]
321  else:
322  rruns=irunlsdict.keys()
323  else:
324  for run in runlist:
325  irunlsdict[run]=None
326  rruns=irunlsdict.keys()
327 
328  if options.verbose:
329  print '[INFO] runs from db: ',irunlsdict
330  if lastDrawnRun:
331  print '[INFO] last run in old plot: ',lastDrawnRun
332  print '[INFO] first run from DB in fresh plot: ',newFirstRun
333  if maxDrawnDay:
334  print '[INFO] last day in old plot: ',maxDrawnDay
335  print '[INFO] first day from DB in fresh plot: ',newFirstDay
336 
337  if len(rruns)==0:
338  if len(resultlines)!=0:
339  print '[INFO] drawing all from old plot data'
340  else:
341  print '[INFO] found no old nor new data, do nothing'
342  exit(0)
343 
344  GrunsummaryData=lumiCalcAPI.runsummaryMap(session.nominalSchema(),irunlsdict)
345  #####################################
346  #resolve data ids
347  #####################################
348  datatagname=options.datatag
349  if not datatagname:
350  (datatagid,datatagname)=revisionDML.currentDataTag(session.nominalSchema())
351  dataidmap=revisionDML.dataIdsByTagId(session.nominalSchema(),datatagid,runlist=rruns,withcomment=False)
352  #{run:(lumidataid,trgdataid,hltdataid,())}
353  else:
354  dataidmap=revisionDML.dataIdsByTagName(session.nominalSchema(),datatagname,runlist=rruns,withcomment=False)
355  #
356  # check normtag and get norm values if required
357  #
358  normname='NONE'
359  normid=0
360  normvalueDict={}
361  if not options.withoutNorm:
362  normname=options.normtag
363  if not normname:
364  normmap=normDML.normIdByType(session.nominalSchema(),lumitype='HF',defaultonly=True)
365  if len(normmap):
366  normname=normmap.keys()[0]
367  normid=normmap[normname]
368  else:
369  normid=normDML.normIdByName(session.nominalSchema(),normname)
370  if not normid:
371  raise RuntimeError('[ERROR] cannot resolve norm/correction')
372  sys.exit(-1)
373  normvalueDict=normDML.normValueById(session.nominalSchema(),normid) #{since:[corrector(0),{paramname:paramvalue}(1),amodetag(2),egev(3),comment(4)]}
374 
375  fig=Figure(figsize=(figureparams['sizex'],figureparams['sizey']),dpi=figureparams['dpi'])
377  logfig=Figure(figsize=(figureparams['sizex'],figureparams['sizey']),dpi=figureparams['dpi'])
379 
380  if not options.hltpath:
381  lumibyls=lumiCalcAPI.lumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=pbeammode,normmap=normvalueDict,lumitype='HF')
382  else:
383  referenceLabel='Recorded'
384  hltname=options.hltpath
385  hltpat=None
386  if hltname=='*' or hltname=='all':
387  hltname=None
388  elif 1 in [c in hltname for c in '*?[]']: #is a fnmatch pattern
389  hltpat=hltname
390  hltname=None
391  lumibyls=lumiCalcAPI.effectiveLumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=pbeammode,normmap=normvalueDict,hltpathname=hltname,hltpathpattern=hltpat)
392  session.transaction().commit()
393  rawdata={}
394  #
395  # start to plot
396  #
397  if options.action=='run':
398  for run in sorted(lumibyls):
399  rundata=lumibyls[run]
400  if not options.hltpath:
401  if len(rundata)!=0:
402  rawdata.setdefault('Delivered',[]).append((run,sum([t[5] for t in rundata if t[5]])))
403  rawdata.setdefault('Recorded',[]).append((run,sum([t[6] for t in rundata if t[6]])))
404  else:
405  labels=['Recorded']
406  if len(rundata)!=0:
407  pathdict={}#{pathname:[eff,]}
408  rawdata.setdefault('Recorded',[]).append((run,sum([t[6] for t in rundata if t[6]])))
409  for perlsdata in rundata:
410  effdict=perlsdata[8]
411  pathnames=effdict.keys()
412  for thispath in pathnames:
413  pathdict.setdefault(thispath,[]).append(effdict[thispath][3])
414  for thispath in pathdict.keys():
415  labels.append(thispath)
416  rawdata.setdefault(thispath,[]).append((run,sum([t for t in pathdict[thispath] if t])))
417  if options.yscale=='linear':
418  m.plotSumX_Run(rawdata,resultlines,textoutput=outtextfilename,yscale='linear',referenceLabel=referenceLabel,labels=labels)
419  elif options.yscale=='log':
420  m.plotSumX_Run(rawdata,resultlines,textoutput=outtextfilename,yscale='log',referenceLabel=referenceLabel,labels=labels)
421  else:
422  m.plotSumX_Run(rawdata,resultlines,textoutput=outtextfilename,yscale='linear',referenceLabel=referenceLabel,labels=labels)
423  m.plotSumX_Run(rawdata,resultlines,textoutput=outtextfilename,yscale='log',referenceLabel=referenceLabel,labels=labels)
424  if options.action=='fill':
425  for fill in sorted(fillrunMap):
426  for run in fillrunMap[fill]:
427  if not lumibyls.has_key(run): continue
428  rundata=lumibyls[run]
429  if not options.hltpath:
430  if len(rundata)!=0:
431  rawdata.setdefault('Delivered',[]).append((fill,run,sum([t[5] for t in rundata if t[5]])))
432  rawdata.setdefault('Recorded',[]).append((fill,run,sum([t[6] for t in rundata if t[6]])))
433  else:
434  labels=['Recorded']
435  if len(rundata)!=0:
436  pathdict={}#{pathname:[eff,]}
437  rawdata.setdefault('Recorded',[]).append((fill,run,sum([t[6] for t in rundata if t[6]])))
438  for perlsdata in rundata:
439  effdict=perlsdata[8]
440  pathnames=effdict.keys()
441  for thispath in pathnames:
442  pathdict.setdefault(thispath,[]).append(effdict[thispath][3])
443  for thispath in pathdict.keys():
444  labels.append(thispath)
445  rawdata.setdefault(thispath,[]).append((fill,run,sum([t for t in pathdict[thispath] if t])))
446  if options.yscale=='linear':
447  m.plotSumX_Fill(rawdata,resultlines,textoutput=outtextfilename,yscale='linear',referenceLabel=referenceLabel)
448  elif options.yscale=='log':
449  m.plotSumX_Fill(rawdata,resultlines,textoutput=outtextfilename,yscale='log',referenceLabel=referenceLabel)
450  else:
451  m.plotSumX_Fill(rawdata,resultlines,textoutput=outtextfilename,yscale='linear',referenceLabel=referenceLabel)
452  m.plotSumX_Fill(rawdata,resultlines,textoutput=outtextfilename,yscale='log',referenceLabel=referenceLabel)
453  if options.action=='time':
454  for run in sorted(lumibyls):
455  rundata=lumibyls[run]
456  if not options.hltpath:
457  if len(rundata)!=0:
458  rawdata.setdefault('Delivered',[]).append((run,rundata[0][2],rundata[-1][2],sum([t[5] for t in rundata if t[5]])))
459  rawdata.setdefault('Recorded',[]).append((run,rundata[0][2],rundata[-1][2],sum([t[6] for t in rundata if t[6]])))
460  else:
461  labels=['Recorded']
462  if len(rundata)!=0:
463  pathdict={}#{pathname:[eff,]}
464  rawdata.setdefault('Recorded',[]).append((run,rundata[0][2],rundata[-1][2],sum([t[6] for t in rundata if t[6]])))
465  for perlsdata in rundata:
466  effdict=perlsdata[8]
467  pathnames=effdict.keys()
468  for thispath in pathnames:
469  pathdict.setdefault(thispath,[]).append(effdict[thispath][3])
470  for thispath in pathdict.keys():
471  labels.append(thispath)
472  rawdata.setdefault(thispath,[]).append((run,rundata[0][2],rundata[-1][2],sum([t for t in pathdict[thispath] if t])))
473  if options.yscale=='linear':
474  m.plotSumX_Time(rawdata,resultlines,minTime=begtime,maxTime=endtime,textoutput=outtextfilename,yscale='linear',referenceLabel=referenceLabel)
475  elif options.yscale=='log':
476  mlog.plotSumX_Time(rawdata,resultlines,minTime=begtime,maxTime=endtime,textoutput=outtextfilename,yscale='log',referenceLabel=referenceLabel)
477  else:
478  m.plotSumX_Time(rawdata,resultlines,minTime=begtime,maxTime=endtime,textoutput=outtextfilename,yscale='linear',referenceLabel=referenceLabel)
479  mlog.plotSumX_Time(rawdata,resultlines,minTime=begtime,maxTime=endtime,textoutput=outtextfilename,yscale='log',referenceLabel=referenceLabel)
480  if options.action=='perday':
481  daydict={}
482  for run in sorted(lumibyls):
483  rundata=lumibyls[run]
484  for lsdata in rundata:
485  lumilsnum=lsdata[0]
486  lsTS=lsdata[2]
487  dellum=lsdata[5]
488  reclum=lsdata[6]
489  daynumber=lsTS.date().toordinal()
490  daydict.setdefault(daynumber,[]).append((run,lumilsnum,dellum,reclum))
491  for day in sorted(daydict):
492  daydata=daydict[day]
493  daybeg=str(daydata[0][0])+':'+str(daydata[0][1])
494  dayend=str(daydata[-1][0])+':'+str(daydata[-1][1])
495  daydel=sum([t[2] for t in daydata if t[2]])
496  dayrec=sum([t[3] for t in daydata if t[3]])
497  rawdata.setdefault('Delivered',[]).append((day,daybeg,dayend,daydel))
498  rawdata.setdefault('Recorded',[]).append((day,daybeg,dayend,dayrec))
499  #print 'rawdata ',rawdata
500  if options.yscale=='linear':
501  m.plotPerdayX_Time(rawdata,resultlines,minTime=begtime,maxTime=endtime,textoutput=outtextfilename,yscale='linear',referenceLabel=referenceLabel)
502  elif options.yscale=='log':
503  mlog.plotPerdayX_Time(rawdata,resultlines,minTime=begtime,maxTime=endtime,textoutput=outtextfilename,yscale='log',referenceLabel=referenceLabel)
504  else:
505  m.plotPerdayX_Time(rawdata,resultlines,minTime=begtime,maxTime=endtime,textoutput=outtextfilename,yscale='linear',referenceLabel=referenceLabel)
506  mlog.plotPerdayX_Time(rawdata,resultlines,minTime=begtime,maxTime=endtime,textoutput=outtextfilename,yscale='log',referenceLabel=referenceLabel)
507  if options.action=='instpeakperday':
508  daydict={}#{daynumber:[(runnumber,lumilsnum,inst),..]}
509  for run in sorted(lumibyls):
510  rundata=lumibyls[run]
511  for lsdata in rundata:
512  lumilsnum=lsdata[0]
513  lsTS=lsdata[2]
514  instlum=lsdata[5]/lslength
515  daynumber=lsTS.date().toordinal()
516  daydict.setdefault(daynumber,[]).append((run,lumilsnum,instlum))
517  for day in sorted(daydict):
518  daydata=daydict[day]
519  daymax_val=0.0
520  daymax_run=0
521  daymax_ls=0
522  for datatp in daydata:
523  if datatp[2]>daymax_val:
524  daymax_val=datatp[2]
525  daymax_run=datatp[0]
526  daymax_ls=datatp[1]
527  rawdata.setdefault('Delivered',[]).append((day,daymax_run,daymax_ls,daymax_val))
528  if options.yscale=='linear':
529  m.plotPeakPerday_Time(rawdata,resultlines,minTime=begtime,maxTime=endtime,textoutput=outtextfilename,yscale='linear',referenceLabel=referenceLabel)
530  elif options.yscale=='log':
531  mlog.plotPeakPerday_Time(rawdata,resultlines,minTime=begtime,maxTime=endtime,textoutput=outtextfilename,yscale='log',referenceLabel=referenceLabel)
532  else:
533  m.plotPeakPerday_Time(rawdata,resultlines,minTime=begtime,maxTime=endtime,textoutput=outtextfilename,yscale='linear',referenceLabel=referenceLabel)
534  mlog.plotPeakPerday_Time(rawdata,resultlines,minTime=begtime,maxTime=endtime,textoutput=outtextfilename,yscale='log',referenceLabel=referenceLabel)
535  if options.action=='inst':
536  thisfillnumber=fillrunMap.keys()[0]
537  starttime=0
538  stoptime=0
539  rawxdata=[]
540  rawydata={}
541  for run,rundata in lumibyls.items():
542  rundata.sort()
543  totlumils=0
544  totcmsls=0
545  starttime=rundata[0][2]
546  stoptime=rundata[-1][2]
547  for lsdata in rundata:
548  lumilsnum=lsdata[0]
549  totlumils+=1
550  cmslsnum=lsdata[1]
551  if cmslsnum!=0:
552  totcmsls+=1
553  lsTS=lsdata[2]
554  dellumi=lsdata[5]
555  reclumi=lsdata[6]
556  rawydata.setdefault('Delivered',[]).append(dellumi)
557  rawydata.setdefault('Recorded',[]).append(reclumi)
558  rawxdata=[run,thisfillnumber,starttime,stoptime,totlumils,totcmsls]
559  m.plotInst_RunLS(rawxdata,rawydata,textoutput=None)
560 
561  if options.yscale=='linear':
562  if options.interactive:
563  m.drawInteractive()
564  exit(0)
565  else:
566  if not options.withoutpng:
567  m.drawPNG(outplotfilename+'.png')
568  exit(0)
569  elif options.yscale=='log':
570  if options.interactive:
571  mlog.drawInteractive()
572  exit(0)
573  else:
574  if not options.withoutpng:
575  mlog.drawPNG(outplotfilename+'_log.png')
576  exit(0)
577  else:
578  if options.interactive:
579  print 'cannot draw both log and linear from interactive'
580  exit(0)
581  if not options.withoutpng:
582  m.drawPNG(outplotfilename+'.png')
583  mlog.drawPNG(outplotfilename+'_log.png')
584  exit(0)
585 
Definition: start.py:1
def dataIdsByTagId
Definition: revisionDML.py:798
const T & max(const T &a, const T &b)
def normIdByType
Definition: normDML.py:92
def effectiveLumiForIds
Definition: lumiCalcAPI.py:532
def dataIdsByTagName
Definition: revisionDML.py:689
def fillrunMap
Definition: lumiCalcAPI.py:41
def currentDataTag
Definition: revisionDML.py:513
def parseInputFiles
Definition: lumiPlot.py:14
def normValueById
Definition: normDML.py:181
def runsummaryMap
Definition: lumiCalcAPI.py:21
def normIdByName
Definition: normDML.py:60