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 pT > 0.9 GeV").
replace(
"tracks",
"tracks pT > 0.9 GeV")
65 _trackQualityNameOrder = collections.OrderedDict([
66 (
"seeding_seeds",
"Seeds"),
67 (
"seeding_seedsa",
"Seeds A"),
68 (
"seeding_seedsb",
"Seeds B"),
69 (
"seeding_seedsc",
"Seeds C"),
70 (
"seeding_seedstripl",
"Seeds triplets"),
71 (
"seeding_seedspair",
"Seeds pairs"),
72 (
"building_",
"Built tracks"),
75 (
"Pt09",
"Tracks pT > 0.9 GeV"),
76 (
"highPurityPt09",
"High purity tracks pT > 0.9 GeV"),
81 (
"tpPtLess09_", _tpPtLess09Name),
82 (
"tpPtLess09_highPurity",
_allToHP(_tpPtLess09Name)),
83 (
"tpPtLess09_ByOriginalAlgo",
_toOriAlgo(_tpPtLess09Name)),
85 (
"tpPtLess09_ByAlgoMask",
_toAlgoMask(_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",
169 "pixel":
"Pixel tracks",
172 _sectionNameMapOrder = collections.OrderedDict([
174 (
"seeding_seeds",
"Seeds"),
175 (
"building",
"Built tracks"),
177 (
"Pt09",
"All tracks (pT>0.9 GeV)"),
178 (
"highPurity",
"High purity tracks"),
179 (
"highPurityPt09",
"High purity tracks (pT>0.9 GeV)"),
180 (
"tpPtLess09", _tpPtLess09Name),
181 (
"tpPtLess09_highPurity",
_allToHP(_tpPtLess09Name)),
182 (
"btvLike",
"BTV-like"),
183 (
"ak4PFJets",
"AK4 PF jets"),
184 (
"allTPEffic", _allTPEfficName),
185 (
"allTPEffic_highPurity",
_allToHP(_allTPEfficName)),
186 (
"fromPV", _fromPVName),
187 (
"fromPV_highPurity",
"High purity "+
_lowerFirst(_fromPVName)),
188 (
"fromPVAllTP", _fromPVAllTPName),
189 (
"fromPVAllTP_highPurity",
"High purity "+
_lowerFirst(_fromPVAllTPName)),
190 (
"conversion", _conversionName),
192 (
"bhadron", _bhadronName),
193 (
"bhadron_highPurity",
_allToHP(_bhadronName)),
195 (
"pixel",
"Pixel tracks"),
197 (
"genvertex",
"Gen vertices"),
198 (
"pixelVertices",
"Pixel vertices"),
199 (
"selectedPixelVertices",
"Selected pixel vertices"),
200 (
"firstStepPrimaryVerticesPreSplitting",
"firstStepPrimaryVerticesPreSplitting"),
201 (
"firstStepPrimaryVertices",
"firstStepPrimaryVertices"),
202 (
"offlinePrimaryVertices",
"All vertices (offlinePrimaryVertices)"),
203 (
"selectedOfflinePrimaryVertices",
"Selected vertices (selectedOfflinePrimaryVertices)"),
204 (
"offlinePrimaryVerticesWithBS",
"All vertices with BS constraint"),
205 (
"selectedOfflinePrimaryVerticesWithBS",
"Selected vertices with BS constraint"),
208 (
"lambda",
"Lambda"),
210 _btvLegend =
"BTV-like selected tracks" 211 _allTPEfficLegend =
"All tracks, efficiency denominator contains all TrackingParticles" 212 _fromPVLegend =
"Tracks from reco PV vs. TrackingParticles from gen PV (fake rate includes pileup tracks)" 213 _fromPVPtLegend =
"Tracks (pT > 0.9 GeV) from reco PV vs. TrackingParticles from gen PV (fake rate includes pileup tracks)" 214 _fromPVAllTPLegend =
"Tracks from reco PV, fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)" 215 _fromPVAllTPPtLegend =
"Tracks (pT > 0.9 GeV) from reco PV, fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)" 216 _fromPVAllTP2Legend =
"Tracks from reco PV (another method), fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)" 217 _fromPVAllTPPt2Legend =
"Tracks (pT > 0.9 GeV) from reco PV (another method), fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)" 218 _bhadronLegend =
"All tracks, efficiency denominator contains only TrackingParticles from B-hadron decays" 222 "btvLike": _btvLegend,
223 "ak4PFJets":
"Tracks from AK4 PF jets (jet corrected pT > 10 GeV)",
224 "allTPEffic": _allTPEfficLegend,
225 "allTPEffic_": _allTPEfficLegend,
226 "allTPEffic_highPurity":
_allToHP(_allTPEfficLegend),
227 "fromPV": _fromPVLegend,
228 "fromPV_": _fromPVLegend,
229 "fromPV_highPurity":
_toHP(_fromPVLegend),
230 "fromPV_Pt09": _fromPVPtLegend,
231 "fromPV_highPurity_Pt09":
_toHP(_fromPVPtLegend),
232 "fromPVAllTP": _fromPVAllTPLegend,
233 "fromPVAllTP_": _fromPVAllTPLegend,
234 "fromPVAllTP_highPurity":
_toHP(_fromPVAllTPLegend),
235 "fromPVAllTP_Pt09": _fromPVAllTPPtLegend,
236 "fromPVAllTP_highPurityPt09":
_toHP(_fromPVAllTPPtLegend),
237 "fromPVAllTP2_": _fromPVAllTP2Legend,
238 "fromPVAllTP2_highPurity":
_toHP(_fromPVAllTP2Legend),
239 "fromPVAllTP2_Pt09": _fromPVAllTPPt2Legend,
240 "fromPVAllTP2_highPurityPt09":
_toHP(_fromPVAllTPPt2Legend),
241 "bhadron_": _bhadronLegend,
242 "bhadron_highPurity":
_allToHP(_bhadronLegend),
243 "bhadron_btvLike": _bhadronLegend.replace(
"All tracks", _btvLegend),
248 def __init__(self, columnHeaders, rowHeaders, table, purpose, page, section):
249 if len(columnHeaders) != len(table):
250 raise Exception(
"Got %d columnHeaders for table with %d columns for page %s, section %s" % (len(columnHeaders), len(table), page, section))
251 lenRow = len(table[0])
252 for icol, column
in enumerate(table):
253 if len(column) != lenRow:
254 raise Exception(
"Got non-square table, first column has %d rows, column %d has %d rows" % (lenRow, icol, len(column)))
255 if len(rowHeaders) != lenRow:
256 raise Exception(
"Got %d rowHeaders for table with %d rows" % (len(rowHeaders), lenRow))
279 return len(self.
_table[0])
307 ' <title>%s</title>' % title,
328 for plotSet
in self._plotSets.itervalues():
346 self._content.extend([
352 f = open(fileName,
"w")
361 if section
in legends:
366 leg =
"<sup>%d</sup>" % legnum
367 leg2 =
"<sup>%d)</sup>" % legnum
368 self._legends.append(
"%s %s" % (leg2, legends[section]))
373 self._content.extend([
380 sections = self.
_orderSets(self._plotSets.keys())
381 for isec, section
in enumerate(sections):
384 self._content.extend([
387 files = [(os.path.basename(f), f)
for f
in self.
_plotSets[section]]
388 for row
in fileTable:
390 for i, (bsf, f)
in enumerate(files):
399 fileTable.append( [bsf] + [
None]*isec + [f] )
401 self._content.extend([
405 for row
in fileTable:
406 self._content.append(
' <tr>')
410 self._content.append(
' <td><a href="%s">%s</a></td>' % (elem, bs))
412 self._content.append(
' <td></td>')
413 self._content.append(
' </tr>')
416 self._content.extend([
426 self._columnHeaders.append(
"%s: %s" % (leg, header))
437 sections = self.
_orderSets(self._tables.keys())
438 for isec, section
in enumerate(sections):
442 self._content.extend([
445 ' <table border="1">' 449 data = table.tableAsRowColumn()
451 self._content.extend([
455 heads = table.columnHeaders()
456 if max(
map(
lambda h: len(h), heads)) > 20:
459 self._content.append(
' <td>%s</td>' % head)
460 self._content.append(
' </tr>')
462 for irow, row
in enumerate(data):
467 self._content.extend([
469 ' <td>%s</td>' % table.rowHeaders()[irow]
472 for icol, item
in enumerate(row):
473 formatted =
str(item)
if item
is not None else "" 474 self._content.append(
' <td align="right">%s</td>' % formatted)
475 self._content.append(
' </tr>')
477 self._content.append(
' </table>')
480 self._content.append(
' %s<br/>' % shortenedColumnHeader)
486 self._content.extend([
491 self._content.append(
' %s<br/>' % leg)
495 return _sectionNameMapOrder.get(section, section)
498 keys_sorted = sorted(keys)
500 for section
in _sectionNameMapOrder.keys():
501 if section
in keys_sorted:
503 keys_sorted.remove(section)
504 ret.extend(keys_sorted)
508 def __init__(self, title, sampleName, sample, fastVsFull, pileupComparison, dqmSubFolderTranslatedToSectionName=None):
520 self.
_prefix += _sampleFileName.get(sample.label(), sample.label())+
"_" 521 if hasattr(sample,
"hasScenario")
and sample.hasScenario():
522 self.
_prefix += sample.scenario()+
"_" 524 if hasattr(sample,
"hasPileup"):
525 if sample.hasPileup():
526 self.
_prefix +=
"pu"+
str(sample.pileupNumber())+
"_"+sample.pileupType()+
"_" 534 if key
not in self.
_pages:
541 def addPlotSet(self, plotterFolder, dqmSubFolder, plotFiles):
542 pageKey = plotterFolder.getPage()
544 if dqmSubFolder
is not None:
545 pageKey = dqmSubFolder.translated
547 pageKey = plotterFolder.getName()
550 sectionName = plotterFolder.getSection()
551 if sectionName
is None:
552 if plotterFolder.getPage()
is not None and dqmSubFolder
is not None:
556 sectionName = dqmSubFolder.translated
560 page.addPlotSet(sectionName, plotFiles)
566 page = self.
_getPage(table.getPage(), Page)
567 page.addTable(table.getSection(), table)
579 fileName =
"%s%s.html" % (self.
_prefix, key)
580 page.write(os.path.join(baseDir, fileName))
585 return _pageNameMap.get(name, name)
594 super(TrackingIterPage, self).
__init__(*args, **kwargs)
597 return _trackQualityNameOrder.get(quality, quality)
601 for qual
in _trackQualityNameOrder.keys():
602 if qual
in qualities:
604 qualities.remove(qual)
605 ret.extend(qualities)
610 super(TrackingPageSet, self).
__init__(*args, **kwargs)
612 def addPlotSet(self, plotterFolder, dqmSubFolder, plotFiles):
613 (algo, quality) = dqmSubFolder.translated
616 sectionName = quality
622 if algo !=
"ootb" and not plotterFolder._plotFolder.isAlgoIterative(algo):
626 folderName = plotterFolder.getName()
628 sectionName = folderName+
"_"+sectionName
630 page = self.
_getPage(pageName, TrackingIterPage)
631 page.addPlotSet(sectionName, plotFiles)
634 return _trackAlgoName.get(algo, algo)
638 for algo
in _trackAlgoOrder:
648 def __init__(self, sample, title, fastVsFull, pileupComparison):
658 if hasattr(sample,
"hasPileup"):
659 pileup =
"with no pileup" 660 if sample.hasPileup():
661 pileup =
"with %d pileup (%s)" % (sample.pileupNumber(), sample.pileupType())
662 if pileupComparison
is not None:
663 pileup +=
" "+pileupComparison
664 if hasattr(sample,
"customPileupLabel"):
665 pileup = sample.customPileupLabel()
668 if hasattr(sample,
"hasScenario")
and sample.hasScenario():
669 scenario =
" (\"%s\")" % sample.scenario()
670 self.
_sampleName +=
"%s sample%s %s" % (_sampleName.get(sample.name(), sample.name()), scenario, pileup)
672 params = [title, self.
_sampleName, sample, fastVsFull, pileupComparison
is not None]
678 self.
_hltPages =
PageSet(*params, dqmSubFolderTranslatedToSectionName=
lambda algoQuality: algoQuality[0])
679 self.
_pixelPages =
PageSet(*params, dqmSubFolderTranslatedToSectionName=
lambda algoQuality: algoQuality[0])
692 def addPlots(self, plotterFolder, dqmSubFolder, plotFiles):
693 page = self._purposePageMap.get(plotterFolder.getPurpose(), self.
_otherPages)
694 page.addPlotSet(plotterFolder, dqmSubFolder, plotFiles)
700 page = self._purposePageMap.get(table.getPurpose(), self.
_otherPages)
712 labelFiles = pages.write(baseDir)
713 for label, fname
in labelFiles:
714 ret.append(
' <li><a href="%s">%s</a></li>' % (fname, label))
725 self.
_title =
"Tracking validation "+validationName
731 ' <title>%s</title>' % self.
_title,
739 self._index.append(
' <p>%s</p>'%note)
741 def beginSample(self, sample, fastVsFull=False, pileupComparison=None):
744 rightAfterRefSample = fastVsFull
or (pileupComparison
is not None)
746 key = (sample.digest(), rightAfterRefSample)
754 self._currentSection.addPlots(*args, **kwargs)
757 self._currentSection.addTable(*args, **kwargs)
761 keys = self._sections.iterkeys()
768 ind_fast = newkeys.index( (key[0],
False) )
769 newkeys.insert(ind_fast+1, key)
773 self._index.extend(section.write(self.
_newBaseDir))
780 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)