ATLAS Offline Software
AtlRunQuerySummary.py
Go to the documentation of this file.
1 #!/bin/env python
2 
3 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4 #
5 # ----------------------------------------------------------------
6 # Script : AtlRunQuerySummary.py
7 # Project: AtlRunQuery
8 # Purpose: Library with the Summary maker
9 # Authors: Andreas Hoecker (CERN), Joerg Stelzer (DESY)
10 # Created: Oct 6, 2009
11 # ----------------------------------------------------------------
12 #
13 from __future__ import print_function
14 import sys, time
15 from CoolRunQuery.utils.AtlRunQueryUtils import prettyNumber, durationInSeconds, filesize, importroot
16 from CoolRunQuery.utils.AtlRunQueryLookup import DQChannelDict, DQSuperGroupsDict, DQGroupDict, DQChannels
17 from CoolRunQuery.output.AtlRunQueryRoot import SetStyle, MakeHtml
18 from CoolRunQuery.selector.AtlRunQuerySelectorBase import DataKey
19 importroot()
20 from ROOT import TCanvas, gPad, gStyle, TGraph, TColor, TGaxis, gROOT, TH1F, TLegend, TText, Double
21 
22 # custom ROOT colours
23 c_White = TColor.GetColor( "#ffffff" )
24 c_NovelBlue = TColor.GetColor( "#2244a5" )
25 c_DarkOrange = TColor.GetColor( "#ff6600" )
26 c_NovelRed = TColor.GetColor( "#dd0033" )
27 c_DarkGreen = TColor.GetColor( "#116600" )
28 c_Violet = TColor.GetColor( "#aa11aa" )
29 c_LightBlue = TColor.GetColor( "#66aaff" )
30 c_VDarkYellow = TColor.GetColor( "#ffa500" )
31 c_Gray = TColor.GetColor( "#888888" )
32 c_VLightGray = TColor.GetColor( "#eeeeee" )
33 c_VDarkGray = TColor.GetColor( "#333333" )
34 
35 def MakeSummaryTableHtml( cornerstr, colstr, rowkeys, table, tablewidth ):
36 
37  # dimensions
38  ncol = len(colstr)
39  nrow = len(rowkeys)
40 
41  s = '<table class="resulttable" width="%i" style="margin-left: 14px">\n' % tablewidth
42  # headline
43  s += '<tr>\n'
44  if cornerstr != '':
45  s += ' <th style="text-align:left">%s</th> ' % cornerstr
46  else:
47  s += ' <th class="emptycorner">&minus;</th>'
48  for ic in range(0,ncol):
49  s += '<th>%s</th>' % colstr[ic]
50  s += '</tr>\n'
51  for ir in range(0,nrow):
52  if ir%2 == 0:
53  color = 1
54  else:
55  color = 2
56  if 'debug_' in rowkeys[ir][1]:
57  s += '<tr class="outRed%s">\n' % color # special colours for debug stream
58  else:
59  s += '<tr class="out%s">\n' % color
60  s += ' <th class="rowsum" style="text-align:left">%s&nbsp;</th> ' % rowkeys[ir][1]
61  for ic in range(ncol):
62  if ic in rowkeys[ir][4]:
63  # exclude from printing
64  s += '<td style="text-align:center">&minus;</td'
65  continue
66  s += '<td style="text-align:right">'
67  if isinstance(table[ir][ic],str):
68  s += "%s" % table[ir][ic] # example filesize
69  elif rowkeys[ir][3] == 'pretty-int':
70  s += "%s" % prettyNumber(int(table[ir][ic])) # example '#Event'
71  else:
72  s += (rowkeys[ir][3] % table[ir][ic]) # format
73  s += '%s</td>' % rowkeys[ir][2] # unit
74 
75  s += '</tr>\n'
76  s += '</table>'
77 
78  return s
79 
80 def MakeDQSummaryTableHtml( cornerstr, title, colstr, colchans, rowstr, rowstrNames, dic, nruns, labeloffset ):
81 
82  if nruns <= 0:
83  return ''
84 
85  # dimensions
86  ncol = len(colstr) # flag types
87  nrow = len(rowstr) # DQ channels
88 
89  # overlay pictures
90  dw_call = '<script type="text/javascript">\n'
91  dw_call += """if(dw_Tooltip.content_vars==undefined) {dw_Tooltip.content_vars = {}; };\n"""
92  for ir in range(0,nrow):
93  for ic in range(0,ncol):
94  if dic[colchans[ic]][rowstr[ir]][0] > 0:
95  var = 'var_%i_%i' % (ir,ic+labeloffset)
96  dw_call += 'dw_Tooltip.content_vars["%s"] = {' % var
97  dw_call += "content: '<strong><b>Corresponding&nbsp;run(s)&nbsp;[#&nbsp;=&nbsp;%i]:</b></strong><br> " % dic[colchans[ic]][rowstr[ir]][0]
98  icc = 0
99  for r in dic[colchans[ic]][rowstr[ir]][1]:
100  dw_call += '%s, ' % r
101  icc += 1
102  if icc%8 == 0:
103  dw_call += '<br>'
104  if dw_call[-1-3:] == '<br>':
105  dw_call = dw_call[0:-1-3] # remove ', <br>'
106  else:
107  dw_call = dw_call[0:-1-1] # remove ', '
108  dw_call += """ ' };\n"""
109  dw_call += '</script>\n\n'
110 
111  s = '<table class="resulttable" width="auto" style="margin-left: 14px">\n'
112  # headline
113  s += '<tr>\n'
114  if cornerstr != '':
115  s += ' <th class="rowsum" style="text-align:left" rowspan="2">%s</th> ' % cornerstr
116  else:
117  s += ' <th class="emptycorner" rowspan="2">&minus;</th>'
118  s += '<th class="colsumL" colspan="%i">%s</th></tr><tr>' % (ncol, title)
119  for ic in range(0,ncol):
120  s += '<th class="colsum">%s</th>' % colstr[ic]
121  s += '</tr>\n'
122  for ir in range(0,nrow):
123  if ir%2 == 0:
124  color = 1
125  else:
126  color = 2
127  s += '<tr class="out%s">\n' % color
128  s += ' <th class="rowsum" style="text-align:left">%s</th> ' % rowstrNames[ir]
129  for ic in range(0,ncol):
130  dqk = rowstr[ir]
131  dqk_tdtype = dqk
132  if dqk == 'n.a.':
133  dqk_tdtype = 'NA'
134  s += '<td class="td%s" style="text-align:center">' % dqk_tdtype
135  if dic[colchans[ic]][rowstr[ir]][0] > 0:
136  s += '<div class="showTip var_%i_%i" style="display:inline;cursor:pointer">' % (ir,ic+labeloffset)
137  if dic[colchans[ic]][dqk][0]>0:
138  s += '%i' % (dic[colchans[ic]][dqk][0])
139  if dic[colchans[ic]][rowstr[ir]][0] > 0:
140  s += '</div>'
141  s += '</td>'
142 
143  s += '</tr>\n'
144  s += '</table>\n\n'
145  s += dw_call
146  s += '\n'
147 
148  return s
149 
150 def ComputeStats( vlist ):
151  if len(vlist) == 0:
152  return [0,0,0,0,0]
153  tot = 0
154  mn = +sys.maxint
155  mx = -sys.maxint
156  for v in vlist:
157  tot += v
158  mn = min(mn,v)
159  mx = max(mx,v)
160  mean = float(tot)/len(vlist)
161  return [tot,mean,mn,mx,len(vlist)]
162 
163 def DecodeStr( s, tpe ):
164  if 'Duration' == tpe:
165  return durationInSeconds(s)/float(3600)
166  elif 'STR:physics_*' == tpe:
167  s = s[0].value
168  if len(s) <= 1:
169  print ('Big troubles... in function "AtlRunQuerySummary::DecodeStr": invalid length for "%s"' % tpe)
170  sys.exit(1)
171  if s[0] <= 0:
172  return 0
173  else:
174  return float(s[1])/s[0]/1.0e6
175 
176  # otherwise
177  return int(s[0].value)
178 
179 def DrawGraph( graph, col, width, style, legend, title,
180  drawNumber=False, unit='M', text=TText() ): # noqa: B008 (TText instance is re-used)
181  hist = graph.GetHistogram()
182  hist.SetLineColor( col )
183  graph.SetLineColor( col )
184  hist.SetLineWidth( width )
185  graph.SetLineWidth( width )
186  hist.SetLineStyle( style )
187  graph.SetLineStyle( style )
188  graph.Draw("lsame")
189  legend.AddEntry( hist, title, "L" )
190 
191  # draw max number
192  if drawNumber:
193  N = graph.GetN()
194  minunit_ = Double(0)
195  maxunit_ = Double(0)
196  minnev_ = Double(0)
197  maxnev_ = Double(0)
198  x = Double(0)
199  y = Double(0)
200  graph.GetPoint( 0, minunit_, minnev_ )
201  graph.GetPoint( N-1, maxunit_, maxnev_ )
202  dist = maxunit_ - minunit_
203  graph.GetPoint( N-1,x,y )
204 
205  text.SetTextAlign( 12 )
206  text.SetTextSize( 0.030 )
207  text.SetTextColor( c_NovelBlue )
208  if y >= 100:
209  yt = '%.0f' % y
210  else:
211  yt = '%#.3g' % y
212  text.DrawText( x+0.015*dist, y, '%s %s' % (yt, unit) )
213 
214 def SetFrameStyle( frame, scale = 1.0 ):
215 
216  c_VLightGray = TColor.GetColor( "#eeeeee" )
217  c_VDarkGray = TColor.GetColor( "#333333" )
218 
219  frame.SetLabelOffset( 0.012, "X" )
220  frame.SetLabelOffset( 0.012, "Y" )
221  frame.GetXaxis().SetTitleOffset( 1.25 )
222  frame.GetYaxis().SetTitleOffset( 0.94 )
223  frame.GetXaxis().SetTitleSize( 0.045*scale )
224  frame.GetYaxis().SetTitleSize( 0.045*scale )
225  labelSize = 0.04*scale
226  frame.GetXaxis().SetLabelSize( labelSize )
227  frame.GetYaxis().SetLabelSize( labelSize )
228  gPad.SetTicks()
229  gPad.SetBottomMargin( 0.120*scale )
230  gStyle.SetTitleFillColor( c_VLightGray )
231  gStyle.SetTitleTextColor( c_VDarkGray )
232  gStyle.SetTitleBorderSize( 1 )
233  gStyle.SetTitleH( 0.06 )
234  gStyle.SetTitleX( gPad.GetLeftMargin() )
235  gStyle.SetTitleY( 1 - gPad.GetTopMargin() + gStyle.GetTitleH() )
236  gStyle.SetTitleW( 1 - gPad.GetLeftMargin() - gPad.GetRightMargin() )
237 
238 def CreateCanvasAndFrame( runmin, runmax, tminS, tmaxS, maxnev, type, unit ):
239  # plots the graphs
240  title = "ATLAS integrated numnber of events in run range %i - %i" % (runmin, runmax)
241  c = TCanvas( "c", title, 0, 0, 800, 550 )
242  c.GetPad(0).SetRightMargin(0.08)
243  c.GetPad(0).SetLeftMargin(0.10)
244  c.GetPad(0).SetTopMargin(0.07)
245  htitle = "Events recorded by ATLAS between %s and %s" % (time.strftime('%b %d',tminS),
246  time.strftime('%b %d, %Y',tmaxS))
247 
248  frame = TH1F( "frame", htitle.strip(), 10000, runmin, runmax )
249 
250  SetFrameStyle( frame )
251  TGaxis.SetMaxDigits(6)
252  frame.GetYaxis().SetTitleOffset( 1.0 )
253  frame.SetMinimum( 0 )
254  frame.SetMaximum( maxnev*1.1 )
255  frame.SetYTitle( "Number of events (in %s)" % unit )
256  frame.SetXTitle( "Run number" )
257  frame.Draw()
258 
259  # legend for plot
260  dx = 0.04
261  dy = -0.05
262  legend = TLegend( c.GetLeftMargin() + dx, 1 - c.GetTopMargin() + dy,
263  c.GetLeftMargin() + 0.48 + dx, 1 - c.GetTopMargin() - 0.38 + dy)
264  legend.SetFillStyle( 1001 )
265  legend.SetFillColor( c_VLightGray )
266  legend.SetBorderSize(1)
267  legend.SetMargin( 0.2 )
268  legend.SetTextColor( c_VDarkGray )
269  legend.Draw("same")
270 
271  return c, frame, legend
272 
273 def MakeRootPlots( rootstreamdic, datapath ):
274 
275  # suppress output
276  gROOT.SetBatch( 1 )
277 
278  # common style, and a few corrections
279  SetStyle()
280 
281  colours = [ c_NovelRed, 4, c_DarkOrange, c_DarkGreen, c_Violet, c_LightBlue, 3, c_VDarkYellow, c_Gray,
282  1, 2, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28 ]
283 
284  # run ranges (note: reverse order!)
285  run_and_time = sorted(rootstreamdic[DataKey('Start and endtime')])
286  runs = [x[0] for x in run_and_time]
287  runmin = min(runs)
288  runmax = max(runs)
289 
290  tmin = min([x[1][0] for x in run_and_time])
291  tmax = max([x[1][1] for x in run_and_time])
292 
293  # time structs
294  tminS = time.gmtime(tmin)
295  tmaxS = time.gmtime(tmax)
296 
297  # html references
298  htmlstr = []
299 
300  # create graphs
301  graphs = []
302  sortdic = {}
303  maxnev = { 'all_':-1, 'debug_':-1,'calibration_':-1 }
304  for key, content in rootstreamdic.iteritems():
305  if type(key)==DataKey:
306  key = key.ResultKey
307  if 'Start and endtime' not in key:
308  graphs.append( TGraph( len(content) ) )
309  graphs[-1].SetName( key.strip().replace(' ','_') )
310  graphs[-1].SetTitle( key.strip() )
311  cumulsum = 0
312  for i in range(len(content)):
313  j = len(content)-1-i # reverse order
314  scale = 1.e6
315  if 'debug_' in key:
316  scale = 1.e3
317  cumulsum += content[j][1]/scale
318  graphs[-1].SetPoint( i, content[j][0], cumulsum ) # number of events in million
319  for stype in maxnev.keys():
320  if stype in key:
321  if cumulsum > maxnev[stype]:
322  maxnev[stype] = cumulsum
323  if 'debug_' not in key and cumulsum > maxnev['all_']:
324  maxnev['all_'] = cumulsum
325  sortdic[len(graphs)-1] = cumulsum
326 
327  # sort dictionary into list
328  sortedlist = sorted(sortdic, key=sortdic.__getitem__, reverse=True)
329 
330  # individual physics streams
331  ic = 0
332  for i in sortedlist:
333  g = graphs[i]
334  name = g.GetTitle()
335  if 'physics_' in name or 'express_' in name:
336  x = Double(0)
337  y = Double(0)
338  g.GetPoint( g.GetN()-1, x, y )
339  c, frame, legend = CreateCanvasAndFrame( runmin, runmax, tminS, tmaxS, y*1.1, '', 'million' )
340  legend.SetX2( legend.GetX2() - 0.2 )
341  legend.SetY1( legend.GetY2() - 0.05 )
342  DrawGraph( g, colours[ic], 2, 1, legend, name.replace('physics_','').replace('express_','').replace('express','Express'), True, 'M', TText() )
343  ic += 1
344 
345  # redraw axes and update
346  frame.Draw("sameaxis")
347  c.Update()
348 
349  # make plot
350  fname = '%s/atlrunquery_%s.png' % (datapath, name)
351  c.Print( fname )
352  del frame
353 
354  # reference in html
355  htmlstr.append( MakeHtml( ['Events in streams %s versus run' % name], [fname], True, 60, 5 ) )
356 
357  # physics streams only ------------------------------------------------------------
358  c, frame, legend = CreateCanvasAndFrame( runmin, runmax, tminS, tmaxS, maxnev['all_'], '', 'million' )
359  ic = 0
360  for i in sortedlist:
361  g = graphs[i]
362  name = g.GetTitle()
363  if '#Events (streamed)' in name:
364  DrawGraph( g, c_NovelBlue, 2, 2, legend, "Total number of streamed events" )
365  elif '#Events' == name:
366  DrawGraph( g, c_NovelBlue, 5, 1, legend, "Total number of triggered events (excl. calib)", True, 'M', TText() )
367  elif 'physics_' in name or 'express_' in name:
368  DrawGraph( g, colours[ic], 2, 1, legend, name.replace('physics_','').replace('express_','').replace('express','Express') )
369  ic += 1
370 
371  # redraw axes and update canvas
372  frame.Draw("sameaxis")
373  c.Update()
374 
375  # make plot
376  fname = '%s/atlrunquery_physicsstreams.png' % datapath
377  c.Print( fname )
378  del frame
379 
380  # reference in html
381  htmlstr.append( MakeHtml( ['Events in physics streams versus run'], [fname], True, 60, 5 ) )
382 
383  # the other types can be
384  # stream_type nice text unit
385  plottypes = { 'debug_' : [ 'Debug', 'thousand', 'k' ],
386  'calibration_' : [ 'Calibration', 'million', 'M' ] }
387 
388  # debug and calibration streams ----------------------------------------------------
389  for key, cprop in plottypes.iteritems():
390 
391  c, frame, legend = CreateCanvasAndFrame( runmin, runmax, tminS, tmaxS, maxnev[key], cprop[0], cprop[1] )
392  legend.SetY1( legend.GetY1() + 0.15 )
393  legend.SetX2( legend.GetX2() - 0.15 )
394  ic = 0
395  for i in sortedlist:
396  g = graphs[i]
397  name = g.GetTitle()
398  if key in name:
399  DrawGraph( g, colours[ic], 2, 1, legend, name, ic == 0, cprop[2], TText() )
400  ic += 1
401 
402  # redraw axes and update canvas
403  frame.Draw("sameaxis")
404  c.Update()
405 
406  # make plot
407  fname = '%s/atlrunquery_%sstreams.png' % (datapath, cprop[0].lower())
408  c.Print( fname )
409  del frame
410 
411  # reference in html
412  htmlstr.append( MakeHtml( ['Events in %s streams versus run' % cprop[0].lower()], [fname], True, 60, 5 ) )
413 
414  # html code ---------------------------------------------------------------------------
415  retstr = '<table width="900" style="margin-left: 14px; background-color: #f0f0f0; border: 2px white solid; border-collapse: collapse;"><tr>'
416  for i,s in enumerate(htmlstr):
417  retstr += '<td style="padding: 4px">%s</td>' % s
418  if (i+1)%5 == 0:
419  retstr += '</tr><tr>'
420  retstr += '</tr></table>'
421 
422  return retstr
423 
424 def MakeSummaryHtml( dic, dicsum, datapath ):
425  # run and time ranges
426  runs = dic[DataKey('Run')]
427  nruns = len(runs)
428  times = dic[DataKey('Start and endtime')]
429 
430  starttime = float(times[-1].partition(',')[0])
431  endtime = float(times[0].partition(',')[2])
432 
433  s = '<table style="color: #777777; font-size: 85%; margin-left: 14px" cellpadding="0" cellspacing="3">\n'
434  # runs in reverse order
435  s += '<tr><td><i>Number of runs selected:</i></td><td>&nbsp;&nbsp;%g</td><td></td></tr>\n' % (len(runs))
436  s += '<tr><td><i>First run selected:</i></td><td>&nbsp;&nbsp;%s</td><td>&nbsp;&nbsp;(%s)</td></tr>\n' % (runs[-1], time.strftime("%a %b %d, %Y, %X",time.gmtime(starttime)))
437  s += '<tr><td><i>Last run selected:</i></td><td>&nbsp;&nbsp;%s</td><td>&nbsp;&nbsp;(%s)</td></tr>\n' % (runs[0], time.strftime("%a %b %d, %Y, %X",time.gmtime(endtime)))
438  s += '</table>\n'
439 
440  # --------------------------------------------------------------------------------------
441  # run summary table
442  s += '<p></p>\n'
443  s += '<table style="margin-left: 14px">\n'
444  s += '<tr><td><b>Run / Event Summary</b></td></tr>\n'
445  s += '</table>\n'
446 
447  table = []
448  # format Title in dico Title in table unit format which columns in table to exclude
449  keys = [ [ 'Duration', 'Run duration', ' h', '%.2f', [] ],
450  [ '#Events', '#Events (excl.)', '', 'pretty-int', [] ],
451  [ '#Events (streamed)', '#Events (incl.)', '', 'pretty-int', [] ],
452  [ 'STR:physics_*', 'Event size <font size="-2">(RAW)</font>',' MB', '%.2f', [0] ] # with wildcard
453  ]
454  for k in keys:
455  v = []
456  for dk, c in dic.iteritems():
457  # exact check?
458  if ('*' in k[0] and k[0].replace('*','') in dk.ResultKey) or ('*' not in k[0] and k[0] == dk.ResultKey):
459  for x in c:
460  try:
461  v.append( DecodeStr( x, k[0] ) )
462  except ValueError: # if n.a.
463  pass
464  # sanity check
465 
466 
470  table.append( ComputeStats( v ) )
471 
472  s += MakeSummaryTableHtml( '', ['Total', 'Average', 'Min', 'Max'], keys, table, 500 )
473 
474  # --------------------------------------------------------------------------------------
475  # stream summary table
476  s += '<p></p>\n'
477  s += '<table style="margin-left: 14px">\n'
478  s += '<tr><td><b>Streams / Events Summary</b> <font size=-2> [ Straight averages given, not weighted by number of events in run ]</font></td></tr>\n'
479  s += '</table>\n'
480 
481  streamdic = {}
482  streamsizedic = {}
483  streamfracdic = {}
484  streamratedic = {}
485  rootstreamdic = {}
486  v = []
487  for dk, c in dic.iteritems():
488  # for root
489  if '#Events' in dk.ResultKey:
490  rootstreamdic[dk] = []
491  for run,dataentries in zip(runs,c):
492  #for i in range(len(c)):
493  run = int(run)
494  data = dataentries[0].value # for events and time info there is only one entry in the list per run
495  try:
496  rootstreamdic[dk].append([run, int(data)])
497  except ValueError:
498  if data != 'n.a.':
499  rootstreamdic[dk].append([run, data])
500 
501  if 'Start and endtime' in dk.ResultKey:
502  rootstreamdic[dk] = []
503  for run,data in zip(runs,c):
504  if data != 'n.a.':
505  rootstreamdic[dk].append([int(run), map(float,data.split(','))])
506 
507  # collect streams
508  if 'STR:' in dk.ResultKey:
509  # loop over runs
510  sname = dk.ResultKey.replace('STR:','')
511  streamdic[sname] = []
512  streamsizedic[sname] = 0
513  streamfracdic[sname] = []
514  streamratedic[sname] = []
515  rootstreamdic[sname] = []
516  #for i in range(len(c)):
517  for run,t,dataentries in zip(runs,times,c):
518  run = int(run)
519  data = dataentries[0].value # for stream data there is only one entry in the list per run
520  if not isinstance(data, str): # not 'n.a.'
521  streamdic[sname].append(data[0])
522  streamfracdic[sname].append(data[0])
523  tmin_ = float(t.partition(',')[0])
524  tmax_ = float(t.partition(',')[2])
525  deltat = tmax_ - tmin_
526  if (deltat > 0):
527  streamratedic[sname].append(data[0]/deltat)
528  else:
529  streamratedic[sname].append(-1)
530  streamsizedic[sname] += data[1]
531  try:
532  rootstreamdic[sname].append([run, data[0]])
533  except ValueError:
534  pass
535  else:
536  streamfracdic[sname].append('na')
537 
538  # sort (physics, debug, calibration)
539  streamtypes = ['physics', 'express', 'debug', 'calibration']
540  sortedstreams = []
541  for stype in streamtypes:
542  keys = {}
543  for key, c in streamdic.iteritems():
544  if stype in key:
545  keys[key] = sum(c)
546  sortedstreams += sorted(keys, key=keys.__getitem__, reverse=True)
547 
548  # fill table
549  keys = []
550  table = []
551  for stream in sortedstreams:
552  stats = ComputeStats( streamdic[stream] )
553  table.append( stats[0:4] )
554 
555  # compute event fractions (not for calibration streams)
556  if 'calibration_' not in stream:
557  v = []
558  for i, evrun in enumerate(streamfracdic[stream]):
559  if evrun != 'na':
560  evsum = float(0)
561  for stream2 in sortedstreams:
562  if 'calibration_' not in stream2:
563  if streamfracdic[stream2][i] != 'na':
564  evsum += streamfracdic[stream2][i]
565  if evsum > 0:
566  v.append( float(evrun)/evsum*100 ) # fraction in percent
567 
568  table[-1] += ['%.3g' % ComputeStats( v )[1]]
569  else:
570  table[-1] += ['&minus']
571 
572  # average rate
573  table[-1] += ['%.3g' % ComputeStats( streamratedic[stream] )[1]]
574 
575  # put here #runs where the stream was produced
576  table[-1] += [stats[4]]
577 
578  # event sizes
579  if table[-1][0] > 0:
580  table[-1] += [filesize(streamsizedic[stream]),
581  filesize(float(streamsizedic[stream])/table[-1][0])]
582  else:
583  table[-1] += [filesize(streamsizedic[stream]),'&minus']
584 
585  prettystr = stream
586  if 'debug' in stream:
587  prettystr = '<font color="#C11B17">' + stream + '</font>'
588  # format Title in dico Title in table unit format which columns in table to exclude
589  keys.append( [stream, prettystr, '', 'pretty-int', []] )
590 
591  s += MakeSummaryTableHtml( 'Stream',
592  ['Total', 'Average', 'Min', 'Max',
593  'Average<br>fraction&nbsp;(%)',
594  'Average<br>rate&nbsp;(Hz)',
595  '#Runs<br><font size="-2">(out&nbsp;of&nbsp;%i)</font>' % nruns,
596  'Total&nbsp;file<br>size&nbsp;<font size="-2">(RAW)</font>',
597  'Average&nbsp;event<br>size&nbsp;<font size="-2">(RAW)</font>'], keys, table, 900 )
598 
599  # make integrated events plots
600  htmlstr = MakeRootPlots( rootstreamdic, datapath )
601  s += htmlstr
602 
603  return s
604 
605  # DQ summary not operational anymore since defects ?
606 
607  # --------------------------------------------------------------------------------------
608  # DQ summary table
609  s += '<p></p>\n'
610  s += '<table style="margin-left: 14px">\n'
611  s += '<tr><td><b>Data Quality Summary - SHIFTOFL (number of runs)</b> <font size=-2> [ No number signifies zero. Move mouse over number to see corresponding runs. ]</font></td></tr>\n'
612  s += '</table>\n'
613 
614  dqflags = ['G','Y','R','B','U','n.a.']
615  dqflagsNames = ['Green', 'Yellow', 'Red', 'Black', 'Unknown', 'Not&nbsp;assigned&nbsp;']
616  dqitems = DQChannels()
617 
618  # DQ flags are grouped together according to their channel numbers
619  # all groups with equal first two digits belong together
620 
621  UseGroups = False
622  if UseGroups:
623  ndq = {}
624  for chan, dqgroup in DQGroupDict.items():
625  ndq[chan] = {}
626  for dqflag in dqflags:
627  ndq[chan][dqflag] = 0
628 
629  for chan, dqchan in dqitems:
630  if dqchan in dic:
631  grchan = int(chan/10)*10
632  if grchan == 430:
633  grchan = 420 # 'ad hoc' correction for TAU trigger
634  for dqflag in dic[dqchan]:
635  ndq[grchan][dqflag] += 1
636 
637  colstr = []
638  colchans = []
639  for chan, dqgroup in DQChannelDict.items():
640  colstr.append( dqgroup )
641  colchans.append( chan )
642 
643  # here per channel
644  colstr = []
645  colchans = []
646  ndq = {}
647  for chan, dqchan in dqitems:
648  dqchan = "SHIFTOFL_%s" % (dqchan)
649  colstr.append( dqchan )
650  colchans.append( chan )
651 
652  ndq[chan] = {}
653  for dqflag in dqflags:
654  ndq[chan][dqflag] = [0, []]
655 
656  if dqchan in dic:
657  for i, dqflag in enumerate(dic[dqchan]):
658  ndq[chan][dqflag][0] += 1
659  ndq[chan][dqflag][1].append(runs[i])
660 
661 
662  # create summary table
663  # break table after 'nc' entries
664  nc = 15
665  colstr_ = []
666  colchans_ = []
667  for i in range(len(colchans)):
668  if (i+1)%nc == 0:
669  labeloffset = i # required to avoid double-labels for tool-tips
670  colstr_ = []
671  colchans_ = []
672  else:
673  colstr_.append(colstr[i])
674  colchans_.append(colchans[i])
675 
676  # groups
677  labeloffset = 0
678  for dqgroup, content in DQSuperGroupsDict.iteritems():
679  colstr_ = []
680  colchans_ = []
681  title = content[0]
682  for dqchan in content[1]:
683  colstr_.append(dqchan)
684  colchans_.append(DQChannelDict[dqchan])
685  s += MakeDQSummaryTableHtml( '', title, colstr_, colchans_, dqflags, dqflagsNames, ndq, nruns, labeloffset )
686  labeloffset += 1 # required to avoid double-labels for tool-tips
687  s += '<p></p>'
688 
689  # return full page string
690  return s
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
python.html.AtlRunQuerySummary.MakeSummaryHtml
def MakeSummaryHtml(dic, dicsum, datapath)
Definition: AtlRunQuerySummary.py:424
python.utils.AtlRunQueryUtils.prettyNumber
def prettyNumber(n, width=-1, delim=',', decimal='.')
Definition: AtlRunQueryUtils.py:73
python.utils.AtlRunQueryUtils.filesize
def filesize(no)
Definition: AtlRunQueryUtils.py:198
python.output.AtlRunQueryRoot.MakeHtml
def MakeHtml(hnames, fnames, uselarge=False, iconwidth=70, nbreakline=10)
Definition: AtlRunQueryRoot.py:742
python.html.AtlRunQuerySummary.SetFrameStyle
def SetFrameStyle(frame, scale=1.0)
Definition: AtlRunQuerySummary.py:214
max
#define max(a, b)
Definition: cfImp.cxx:41
python.utils.AtlRunQueryUtils.importroot
def importroot(batch=True)
Definition: AtlRunQueryUtils.py:58
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.html.AtlRunQuerySummary.DecodeStr
def DecodeStr(s, tpe)
Definition: AtlRunQuerySummary.py:163
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
python.output.AtlRunQueryRoot.SetStyle
def SetStyle(whiteCanvas=False)
Definition: AtlRunQueryRoot.py:28
python.utils.AtlRunQueryUtils.durationInSeconds
def durationInSeconds(duration_string)
Definition: AtlRunQueryUtils.py:88
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
python.html.AtlRunQuerySummary.MakeSummaryTableHtml
def MakeSummaryTableHtml(cornerstr, colstr, rowkeys, table, tablewidth)
Definition: AtlRunQuerySummary.py:35
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
python.html.AtlRunQuerySummary.CreateCanvasAndFrame
def CreateCanvasAndFrame(runmin, runmax, tminS, tmaxS, maxnev, type, unit)
Definition: AtlRunQuerySummary.py:238
python.html.AtlRunQuerySummary.ComputeStats
def ComputeStats(vlist)
Definition: AtlRunQuerySummary.py:150
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
min
#define min(a, b)
Definition: cfImp.cxx:40
python.utils.AtlRunQueryLookup.DQChannels
def DQChannels()
Definition: AtlRunQueryLookup.py:119
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
StateLessPT_NewConfig.partition
partition
Definition: StateLessPT_NewConfig.py:49
python.html.AtlRunQuerySummary.MakeDQSummaryTableHtml
def MakeDQSummaryTableHtml(cornerstr, title, colstr, colchans, rowstr, rowstrNames, dic, nruns, labeloffset)
Definition: AtlRunQuerySummary.py:80
python.html.AtlRunQuerySummary.MakeRootPlots
def MakeRootPlots(rootstreamdic, datapath)
Definition: AtlRunQuerySummary.py:273
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
python.html.AtlRunQuerySummary.DrawGraph
def DrawGraph(graph, col, width, style, legend, title, drawNumber=False, unit='M', text=TText())
Definition: AtlRunQuerySummary.py:179
readCCLHist.float
float
Definition: readCCLHist.py:83