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