CMS 3D CMS Logo

html.py
Go to the documentation of this file.
1 import os
2 import collections
3 
4 def _lowerFirst(s):
5  return s[0].lower()+s[1:]
6 
7 _sampleName = {
8  "RelValMinBias": "Min Bias",
9  "RelValTTbar": "TTbar",
10  "RelValQCD_Pt_600_800": "QCD Pt 600 to 800",
11  "RelValQCD_Pt_3000_3500": "QCD Pt 3000 to 3500",
12  "RelValQCD_FlatPt_15_3000": "QCD Flat Pt 15 to 3000",
13  "RelValZMM": "ZMuMu",
14  "RelValWjet_Pt_3000_3500": "Wjet Pt 3000 to 3500",
15  "RelValH125GGgluonfusion": "Higgs to gamma gamma",
16  "RelValSingleElectronPt35": "Single Electron Pt 35",
17  "RelValSingleElectronPt35Extended": "Single Electron Pt 35 (extended eta)",
18  "RelValSingleElectronPt10": "Single Electron Pt 10",
19  "RelValSingleMuPt10": "Single Muon Pt 10",
20  "RelValSingleMuPt10Extended": "Single Muon Pt 10 (extended eta)",
21  "RelValSingleMuPt100": "Single Muon Pt 100",
22  "RelValTenMuE_0_200": "Ten muon Pt 0-200",
23 }
24 
25 _sampleFileName = {
26  "RelValMinBias": "minbias",
27  "RelValTTbar": "ttbar",
28  "RelValQCD_Pt_600_800": "qcd600",
29  "RelValQCD_Pt_3000_3500": "qcd3000",
30  "RelValQCD_FlatPt_15_3000": "qcdflat",
31  "RelValZMM": "zmm",
32  "RelValWjet_Pt_3000_3500": "wjet3000",
33  "RelValH125GGgluonfusion": "hgg",
34  "RelValSingleElectronPt35": "ele35",
35  "RelValSingleElectronPt35Extended": "ele35ext",
36  "RelValSingleElectronPt10": "ele10",
37  "RelValSingleMuPt10": "mu10",
38  "RelValSingleMuPt10Extended": "mu10ext",
39  "RelValSingleMuPt100": "mu100",
40  "RelValTenMuE_0_200": "tenmu200",
41 }
42 
43 _allTPEfficName = "All tracks (all TPs)"
44 _fromPVName = "Tracks from PV"
45 _fromPVAllTPName = "Tracks from PV (all TPs)"
46 _conversionName = "Tracks for conversions"
47 _gsfName = "Electron GSF tracks"
48 def _toHP(s):
49  return "High purity "+_lowerFirst(s)
50 def _allToHP(s):
51  return s.replace("All", "High purity")
52 def _ptCut(s):
53  return s.replace("Tracks", "Tracks pT > 0.9 GeV").replace("tracks", "tracks pT > 0.9 GeV")
54 _trackQualityNameOrder = collections.OrderedDict([
55  ("seeding_seeds", "Seeds"),
56  ("seeding_seedsa", "Seeds A"),
57  ("seeding_seedsb", "Seeds B"),
58  ("seeding_seedstripl", "Seeds triplets"),
59  ("seeding_seedspair", "Seeds pairs"),
60  ("building_", "Built tracks"),
61  ("", "All tracks"),
62  ("highPurity", "High purity tracks"),
63  ("Pt09", "Tracks pT > 0.9 GeV"),
64  ("highPurityPt09", "High purity tracks pT > 0.9 GeV"),
65  ("ByOriginalAlgo", "All tracks by originalAlgo"),
66  ("highPurityByOriginalAlgo", "High purity tracks by originalAlgo"),
67  ("ByAlgoMask", "All tracks by algoMask"),
68  ("highPurityByAlgoMask", "High purity tracks by algoMask"),
69  ("btvLike", "BTV-like"),
70  ("ak4PFJets", "AK4 PF jets"),
71  ("allTPEffic_", _allTPEfficName),
72  ("allTPEffic_highPurity", _allToHP(_allTPEfficName)),
73  ("fromPV_", _fromPVName),
74  ("fromPV_highPurity", _toHP(_fromPVName)),
75  ("fromPV_Pt09", _ptCut(_fromPVName)),
76  ("fromPV_highPurityPt09", _toHP(_ptCut(_fromPVName))),
77  ("fromPVAllTP_", _fromPVAllTPName),
78  ("fromPVAllTP_highPurity", _toHP(_fromPVAllTPName)),
79  ("fromPVAllTP_Pt09", _ptCut(_fromPVAllTPName)),
80  ("fromPVAllTP_highPurityPt09", _toHP(_ptCut(_fromPVAllTPName))),
81  ("fromPVAllTP2_", _fromPVAllTPName.replace("PV", "PV v2")),
82  ("fromPVAllTP2_highPurity", "High purity "+_lowerFirst(_fromPVAllTPName).replace("PV", "PV v2")),
83  ("fromPVAllTP2_Pt09", _fromPVAllTPName.replace("Tracks", "Tracks pT > 0.9 GeV").replace("PV", "PV v2")),
84  ("fromPVAllTP2_highPurityPt09", _toHP(_ptCut(_fromPVAllTPName)).replace("PV", "PV v2")),
85  ("conversion_", _conversionName),
86  ("gsf_", _gsfName),
87 ])
88 
89 _trackAlgoName = {
90  "ootb": "Out of the box",
91  "iter0" : "Iterative Step 0",
92  "iter1" : "Iterative Step 1",
93  "iter2" : "Iterative Step 2",
94  "iter3" : "Iterative Step 3",
95  "iter4" : "Iterative Step 4",
96  "iter5" : "Iterative Step 5",
97  "iter6" : "Iterative Step 6",
98  "iter7" : "Iterative Step 7",
99  "iter9" : "Iterative Step 9",
100  "iter10": "Iterative Step 10",
101 }
102 
103 _trackAlgoOrder = [
104  'ootb',
105  'initialStepPreSplitting',
106  'initialStep',
107  'highPtTripletStep',
108  'detachedQuadStep',
109  'detachedTripletStep',
110  'lowPtQuadStep',
111  'lowPtTripletStep',
112  'pixelPairStep',
113  'mixedTripletStep',
114  'pixelLessStep',
115  'tobTecStep',
116  'jetCoreRegionalStep',
117  'muonSeededStepInOut',
118  'muonSeededStepOutIn',
119  'duplicateMerge',
120  'convStep',
121  'conversionStep',
122  'ckfInOutFromConversions',
123  'ckfOutInFromConversions',
124  'electronGsf',
125  'iter0',
126  'iter1',
127  'iter2',
128  'iter3',
129  'iter4',
130  'iter5',
131  'iter6',
132  'iter7',
133  'iter9',
134  'iter10',
135 ]
136 
137 _pageNameMap = {
138  "summary": "Summary",
139  "vertex": "Vertex",
140  "v0": "V0",
141  "miniaod": "MiniAOD",
142  "timing": "Timing",
143  "hlt": "HLT",
144 }
145 
146 _sectionNameMapOrder = collections.OrderedDict([
147  # These are for the summary page
148  ("seeding_seeds", "Seeds"),
149  ("building", "Built tracks"),
150  ("", "All tracks"),
151  ("highPurity", "High purity tracks"),
152  ("btvLike", "BTV-like"),
153  ("ak4PFJets", "AK4 PF jets"),
154  ("allTPEffic", _allTPEfficName),
155  ("allTPEffic_highPurity", _allTPEfficName.replace("All", "High purity")),
156  ("fromPV", _fromPVName),
157  ("fromPV_highPurity", "High purity "+_lowerFirst(_fromPVName)),
158  ("fromPVAllTP", _fromPVAllTPName),
159  ("fromPVAllTP_highPurity", "High purity "+_lowerFirst(_fromPVAllTPName)),
160  ("conversion", _conversionName),
161  ("gsf", _gsfName),
162  # These are for vertices
163  ("genvertex", "Gen vertices"),
164  ("pixelVertices", "Pixel vertices"),
165  ("selectedPixelVertices", "Selected pixel vertices"),
166  ("firstStepPrimaryVerticesPreSplitting", "firstStepPrimaryVerticesPreSplitting"),
167  ("firstStepPrimaryVertices", "firstStepPrimaryVertices"),
168  ("offlinePrimaryVertices", "All vertices (offlinePrimaryVertices)"),
169  ("selectedOfflinePrimaryVertices", "Selected vertices (selectedOfflinePrimaryVertices)"),
170  ("offlinePrimaryVerticesWithBS", "All vertices with BS constraint"),
171  ("selectedOfflinePrimaryVerticesWithBS", "Selected vertices with BS constraint"),
172  # These are for V0
173  ("k0", "K0"),
174  ("lambda", "Lambda"),
175 ])
176 _allTPEfficLegend = "All tracks, efficiency denominator contains all TrackingParticles"
177 _fromPVLegend = "Tracks from reco PV vs. TrackingParticles from gen PV (fake rate includes pileup tracks)"
178 _fromPVPtLegend = "Tracks (pT > 0.9 GeV) from reco PV vs. TrackingParticles from gen PV (fake rate includes pileup tracks)"
179 _fromPVAllTPLegend = "Tracks from reco PV, fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)"
180 _fromPVAllTPPtLegend = "Tracks (pT > 0.9 GeV) from reco PV, fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)"
181 _fromPVAllTP2Legend = "Tracks from reco PV (another method), fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)"
182 _fromPVAllTPPt2Legend = "Tracks (pT > 0.9 GeV) from reco PV (another method), fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)"
183 
185  return {
186  "btvLike": "BTV-like selected tracks",
187  "ak4PFJets": "Tracks from AK4 PF jets (jet corrected pT > 10 GeV)",
188  "allTPEffic": _allTPEfficLegend,
189  "allTPEffic_": _allTPEfficLegend,
190  "allTPEffic_highPurity": _allToHP(_allTPEfficLegend),
191  "fromPV": _fromPVLegend,
192  "fromPV_": _fromPVLegend,
193  "fromPV_highPurity": _toHP(_fromPVLegend),
194  "fromPV_Pt09": _fromPVPtLegend,
195  "fromPV_highPurity_Pt09": _toHP(_fromPVPtLegend),
196  "fromPVAllTP": _fromPVAllTPLegend,
197  "fromPVAllTP_": _fromPVAllTPLegend,
198  "fromPVAllTP_highPurity": _toHP(_fromPVAllTPLegend),
199  "fromPVAllTP_Pt09": _fromPVAllTPPtLegend,
200  "fromPVAllTP_highPurityPt09": _toHP(_fromPVAllTPPtLegend),
201  "fromPVAllTP2_": _fromPVAllTP2Legend,
202  "fromPVAllTP2_highPurity": _toHP(_fromPVAllTP2Legend),
203  "fromPVAllTP2_Pt09": _fromPVAllTPPt2Legend,
204  "fromPVAllTP2_highPurityPt09": _toHP(_fromPVAllTPPt2Legend),
205  }
206 
207 class Table:
208  # table [column][row]
209  def __init__(self, columnHeaders, rowHeaders, table, purpose, page, section):
210  if len(columnHeaders) != len(table):
211  raise Exception("Got %d columnHeaders for table with %d columns for page %s, section %s" % (len(columnHeaders), len(table), page, section))
212  lenRow = len(table[0])
213  for icol, column in enumerate(table):
214  if len(column) != lenRow:
215  raise Exception("Got non-square table, first column has %d rows, column %d has %d rows" % (lenRow, icol, len(column)))
216  if len(rowHeaders) != lenRow:
217  raise Exception("Got %d rowHeaders for table with %d rows" % (len(rowHeaders), lenRow))
218 
219  self._columnHeaders = columnHeaders
220  self._rowHeaders = rowHeaders
221  self._table = table
222 
223  self._purpose = purpose
224  self._page = page
225  self._section = section
226 
227  def getPurpose(self):
228  return self._purpose
229 
230  def getPage(self):
231  return self._page
232 
233  def getSection(self):
234  return self._section
235 
236  def ncolumns(self):
237  return len(self._table)
238 
239  def nrows(self):
240  return len(self._table[0])
241 
242  def columnHeaders(self):
243  return self._columnHeaders
244 
245  def rowHeaders(self):
246  return self._rowHeaders
247 
248  def tableAsColumnRow(self):
249  return self._table
250 
251  def tableAsRowColumn(self):
252  return map(list, zip(*self._table))
253 
255  class TrackingIteration: pass
256  class TrackingSummary: pass
257  class Vertexing: pass
258  class MiniAOD: pass
259  class Timing: pass
260  class HLT: pass
261 
262 class Page(object):
263  def __init__(self, title, sampleName):
264  self._content = [
265  '<html>',
266  ' <head>',
267  ' <title>%s</title>' % title,
268  ' </head>',
269  ' <body>',
270  ' '+sampleName,
271  ' <br/>',
272  ' <br/>',
273  ]
274 
275  self._plotSets = {}
276  self._tables = {}
277 
278  def addPlotSet(self, section, plotSet):
279  if section in self._plotSets:
280  self._plotSets[section].extend(plotSet)
281  else:
282  self._plotSets[section] = plotSet
283 
284  def addTable(self, section, table):
285  self._tables[section] = table
286 
287  def isEmpty(self):
288  for plotSet in self._plotSets.itervalues():
289  if len(plotSet) > 0:
290  return False
291 
292  if len(self._tables) > 0:
293  return False
294 
295  return True
296 
297  def write(self, fileName):
298  self._legends = []
300  self._columnHeaders = []
302  self._formatPlotSets()
303  self._formatTables()
304  self._formatLegend()
305 
306  self._content.extend([
307  ' </body>',
308  '</html>',
309  ])
310 
311  #print "Writing HTML report page", fileName
312  f = open(fileName, "w")
313  for line in self._content:
314  f.write(line)
315  f.write("\n")
316  f.close()
317 
318  def _appendLegend(self, section):
319  leg = ""
320  legends = _sectionNameLegend()
321  if section in legends:
322  if section in self._sectionLegendIndex:
323  leg = self._sectionLegendIndex[section]
324  else:
325  legnum = len(self._legends)+1
326  leg = "<sup>%d</sup>" % legnum
327  leg2 = "<sup>%d)</sup>" % legnum
328  self._legends.append("%s %s" % (leg2, legends[section]))
329  self._sectionLegendIndex[section] = leg
330  return leg
331 
332  def _formatPlotSets(self):
333  self._content.extend([
334  ' <table>'
335  ' <tr>',
336  ])
337 
338  fileTable = []
339 
340  sections = self._orderSets(self._plotSets.keys())
341  for isec, section in enumerate(sections):
342  leg = self._appendLegend(section)
343 
344  self._content.extend([
345  ' <td>%s%s</td>' % (self._mapSectionName(section), leg),
346  ])
347  files = [(os.path.basename(f), f) for f in self._plotSets[section]]
348  for row in fileTable:
349  found = False
350  for i, (bsf, f) in enumerate(files):
351  if bsf == row[0]:
352  row.append(f)
353  found = True
354  del files[i]
355  break
356  if not found:
357  row.append(None)
358  for bsf, f in files:
359  fileTable.append( [bsf] + [None]*isec + [f] )
360 
361  self._content.extend([
362  ' </tr>',
363  ])
364 
365  for row in fileTable:
366  self._content.append(' <tr>')
367  bs = row[0]
368  for elem in row[1:]:
369  if elem is not None:
370  self._content.append(' <td><a href="%s">%s</a></td>' % (elem, bs))
371  else:
372  self._content.append(' <td></td>')
373  self._content.append(' </tr>')
374 
375 
376  self._content.extend([
377  ' </table>',
378  ])
379 
380  def _appendColumnHeader(self, header):
381  leg = ""
382  if header in self._columnHeadersIndex:
383  leg = self._columnHeadersIndex[header]
384  else:
385  leg = str(chr(ord('A')+len(self._columnHeaders)))
386  self._columnHeaders.append("%s: %s" % (leg, header))
387  self._columnHeadersIndex[header] = leg
388  return leg
389 
390  def _formatTables(self):
391  def _allNone(row):
392  for item in row:
393  if item is not None:
394  return False
395  return True
396 
397  sections = self._orderSets(self._tables.keys())
398  for isec, section in enumerate(sections):
399  leg = self._appendLegend(section)
400 
401  table = self._tables[section]
402  self._content.extend([
403  ' <br/>',
404  ' %s%s' % (self._mapSectionName(section), leg),
405  ' <table border="1">'
406  ])
407 
408  # table is stored in column-row, need to transpose
409  data = table.tableAsRowColumn()
410 
411  self._content.extend([
412  ' <tr>'
413  ' <td></td>'
414  ])
415  heads = table.columnHeaders()
416  if max(map(lambda h: len(h), heads)) > 20:
417  heads = [self._appendColumnHeader(h) for h in heads]
418  for head in heads:
419  self._content.append(' <td>%s</td>' % head)
420  self._content.append(' </tr>')
421 
422  for irow, row in enumerate(data):
423  # Skip row if all values are non-existent
424  if _allNone(row):
425  continue
426 
427  self._content.extend([
428  ' <tr>'
429  ' <td>%s</td>' % table.rowHeaders()[irow]
430  ])
431  # align the number columns to right
432  for icol, item in enumerate(row):
433  formatted = str(item) if item is not None else ""
434  self._content.append(' <td align="right">%s</td>' % formatted)
435  self._content.append(' </tr>')
436 
437  self._content.append(' </table>')
438 
439  for shortenedColumnHeader in self._columnHeaders:
440  self._content.append(' %s<br/>' % shortenedColumnHeader)
441  self._columnHeaders = []
442  self._columnHeadersIndex = {}
443 
444  def _formatLegend(self):
445  if len(self._legends) > 0:
446  self._content.extend([
447  ' <br/>'
448  ' Details:</br>',
449  ])
450  for leg in self._legends:
451  self._content.append(' %s<br/>' % leg)
452 
453 
454  def _mapSectionName(self, section):
455  return _sectionNameMapOrder.get(section, section)
456 
457  def _orderSets(self, keys):
458  keys_sorted = sorted(keys)
459  ret = []
460  for section in _sectionNameMapOrder.keys():
461  if section in keys_sorted:
462  ret.append(section)
463  keys.remove(section)
464  ret.extend(keys_sorted)
465  return ret
466 
468  def __init__(self, title, sampleName, sample, fastVsFull, pileupComparison, dqmSubFolderTranslatedToSectionName=None):
469  self._title = title
470  self._sampleName = sampleName
471  self._pages = collections.OrderedDict()
472  self._dqmSubFolderTranslatedToSectionName = dqmSubFolderTranslatedToSectionName
473 
474  self._prefix = ""
475  if sample.fastsim():
476  self._prefix += "fast_"
477  if fastVsFull:
478  self._prefix += "full_"
479 
480  self._prefix += _sampleFileName.get(sample.label(), sample.label())+"_"
481  if hasattr(sample, "hasScenario") and sample.hasScenario():
482  self._prefix += sample.scenario()+"_"
483 
484  if hasattr(sample, "hasPileup"):
485  if sample.hasPileup():
486  self._prefix += "pu"+str(sample.pileupNumber())+"_"+sample.pileupType()+"_"
487  else:
488  self._prefix += "nopu_"
489  if pileupComparison:
490  self._prefix += "vspu_"
491 
492 
493  def _getPage(self, key, pageClass):
494  if key not in self._pages:
495  page = pageClass(self._title, self._sampleName)
496  self._pages[key] = page
497  else:
498  page = self._pages[key]
499  return page
500 
501  def addPlotSet(self, plotterFolder, dqmSubFolder, plotFiles):
502  pageKey = plotterFolder.getPage()
503  if pageKey is None:
504  if dqmSubFolder is not None:
505  pageKey = dqmSubFolder.translated
506  else:
507  pageKey = plotterFolder.getName()
508 
509  page = self._getPage(pageKey, Page)
510  sectionName = plotterFolder.getSection()
511  if sectionName is None:
512  if plotterFolder.getPage() is not None and dqmSubFolder is not None:
513  if self._dqmSubFolderTranslatedToSectionName is not None:
514  sectionName = self._dqmSubFolderTranslatedToSectionName(dqmSubFolder.translated)
515  else:
516  sectionName = dqmSubFolder.translated
517  else:
518  sectionName = ""
519 
520  page.addPlotSet(sectionName, plotFiles)
521 
522  def addTable(self, table):
523  if table is None:
524  return
525 
526  page = self._getPage(table.getPage(), Page)
527  page.addTable(table.getSection(), table)
528 
529  def write(self, baseDir):
530  #print "TrackingPageSet.write"
531  ret = []
532 
533  keys = self._orderPages(self._pages.keys())
534  for key in keys:
535  page = self._pages[key]
536  if page.isEmpty():
537  continue
538 
539  fileName = "%s%s.html" % (self._prefix, key)
540  page.write(os.path.join(baseDir, fileName))
541  ret.append( (self._mapPagesName(key), fileName) )
542  return ret
543 
544  def _mapPagesName(self, name):
545  return _pageNameMap.get(name, name)
546 
547  def _orderPages(self, keys):
548  return keys
549 
550 
551 
553  def __init__(self, *args, **kwargs):
554  super(TrackingIterPage, self).__init__(*args, **kwargs)
555 
556  def _mapSectionName(self, quality):
557  return _trackQualityNameOrder.get(quality, quality)
558 
559  def _orderSets(self, qualities):
560  ret = []
561  for qual in _trackQualityNameOrder.keys():
562  if qual in qualities:
563  ret.append(qual)
564  qualities.remove(qual)
565  ret.extend(qualities)
566  return ret
567 
569  def __init__(self, *args, **kwargs):
570  super(TrackingPageSet, self).__init__(*args, **kwargs)
571 
572  def addPlotSet(self, plotterFolder, dqmSubFolder, plotFiles):
573  (algo, quality) = dqmSubFolder.translated
574 
575  pageName = algo
576  sectionName = quality
577 
578  # put all non-iterative stuff under OOTB
579  #
580  # it is bit of a hack to access trackingPlots.TrackingPlotFolder this way,
581  # but it was simple and it works
582  if algo != "ootb" and not plotterFolder._plotFolder.isAlgoIterative(algo):
583  pageName = "ootb"
584  sectionName = algo
585 
586  folderName = plotterFolder.getName()
587  if folderName != "":
588  sectionName = folderName+"_"+sectionName
589 
590  page = self._getPage(pageName, TrackingIterPage)
591  page.addPlotSet(sectionName, plotFiles)
592 
593  def _mapPagesName(self, algo): # algo = pageName
594  return _trackAlgoName.get(algo, algo)
595 
596  def _orderPages(self, algos):
597  ret = []
598  for algo in _trackAlgoOrder:
599  if algo in algos:
600  ret.append(algo)
601  algos.remove(algo)
602  ret.extend(algos)
603  return ret
604 
605 
606 
608  def __init__(self, sample, title, fastVsFull, pileupComparison):
609  self._sample = sample
610 
611  self._sampleName = ""
612  if sample.fastsim():
613  self._sampleName += "FastSim "
614  if fastVsFull:
615  self._sampleName += "vs FullSim "
616 
617  pileup = ""
618  if hasattr(sample, "hasPileup"):
619  pileup = "with no pileup"
620  if sample.hasPileup():
621  pileup = "with %d pileup (%s)" % (sample.pileupNumber(), sample.pileupType())
622  if pileupComparison is not None:
623  pileup += " "+pileupComparison
624  if hasattr(sample, "customPileupLabel"):
625  pileup = sample.customPileupLabel()
626 
627  scenario = ""
628  if hasattr(sample, "hasScenario") and sample.hasScenario():
629  scenario = " (\"%s\")" % sample.scenario()
630  self._sampleName += "%s sample%s %s" % (_sampleName.get(sample.name(), sample.name()), scenario, pileup)
631 
632  params = [title, self._sampleName, sample, fastVsFull, pileupComparison is not None]
633  self._summaryPage = PageSet(*params)
635  self._vertexPage = PageSet(*params)
636  self._miniaodPage = PageSet(*params)
637  self._timingPage = PageSet(*params)
638  self._hltPages = PageSet(*params, dqmSubFolderTranslatedToSectionName=lambda algoQuality: algoQuality[0])
639  self._otherPages = PageSet(*params)
640 
648  }
649 
650  def addPlots(self, plotterFolder, dqmSubFolder, plotFiles):
651  page = self._purposePageMap.get(plotterFolder.getPurpose(), self._otherPages)
652  page.addPlotSet(plotterFolder, dqmSubFolder, plotFiles)
653 
654  def addTable(self, table):
655  if table is None:
656  return
657 
658  page = self._purposePageMap.get(table.getPurpose(), self._otherPages)
659  page.addTable(table)
660  params = []
661 
662  def write(self, baseDir):
663  ret = [
664  " "+self._sampleName,
665  " <br/>",
666  " <ul>",
667  ]
668 
669  for pages in [self._summaryPage, self._iterationPages, self._vertexPage, self._miniaodPage, self._timingPage, self._hltPages, self._otherPages]:
670  labelFiles = pages.write(baseDir)
671  for label, fname in labelFiles:
672  ret.append(' <li><a href="%s">%s</a></li>' % (fname, label))
673 
674  ret.extend([
675  ' </ul>',
676  ' <br/>',
677  ])
678 
679  return ret
680 
682  def __init__(self, validationName, newBaseDir):
683  self._title = "Tracking validation "+validationName
684  self._newBaseDir = newBaseDir
685 
686  self._index = [
687  '<html>',
688  ' <head>',
689  ' <title>%s</title>' % self._title,
690  ' </head>',
691  ' <body>',
692  ]
693 
694  self._sections = collections.OrderedDict()
695 
696  def addNote(self, note):
697  self._index.append(' <p>%s</p>'%note)
698 
699  def beginSample(self, sample, fastVsFull=False, pileupComparison=None):
700  # Fast vs. Full becomes just after the corresponding Fast
701  # Same for PU
702  rightAfterRefSample = fastVsFull or (pileupComparison is not None)
703 
704  key = (sample.digest(), rightAfterRefSample)
705  if key in self._sections:
706  self._currentSection = self._sections[key]
707  else:
708  self._currentSection = IndexSection(sample, self._title, fastVsFull, pileupComparison)
709  self._sections[key] = self._currentSection
710 
711  def addPlots(self, *args, **kwargs):
712  self._currentSection.addPlots(*args, **kwargs)
713 
714  def addTable(self, *args, **kwargs):
715  self._currentSection.addTable(*args, **kwargs)
716 
717  def write(self):
718  # Reorder sections such that Fast vs. Full becomes just after the corresponding Fast
719  keys = self._sections.iterkeys()
720  newkeys = []
721  for key in keys:
722  if not key[1]:
723  newkeys.append(key)
724  continue
725  # is fast vs full
726  ind_fast = newkeys.index( (key[0], False) )
727  newkeys.insert(ind_fast+1, key)
728 
729  for key in newkeys:
730  section = self._sections[key]
731  self._index.extend(section.write(self._newBaseDir))
732 
733  self._index.extend([
734  " </body>",
735  "</html>",
736  ])
737 
738  f = open(os.path.join(self._newBaseDir, "index.html"), "w")
739  for line in self._index:
740  f.write(line)
741  f.write("\n")
742  f.close()
743 
745  def __init__(self):
746  pass
747 
748  def beginSample(self, *args, **kwargs):
749  pass
750 
751  def addPlots(self, *args, **kwargs):
752  pass
753 
754  def addTable(self, *args, **kwargs):
755  pass
def _appendColumnHeader(self, header)
Definition: html.py:380
_purpose
Definition: html.py:223
def write(self, fileName)
Definition: html.py:297
_dqmSubFolderTranslatedToSectionName
Definition: html.py:472
def __init__(self, columnHeaders, rowHeaders, table, purpose, page, section)
Definition: html.py:209
def addTable(self, args, kwargs)
Definition: html.py:714
_legends
Definition: html.py:298
def write(self, baseDir)
Definition: html.py:662
def addTable(self, args, kwargs)
Definition: html.py:754
def _lowerFirst(s)
Definition: html.py:4
def addPlots(self, args, kwargs)
Definition: html.py:711
_content
Definition: html.py:264
def __init__(self, args, kwargs)
Definition: html.py:553
def _formatLegend(self)
Definition: html.py:444
def isEmpty(self)
Definition: html.py:287
def _mapPagesName(self, name)
Definition: html.py:544
_rowHeaders
Definition: html.py:220
def __init__(self, sample, title, fastVsFull, pileupComparison)
Definition: html.py:608
def replace(string, replacements)
def __init__(self, title, sampleName)
Definition: html.py:263
def addNote(self, note)
Definition: html.py:696
def _mapPagesName(self, algo)
Definition: html.py:593
_columnHeaders
Definition: html.py:219
def _allToHP(s)
Definition: html.py:50
def _orderSets(self, qualities)
Definition: html.py:559
def _orderSets(self, keys)
Definition: html.py:457
def getPage(self)
Definition: html.py:230
def __init__(self, title, sampleName, sample, fastVsFull, pileupComparison, dqmSubFolderTranslatedToSectionName=None)
Definition: html.py:468
def _mapSectionName(self, section)
Definition: html.py:454
def __init__(self, args, kwargs)
Definition: html.py:569
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
def addTable(self, table)
Definition: html.py:522
def addPlots(self, args, kwargs)
Definition: html.py:751
def __init__(self)
Definition: html.py:745
def _orderPages(self, algos)
Definition: html.py:596
def _appendLegend(self, section)
Definition: html.py:318
_columnHeaders
Definition: html.py:300
def columnHeaders(self)
Definition: html.py:242
def addPlotSet(self, section, plotSet)
Definition: html.py:278
def getSection(self)
Definition: html.py:233
def addPlotSet(self, plotterFolder, dqmSubFolder, plotFiles)
Definition: html.py:501
def addTable(self, table)
Definition: html.py:654
_plotSets
Definition: html.py:275
def _getPage(self, key, pageClass)
Definition: html.py:493
def _mapSectionName(self, quality)
Definition: html.py:556
def addPlotSet(self, plotterFolder, dqmSubFolder, plotFiles)
Definition: html.py:572
def _formatTables(self)
Definition: html.py:390
def ncolumns(self)
Definition: html.py:236
_columnHeadersIndex
Definition: html.py:301
_section
Definition: html.py:225
def _formatPlotSets(self)
Definition: html.py:332
def rowHeaders(self)
Definition: html.py:245
_tables
Definition: html.py:276
def getPurpose(self)
Definition: html.py:227
def tableAsRowColumn(self)
Definition: html.py:251
def beginSample(self, sample, fastVsFull=False, pileupComparison=None)
Definition: html.py:699
def beginSample(self, args, kwargs)
Definition: html.py:748
def __init__(self, validationName, newBaseDir)
Definition: html.py:682
def tableAsColumnRow(self)
Definition: html.py:248
def addPlots(self, plotterFolder, dqmSubFolder, plotFiles)
Definition: html.py:650
def write(self)
Definition: html.py:717
def _sectionNameLegend()
Definition: html.py:184
_sectionLegendIndex
Definition: html.py:299
def _ptCut(s)
Definition: html.py:52
def _orderPages(self, keys)
Definition: html.py:547
def nrows(self)
Definition: html.py:239
def _toHP(s)
Definition: html.py:48
def addTable(self, section, table)
Definition: html.py:284
def write(self, baseDir)
Definition: html.py:529