5 return s[0].lower()+s[1:]
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",
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",
26 "RelValMinBias":
"minbias",
27 "RelValTTbar":
"ttbar",
28 "RelValQCD_Pt_600_800":
"qcd600",
29 "RelValQCD_Pt_3000_3500":
"qcd3000",
30 "RelValQCD_FlatPt_15_3000":
"qcdflat",
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",
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" 51 return s.replace(
"All",
"High purity")
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_seedsc",
"Seeds C"),
59 (
"seeding_seedstripl",
"Seeds triplets"),
60 (
"seeding_seedspair",
"Seeds pairs"),
61 (
"building_",
"Built tracks"),
63 (
"highPurity",
"High purity tracks"),
64 (
"Pt09",
"Tracks pT > 0.9 GeV"),
65 (
"highPurityPt09",
"High purity tracks pT > 0.9 GeV"),
66 (
"ByOriginalAlgo",
"All tracks by originalAlgo"),
67 (
"highPurityByOriginalAlgo",
"High purity tracks by originalAlgo"),
68 (
"ByAlgoMask",
"All tracks by algoMask"),
69 (
"highPurityByAlgoMask",
"High purity tracks by algoMask"),
70 (
"btvLike",
"BTV-like"),
71 (
"ak4PFJets",
"AK4 PF jets"),
72 (
"allTPEffic_", _allTPEfficName),
73 (
"allTPEffic_highPurity",
_allToHP(_allTPEfficName)),
74 (
"fromPV_", _fromPVName),
75 (
"fromPV_highPurity",
_toHP(_fromPVName)),
76 (
"fromPV_Pt09",
_ptCut(_fromPVName)),
77 (
"fromPV_highPurityPt09",
_toHP(
_ptCut(_fromPVName))),
78 (
"fromPVAllTP_", _fromPVAllTPName),
79 (
"fromPVAllTP_highPurity",
_toHP(_fromPVAllTPName)),
80 (
"fromPVAllTP_Pt09",
_ptCut(_fromPVAllTPName)),
81 (
"fromPVAllTP_highPurityPt09",
_toHP(
_ptCut(_fromPVAllTPName))),
82 (
"fromPVAllTP2_", _fromPVAllTPName.replace(
"PV",
"PV v2")),
83 (
"fromPVAllTP2_highPurity",
"High purity "+
_lowerFirst(_fromPVAllTPName).
replace(
"PV",
"PV v2")),
84 (
"fromPVAllTP2_Pt09", _fromPVAllTPName.replace(
"Tracks",
"Tracks pT > 0.9 GeV").
replace(
"PV",
"PV v2")),
85 (
"fromPVAllTP2_highPurityPt09",
_toHP(
_ptCut(_fromPVAllTPName)).
replace(
"PV",
"PV v2")),
86 (
"conversion_", _conversionName),
91 "ootb":
"Out of the box",
92 "iter0" :
"Iterative Step 0",
93 "iter1" :
"Iterative Step 1",
94 "iter2" :
"Iterative Step 2",
95 "iter3" :
"Iterative Step 3",
96 "iter4" :
"Iterative Step 4",
97 "iter5" :
"Iterative Step 5",
98 "iter6" :
"Iterative Step 6",
99 "iter7" :
"Iterative Step 7",
100 "iter9" :
"Iterative Step 9",
101 "iter10":
"Iterative Step 10",
106 'initialStepPreSplitting',
110 'detachedTripletStep',
117 'jetCoreRegionalStep',
118 'muonSeededStepInOut',
119 'muonSeededStepOutIn',
123 'ckfInOutFromConversions',
124 'ckfOutInFromConversions',
139 "summary":
"Summary",
142 "miniaod":
"MiniAOD",
147 _sectionNameMapOrder = collections.OrderedDict([
149 (
"seeding_seeds",
"Seeds"),
150 (
"building",
"Built tracks"),
152 (
"highPurity",
"High purity tracks"),
153 (
"btvLike",
"BTV-like"),
154 (
"ak4PFJets",
"AK4 PF jets"),
155 (
"allTPEffic", _allTPEfficName),
156 (
"allTPEffic_highPurity", _allTPEfficName.replace(
"All",
"High purity")),
157 (
"fromPV", _fromPVName),
158 (
"fromPV_highPurity",
"High purity "+
_lowerFirst(_fromPVName)),
159 (
"fromPVAllTP", _fromPVAllTPName),
160 (
"fromPVAllTP_highPurity",
"High purity "+
_lowerFirst(_fromPVAllTPName)),
161 (
"conversion", _conversionName),
164 (
"genvertex",
"Gen vertices"),
165 (
"pixelVertices",
"Pixel vertices"),
166 (
"selectedPixelVertices",
"Selected pixel vertices"),
167 (
"firstStepPrimaryVerticesPreSplitting",
"firstStepPrimaryVerticesPreSplitting"),
168 (
"firstStepPrimaryVertices",
"firstStepPrimaryVertices"),
169 (
"offlinePrimaryVertices",
"All vertices (offlinePrimaryVertices)"),
170 (
"selectedOfflinePrimaryVertices",
"Selected vertices (selectedOfflinePrimaryVertices)"),
171 (
"offlinePrimaryVerticesWithBS",
"All vertices with BS constraint"),
172 (
"selectedOfflinePrimaryVerticesWithBS",
"Selected vertices with BS constraint"),
175 (
"lambda",
"Lambda"),
177 _allTPEfficLegend =
"All tracks, efficiency denominator contains all TrackingParticles" 178 _fromPVLegend =
"Tracks from reco PV vs. TrackingParticles from gen PV (fake rate includes pileup tracks)" 179 _fromPVPtLegend =
"Tracks (pT > 0.9 GeV) from reco PV vs. TrackingParticles from gen PV (fake rate includes pileup tracks)" 180 _fromPVAllTPLegend =
"Tracks from reco PV, fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)" 181 _fromPVAllTPPtLegend =
"Tracks (pT > 0.9 GeV) from reco PV, fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)" 182 _fromPVAllTP2Legend =
"Tracks from reco PV (another method), fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)" 183 _fromPVAllTPPt2Legend =
"Tracks (pT > 0.9 GeV) from reco PV (another method), fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)" 187 "btvLike":
"BTV-like selected tracks",
188 "ak4PFJets":
"Tracks from AK4 PF jets (jet corrected pT > 10 GeV)",
189 "allTPEffic": _allTPEfficLegend,
190 "allTPEffic_": _allTPEfficLegend,
191 "allTPEffic_highPurity":
_allToHP(_allTPEfficLegend),
192 "fromPV": _fromPVLegend,
193 "fromPV_": _fromPVLegend,
194 "fromPV_highPurity":
_toHP(_fromPVLegend),
195 "fromPV_Pt09": _fromPVPtLegend,
196 "fromPV_highPurity_Pt09":
_toHP(_fromPVPtLegend),
197 "fromPVAllTP": _fromPVAllTPLegend,
198 "fromPVAllTP_": _fromPVAllTPLegend,
199 "fromPVAllTP_highPurity":
_toHP(_fromPVAllTPLegend),
200 "fromPVAllTP_Pt09": _fromPVAllTPPtLegend,
201 "fromPVAllTP_highPurityPt09":
_toHP(_fromPVAllTPPtLegend),
202 "fromPVAllTP2_": _fromPVAllTP2Legend,
203 "fromPVAllTP2_highPurity":
_toHP(_fromPVAllTP2Legend),
204 "fromPVAllTP2_Pt09": _fromPVAllTPPt2Legend,
205 "fromPVAllTP2_highPurityPt09":
_toHP(_fromPVAllTPPt2Legend),
210 def __init__(self, columnHeaders, rowHeaders, table, purpose, page, section):
211 if len(columnHeaders) != len(table):
212 raise Exception(
"Got %d columnHeaders for table with %d columns for page %s, section %s" % (len(columnHeaders), len(table), page, section))
213 lenRow = len(table[0])
214 for icol, column
in enumerate(table):
215 if len(column) != lenRow:
216 raise Exception(
"Got non-square table, first column has %d rows, column %d has %d rows" % (lenRow, icol, len(column)))
217 if len(rowHeaders) != lenRow:
218 raise Exception(
"Got %d rowHeaders for table with %d rows" % (len(rowHeaders), lenRow))
241 return len(self.
_table[0])
268 ' <title>%s</title>' % title,
289 for plotSet
in self._plotSets.itervalues():
307 self._content.extend([
313 f = open(fileName,
"w")
322 if section
in legends:
327 leg =
"<sup>%d</sup>" % legnum
328 leg2 =
"<sup>%d)</sup>" % legnum
329 self._legends.append(
"%s %s" % (leg2, legends[section]))
334 self._content.extend([
341 sections = self.
_orderSets(self._plotSets.keys())
342 for isec, section
in enumerate(sections):
345 self._content.extend([
348 files = [(os.path.basename(f), f)
for f
in self.
_plotSets[section]]
349 for row
in fileTable:
351 for i, (bsf, f)
in enumerate(files):
360 fileTable.append( [bsf] + [
None]*isec + [f] )
362 self._content.extend([
366 for row
in fileTable:
367 self._content.append(
' <tr>')
371 self._content.append(
' <td><a href="%s">%s</a></td>' % (elem, bs))
373 self._content.append(
' <td></td>')
374 self._content.append(
' </tr>')
377 self._content.extend([
387 self._columnHeaders.append(
"%s: %s" % (leg, header))
398 sections = self.
_orderSets(self._tables.keys())
399 for isec, section
in enumerate(sections):
403 self._content.extend([
406 ' <table border="1">' 410 data = table.tableAsRowColumn()
412 self._content.extend([
416 heads = table.columnHeaders()
417 if max(
map(
lambda h: len(h), heads)) > 20:
420 self._content.append(
' <td>%s</td>' % head)
421 self._content.append(
' </tr>')
423 for irow, row
in enumerate(data):
428 self._content.extend([
430 ' <td>%s</td>' % table.rowHeaders()[irow]
433 for icol, item
in enumerate(row):
434 formatted =
str(item)
if item
is not None else "" 435 self._content.append(
' <td align="right">%s</td>' % formatted)
436 self._content.append(
' </tr>')
438 self._content.append(
' </table>')
441 self._content.append(
' %s<br/>' % shortenedColumnHeader)
447 self._content.extend([
452 self._content.append(
' %s<br/>' % leg)
456 return _sectionNameMapOrder.get(section, section)
459 keys_sorted = sorted(keys)
461 for section
in _sectionNameMapOrder.keys():
462 if section
in keys_sorted:
465 ret.extend(keys_sorted)
469 def __init__(self, title, sampleName, sample, fastVsFull, pileupComparison, dqmSubFolderTranslatedToSectionName=None):
481 self.
_prefix += _sampleFileName.get(sample.label(), sample.label())+
"_" 482 if hasattr(sample,
"hasScenario")
and sample.hasScenario():
483 self.
_prefix += sample.scenario()+
"_" 485 if hasattr(sample,
"hasPileup"):
486 if sample.hasPileup():
487 self.
_prefix +=
"pu"+
str(sample.pileupNumber())+
"_"+sample.pileupType()+
"_" 495 if key
not in self.
_pages:
502 def addPlotSet(self, plotterFolder, dqmSubFolder, plotFiles):
503 pageKey = plotterFolder.getPage()
505 if dqmSubFolder
is not None:
506 pageKey = dqmSubFolder.translated
508 pageKey = plotterFolder.getName()
511 sectionName = plotterFolder.getSection()
512 if sectionName
is None:
513 if plotterFolder.getPage()
is not None and dqmSubFolder
is not None:
517 sectionName = dqmSubFolder.translated
521 page.addPlotSet(sectionName, plotFiles)
527 page = self.
_getPage(table.getPage(), Page)
528 page.addTable(table.getSection(), table)
540 fileName =
"%s%s.html" % (self.
_prefix, key)
541 page.write(os.path.join(baseDir, fileName))
546 return _pageNameMap.get(name, name)
555 super(TrackingIterPage, self).
__init__(*args, **kwargs)
558 return _trackQualityNameOrder.get(quality, quality)
562 for qual
in _trackQualityNameOrder.keys():
563 if qual
in qualities:
565 qualities.remove(qual)
566 ret.extend(qualities)
571 super(TrackingPageSet, self).
__init__(*args, **kwargs)
573 def addPlotSet(self, plotterFolder, dqmSubFolder, plotFiles):
574 (algo, quality) = dqmSubFolder.translated
577 sectionName = quality
583 if algo !=
"ootb" and not plotterFolder._plotFolder.isAlgoIterative(algo):
587 folderName = plotterFolder.getName()
589 sectionName = folderName+
"_"+sectionName
591 page = self.
_getPage(pageName, TrackingIterPage)
592 page.addPlotSet(sectionName, plotFiles)
595 return _trackAlgoName.get(algo, algo)
599 for algo
in _trackAlgoOrder:
609 def __init__(self, sample, title, fastVsFull, pileupComparison):
619 if hasattr(sample,
"hasPileup"):
620 pileup =
"with no pileup" 621 if sample.hasPileup():
622 pileup =
"with %d pileup (%s)" % (sample.pileupNumber(), sample.pileupType())
623 if pileupComparison
is not None:
624 pileup +=
" "+pileupComparison
625 if hasattr(sample,
"customPileupLabel"):
626 pileup = sample.customPileupLabel()
629 if hasattr(sample,
"hasScenario")
and sample.hasScenario():
630 scenario =
" (\"%s\")" % sample.scenario()
631 self.
_sampleName +=
"%s sample%s %s" % (_sampleName.get(sample.name(), sample.name()), scenario, pileup)
633 params = [title, self.
_sampleName, sample, fastVsFull, pileupComparison
is not None]
639 self.
_hltPages =
PageSet(*params, dqmSubFolderTranslatedToSectionName=
lambda algoQuality: algoQuality[0])
651 def addPlots(self, plotterFolder, dqmSubFolder, plotFiles):
652 page = self._purposePageMap.get(plotterFolder.getPurpose(), self.
_otherPages)
653 page.addPlotSet(plotterFolder, dqmSubFolder, plotFiles)
659 page = self._purposePageMap.get(table.getPurpose(), self.
_otherPages)
671 labelFiles = pages.write(baseDir)
672 for label, fname
in labelFiles:
673 ret.append(
' <li><a href="%s">%s</a></li>' % (fname, label))
684 self.
_title =
"Tracking validation "+validationName
690 ' <title>%s</title>' % self.
_title,
698 self._index.append(
' <p>%s</p>'%note)
700 def beginSample(self, sample, fastVsFull=False, pileupComparison=None):
703 rightAfterRefSample = fastVsFull
or (pileupComparison
is not None)
705 key = (sample.digest(), rightAfterRefSample)
713 self._currentSection.addPlots(*args, **kwargs)
716 self._currentSection.addTable(*args, **kwargs)
720 keys = self._sections.iterkeys()
727 ind_fast = newkeys.index( (key[0],
False) )
728 newkeys.insert(ind_fast+1, key)
732 self._index.extend(section.write(self.
_newBaseDir))
739 f = open(os.path.join(self.
_newBaseDir,
"index.html"),
"w")
def _appendColumnHeader(self, header)
def write(self, fileName)
_dqmSubFolderTranslatedToSectionName
def __init__(self, columnHeaders, rowHeaders, table, purpose, page, section)
def addTable(self, args, kwargs)
def addTable(self, args, kwargs)
def addPlots(self, args, kwargs)
def __init__(self, args, kwargs)
def _mapPagesName(self, name)
def __init__(self, sample, title, fastVsFull, pileupComparison)
def replace(string, replacements)
def __init__(self, title, sampleName)
def _mapPagesName(self, algo)
def _orderSets(self, qualities)
def _orderSets(self, keys)
def __init__(self, title, sampleName, sample, fastVsFull, pileupComparison, dqmSubFolderTranslatedToSectionName=None)
def _mapSectionName(self, section)
def __init__(self, args, kwargs)
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
def addTable(self, table)
def addPlots(self, args, kwargs)
def _orderPages(self, algos)
def _appendLegend(self, section)
def addPlotSet(self, section, plotSet)
def addPlotSet(self, plotterFolder, dqmSubFolder, plotFiles)
def addTable(self, table)
def _getPage(self, key, pageClass)
def _mapSectionName(self, quality)
def addPlotSet(self, plotterFolder, dqmSubFolder, plotFiles)
def _formatPlotSets(self)
def tableAsRowColumn(self)
def beginSample(self, sample, fastVsFull=False, pileupComparison=None)
def beginSample(self, args, kwargs)
def __init__(self, validationName, newBaseDir)
def tableAsColumnRow(self)
def addPlots(self, plotterFolder, dqmSubFolder, plotFiles)
def _orderPages(self, keys)
def addTable(self, section, table)