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 _tpEtaGreater2p7Name =
"All tracks (TP |eta| > 2.7)"
52 _conversionName =
"Tracks for conversions"
53 _gsfName =
"Electron GSF tracks"
54 _bhadronName =
"All tracks (B-hadron TPs)"
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(
"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)),
85 (
"tpPtLess09_ByOriginalAlgo",
_toOriAlgo(_tpPtLess09Name)),
87 (
"tpPtLess09_ByAlgoMask",
_toAlgoMask(_tpPtLess09Name)),
89 (
"tpEtaGreater2p7_", _tpEtaGreater2p7Name),
90 (
"tpEtaGreater2p7_highPurity",
_allToHP(_tpEtaGreater2p7Name)),
92 (
"ak4PFJets",
"AK4 PF jets"),
93 (
"allTPEffic_", _allTPEfficName),
94 (
"allTPEffic_highPurity",
_allToHP(_allTPEfficName)),
95 (
"fromPV_", _fromPVName),
96 (
"fromPV_highPurity",
_toHP(_fromPVName)),
97 (
"fromPV_Pt09",
_ptCut(_fromPVName)),
98 (
"fromPV_highPurityPt09",
_toHP(
_ptCut(_fromPVName))),
99 (
"fromPVAllTP_", _fromPVAllTPName),
100 (
"fromPVAllTP_highPurity",
_toHP(_fromPVAllTPName)),
101 (
"fromPVAllTP_Pt09",
_ptCut(_fromPVAllTPName)),
102 (
"fromPVAllTP_highPurityPt09",
_toHP(
_ptCut(_fromPVAllTPName))),
103 (
"fromPVAllTP2_", _fromPVAllTPName.replace(
"PV",
"PV v2")),
104 (
"fromPVAllTP2_highPurity",
"High purity "+
_lowerFirst(_fromPVAllTPName).
replace(
"PV",
"PV v2")),
105 (
"fromPVAllTP2_Pt09", _fromPVAllTPName.replace(
"Tracks",
"Tracks pT > 0.9 GeV").
replace(
"PV",
"PV v2")),
106 (
"fromPVAllTP2_highPurityPt09",
_toHP(
_ptCut(_fromPVAllTPName)).
replace(
"PV",
"PV v2")),
107 (
"conversion_", _conversionName),
109 (
"bhadron_", _bhadronName),
110 (
"bhadron_highPurity",
_allToHP(_bhadronName)),
111 (
"bhadron_ByOriginalAlgo",
_toOriAlgo(_bhadronName)),
115 (
"bhadron_btvLike",
_allToBTV(_bhadronName)),
119 "ootb":
"Out of the box",
120 "iter0" :
"Iterative Step 0",
121 "iter1" :
"Iterative Step 1",
122 "iter2" :
"Iterative Step 2",
123 "iter3" :
"Iterative Step 3",
124 "iter4" :
"Iterative Step 4",
125 "iter5" :
"Iterative Step 5",
126 "iter6" :
"Iterative Step 6",
127 "iter7" :
"Iterative Step 7",
128 "iter9" :
"Iterative Step 9",
129 "iter10":
"Iterative Step 10",
134 'initialStepPreSplitting',
138 'detachedTripletStep',
145 'jetCoreRegionalStep',
146 'muonSeededStepInOut',
147 'muonSeededStepOutIn',
151 'ckfInOutFromConversions',
152 'ckfOutInFromConversions',
167 "summary":
"Summary",
170 "miniaod":
"MiniAOD",
173 "pixel":
"Pixel tracks",
177 _sectionNameMapOrder = collections.OrderedDict([
179 (
"seeding_seeds",
"Seeds"),
180 (
"building",
"Built tracks"),
182 (
"Pt09",
"All tracks (pT>0.9 GeV)"),
183 (
"highPurity",
"High purity tracks"),
184 (
"highPurityPt09",
"High purity tracks (pT>0.9 GeV)"),
185 (
"tpPtLess09", _tpPtLess09Name),
186 (
"tpPtLess09_highPurity",
_allToHP(_tpPtLess09Name)),
187 (
"tpEtaGreater2p7", _tpEtaGreater2p7Name),
188 (
"tpEtaGreater2p7_highPurity",
_allToHP(_tpEtaGreater2p7Name)),
189 (
"btvLike",
"BTV-like"),
190 (
"ak4PFJets",
"AK4 PF jets"),
191 (
"allTPEffic", _allTPEfficName),
192 (
"allTPEffic_highPurity",
_allToHP(_allTPEfficName)),
193 (
"fromPV", _fromPVName),
194 (
"fromPV_highPurity",
"High purity "+
_lowerFirst(_fromPVName)),
195 (
"fromPVAllTP", _fromPVAllTPName),
196 (
"fromPVAllTP_highPurity",
"High purity "+
_lowerFirst(_fromPVAllTPName)),
197 (
"conversion", _conversionName),
199 (
"bhadron", _bhadronName),
200 (
"bhadron_highPurity",
_allToHP(_bhadronName)),
202 (
"pixel",
"Pixel tracks"),
204 (
"genvertex",
"Gen vertices"),
205 (
"pixelVertices",
"Pixel vertices"),
206 (
"selectedPixelVertices",
"Selected pixel vertices"),
207 (
"firstStepPrimaryVerticesPreSplitting",
"firstStepPrimaryVerticesPreSplitting"),
208 (
"firstStepPrimaryVertices",
"firstStepPrimaryVertices"),
209 (
"offlinePrimaryVertices",
"All vertices (offlinePrimaryVertices)"),
210 (
"selectedOfflinePrimaryVertices",
"Selected vertices (selectedOfflinePrimaryVertices)"),
211 (
"offlinePrimaryVerticesWithBS",
"All vertices with BS constraint"),
212 (
"selectedOfflinePrimaryVerticesWithBS",
"Selected vertices with BS constraint"),
215 (
"lambda",
"Lambda"),
217 _btvLegend =
"BTV-like selected tracks"
218 _allTPEfficLegend =
"All tracks, efficiency denominator contains all TrackingParticles"
219 _fromPVLegend =
"Tracks from reco PV vs. TrackingParticles from gen PV (fake rate includes pileup tracks)"
220 _fromPVPtLegend =
"Tracks (pT > 0.9 GeV) from reco PV vs. TrackingParticles from gen PV (fake rate includes pileup tracks)"
221 _fromPVAllTPLegend =
"Tracks from reco PV, fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)"
222 _fromPVAllTPPtLegend =
"Tracks (pT > 0.9 GeV) from reco PV, fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)"
223 _fromPVAllTP2Legend =
"Tracks from reco PV (another method), fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)"
224 _fromPVAllTPPt2Legend =
"Tracks (pT > 0.9 GeV) from reco PV (another method), fake rate numerator contains all TrackingParticles (separates fake tracks from pileup tracks)"
225 _bhadronLegend =
"All tracks, efficiency denominator contains only TrackingParticles from B-hadron decays"
229 "btvLike": _btvLegend,
230 "ak4PFJets":
"Tracks from AK4 PF jets (jet corrected pT > 10 GeV)",
231 "allTPEffic": _allTPEfficLegend,
232 "allTPEffic_": _allTPEfficLegend,
233 "allTPEffic_highPurity":
_allToHP(_allTPEfficLegend),
234 "fromPV": _fromPVLegend,
235 "fromPV_": _fromPVLegend,
236 "fromPV_highPurity":
_toHP(_fromPVLegend),
237 "fromPV_Pt09": _fromPVPtLegend,
238 "fromPV_highPurity_Pt09":
_toHP(_fromPVPtLegend),
239 "fromPVAllTP": _fromPVAllTPLegend,
240 "fromPVAllTP_": _fromPVAllTPLegend,
241 "fromPVAllTP_highPurity":
_toHP(_fromPVAllTPLegend),
242 "fromPVAllTP_Pt09": _fromPVAllTPPtLegend,
243 "fromPVAllTP_highPurityPt09":
_toHP(_fromPVAllTPPtLegend),
244 "fromPVAllTP2_": _fromPVAllTP2Legend,
245 "fromPVAllTP2_highPurity":
_toHP(_fromPVAllTP2Legend),
246 "fromPVAllTP2_Pt09": _fromPVAllTPPt2Legend,
247 "fromPVAllTP2_highPurityPt09":
_toHP(_fromPVAllTPPt2Legend),
248 "bhadron_": _bhadronLegend,
249 "bhadron_highPurity":
_allToHP(_bhadronLegend),
250 "bhadron_btvLike": _bhadronLegend.replace(
"All tracks", _btvLegend),
255 def __init__(self, columnHeaders, rowHeaders, table, purpose, page, section):
256 if len(columnHeaders) != len(table):
257 raise Exception(
"Got %d columnHeaders for table with %d columns for page %s, section %s" % (len(columnHeaders), len(table), page, section))
258 lenRow = len(table[0])
259 for icol, column
in enumerate(table):
260 if len(column) != lenRow:
261 raise Exception(
"Got non-square table, first column has %d rows, column %d has %d rows" % (lenRow, icol, len(column)))
262 if len(rowHeaders) != lenRow:
263 raise Exception(
"Got %d rowHeaders for table with %d rows" % (len(rowHeaders), lenRow))
286 return len(self.
_table[0])
315 ' <title>%s</title>' % title,
336 for plotSet
in six.itervalues(self.
_plotSets):
360 f = open(fileName,
"w")
369 if section
in legends:
374 leg =
"<sup>%d</sup>" % legnum
375 leg2 =
"<sup>%d)</sup>" % legnum
389 for isec, section
in enumerate(sections):
395 files = [(os.path.basename(f), f)
for f
in self.
_plotSets[section]]
396 for row
in fileTable:
398 for i, (bsf, f)
in enumerate(files):
407 fileTable.append( [bsf] + [
None]*isec + [f] )
413 for row
in fileTable:
418 self.
_content.
append(
' <td><a href="%s">%s</a></td>' % (elem, bs))
429 first_row = fileTable[0]
431 ' <a href="%s">Browse Folder</a>' % (first_row[1][0:first_row[1].rfind(
'/')])
452 for isec, section
in enumerate(sections):
459 ' <table border="1">'
463 data = table.tableAsRowColumn()
469 heads = table.columnHeaders()
470 if max(
map(
lambda h: len(h), heads)) > 20:
476 for irow, row
in enumerate(data):
483 ' <td>%s</td>' % table.rowHeaders()[irow]
486 for icol, item
in enumerate(row):
487 formatted =
str(item)
if item
is not None else ""
509 return _sectionNameMapOrder.get(section, section)
512 keys_sorted = sorted(keys)
514 for section
in _sectionNameMapOrder.keys():
515 if section
in keys_sorted:
517 keys_sorted.remove(section)
518 ret.extend(keys_sorted)
522 def __init__(self, title, sampleName, sample, fastVsFull, pileupComparison, dqmSubFolderTranslatedToSectionName=None):
534 self.
_prefix += _sampleFileName.get(sample.label(), sample.label())+
"_"
535 if hasattr(sample,
"hasScenario")
and sample.hasScenario():
536 self.
_prefix += sample.scenario()+
"_"
538 if hasattr(sample,
"hasPileup"):
539 if sample.hasPileup():
540 self.
_prefix +=
"pu"+
str(sample.pileupNumber())+
"_"+sample.pileupType()+
"_"
548 if key
not in self.
_pages:
555 def addPlotSet(self, plotterFolder, dqmSubFolder, plotFiles):
556 pageKey = plotterFolder.getPage()
558 if dqmSubFolder
is not None:
559 pageKey = dqmSubFolder.translated
561 pageKey = plotterFolder.getName()
564 sectionName = plotterFolder.getSection()
565 if sectionName
is None:
566 if plotterFolder.getPage()
is not None and dqmSubFolder
is not None:
570 sectionName = dqmSubFolder.translated
574 page.addPlotSet(sectionName, plotFiles)
580 page = self.
_getPage(table.getPage(), Page)
581 page.addTable(table.getSection(), table)
593 fileName =
"%s%s.html" % (self.
_prefix, key)
594 page.write(os.path.join(baseDir, fileName))
599 return _pageNameMap.get(name, name)
608 super(TrackingIterPage, self).
__init__(*args, **kwargs)
611 return _trackQualityNameOrder.get(quality, quality)
615 for qual
in _trackQualityNameOrder.keys():
616 if qual
in qualities:
618 qualities.remove(qual)
619 ret.extend(qualities)
624 super(TrackingPageSet, self).
__init__(*args, **kwargs)
626 def addPlotSet(self, plotterFolder, dqmSubFolder, plotFiles):
627 (algo, quality) = dqmSubFolder.translated
630 sectionName = quality
636 if algo !=
"ootb" and not plotterFolder._plotFolder.isAlgoIterative(algo):
640 folderName = plotterFolder.getName()
642 sectionName = folderName+
"_"+sectionName
644 page = self.
_getPage(pageName, TrackingIterPage)
645 page.addPlotSet(sectionName, plotFiles)
648 return _trackAlgoName.get(algo, algo)
652 for algo
in _trackAlgoOrder:
662 def __init__(self, sample, title, fastVsFull, pileupComparison):
672 if hasattr(sample,
"hasPileup"):
673 pileup =
"with no pileup"
674 if sample.hasPileup():
675 pileup =
"with %d pileup (%s)" % (sample.pileupNumber(), sample.pileupType())
676 if pileupComparison
is not None:
677 pileup +=
" "+pileupComparison
678 if hasattr(sample,
"customPileupLabel"):
679 pileup = sample.customPileupLabel()
682 if hasattr(sample,
"hasScenario")
and sample.hasScenario():
683 scenario =
" (\"%s\")" % sample.scenario()
684 self.
_sampleName +=
"%s sample%s %s" % (_sampleName.get(sample.name(), sample.name()), scenario, pileup)
686 params = [title, self.
_sampleName, sample, fastVsFull, pileupComparison
is not None]
693 self.
_hltPages =
PageSet(*params, dqmSubFolderTranslatedToSectionName=
lambda algoQuality: algoQuality[0])
694 self.
_pixelPages =
PageSet(*params, dqmSubFolderTranslatedToSectionName=
lambda algoQuality: algoQuality[0])
708 def addPlots(self, plotterFolder, dqmSubFolder, plotFiles):
710 page.addPlotSet(plotterFolder, dqmSubFolder, plotFiles)
728 labelFiles = pages.write(baseDir)
729 for label, fname
in labelFiles:
730 ret.append(
' <li><a href="%s">%s</a></li>' % (fname, label))
741 self.
_title =
"Tracking validation "+validationName
747 ' <title>%s</title>' % self.
_title,
757 def beginSample(self, sample, fastVsFull=False, pileupComparison=None):
760 rightAfterRefSample = fastVsFull
or (pileupComparison
is not None)
762 key = (sample.digest(), rightAfterRefSample)
784 ind_fast = newkeys.index( (key[0],
False) )
785 newkeys.insert(ind_fast+1, key)
796 f = open(os.path.join(self.
_newBaseDir,
"index.html"),
"w")