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 _tpEtaGreater2p7Name =
"All tracks (TP |eta| > 2.7)"
51 _conversionName =
"Tracks for conversions"
52 _gsfName =
"Electron GSF tracks"
53 _bhadronName =
"All tracks (B-hadron TPs)"
54 _displacedName =
"All tracks (TPs with no tip or lip cuts)"
58 return s.replace(
"tracks",
"tracks by originalAlgo")
60 return s.replace(
"tracks",
"tracks by algoMask")
62 return s.replace(
"All",
"High purity")
64 return s.replace(
"All",
"BTV-like")
66 return s.replace(
"All tracks",
"Tracks pT > 0.9 GeV")
68 return s.replace(
"Tracks",
"Tracks pT > 0.9 GeV").
replace(
"tracks",
"tracks pT > 0.9 GeV")
70 return s.replace(
"All",
"Pixel")
72 return s.replace(
"Tracks",
"Pixel tracks")
73 _trackQualityNameOrder = collections.OrderedDict([
74 (
"seeding_seeds",
"Seeds"),
75 (
"seeding_seedsa",
"Seeds A"),
76 (
"seeding_seedsb",
"Seeds B"),
77 (
"seeding_seedsc",
"Seeds C"),
78 (
"seeding_seedstripl",
"Seeds triplets"),
79 (
"seeding_seedspair",
"Seeds pairs"),
80 (
"building_",
"Built tracks"),
89 (
"tpPtLess09_", _tpPtLess09Name),
90 (
"tpPtLess09_highPurity",
_allToHP(_tpPtLess09Name)),
91 (
"tpPtLess09_ByOriginalAlgo",
_toOriAlgo(_tpPtLess09Name)),
93 (
"tpPtLess09_ByAlgoMask",
_toAlgoMask(_tpPtLess09Name)),
95 (
"tpEtaGreater2p7_", _tpEtaGreater2p7Name),
96 (
"tpEtaGreater2p7_highPurity",
_allToHP(_tpEtaGreater2p7Name)),
98 (
"ak4PFJets",
"AK4 PF jets"),
99 (
"allTPEffic_", _allTPEfficName),
100 (
"allTPEffic_highPurity",
_allToHP(_allTPEfficName)),
101 (
"fromPV_", _fromPVName),
102 (
"fromPV_highPurity",
_toHP(_fromPVName)),
103 (
"fromPV_Pt09",
_ptCut(_fromPVName)),
104 (
"fromPV_highPurityPt09",
_toHP(
_ptCut(_fromPVName))),
105 (
"fromPVAllTP_", _fromPVAllTPName),
106 (
"fromPVAllTP_highPurity",
_toHP(_fromPVAllTPName)),
107 (
"fromPVAllTP_Pt09",
_ptCut(_fromPVAllTPName)),
108 (
"fromPVAllTP_highPurityPt09",
_toHP(
_ptCut(_fromPVAllTPName))),
109 (
"fromPVAllTP2_", _fromPVAllTPName.replace(
"PV",
"PV v2")),
110 (
"fromPVAllTP2_highPurity",
"High purity "+
_lowerFirst(_fromPVAllTPName).
replace(
"PV",
"PV v2")),
111 (
"fromPVAllTP2_Pt09", _fromPVAllTPName.replace(
"Tracks",
"Tracks pT > 0.9 GeV").
replace(
"PV",
"PV v2")),
112 (
"fromPVAllTP2_highPurityPt09",
_toHP(
_ptCut(_fromPVAllTPName)).
replace(
"PV",
"PV v2")),
113 (
"conversion_", _conversionName),
115 (
"bhadron_", _bhadronName),
116 (
"bhadron_highPurity",
_allToHP(_bhadronName)),
117 (
"bhadron_ByOriginalAlgo",
_toOriAlgo(_bhadronName)),
121 (
"bhadron_btvLike",
_allToBTV(_bhadronName)),
122 (
"displaced_", _displacedName),
123 (
"displaced_highPurity",
_allToHP(_displacedName)),
124 (
"displaced_ByOriginalAlgo",
_toOriAlgo(_displacedName)),
126 (
"displaced_ByAlgoMask",
_toAlgoMask(_displacedName)),
131 (
"pixelFromPV_",
_toPixel(_fromPVName)),
133 (
"pixelFromPVAllTP_",
_toPixel(_fromPVAllTPName)),
140 "ootb":
"Out of the box",
141 "iter0" :
"Iterative Step 0",
142 "iter1" :
"Iterative Step 1",
143 "iter2" :
"Iterative Step 2",
144 "iter3" :
"Iterative Step 3",
145 "iter4" :
"Iterative Step 4",
146 "iter5" :
"Iterative Step 5",
147 "iter6" :
"Iterative Step 6",
148 "iter7" :
"Iterative Step 7",
149 "iter9" :
"Iterative Step 9",
150 "iter10":
"Iterative Step 10",
151 "pixel":
"Pixel tracks",
156 'initialStepPreSplitting',
160 'detachedTripletStep',
167 'displacedGeneralStep',
168 'jetCoreRegionalStep',
169 'muonSeededStepInOut',
170 'muonSeededStepOutIn',
174 'ckfInOutFromConversions',
175 'ckfOutInFromConversions',
191 "summary":
"Summary",
194 "miniaod":
"MiniAOD",
197 "pixel":
"Pixel tracks",
201 _sectionNameMapOrder = collections.OrderedDict([
203 (
"seeding_seeds",
"Seeds"),
204 (
"building",
"Built tracks"),
209 (
"tpPtLess09", _tpPtLess09Name),
210 (
"tpPtLess09_highPurity",
_allToHP(_tpPtLess09Name)),
211 (
"tpEtaGreater2p7", _tpEtaGreater2p7Name),
212 (
"tpEtaGreater2p7_highPurity",
_allToHP(_tpEtaGreater2p7Name)),
213 (
"btvLike",
"BTV-like"),
214 (
"ak4PFJets",
"AK4 PF jets"),
215 (
"allTPEffic", _allTPEfficName),
216 (
"allTPEffic_highPurity",
_allToHP(_allTPEfficName)),
217 (
"fromPV", _fromPVName),
218 (
"fromPV_highPurity",
"High purity "+
_lowerFirst(_fromPVName)),
219 (
"fromPVAllTP", _fromPVAllTPName),
220 (
"fromPVAllTP_highPurity",
"High purity "+
_lowerFirst(_fromPVAllTPName)),
221 (
"conversion", _conversionName),
223 (
"bhadron", _bhadronName),
224 (
"bhadron_highPurity",
_allToHP(_bhadronName)),
225 (
"displaced", _displacedName),
226 (
"displaced_highPurity",
_allToHP(_displacedName)),
230 (
"pixelFromPV",
_toPixel(_fromPVName)),
232 (
"pixelFromPVAllTP",
_toPixel(_fromPVAllTPName)),
237 (
"genvertex",
"Gen vertices"),
238 (
"pixelVertices",
"Pixel vertices"),
239 (
"selectedPixelVertices",
"Selected pixel vertices"),
240 (
"firstStepPrimaryVerticesPreSplitting",
"firstStepPrimaryVerticesPreSplitting"),
241 (
"firstStepPrimaryVertices",
"firstStepPrimaryVertices"),
242 (
"offlinePrimaryVertices",
"All vertices (offlinePrimaryVertices)"),
243 (
"selectedOfflinePrimaryVertices",
"Selected vertices (selectedOfflinePrimaryVertices)"),
244 (
"offlinePrimaryVerticesWithBS",
"All vertices with BS constraint"),
245 (
"selectedOfflinePrimaryVerticesWithBS",
"Selected vertices with BS constraint"),
248 (
"lambda",
"Lambda"),
250 _btvLegend =
"BTV-like selected tracks"
251 _allTPEfficLegend =
"All tracks, efficiency denominator contains all TrackingParticles"
252 _fromPVLegend =
"Tracks from reco PV vs. TrackingParticles from gen PV (fake rate includes pileup tracks)"
253 _fromPVPtLegend =
"Tracks (pT > 0.9 GeV) from reco PV vs. TrackingParticles from gen PV (fake rate includes pileup tracks)"
254 _fromPVAllTPLegend =
"Tracks from reco PV, fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)"
255 _fromPVAllTPPtLegend =
"Tracks (pT > 0.9 GeV) from reco PV, fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)"
256 _fromPVAllTP2Legend =
"Tracks from reco PV (another method), fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)"
257 _fromPVAllTPPt2Legend =
"Tracks (pT > 0.9 GeV) from reco PV (another method), fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)"
258 _bhadronLegend =
"All tracks, efficiency denominator contains only TrackingParticles from B-hadron decays"
259 _bhadronPtLegend =
"Tracks (pT > 0.9 GeV), efficiency denominator contains only TrackingParticles from B-hadron decays"
263 "btvLike": _btvLegend,
264 "ak4PFJets":
"Tracks from AK4 PF jets (jet corrected pT > 10 GeV)",
265 "allTPEffic": _allTPEfficLegend,
266 "allTPEffic_": _allTPEfficLegend,
267 "allTPEffic_highPurity":
_allToHP(_allTPEfficLegend),
268 "fromPV": _fromPVLegend,
269 "fromPV_": _fromPVLegend,
270 "fromPV_highPurity":
_toHP(_fromPVLegend),
271 "fromPV_Pt09": _fromPVPtLegend,
272 "fromPV_highPurity_Pt09":
_toHP(_fromPVPtLegend),
273 "fromPVAllTP": _fromPVAllTPLegend,
274 "fromPVAllTP_": _fromPVAllTPLegend,
275 "fromPVAllTP_highPurity":
_toHP(_fromPVAllTPLegend),
276 "fromPVAllTP_Pt09": _fromPVAllTPPtLegend,
277 "fromPVAllTP_highPurityPt09":
_toHP(_fromPVAllTPPtLegend),
278 "fromPVAllTP2_": _fromPVAllTP2Legend,
279 "fromPVAllTP2_highPurity":
_toHP(_fromPVAllTP2Legend),
280 "fromPVAllTP2_Pt09": _fromPVAllTPPt2Legend,
281 "fromPVAllTP2_highPurityPt09":
_toHP(_fromPVAllTPPt2Legend),
282 "bhadron_": _bhadronLegend,
283 "bhadron_highPurity":
_allToHP(_bhadronLegend),
284 "bhadron_btvLike": _bhadronLegend.replace(
"All tracks", _btvLegend),
285 "pixelFromPV_": _fromPVLegend,
286 "pixelFromPV_Pt09": _fromPVPtLegend,
287 "pixelFromPVAllTP_": _fromPVAllTPLegend,
288 "pixelFromPVAllTP_Pt09": _fromPVAllTPPtLegend,
289 "pixelbhadron_": _bhadronLegend,
290 "pixelbhadron_Pt09": _bhadronPtLegend,
295 def __init__(self, columnHeaders, rowHeaders, table, purpose, page, section):
296 if len(columnHeaders) != len(table):
297 raise Exception(
"Got %d columnHeaders for table with %d columns for page %s, section %s" % (len(columnHeaders), len(table), page, section))
298 lenRow = len(table[0])
299 for icol, column
in enumerate(table):
300 if len(column) != lenRow:
301 raise Exception(
"Got non-square table, first column has %d rows, column %d has %d rows" % (lenRow, icol, len(column)))
302 if len(rowHeaders) != lenRow:
303 raise Exception(
"Got %d rowHeaders for table with %d rows" % (len(rowHeaders), lenRow))
326 return len(self.
_table[0])
355 ' <title>%s</title>' % title,
376 for plotSet
in self._plotSets.values():
394 self._content.extend([
400 f = open(fileName,
"w")
409 if section
in legends:
414 leg =
"<sup>%d</sup>" % legnum
415 leg2 =
"<sup>%d)</sup>" % legnum
416 self._legends.append(
"%s %s" % (leg2, legends[section]))
421 self._content.extend([
428 sections = self.
_orderSets(list(self._plotSets.keys()))
429 for isec, section
in enumerate(sections):
432 self._content.extend([
435 files = [(os.path.basename(f), f)
for f
in self.
_plotSets[section]]
436 for row
in fileTable:
438 for i, (bsf, f)
in enumerate(files):
447 fileTable.append( [bsf] + [
None]*isec + [f] )
449 self._content.extend([
453 for row
in fileTable:
454 self._content.append(
' <tr>')
458 self._content.append(
' <td><a href="%s">%s</a></td>' % (elem, bs))
460 self._content.append(
' <td></td>')
461 self._content.append(
' </tr>')
464 self._content.extend([
469 first_row = fileTable[0]
470 self._content.extend([
471 ' <a href="%s">Browse Folder</a>' % (first_row[1][0:first_row[1].rfind(
'/')])
480 self._columnHeaders.append(
"%s: %s" % (leg, header))
491 sections = self.
_orderSets(list(self._tables.keys()))
492 for isec, section
in enumerate(sections):
496 self._content.extend([
499 ' <table border="1">'
503 data = table.tableAsRowColumn()
505 self._content.extend([
509 heads = table.columnHeaders()
510 if max(map(
lambda h: len(h), heads)) > 20:
513 self._content.append(
' <td>%s</td>' % head)
514 self._content.append(
' </tr>')
516 for irow, row
in enumerate(data):
521 self._content.extend([
523 ' <td>%s</td>' % table.rowHeaders()[irow]
526 for icol, item
in enumerate(row):
527 formatted =
str(item)
if item
is not None else ""
528 self._content.append(
' <td align="right">%s</td>' % formatted)
529 self._content.append(
' </tr>')
531 self._content.append(
' </table>')
534 self._content.append(
' %s<br/>' % shortenedColumnHeader)
540 self._content.extend([
545 self._content.append(
' %s<br/>' % leg)
549 return _sectionNameMapOrder.get(section, section)
552 keys_sorted = sorted(keys)
554 for section
in _sectionNameMapOrder.keys():
555 if section
in keys_sorted:
557 keys_sorted.remove(section)
558 ret.extend(keys_sorted)
562 def __init__(self, title, sampleName, sample, fastVsFull, pileupComparison, dqmSubFolderTranslatedToSectionName=None):
574 self.
_prefix += _sampleFileName.get(sample.label(), sample.label())+
"_"
575 if hasattr(sample,
"hasScenario")
and sample.hasScenario():
576 self.
_prefix += sample.scenario()+
"_"
578 if hasattr(sample,
"hasPileup"):
579 if sample.hasPileup():
580 self.
_prefix +=
"pu"+
str(sample.pileupNumber())+
"_"+sample.pileupType()+
"_"
588 if key
not in self.
_pages:
595 def addPlotSet(self, plotterFolder, dqmSubFolder, plotFiles):
596 pageKey = plotterFolder.getPage()
598 if dqmSubFolder
is not None:
599 pageKey = dqmSubFolder.translated
601 pageKey = plotterFolder.getName()
604 sectionName = plotterFolder.getSection()
605 if sectionName
is None:
606 if plotterFolder.getPage()
is not None and dqmSubFolder
is not None:
610 sectionName = dqmSubFolder.translated
614 page.addPlotSet(sectionName, plotFiles)
620 page = self.
_getPage(table.getPage(), Page)
621 page.addTable(table.getSection(), table)
633 fileName =
"%s%s.html" % (self.
_prefix, key)
634 page.write(os.path.join(baseDir, fileName))
639 return _pageNameMap.get(name, name)
648 super(TrackingIterPage, self).
__init__(*args, **kwargs)
651 return _trackQualityNameOrder.get(quality, quality)
655 for qual
in _trackQualityNameOrder.keys():
656 if qual
in qualities:
658 qualities.remove(qual)
659 ret.extend(qualities)
664 super(TrackingPageSet, self).
__init__(*args, **kwargs)
666 def addPlotSet(self, plotterFolder, dqmSubFolder, plotFiles):
667 (algo, quality) = dqmSubFolder.translated
670 sectionName = quality
676 if algo !=
"ootb" and not plotterFolder._plotFolder.isAlgoIterative(algo):
680 folderName = plotterFolder.getName()
682 sectionName = folderName+
"_"+sectionName
684 page = self.
_getPage(pageName, TrackingIterPage)
685 page.addPlotSet(sectionName, plotFiles)
688 return _trackAlgoName.get(algo, algo)
692 for algo
in _trackAlgoOrder:
702 def __init__(self, sample, title, fastVsFull, pileupComparison):
712 if hasattr(sample,
"hasPileup"):
713 pileup =
"with no pileup"
714 if sample.hasPileup():
715 pileup =
"with %d pileup (%s)" % (sample.pileupNumber(), sample.pileupType())
716 if pileupComparison
is not None:
717 pileup +=
" "+pileupComparison
718 if hasattr(sample,
"customPileupLabel"):
719 pileup = sample.customPileupLabel()
722 if hasattr(sample,
"hasScenario")
and sample.hasScenario():
723 scenario =
" (\"%s\")" % sample.scenario()
724 self.
_sampleName +=
"%s sample%s %s" % (_sampleName.get(sample.name(), sample.name()), scenario, pileup)
726 params = [title, self.
_sampleName, sample, fastVsFull, pileupComparison
is not None]
733 self.
_hltPages =
PageSet(*params, dqmSubFolderTranslatedToSectionName=
lambda algoQuality: algoQuality[0])
748 def addPlots(self, plotterFolder, dqmSubFolder, plotFiles):
749 page = self._purposePageMap.get(plotterFolder.getPurpose(), self.
_otherPages)
750 page.addPlotSet(plotterFolder, dqmSubFolder, plotFiles)
756 page = self._purposePageMap.get(table.getPurpose(), self.
_otherPages)
768 labelFiles = pages.write(baseDir)
769 for label, fname
in labelFiles:
770 ret.append(
' <li><a href="%s">%s</a></li>' % (fname, label))
781 self.
_title =
"Tracking validation "+validationName
787 ' <title>%s</title>' % self.
_title,
795 self._index.append(
' <p>%s</p>'%note)
797 def beginSample(self, sample, fastVsFull=False, pileupComparison=None):
800 rightAfterRefSample = fastVsFull
or (pileupComparison
is not None)
802 key = (sample.digest(), rightAfterRefSample)
810 self._currentSection.addPlots(*args, **kwargs)
813 self._currentSection.addTable(*args, **kwargs)
817 keys = self._sections.keys()
824 ind_fast = newkeys.index( (key[0],
False) )
825 newkeys.insert(ind_fast+1, key)
829 self._index.extend(section.write(self.
_newBaseDir))
836 f = open(os.path.join(self.
_newBaseDir,
"index.html"),
"w")
_dqmSubFolderTranslatedToSectionName
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)