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 "RelValSingleMuPt1":
"Single Muon Pt 1",
20 "RelValSingleMuPt10":
"Single Muon Pt 10",
21 "RelValSingleMuPt10Extended":
"Single Muon Pt 10 (extended eta)",
22 "RelValSingleMuPt100":
"Single Muon Pt 100",
23 "RelValTenMuE_0_200":
"Ten muon Pt 0-200",
27 "RelValMinBias":
"minbias",
28 "RelValTTbar":
"ttbar",
29 "RelValQCD_Pt_600_800":
"qcd600",
30 "RelValQCD_Pt_3000_3500":
"qcd3000",
31 "RelValQCD_FlatPt_15_3000":
"qcdflat",
33 "RelValWjet_Pt_3000_3500":
"wjet3000",
34 "RelValH125GGgluonfusion":
"hgg",
35 "RelValSingleElectronPt35":
"ele35",
36 "RelValSingleElectronPt35Extended":
"ele35ext",
37 "RelValSingleElectronPt10":
"ele10",
38 "RelValSingleMuPt1":
"mu1",
39 "RelValSingleMuPt10":
"mu10",
40 "RelValSingleMuPt10Extended":
"mu10ext",
41 "RelValSingleMuPt100":
"mu100",
42 "RelValTenMuE_0_200":
"tenmu200",
45 _allName =
"All tracks" 46 _allTPEfficName = _allName+
" (all TPs)" 47 _fromPVName =
"Tracks from PV" 48 _fromPVAllTPName =
"Tracks from PV (all TPs)" 49 _tpPtLess09Name =
"All tracks (TP pT < 0.9 GeV)" 50 _conversionName =
"Tracks for conversions" 51 _gsfName =
"Electron GSF tracks" 52 _bhadronName =
"All tracks (B-hadron TPs)" 56 return s.replace(
"tracks",
"tracks by originalAlgo")
58 return s.replace(
"tracks",
"tracks by algoMask")
60 return s.replace(
"All",
"High purity")
62 return s.replace(
"All",
"BTV-like")
64 return s.replace(
"tracks",
"tracks by originalAlgo")
66 return s.replace(
"Tracks",
"Tracks pT > 0.9 GeV").
replace(
"tracks",
"tracks pT > 0.9 GeV")
67 _trackQualityNameOrder = collections.OrderedDict([
68 (
"seeding_seeds",
"Seeds"),
69 (
"seeding_seedsa",
"Seeds A"),
70 (
"seeding_seedsb",
"Seeds B"),
71 (
"seeding_seedsc",
"Seeds C"),
72 (
"seeding_seedstripl",
"Seeds triplets"),
73 (
"seeding_seedspair",
"Seeds pairs"),
74 (
"building_",
"Built tracks"),
77 (
"Pt09",
"Tracks pT > 0.9 GeV"),
78 (
"highPurityPt09",
"High purity tracks pT > 0.9 GeV"),
83 (
"tpPtLess09_", _tpPtLess09Name),
84 (
"tpPtLess09_highPurity",
_allToHP(_tpPtLess09Name)),
88 (
"ak4PFJets",
"AK4 PF jets"),
89 (
"allTPEffic_", _allTPEfficName),
90 (
"allTPEffic_highPurity",
_allToHP(_allTPEfficName)),
91 (
"fromPV_", _fromPVName),
92 (
"fromPV_highPurity",
_toHP(_fromPVName)),
93 (
"fromPV_Pt09",
_ptCut(_fromPVName)),
94 (
"fromPV_highPurityPt09",
_toHP(
_ptCut(_fromPVName))),
95 (
"fromPVAllTP_", _fromPVAllTPName),
96 (
"fromPVAllTP_highPurity",
_toHP(_fromPVAllTPName)),
97 (
"fromPVAllTP_Pt09",
_ptCut(_fromPVAllTPName)),
98 (
"fromPVAllTP_highPurityPt09",
_toHP(
_ptCut(_fromPVAllTPName))),
99 (
"fromPVAllTP2_", _fromPVAllTPName.replace(
"PV",
"PV v2")),
100 (
"fromPVAllTP2_highPurity",
"High purity "+
_lowerFirst(_fromPVAllTPName).
replace(
"PV",
"PV v2")),
101 (
"fromPVAllTP2_Pt09", _fromPVAllTPName.replace(
"Tracks",
"Tracks pT > 0.9 GeV").
replace(
"PV",
"PV v2")),
102 (
"fromPVAllTP2_highPurityPt09",
_toHP(
_ptCut(_fromPVAllTPName)).
replace(
"PV",
"PV v2")),
103 (
"conversion_", _conversionName),
105 (
"bhadron_", _bhadronName),
106 (
"bhadron_highPurity",
_allToHP(_bhadronName)),
107 (
"bhadron_ByOriginalAlgo",
_toOriAlgo(_bhadronName)),
111 (
"bhadron_btvLike",
_allToBTV(_bhadronName)),
115 "ootb":
"Out of the box",
116 "iter0" :
"Iterative Step 0",
117 "iter1" :
"Iterative Step 1",
118 "iter2" :
"Iterative Step 2",
119 "iter3" :
"Iterative Step 3",
120 "iter4" :
"Iterative Step 4",
121 "iter5" :
"Iterative Step 5",
122 "iter6" :
"Iterative Step 6",
123 "iter7" :
"Iterative Step 7",
124 "iter9" :
"Iterative Step 9",
125 "iter10":
"Iterative Step 10",
130 'initialStepPreSplitting',
134 'detachedTripletStep',
141 'jetCoreRegionalStep',
142 'muonSeededStepInOut',
143 'muonSeededStepOutIn',
147 'ckfInOutFromConversions',
148 'ckfOutInFromConversions',
163 "summary":
"Summary",
166 "miniaod":
"MiniAOD",
171 _sectionNameMapOrder = collections.OrderedDict([
173 (
"seeding_seeds",
"Seeds"),
174 (
"building",
"Built tracks"),
176 (
"Pt09",
"All tracks (pT>0.9 GeV)"),
177 (
"highPurity",
"High purity tracks"),
178 (
"highPurityPt09",
"High purity tracks (pT>0.9 GeV)"),
179 (
"tpPtLess09", _tpPtLess09Name),
180 (
"tpPtLess09_highPurity",
_allToHP(_tpPtLess09Name)),
181 (
"btvLike",
"BTV-like"),
182 (
"ak4PFJets",
"AK4 PF jets"),
183 (
"allTPEffic", _allTPEfficName),
184 (
"allTPEffic_highPurity",
_allToHP(_allTPEfficName)),
185 (
"fromPV", _fromPVName),
186 (
"fromPV_highPurity",
"High purity "+
_lowerFirst(_fromPVName)),
187 (
"fromPVAllTP", _fromPVAllTPName),
188 (
"fromPVAllTP_highPurity",
"High purity "+
_lowerFirst(_fromPVAllTPName)),
189 (
"conversion", _conversionName),
191 (
"bhadron", _bhadronName),
192 (
"bhadron_highPurity",
_allToHP(_bhadronName)),
194 (
"genvertex",
"Gen vertices"),
195 (
"pixelVertices",
"Pixel vertices"),
196 (
"selectedPixelVertices",
"Selected pixel vertices"),
197 (
"firstStepPrimaryVerticesPreSplitting",
"firstStepPrimaryVerticesPreSplitting"),
198 (
"firstStepPrimaryVertices",
"firstStepPrimaryVertices"),
199 (
"offlinePrimaryVertices",
"All vertices (offlinePrimaryVertices)"),
200 (
"selectedOfflinePrimaryVertices",
"Selected vertices (selectedOfflinePrimaryVertices)"),
201 (
"offlinePrimaryVerticesWithBS",
"All vertices with BS constraint"),
202 (
"selectedOfflinePrimaryVerticesWithBS",
"Selected vertices with BS constraint"),
205 (
"lambda",
"Lambda"),
207 _btvLegend =
"BTV-like selected tracks" 208 _allTPEfficLegend =
"All tracks, efficiency denominator contains all TrackingParticles" 209 _fromPVLegend =
"Tracks from reco PV vs. TrackingParticles from gen PV (fake rate includes pileup tracks)" 210 _fromPVPtLegend =
"Tracks (pT > 0.9 GeV) from reco PV vs. TrackingParticles from gen PV (fake rate includes pileup tracks)" 211 _fromPVAllTPLegend =
"Tracks from reco PV, fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)" 212 _fromPVAllTPPtLegend =
"Tracks (pT > 0.9 GeV) from reco PV, fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)" 213 _fromPVAllTP2Legend =
"Tracks from reco PV (another method), fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)" 214 _fromPVAllTPPt2Legend =
"Tracks (pT > 0.9 GeV) from reco PV (another method), fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)" 215 _bhadronLegend =
"All tracks, efficiency denominator contains only TrackingParticles from B-hadron decays" 219 "btvLike": _btvLegend,
220 "ak4PFJets":
"Tracks from AK4 PF jets (jet corrected pT > 10 GeV)",
221 "allTPEffic": _allTPEfficLegend,
222 "allTPEffic_": _allTPEfficLegend,
223 "allTPEffic_highPurity":
_allToHP(_allTPEfficLegend),
224 "fromPV": _fromPVLegend,
225 "fromPV_": _fromPVLegend,
226 "fromPV_highPurity":
_toHP(_fromPVLegend),
227 "fromPV_Pt09": _fromPVPtLegend,
228 "fromPV_highPurity_Pt09":
_toHP(_fromPVPtLegend),
229 "fromPVAllTP": _fromPVAllTPLegend,
230 "fromPVAllTP_": _fromPVAllTPLegend,
231 "fromPVAllTP_highPurity":
_toHP(_fromPVAllTPLegend),
232 "fromPVAllTP_Pt09": _fromPVAllTPPtLegend,
233 "fromPVAllTP_highPurityPt09":
_toHP(_fromPVAllTPPtLegend),
234 "fromPVAllTP2_": _fromPVAllTP2Legend,
235 "fromPVAllTP2_highPurity":
_toHP(_fromPVAllTP2Legend),
236 "fromPVAllTP2_Pt09": _fromPVAllTPPt2Legend,
237 "fromPVAllTP2_highPurityPt09":
_toHP(_fromPVAllTPPt2Legend),
238 "bhadron_": _bhadronLegend,
239 "bhadron_highPurity":
_allToHP(_bhadronLegend),
240 "bhadron_btvLike": _bhadronLegend.replace(
"All tracks", _btvLegend),
245 def __init__(self, columnHeaders, rowHeaders, table, purpose, page, section):
246 if len(columnHeaders) != len(table):
247 raise Exception(
"Got %d columnHeaders for table with %d columns for page %s, section %s" % (len(columnHeaders), len(table), page, section))
248 lenRow = len(table[0])
249 for icol, column
in enumerate(table):
250 if len(column) != lenRow:
251 raise Exception(
"Got non-square table, first column has %d rows, column %d has %d rows" % (lenRow, icol, len(column)))
252 if len(rowHeaders) != lenRow:
253 raise Exception(
"Got %d rowHeaders for table with %d rows" % (len(rowHeaders), lenRow))
276 return len(self.
_table[0])
303 ' <title>%s</title>' % title,
324 for plotSet
in self._plotSets.itervalues():
342 self._content.extend([
348 f = open(fileName,
"w")
357 if section
in legends:
362 leg =
"<sup>%d</sup>" % legnum
363 leg2 =
"<sup>%d)</sup>" % legnum
364 self._legends.append(
"%s %s" % (leg2, legends[section]))
369 self._content.extend([
376 sections = self.
_orderSets(self._plotSets.keys())
377 for isec, section
in enumerate(sections):
380 self._content.extend([
383 files = [(os.path.basename(f), f)
for f
in self.
_plotSets[section]]
384 for row
in fileTable:
386 for i, (bsf, f)
in enumerate(files):
395 fileTable.append( [bsf] + [
None]*isec + [f] )
397 self._content.extend([
401 for row
in fileTable:
402 self._content.append(
' <tr>')
406 self._content.append(
' <td><a href="%s">%s</a></td>' % (elem, bs))
408 self._content.append(
' <td></td>')
409 self._content.append(
' </tr>')
412 self._content.extend([
422 self._columnHeaders.append(
"%s: %s" % (leg, header))
433 sections = self.
_orderSets(self._tables.keys())
434 for isec, section
in enumerate(sections):
438 self._content.extend([
441 ' <table border="1">' 445 data = table.tableAsRowColumn()
447 self._content.extend([
451 heads = table.columnHeaders()
452 if max(
map(
lambda h: len(h), heads)) > 20:
455 self._content.append(
' <td>%s</td>' % head)
456 self._content.append(
' </tr>')
458 for irow, row
in enumerate(data):
463 self._content.extend([
465 ' <td>%s</td>' % table.rowHeaders()[irow]
468 for icol, item
in enumerate(row):
469 formatted =
str(item)
if item
is not None else "" 470 self._content.append(
' <td align="right">%s</td>' % formatted)
471 self._content.append(
' </tr>')
473 self._content.append(
' </table>')
476 self._content.append(
' %s<br/>' % shortenedColumnHeader)
482 self._content.extend([
487 self._content.append(
' %s<br/>' % leg)
491 return _sectionNameMapOrder.get(section, section)
494 keys_sorted = sorted(keys)
496 for section
in _sectionNameMapOrder.keys():
497 if section
in keys_sorted:
499 keys_sorted.remove(section)
500 ret.extend(keys_sorted)
504 def __init__(self, title, sampleName, sample, fastVsFull, pileupComparison, dqmSubFolderTranslatedToSectionName=None):
516 self.
_prefix += _sampleFileName.get(sample.label(), sample.label())+
"_" 517 if hasattr(sample,
"hasScenario")
and sample.hasScenario():
518 self.
_prefix += sample.scenario()+
"_" 520 if hasattr(sample,
"hasPileup"):
521 if sample.hasPileup():
522 self.
_prefix +=
"pu"+
str(sample.pileupNumber())+
"_"+sample.pileupType()+
"_" 530 if key
not in self.
_pages:
537 def addPlotSet(self, plotterFolder, dqmSubFolder, plotFiles):
538 pageKey = plotterFolder.getPage()
540 if dqmSubFolder
is not None:
541 pageKey = dqmSubFolder.translated
543 pageKey = plotterFolder.getName()
546 sectionName = plotterFolder.getSection()
547 if sectionName
is None:
548 if plotterFolder.getPage()
is not None and dqmSubFolder
is not None:
552 sectionName = dqmSubFolder.translated
556 page.addPlotSet(sectionName, plotFiles)
562 page = self.
_getPage(table.getPage(), Page)
563 page.addTable(table.getSection(), table)
575 fileName =
"%s%s.html" % (self.
_prefix, key)
576 page.write(os.path.join(baseDir, fileName))
581 return _pageNameMap.get(name, name)
590 super(TrackingIterPage, self).
__init__(*args, **kwargs)
593 return _trackQualityNameOrder.get(quality, quality)
597 for qual
in _trackQualityNameOrder.keys():
598 if qual
in qualities:
600 qualities.remove(qual)
601 ret.extend(qualities)
606 super(TrackingPageSet, self).
__init__(*args, **kwargs)
608 def addPlotSet(self, plotterFolder, dqmSubFolder, plotFiles):
609 (algo, quality) = dqmSubFolder.translated
612 sectionName = quality
618 if algo !=
"ootb" and not plotterFolder._plotFolder.isAlgoIterative(algo):
622 folderName = plotterFolder.getName()
624 sectionName = folderName+
"_"+sectionName
626 page = self.
_getPage(pageName, TrackingIterPage)
627 page.addPlotSet(sectionName, plotFiles)
630 return _trackAlgoName.get(algo, algo)
634 for algo
in _trackAlgoOrder:
644 def __init__(self, sample, title, fastVsFull, pileupComparison):
654 if hasattr(sample,
"hasPileup"):
655 pileup =
"with no pileup" 656 if sample.hasPileup():
657 pileup =
"with %d pileup (%s)" % (sample.pileupNumber(), sample.pileupType())
658 if pileupComparison
is not None:
659 pileup +=
" "+pileupComparison
660 if hasattr(sample,
"customPileupLabel"):
661 pileup = sample.customPileupLabel()
664 if hasattr(sample,
"hasScenario")
and sample.hasScenario():
665 scenario =
" (\"%s\")" % sample.scenario()
666 self.
_sampleName +=
"%s sample%s %s" % (_sampleName.get(sample.name(), sample.name()), scenario, pileup)
668 params = [title, self.
_sampleName, sample, fastVsFull, pileupComparison
is not None]
674 self.
_hltPages =
PageSet(*params, dqmSubFolderTranslatedToSectionName=
lambda algoQuality: algoQuality[0])
686 def addPlots(self, plotterFolder, dqmSubFolder, plotFiles):
687 page = self._purposePageMap.get(plotterFolder.getPurpose(), self.
_otherPages)
688 page.addPlotSet(plotterFolder, dqmSubFolder, plotFiles)
694 page = self._purposePageMap.get(table.getPurpose(), self.
_otherPages)
706 labelFiles = pages.write(baseDir)
707 for label, fname
in labelFiles:
708 ret.append(
' <li><a href="%s">%s</a></li>' % (fname, label))
719 self.
_title =
"Tracking validation "+validationName
725 ' <title>%s</title>' % self.
_title,
733 self._index.append(
' <p>%s</p>'%note)
735 def beginSample(self, sample, fastVsFull=False, pileupComparison=None):
738 rightAfterRefSample = fastVsFull
or (pileupComparison
is not None)
740 key = (sample.digest(), rightAfterRefSample)
748 self._currentSection.addPlots(*args, **kwargs)
751 self._currentSection.addTable(*args, **kwargs)
755 keys = self._sections.iterkeys()
762 ind_fast = newkeys.index( (key[0],
False) )
763 newkeys.insert(ind_fast+1, key)
767 self._index.extend(section.write(self.
_newBaseDir))
774 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)