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_seedstripl",
"Seeds triplets"),
59 (
"seeding_seedspair",
"Seeds pairs"),
60 (
"building_",
"Built 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),
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",
105 'initialStepPreSplitting',
109 'detachedTripletStep',
116 'jetCoreRegionalStep',
117 'muonSeededStepInOut',
118 'muonSeededStepOutIn',
122 'ckfInOutFromConversions',
123 'ckfOutInFromConversions',
138 "summary":
"Summary",
141 "miniaod":
"MiniAOD",
146 _sectionNameMapOrder = collections.OrderedDict([
148 (
"seeding_seeds",
"Seeds"),
149 (
"building",
"Built 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),
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"),
174 (
"lambda",
"Lambda"),
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)" 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),
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))
240 return len(self.
_table[0])
267 ' <title>%s</title>' % title,
288 for plotSet
in self._plotSets.itervalues():
306 self._content.extend([
312 f = open(fileName,
"w")
321 if section
in legends:
326 leg =
"<sup>%d</sup>" % legnum
327 leg2 =
"<sup>%d)</sup>" % legnum
328 self._legends.append(
"%s %s" % (leg2, legends[section]))
333 self._content.extend([
340 sections = self.
_orderSets(self._plotSets.keys())
341 for isec, section
in enumerate(sections):
344 self._content.extend([
347 files = [(os.path.basename(f), f)
for f
in self.
_plotSets[section]]
348 for row
in fileTable:
350 for i, (bsf, f)
in enumerate(files):
359 fileTable.append( [bsf] + [
None]*isec + [f] )
361 self._content.extend([
365 for row
in fileTable:
366 self._content.append(
' <tr>')
370 self._content.append(
' <td><a href="%s">%s</a></td>' % (elem, bs))
372 self._content.append(
' <td></td>')
373 self._content.append(
' </tr>')
376 self._content.extend([
386 self._columnHeaders.append(
"%s: %s" % (leg, header))
397 sections = self.
_orderSets(self._tables.keys())
398 for isec, section
in enumerate(sections):
402 self._content.extend([
405 ' <table border="1">' 409 data = table.tableAsRowColumn()
411 self._content.extend([
415 heads = table.columnHeaders()
416 if max(
map(
lambda h: len(h), heads)) > 20:
419 self._content.append(
' <td>%s</td>' % head)
420 self._content.append(
' </tr>')
422 for irow, row
in enumerate(data):
427 self._content.extend([
429 ' <td>%s</td>' % table.rowHeaders()[irow]
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>')
437 self._content.append(
' </table>')
440 self._content.append(
' %s<br/>' % shortenedColumnHeader)
446 self._content.extend([
451 self._content.append(
' %s<br/>' % leg)
455 return _sectionNameMapOrder.get(section, section)
458 keys_sorted = sorted(keys)
460 for section
in _sectionNameMapOrder.keys():
461 if section
in keys_sorted:
464 ret.extend(keys_sorted)
468 def __init__(self, title, sampleName, sample, fastVsFull, pileupComparison, dqmSubFolderTranslatedToSectionName=None):
480 self.
_prefix += _sampleFileName.get(sample.label(), sample.label())+
"_" 481 if hasattr(sample,
"hasScenario")
and sample.hasScenario():
482 self.
_prefix += sample.scenario()+
"_" 484 if hasattr(sample,
"hasPileup"):
485 if sample.hasPileup():
486 self.
_prefix +=
"pu"+
str(sample.pileupNumber())+
"_"+sample.pileupType()+
"_" 494 if key
not in self.
_pages:
501 def addPlotSet(self, plotterFolder, dqmSubFolder, plotFiles):
502 pageKey = plotterFolder.getPage()
504 if dqmSubFolder
is not None:
505 pageKey = dqmSubFolder.translated
507 pageKey = plotterFolder.getName()
510 sectionName = plotterFolder.getSection()
511 if sectionName
is None:
512 if plotterFolder.getPage()
is not None and dqmSubFolder
is not None:
516 sectionName = dqmSubFolder.translated
520 page.addPlotSet(sectionName, plotFiles)
526 page = self.
_getPage(table.getPage(), Page)
527 page.addTable(table.getSection(), table)
539 fileName =
"%s%s.html" % (self.
_prefix, key)
540 page.write(os.path.join(baseDir, fileName))
545 return _pageNameMap.get(name, name)
554 super(TrackingIterPage, self).
__init__(*args, **kwargs)
557 return _trackQualityNameOrder.get(quality, quality)
561 for qual
in _trackQualityNameOrder.keys():
562 if qual
in qualities:
564 qualities.remove(qual)
565 ret.extend(qualities)
570 super(TrackingPageSet, self).
__init__(*args, **kwargs)
572 def addPlotSet(self, plotterFolder, dqmSubFolder, plotFiles):
573 (algo, quality) = dqmSubFolder.translated
576 sectionName = quality
582 if algo !=
"ootb" and not plotterFolder._plotFolder.isAlgoIterative(algo):
586 folderName = plotterFolder.getName()
588 sectionName = folderName+
"_"+sectionName
590 page = self.
_getPage(pageName, TrackingIterPage)
591 page.addPlotSet(sectionName, plotFiles)
594 return _trackAlgoName.get(algo, algo)
598 for algo
in _trackAlgoOrder:
608 def __init__(self, sample, title, fastVsFull, pileupComparison):
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()
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)
632 params = [title, self.
_sampleName, sample, fastVsFull, pileupComparison
is not None]
638 self.
_hltPages =
PageSet(*params, dqmSubFolderTranslatedToSectionName=
lambda algoQuality: algoQuality[0])
650 def addPlots(self, plotterFolder, dqmSubFolder, plotFiles):
651 page = self._purposePageMap.get(plotterFolder.getPurpose(), self.
_otherPages)
652 page.addPlotSet(plotterFolder, dqmSubFolder, plotFiles)
658 page = self._purposePageMap.get(table.getPurpose(), 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))
683 self.
_title =
"Tracking validation "+validationName
689 ' <title>%s</title>' % self.
_title,
697 self._index.append(
' <p>%s</p>'%note)
699 def beginSample(self, sample, fastVsFull=False, pileupComparison=None):
702 rightAfterRefSample = fastVsFull
or (pileupComparison
is not None)
704 key = (sample.digest(), rightAfterRefSample)
712 self._currentSection.addPlots(*args, **kwargs)
715 self._currentSection.addTable(*args, **kwargs)
719 keys = self._sections.iterkeys()
726 ind_fast = newkeys.index( (key[0],
False) )
727 newkeys.insert(ind_fast+1, key)
731 self._index.extend(section.write(self.
_newBaseDir))
738 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)