6 return s[0].lower()+s[1:]
9 "RelValMinBias":
"Min Bias",
10 "RelValTTbar":
"TTbar",
11 "RelValQCD_Pt_600_800":
"QCD Pt 600 to 800",
12 "RelValQCD_Pt_3000_3500":
"QCD Pt 3000 to 3500",
13 "RelValQCD_FlatPt_15_3000":
"QCD Flat Pt 15 to 3000",
15 "RelValWjet_Pt_3000_3500":
"Wjet Pt 3000 to 3500",
16 "RelValH125GGgluonfusion":
"Higgs to gamma gamma",
17 "RelValSingleElectronPt35":
"Single Electron Pt 35",
18 "RelValSingleElectronPt35Extended":
"Single Electron Pt 35 (extended eta)",
19 "RelValSingleElectronPt10":
"Single Electron Pt 10",
20 "RelValSingleMuPt1":
"Single Muon Pt 1",
21 "RelValSingleMuPt10":
"Single Muon Pt 10",
22 "RelValSingleMuPt10Extended":
"Single Muon Pt 10 (extended eta)",
23 "RelValSingleMuPt100":
"Single Muon Pt 100",
24 "RelValTenMuE_0_200":
"Ten muon Pt 0-200",
28 "RelValMinBias":
"minbias",
29 "RelValTTbar":
"ttbar",
30 "RelValQCD_Pt_600_800":
"qcd600",
31 "RelValQCD_Pt_3000_3500":
"qcd3000",
32 "RelValQCD_FlatPt_15_3000":
"qcdflat",
34 "RelValWjet_Pt_3000_3500":
"wjet3000",
35 "RelValH125GGgluonfusion":
"hgg",
36 "RelValSingleElectronPt35":
"ele35",
37 "RelValSingleElectronPt35Extended":
"ele35ext",
38 "RelValSingleElectronPt10":
"ele10",
39 "RelValSingleMuPt1":
"mu1",
40 "RelValSingleMuPt10":
"mu10",
41 "RelValSingleMuPt10Extended":
"mu10ext",
42 "RelValSingleMuPt100":
"mu100",
43 "RelValTenMuE_0_200":
"tenmu200",
46 _allName =
"All tracks" 47 _allTPEfficName = _allName+
" (all TPs)" 48 _fromPVName =
"Tracks from PV" 49 _fromPVAllTPName =
"Tracks from PV (all TPs)" 50 _tpPtLess09Name =
"All tracks (TP pT < 0.9 GeV)" 51 _conversionName =
"Tracks for conversions" 52 _gsfName =
"Electron GSF tracks" 53 _bhadronName =
"All tracks (B-hadron TPs)" 57 return s.replace(
"tracks",
"tracks by originalAlgo")
59 return s.replace(
"tracks",
"tracks by algoMask")
61 return s.replace(
"All",
"High purity")
63 return s.replace(
"All",
"BTV-like")
65 return s.replace(
"Tracks",
"Tracks pT > 0.9 GeV").
replace(
"tracks",
"tracks pT > 0.9 GeV")
66 _trackQualityNameOrder = collections.OrderedDict([
67 (
"seeding_seeds",
"Seeds"),
68 (
"seeding_seedsa",
"Seeds A"),
69 (
"seeding_seedsb",
"Seeds B"),
70 (
"seeding_seedsc",
"Seeds C"),
71 (
"seeding_seedstripl",
"Seeds triplets"),
72 (
"seeding_seedspair",
"Seeds pairs"),
73 (
"building_",
"Built tracks"),
76 (
"Pt09",
"Tracks pT > 0.9 GeV"),
77 (
"highPurityPt09",
"High purity tracks pT > 0.9 GeV"),
82 (
"tpPtLess09_", _tpPtLess09Name),
83 (
"tpPtLess09_highPurity",
_allToHP(_tpPtLess09Name)),
84 (
"tpPtLess09_ByOriginalAlgo",
_toOriAlgo(_tpPtLess09Name)),
86 (
"tpPtLess09_ByAlgoMask",
_toAlgoMask(_tpPtLess09Name)),
89 (
"ak4PFJets",
"AK4 PF jets"),
90 (
"allTPEffic_", _allTPEfficName),
91 (
"allTPEffic_highPurity",
_allToHP(_allTPEfficName)),
92 (
"fromPV_", _fromPVName),
93 (
"fromPV_highPurity",
_toHP(_fromPVName)),
94 (
"fromPV_Pt09",
_ptCut(_fromPVName)),
95 (
"fromPV_highPurityPt09",
_toHP(
_ptCut(_fromPVName))),
96 (
"fromPVAllTP_", _fromPVAllTPName),
97 (
"fromPVAllTP_highPurity",
_toHP(_fromPVAllTPName)),
98 (
"fromPVAllTP_Pt09",
_ptCut(_fromPVAllTPName)),
99 (
"fromPVAllTP_highPurityPt09",
_toHP(
_ptCut(_fromPVAllTPName))),
100 (
"fromPVAllTP2_", _fromPVAllTPName.replace(
"PV",
"PV v2")),
101 (
"fromPVAllTP2_highPurity",
"High purity "+
_lowerFirst(_fromPVAllTPName).
replace(
"PV",
"PV v2")),
102 (
"fromPVAllTP2_Pt09", _fromPVAllTPName.replace(
"Tracks",
"Tracks pT > 0.9 GeV").
replace(
"PV",
"PV v2")),
103 (
"fromPVAllTP2_highPurityPt09",
_toHP(
_ptCut(_fromPVAllTPName)).
replace(
"PV",
"PV v2")),
104 (
"conversion_", _conversionName),
106 (
"bhadron_", _bhadronName),
107 (
"bhadron_highPurity",
_allToHP(_bhadronName)),
108 (
"bhadron_ByOriginalAlgo",
_toOriAlgo(_bhadronName)),
112 (
"bhadron_btvLike",
_allToBTV(_bhadronName)),
116 "ootb":
"Out of the box",
117 "iter0" :
"Iterative Step 0",
118 "iter1" :
"Iterative Step 1",
119 "iter2" :
"Iterative Step 2",
120 "iter3" :
"Iterative Step 3",
121 "iter4" :
"Iterative Step 4",
122 "iter5" :
"Iterative Step 5",
123 "iter6" :
"Iterative Step 6",
124 "iter7" :
"Iterative Step 7",
125 "iter9" :
"Iterative Step 9",
126 "iter10":
"Iterative Step 10",
131 'initialStepPreSplitting',
135 'detachedTripletStep',
142 'jetCoreRegionalStep',
143 'muonSeededStepInOut',
144 'muonSeededStepOutIn',
148 'ckfInOutFromConversions',
149 'ckfOutInFromConversions',
164 "summary":
"Summary",
167 "miniaod":
"MiniAOD",
170 "pixel":
"Pixel tracks",
173 _sectionNameMapOrder = collections.OrderedDict([
175 (
"seeding_seeds",
"Seeds"),
176 (
"building",
"Built tracks"),
178 (
"Pt09",
"All tracks (pT>0.9 GeV)"),
179 (
"highPurity",
"High purity tracks"),
180 (
"highPurityPt09",
"High purity tracks (pT>0.9 GeV)"),
181 (
"tpPtLess09", _tpPtLess09Name),
182 (
"tpPtLess09_highPurity",
_allToHP(_tpPtLess09Name)),
183 (
"btvLike",
"BTV-like"),
184 (
"ak4PFJets",
"AK4 PF jets"),
185 (
"allTPEffic", _allTPEfficName),
186 (
"allTPEffic_highPurity",
_allToHP(_allTPEfficName)),
187 (
"fromPV", _fromPVName),
188 (
"fromPV_highPurity",
"High purity "+
_lowerFirst(_fromPVName)),
189 (
"fromPVAllTP", _fromPVAllTPName),
190 (
"fromPVAllTP_highPurity",
"High purity "+
_lowerFirst(_fromPVAllTPName)),
191 (
"conversion", _conversionName),
193 (
"bhadron", _bhadronName),
194 (
"bhadron_highPurity",
_allToHP(_bhadronName)),
196 (
"pixel",
"Pixel tracks"),
198 (
"genvertex",
"Gen vertices"),
199 (
"pixelVertices",
"Pixel vertices"),
200 (
"selectedPixelVertices",
"Selected pixel vertices"),
201 (
"firstStepPrimaryVerticesPreSplitting",
"firstStepPrimaryVerticesPreSplitting"),
202 (
"firstStepPrimaryVertices",
"firstStepPrimaryVertices"),
203 (
"offlinePrimaryVertices",
"All vertices (offlinePrimaryVertices)"),
204 (
"selectedOfflinePrimaryVertices",
"Selected vertices (selectedOfflinePrimaryVertices)"),
205 (
"offlinePrimaryVerticesWithBS",
"All vertices with BS constraint"),
206 (
"selectedOfflinePrimaryVerticesWithBS",
"Selected vertices with BS constraint"),
209 (
"lambda",
"Lambda"),
211 _btvLegend =
"BTV-like selected tracks" 212 _allTPEfficLegend =
"All tracks, efficiency denominator contains all TrackingParticles" 213 _fromPVLegend =
"Tracks from reco PV vs. TrackingParticles from gen PV (fake rate includes pileup tracks)" 214 _fromPVPtLegend =
"Tracks (pT > 0.9 GeV) from reco PV vs. TrackingParticles from gen PV (fake rate includes pileup tracks)" 215 _fromPVAllTPLegend =
"Tracks from reco PV, fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)" 216 _fromPVAllTPPtLegend =
"Tracks (pT > 0.9 GeV) from reco PV, fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)" 217 _fromPVAllTP2Legend =
"Tracks from reco PV (another method), fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)" 218 _fromPVAllTPPt2Legend =
"Tracks (pT > 0.9 GeV) from reco PV (another method), fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)" 219 _bhadronLegend =
"All tracks, efficiency denominator contains only TrackingParticles from B-hadron decays" 223 "btvLike": _btvLegend,
224 "ak4PFJets":
"Tracks from AK4 PF jets (jet corrected pT > 10 GeV)",
225 "allTPEffic": _allTPEfficLegend,
226 "allTPEffic_": _allTPEfficLegend,
227 "allTPEffic_highPurity":
_allToHP(_allTPEfficLegend),
228 "fromPV": _fromPVLegend,
229 "fromPV_": _fromPVLegend,
230 "fromPV_highPurity":
_toHP(_fromPVLegend),
231 "fromPV_Pt09": _fromPVPtLegend,
232 "fromPV_highPurity_Pt09":
_toHP(_fromPVPtLegend),
233 "fromPVAllTP": _fromPVAllTPLegend,
234 "fromPVAllTP_": _fromPVAllTPLegend,
235 "fromPVAllTP_highPurity":
_toHP(_fromPVAllTPLegend),
236 "fromPVAllTP_Pt09": _fromPVAllTPPtLegend,
237 "fromPVAllTP_highPurityPt09":
_toHP(_fromPVAllTPPtLegend),
238 "fromPVAllTP2_": _fromPVAllTP2Legend,
239 "fromPVAllTP2_highPurity":
_toHP(_fromPVAllTP2Legend),
240 "fromPVAllTP2_Pt09": _fromPVAllTPPt2Legend,
241 "fromPVAllTP2_highPurityPt09":
_toHP(_fromPVAllTPPt2Legend),
242 "bhadron_": _bhadronLegend,
243 "bhadron_highPurity":
_allToHP(_bhadronLegend),
244 "bhadron_btvLike": _bhadronLegend.replace(
"All tracks", _btvLegend),
249 def __init__(self, columnHeaders, rowHeaders, table, purpose, page, section):
250 if len(columnHeaders) != len(table):
251 raise Exception(
"Got %d columnHeaders for table with %d columns for page %s, section %s" % (len(columnHeaders), len(table), page, section))
252 lenRow = len(table[0])
253 for icol, column
in enumerate(table):
254 if len(column) != lenRow:
255 raise Exception(
"Got non-square table, first column has %d rows, column %d has %d rows" % (lenRow, icol, len(column)))
256 if len(rowHeaders) != lenRow:
257 raise Exception(
"Got %d rowHeaders for table with %d rows" % (len(rowHeaders), lenRow))
280 return len(self.
_table[0])
308 ' <title>%s</title>' % title,
329 for plotSet
in six.itervalues(self.
_plotSets):
347 self._content.extend([
353 f = open(fileName,
"w")
362 if section
in legends:
367 leg =
"<sup>%d</sup>" % legnum
368 leg2 =
"<sup>%d)</sup>" % legnum
369 self._legends.append(
"%s %s" % (leg2, legends[section]))
374 self._content.extend([
381 sections = self.
_orderSets(self._plotSets.keys())
382 for isec, section
in enumerate(sections):
385 self._content.extend([
388 files = [(os.path.basename(f), f)
for f
in self.
_plotSets[section]]
389 for row
in fileTable:
391 for i, (bsf, f)
in enumerate(files):
400 fileTable.append( [bsf] + [
None]*isec + [f] )
402 self._content.extend([
406 for row
in fileTable:
407 self._content.append(
' <tr>')
411 self._content.append(
' <td><a href="%s">%s</a></td>' % (elem, bs))
413 self._content.append(
' <td></td>')
414 self._content.append(
' </tr>')
417 self._content.extend([
427 self._columnHeaders.append(
"%s: %s" % (leg, header))
438 sections = self.
_orderSets(self._tables.keys())
439 for isec, section
in enumerate(sections):
443 self._content.extend([
446 ' <table border="1">' 450 data = table.tableAsRowColumn()
452 self._content.extend([
456 heads = table.columnHeaders()
457 if max(
map(
lambda h: len(h), heads)) > 20:
460 self._content.append(
' <td>%s</td>' % head)
461 self._content.append(
' </tr>')
463 for irow, row
in enumerate(data):
468 self._content.extend([
470 ' <td>%s</td>' % table.rowHeaders()[irow]
473 for icol, item
in enumerate(row):
474 formatted =
str(item)
if item
is not None else "" 475 self._content.append(
' <td align="right">%s</td>' % formatted)
476 self._content.append(
' </tr>')
478 self._content.append(
' </table>')
481 self._content.append(
' %s<br/>' % shortenedColumnHeader)
487 self._content.extend([
492 self._content.append(
' %s<br/>' % leg)
496 return _sectionNameMapOrder.get(section, section)
499 keys_sorted = sorted(keys)
501 for section
in _sectionNameMapOrder.keys():
502 if section
in keys_sorted:
504 keys_sorted.remove(section)
505 ret.extend(keys_sorted)
509 def __init__(self, title, sampleName, sample, fastVsFull, pileupComparison, dqmSubFolderTranslatedToSectionName=None):
521 self.
_prefix += _sampleFileName.get(sample.label(), sample.label())+
"_" 522 if hasattr(sample,
"hasScenario")
and sample.hasScenario():
523 self.
_prefix += sample.scenario()+
"_" 525 if hasattr(sample,
"hasPileup"):
526 if sample.hasPileup():
527 self.
_prefix +=
"pu"+
str(sample.pileupNumber())+
"_"+sample.pileupType()+
"_" 535 if key
not in self.
_pages:
542 def addPlotSet(self, plotterFolder, dqmSubFolder, plotFiles):
543 pageKey = plotterFolder.getPage()
545 if dqmSubFolder
is not None:
546 pageKey = dqmSubFolder.translated
548 pageKey = plotterFolder.getName()
551 sectionName = plotterFolder.getSection()
552 if sectionName
is None:
553 if plotterFolder.getPage()
is not None and dqmSubFolder
is not None:
557 sectionName = dqmSubFolder.translated
561 page.addPlotSet(sectionName, plotFiles)
567 page = self.
_getPage(table.getPage(), Page)
568 page.addTable(table.getSection(), table)
580 fileName =
"%s%s.html" % (self.
_prefix, key)
581 page.write(os.path.join(baseDir, fileName))
586 return _pageNameMap.get(name, name)
595 super(TrackingIterPage, self).
__init__(*args, **kwargs)
598 return _trackQualityNameOrder.get(quality, quality)
602 for qual
in _trackQualityNameOrder.keys():
603 if qual
in qualities:
605 qualities.remove(qual)
606 ret.extend(qualities)
611 super(TrackingPageSet, self).
__init__(*args, **kwargs)
613 def addPlotSet(self, plotterFolder, dqmSubFolder, plotFiles):
614 (algo, quality) = dqmSubFolder.translated
617 sectionName = quality
623 if algo !=
"ootb" and not plotterFolder._plotFolder.isAlgoIterative(algo):
627 folderName = plotterFolder.getName()
629 sectionName = folderName+
"_"+sectionName
631 page = self.
_getPage(pageName, TrackingIterPage)
632 page.addPlotSet(sectionName, plotFiles)
635 return _trackAlgoName.get(algo, algo)
639 for algo
in _trackAlgoOrder:
649 def __init__(self, sample, title, fastVsFull, pileupComparison):
659 if hasattr(sample,
"hasPileup"):
660 pileup =
"with no pileup" 661 if sample.hasPileup():
662 pileup =
"with %d pileup (%s)" % (sample.pileupNumber(), sample.pileupType())
663 if pileupComparison
is not None:
664 pileup +=
" "+pileupComparison
665 if hasattr(sample,
"customPileupLabel"):
666 pileup = sample.customPileupLabel()
669 if hasattr(sample,
"hasScenario")
and sample.hasScenario():
670 scenario =
" (\"%s\")" % sample.scenario()
671 self.
_sampleName +=
"%s sample%s %s" % (_sampleName.get(sample.name(), sample.name()), scenario, pileup)
673 params = [title, self.
_sampleName, sample, fastVsFull, pileupComparison
is not None]
679 self.
_hltPages =
PageSet(*params, dqmSubFolderTranslatedToSectionName=
lambda algoQuality: algoQuality[0])
680 self.
_pixelPages =
PageSet(*params, dqmSubFolderTranslatedToSectionName=
lambda algoQuality: algoQuality[0])
693 def addPlots(self, plotterFolder, dqmSubFolder, plotFiles):
694 page = self._purposePageMap.get(plotterFolder.getPurpose(), self.
_otherPages)
695 page.addPlotSet(plotterFolder, dqmSubFolder, plotFiles)
701 page = self._purposePageMap.get(table.getPurpose(), self.
_otherPages)
713 labelFiles = pages.write(baseDir)
714 for label, fname
in labelFiles:
715 ret.append(
' <li><a href="%s">%s</a></li>' % (fname, label))
726 self.
_title =
"Tracking validation "+validationName
732 ' <title>%s</title>' % self.
_title,
740 self._index.append(
' <p>%s</p>'%note)
742 def beginSample(self, sample, fastVsFull=False, pileupComparison=None):
745 rightAfterRefSample = fastVsFull
or (pileupComparison
is not None)
747 key = (sample.digest(), rightAfterRefSample)
755 self._currentSection.addPlots(*args, **kwargs)
758 self._currentSection.addTable(*args, **kwargs)
762 keys = self._sections.iterkeys()
769 ind_fast = newkeys.index( (key[0],
False) )
770 newkeys.insert(ind_fast+1, key)
774 self._index.extend(section.write(self.
_newBaseDir))
781 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)