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",
174 _sectionNameMapOrder = collections.OrderedDict([
176 (
"seeding_seeds",
"Seeds"),
177 (
"building",
"Built tracks"),
179 (
"Pt09",
"All tracks (pT>0.9 GeV)"),
180 (
"highPurity",
"High purity tracks"),
181 (
"highPurityPt09",
"High purity tracks (pT>0.9 GeV)"),
182 (
"tpPtLess09", _tpPtLess09Name),
183 (
"tpPtLess09_highPurity",
_allToHP(_tpPtLess09Name)),
184 (
"btvLike",
"BTV-like"),
185 (
"ak4PFJets",
"AK4 PF jets"),
186 (
"allTPEffic", _allTPEfficName),
187 (
"allTPEffic_highPurity",
_allToHP(_allTPEfficName)),
188 (
"fromPV", _fromPVName),
189 (
"fromPV_highPurity",
"High purity "+
_lowerFirst(_fromPVName)),
190 (
"fromPVAllTP", _fromPVAllTPName),
191 (
"fromPVAllTP_highPurity",
"High purity "+
_lowerFirst(_fromPVAllTPName)),
192 (
"conversion", _conversionName),
194 (
"bhadron", _bhadronName),
195 (
"bhadron_highPurity",
_allToHP(_bhadronName)),
197 (
"pixel",
"Pixel tracks"),
199 (
"genvertex",
"Gen vertices"),
200 (
"pixelVertices",
"Pixel vertices"),
201 (
"selectedPixelVertices",
"Selected pixel vertices"),
202 (
"firstStepPrimaryVerticesPreSplitting",
"firstStepPrimaryVerticesPreSplitting"),
203 (
"firstStepPrimaryVertices",
"firstStepPrimaryVertices"),
204 (
"offlinePrimaryVertices",
"All vertices (offlinePrimaryVertices)"),
205 (
"selectedOfflinePrimaryVertices",
"Selected vertices (selectedOfflinePrimaryVertices)"),
206 (
"offlinePrimaryVerticesWithBS",
"All vertices with BS constraint"),
207 (
"selectedOfflinePrimaryVerticesWithBS",
"Selected vertices with BS constraint"),
210 (
"lambda",
"Lambda"),
212 _btvLegend =
"BTV-like selected tracks" 213 _allTPEfficLegend =
"All tracks, efficiency denominator contains all TrackingParticles" 214 _fromPVLegend =
"Tracks from reco PV vs. TrackingParticles from gen PV (fake rate includes pileup tracks)" 215 _fromPVPtLegend =
"Tracks (pT > 0.9 GeV) from reco PV vs. TrackingParticles from gen PV (fake rate includes pileup tracks)" 216 _fromPVAllTPLegend =
"Tracks from reco PV, fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)" 217 _fromPVAllTPPtLegend =
"Tracks (pT > 0.9 GeV) from reco PV, fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)" 218 _fromPVAllTP2Legend =
"Tracks from reco PV (another method), fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)" 219 _fromPVAllTPPt2Legend =
"Tracks (pT > 0.9 GeV) from reco PV (another method), fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)" 220 _bhadronLegend =
"All tracks, efficiency denominator contains only TrackingParticles from B-hadron decays" 224 "btvLike": _btvLegend,
225 "ak4PFJets":
"Tracks from AK4 PF jets (jet corrected pT > 10 GeV)",
226 "allTPEffic": _allTPEfficLegend,
227 "allTPEffic_": _allTPEfficLegend,
228 "allTPEffic_highPurity":
_allToHP(_allTPEfficLegend),
229 "fromPV": _fromPVLegend,
230 "fromPV_": _fromPVLegend,
231 "fromPV_highPurity":
_toHP(_fromPVLegend),
232 "fromPV_Pt09": _fromPVPtLegend,
233 "fromPV_highPurity_Pt09":
_toHP(_fromPVPtLegend),
234 "fromPVAllTP": _fromPVAllTPLegend,
235 "fromPVAllTP_": _fromPVAllTPLegend,
236 "fromPVAllTP_highPurity":
_toHP(_fromPVAllTPLegend),
237 "fromPVAllTP_Pt09": _fromPVAllTPPtLegend,
238 "fromPVAllTP_highPurityPt09":
_toHP(_fromPVAllTPPtLegend),
239 "fromPVAllTP2_": _fromPVAllTP2Legend,
240 "fromPVAllTP2_highPurity":
_toHP(_fromPVAllTP2Legend),
241 "fromPVAllTP2_Pt09": _fromPVAllTPPt2Legend,
242 "fromPVAllTP2_highPurityPt09":
_toHP(_fromPVAllTPPt2Legend),
243 "bhadron_": _bhadronLegend,
244 "bhadron_highPurity":
_allToHP(_bhadronLegend),
245 "bhadron_btvLike": _bhadronLegend.replace(
"All tracks", _btvLegend),
250 def __init__(self, columnHeaders, rowHeaders, table, purpose, page, section):
251 if len(columnHeaders) != len(table):
252 raise Exception(
"Got %d columnHeaders for table with %d columns for page %s, section %s" % (len(columnHeaders), len(table), page, section))
253 lenRow = len(table[0])
254 for icol, column
in enumerate(table):
255 if len(column) != lenRow:
256 raise Exception(
"Got non-square table, first column has %d rows, column %d has %d rows" % (lenRow, icol, len(column)))
257 if len(rowHeaders) != lenRow:
258 raise Exception(
"Got %d rowHeaders for table with %d rows" % (len(rowHeaders), lenRow))
281 return len(self.
_table[0])
310 ' <title>%s</title>' % title,
331 for plotSet
in six.itervalues(self.
_plotSets):
349 self._content.extend([
355 f = open(fileName,
"w")
364 if section
in legends:
369 leg =
"<sup>%d</sup>" % legnum
370 leg2 =
"<sup>%d)</sup>" % legnum
371 self._legends.append(
"%s %s" % (leg2, legends[section]))
376 self._content.extend([
383 sections = self.
_orderSets(self._plotSets.keys())
384 for isec, section
in enumerate(sections):
387 self._content.extend([
390 files = [(os.path.basename(f), f)
for f
in self.
_plotSets[section]]
391 for row
in fileTable:
393 for i, (bsf, f)
in enumerate(files):
402 fileTable.append( [bsf] + [
None]*isec + [f] )
404 self._content.extend([
408 for row
in fileTable:
409 self._content.append(
' <tr>')
413 self._content.append(
' <td><a href="%s">%s</a></td>' % (elem, bs))
415 self._content.append(
' <td></td>')
416 self._content.append(
' </tr>')
419 self._content.extend([
424 first_row = fileTable[0]
425 self._content.extend([
426 ' <a href="%s">Browse Folder</a>' % (first_row[1][0:first_row[1].rfind(
'/')])
435 self._columnHeaders.append(
"%s: %s" % (leg, header))
446 sections = self.
_orderSets(self._tables.keys())
447 for isec, section
in enumerate(sections):
451 self._content.extend([
454 ' <table border="1">' 458 data = table.tableAsRowColumn()
460 self._content.extend([
464 heads = table.columnHeaders()
465 if max(
map(
lambda h: len(h), heads)) > 20:
468 self._content.append(
' <td>%s</td>' % head)
469 self._content.append(
' </tr>')
471 for irow, row
in enumerate(data):
476 self._content.extend([
478 ' <td>%s</td>' % table.rowHeaders()[irow]
481 for icol, item
in enumerate(row):
482 formatted =
str(item)
if item
is not None else "" 483 self._content.append(
' <td align="right">%s</td>' % formatted)
484 self._content.append(
' </tr>')
486 self._content.append(
' </table>')
489 self._content.append(
' %s<br/>' % shortenedColumnHeader)
495 self._content.extend([
500 self._content.append(
' %s<br/>' % leg)
504 return _sectionNameMapOrder.get(section, section)
507 keys_sorted = sorted(keys)
509 for section
in _sectionNameMapOrder.keys():
510 if section
in keys_sorted:
512 keys_sorted.remove(section)
513 ret.extend(keys_sorted)
517 def __init__(self, title, sampleName, sample, fastVsFull, pileupComparison, dqmSubFolderTranslatedToSectionName=None):
529 self.
_prefix += _sampleFileName.get(sample.label(), sample.label())+
"_" 530 if hasattr(sample,
"hasScenario")
and sample.hasScenario():
531 self.
_prefix += sample.scenario()+
"_" 533 if hasattr(sample,
"hasPileup"):
534 if sample.hasPileup():
535 self.
_prefix +=
"pu"+
str(sample.pileupNumber())+
"_"+sample.pileupType()+
"_" 543 if key
not in self.
_pages:
550 def addPlotSet(self, plotterFolder, dqmSubFolder, plotFiles):
551 pageKey = plotterFolder.getPage()
553 if dqmSubFolder
is not None:
554 pageKey = dqmSubFolder.translated
556 pageKey = plotterFolder.getName()
559 sectionName = plotterFolder.getSection()
560 if sectionName
is None:
561 if plotterFolder.getPage()
is not None and dqmSubFolder
is not None:
565 sectionName = dqmSubFolder.translated
569 page.addPlotSet(sectionName, plotFiles)
575 page = self.
_getPage(table.getPage(), Page)
576 page.addTable(table.getSection(), table)
588 fileName =
"%s%s.html" % (self.
_prefix, key)
589 page.write(os.path.join(baseDir, fileName))
594 return _pageNameMap.get(name, name)
603 super(TrackingIterPage, self).
__init__(*args, **kwargs)
606 return _trackQualityNameOrder.get(quality, quality)
610 for qual
in _trackQualityNameOrder.keys():
611 if qual
in qualities:
613 qualities.remove(qual)
614 ret.extend(qualities)
619 super(TrackingPageSet, self).
__init__(*args, **kwargs)
621 def addPlotSet(self, plotterFolder, dqmSubFolder, plotFiles):
622 (algo, quality) = dqmSubFolder.translated
625 sectionName = quality
631 if algo !=
"ootb" and not plotterFolder._plotFolder.isAlgoIterative(algo):
635 folderName = plotterFolder.getName()
637 sectionName = folderName+
"_"+sectionName
639 page = self.
_getPage(pageName, TrackingIterPage)
640 page.addPlotSet(sectionName, plotFiles)
643 return _trackAlgoName.get(algo, algo)
647 for algo
in _trackAlgoOrder:
657 def __init__(self, sample, title, fastVsFull, pileupComparison):
667 if hasattr(sample,
"hasPileup"):
668 pileup =
"with no pileup" 669 if sample.hasPileup():
670 pileup =
"with %d pileup (%s)" % (sample.pileupNumber(), sample.pileupType())
671 if pileupComparison
is not None:
672 pileup +=
" "+pileupComparison
673 if hasattr(sample,
"customPileupLabel"):
674 pileup = sample.customPileupLabel()
677 if hasattr(sample,
"hasScenario")
and sample.hasScenario():
678 scenario =
" (\"%s\")" % sample.scenario()
679 self.
_sampleName +=
"%s sample%s %s" % (_sampleName.get(sample.name(), sample.name()), scenario, pileup)
681 params = [title, self.
_sampleName, sample, fastVsFull, pileupComparison
is not None]
688 self.
_hltPages =
PageSet(*params, dqmSubFolderTranslatedToSectionName=
lambda algoQuality: algoQuality[0])
689 self.
_pixelPages =
PageSet(*params, dqmSubFolderTranslatedToSectionName=
lambda algoQuality: algoQuality[0])
703 def addPlots(self, plotterFolder, dqmSubFolder, plotFiles):
704 page = self._purposePageMap.get(plotterFolder.getPurpose(), self.
_otherPages)
705 page.addPlotSet(plotterFolder, dqmSubFolder, plotFiles)
711 page = self._purposePageMap.get(table.getPurpose(), self.
_otherPages)
723 labelFiles = pages.write(baseDir)
724 for label, fname
in labelFiles:
725 ret.append(
' <li><a href="%s">%s</a></li>' % (fname, label))
736 self.
_title =
"Tracking validation "+validationName
742 ' <title>%s</title>' % self.
_title,
750 self._index.append(
' <p>%s</p>'%note)
752 def beginSample(self, sample, fastVsFull=False, pileupComparison=None):
755 rightAfterRefSample = fastVsFull
or (pileupComparison
is not None)
757 key = (sample.digest(), rightAfterRefSample)
765 self._currentSection.addPlots(*args, **kwargs)
768 self._currentSection.addTable(*args, **kwargs)
772 keys = self._sections.iterkeys()
779 ind_fast = newkeys.index( (key[0],
False) )
780 newkeys.insert(ind_fast+1, key)
784 self._index.extend(section.write(self.
_newBaseDir))
791 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)