CMS 3D CMS Logo

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