CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
vertexPlots.py
Go to the documentation of this file.
1 from Validation.RecoTrack.plotting.plotting import Plot, PlotGroup, PlotFolder, Plotter
2 import Validation.RecoTrack.plotting.validation as validation
3 from Validation.RecoTrack.plotting.html import PlotPurpose
4 
5 
6 _maxPU = 80
7 _maxVtx = 60
8 _maxEff = 1.025
9 _maxFake = [0.05, 0.1, 0.2, 0.5, 0.7, 1.025]
10 
11 _common = {"xlabel": "Pileup interactions", "xmax": _maxPU, "ymax": _maxVtx}
12 _recovsgen = PlotGroup("recovsgen", [
13  Plot("RecoVtx_vs_GenVtx", ytitle="Reco vertices", **_common),
14  Plot("MatchedRecoVtx_vs_GenVtx", ytitle="Matched reco vertices", **_common),
15  Plot("merged_vs_ClosestVertexInZ", xtitle="Closest distance in Z (cm)", ytitle="Merge rate", xlog=True),
16 ],
17  legendDy=-0.025
18 )
19 _pvtagging = PlotGroup("pvtagging", [
20  Plot("TruePVLocationIndexCumulative", xtitle="Signal PV status in reco collection", ytitle="Fraction of events", drawStyle="hist", normalizeToUnitArea=True, xbinlabels=["Not reconstructed", "Reco and identified", "Reco, not identified"], xbinlabelsize=15, xbinlabeloption="h", xgrid=False, ylog=True, ymin=1e-3),
21  Plot("TruePVLocationIndex", xtitle="Index of signal PV in reco collection", ytitle="Fraction of events", drawStyle="hist", normalizeToUnitArea=True, ylog=True, ymin=1e-5),
22  Plot("MisTagRate_vs_PU", xtitle="PU", ytitle="Mistag rate vs. PU", title="", xmax=_maxPU, ymax=_maxFake),
23  Plot("MisTagRate_vs_sum-pt2", xtitle="#Sigmap_{T}^{2}", ytitle="Mistag rate vs. #Sigmap_{T}^{2}", title="", xlog=True, ymax=_maxFake),
24 ],
25  legendDy=-0.025
26 )
27 _effandfake = PlotGroup("effandfake", [
28  Plot("effic_vs_NumVertices", xtitle="Reco vertices", ytitle="Efficiency vs. N vertices", xmax=_maxVtx, ymax=_maxEff),
29  Plot("fakerate_vs_PU", xtitle="Pileup interactions", ytitle="Fake rate vs. PU", xmax=_maxPU, ymax=_maxFake),
30  Plot("effic_vs_NumTracks", xtitle="Tracks", ytitle="Efficiency vs. N tracks", title="", ymax=_maxEff),
31  Plot("fakerate_vs_NumTracks", xtitle="Tracks", ytitle="Fake rate vs. N tracks", title="", ymax=_maxFake),
32  Plot("effic_vs_Pt2", xtitle="Sum p_{T}^{2} ", ytitle="Efficiency vs. sum p_{T}^{2}", xlog=True, ymax=_maxEff),
33  Plot("fakerate_vs_Pt2", xtitle="Sum p_{T}^{2} ", ytitle="Fake rate vs. sum p_{T}^{2}", xlog=True, ymax=_maxFake),
34 ])
35 _common = {"title": "", "xtitle": "Number of tracks", "scale": 1e4, "ylog": True, "ymin": 5, "ymax": 500}
36 _resolution = PlotGroup("resolution", [
37  Plot("RecoAllAssoc2GenMatched_ResolX_vs_NumTracks_Sigma", ytitle="Resolution in x (#mum)", **_common),
38  Plot("RecoAllAssoc2GenMatchedMerged_ResolX_vs_NumTracks_Sigma", ytitle="Resolution in x for merged vertices (#mum)", **_common),
39  Plot("RecoAllAssoc2GenMatched_ResolY_vs_NumTracks_Sigma", ytitle="Resolution in y (#mum)", **_common),
40  Plot("RecoAllAssoc2GenMatchedMerged_ResolY_vs_NumTracks_Sigma", ytitle="Resolution in y for merged vertices (#mum)", **_common),
41  Plot("RecoAllAssoc2GenMatched_ResolZ_vs_NumTracks_Sigma", ytitle="Resolution in z (#mum)", **_common),
42  Plot("RecoAllAssoc2GenMatchedMerged_ResolZ_vs_NumTracks_Sigma", ytitle="Resolution in z for merged vertices (#mum)", **_common),
43 ])
44 _common = {"stat": True, "fit": True, "normalizeToUnitArea": True, "drawStyle": "hist", "drawCommand": "", "xmin": -6, "xmax": 6, "ylog": True, "ymin": 5e-5, "ymax": [0.01, 0.05, 0.1, 0.2, 0.5, 0.8, 1.025]}
45 _pull = PlotGroup("pull", [
46  Plot("RecoAllAssoc2GenMatched_PullX", xtitle="x", ytitle="Pull vs. x", **_common),
47  Plot("RecoAllAssoc2GenMatched_PullY", xtitle="y", ytitle="Pull vs. y", **_common),
48  Plot("RecoAllAssoc2GenMatched_PullZ", xtitle="z", ytitle="Pull vs. z", **_common),
49 ],
50  legendDy=-0.025
51 )
52 _common={"drawStyle": "HIST", "normalizeToUnitArea": True}
53 _puritymissing = PlotGroup("puritymissing", [
54  Plot("RecoPVAssoc2GenPVMatched_Purity", xtitle="Purity", ytitle="Number of reco PVs matched to gen PVs", ylog=True, ymin=1e-4, **_common),
55  Plot("RecoPVAssoc2GenPVNotMatched_Purity", xtitle="Purity", ytitle="Number of reco PVs not matcched to gen PVs", ylog=True, ymin=1e-3, **_common),
56  Plot("RecoPVAssoc2GenPVMatched_Missing", xtitle="Fraction of reco p_{T} associated to gen PV \"missing\" from reco PV", ytitle="Number of reco PVs matched to gen PVs", ylog=True, ymin=1e-4, **_common),
57  Plot("RecoPVAssoc2GenPVNotMatched_Missing", xtitle="Fraction of reco p_{T} associated to gen PV \"missing\" from reco PV", ytitle="Number of reco PVs not matcched to gen PVs", ylog=True, ymin=1e-3, **_common),
58 # Plot("fakerate_vs_Purity", xtitle="Purity", ytitle="Fake rate", ymax=_maxFake),
59 ])
60 # "xgrid": False, "ygrid": False,
61 _common={"drawStyle": "HIST", "xlog": True, "ylog": True, "ymin": 0.5}
62 _sumpt2 = PlotGroup("sumpt2", [
63  Plot("RecoAssoc2GenPVMatched_Pt2", xtitle="#sum^{}p_{T}^{2}", ytitle="Reco vertices matched to gen PV", **_common),
64  Plot("RecoAssoc2GenPVMatchedNotHighest_Pt2", xtitle="#sum^{}p_{T}^{2}", ytitle="Reco non-PV-vertices matched to gen PV", **_common),
65  Plot("RecoAssoc2GenPVNotMatched_Pt2", xtitle="#sum^{}p_{T}^{2}", ytitle="Reco vertices not matched to gen PV", **_common),
66  Plot("RecoAssoc2GenPVNotMatched_GenPVTracksRemoved_Pt2", xtitle="#sum^{}p_{T}^{2}, gen PV tracks removed", ytitle="Reco vertices not matched to gen PV", **_common),
67 ],
68  legendDy=-0.025
69 )
70 
71 _common = {"drawStyle": "HIST"}
72 _genpos = PlotGroup("genpos", [
73  Plot("GenAllV_X", xtitle="Gen AllV pos x", ytitle="N", **_common),
74  Plot("GenPV_X", xtitle="Gen PV pos x", ytitle="N", **_common),
75  Plot("GenAllV_Y", xtitle="Gen AllV pos y", ytitle="N", **_common),
76  Plot("GenPV_Y", xtitle="Gen PV pos y", ytitle="N", **_common),
77  Plot("GenAllV_Z", xtitle="Gen AllV pos z", ytitle="N", **_common),
78  Plot("GenPV_Z", xtitle="Gen PV pos z", ytitle="N", **_common),
79 ])
80 
81 _vertexFolders = [
82  "DQMData/Run 1/Vertexing/Run summary/PrimaryVertex",
83  "DQMData/Vertexing/PrimaryVertex",
84  "DQMData/Run 1/Vertexing/Run summary/PrimaryVertexV",
85  "DQMData/Vertexing/PrimaryVertexV",
86 ]
87 plotter = Plotter()
88 plotter.append("", _vertexFolders, PlotFolder(
89  _recovsgen,
90  _pvtagging,
91  _effandfake,
92  _resolution,
93  _pull,
94  _puritymissing,
95  _sumpt2,
96  purpose=PlotPurpose.Vertexing,
97  page="vertex"
98 ))
99 plotterGen = Plotter()
100 plotterGen.append("", _vertexFolders, PlotFolder(
101  _genpos
102 ))
103 
105  def _init__(self, *args, **kwargs):
106  super(TrackingValidation, self).__init__(*args, **kwargs)
107 
108  def _getDirectoryName(self, quality, algo):
109  return algo
110 
111  def _getSelectionName(self, quality, algo):
112  if algo is None:
113  return ""
114  return "_"+algo