CMS 3D CMS Logo

vertexPlots.py
Go to the documentation of this file.
1 import copy
2 
3 from Validation.RecoTrack.plotting.plotting import Plot, PlotGroup, PlotFolder, Plotter
4 import Validation.RecoTrack.plotting.validation as validation
5 from Validation.RecoTrack.plotting.html import PlotPurpose
6 from Validation.RecoTrack.plotting.trackingPlots import _legendDy_1row, _legendDy_2rows, _legendDy_2rows_3cols, _legendDy_4rows, _minMaxResidual
7 
8 _minPU = [0, 10, 20, 40, 80, 120]
9 _maxPU = [60, 80, 100, 150, 200, 250]
10 _minVtx = [0, 80, 120]
11 _maxVtx = [60, 100, 150, 200, 250]
12 _maxEff = 1.025
13 _maxFake = [0.05, 0.1, 0.2, 0.5, 0.7, 1.025]
14 _minMaxRes = [0.1, 0.5, 1, 5, 10, 50, 100, 200, 500, 1000, 2000, 5000]
15 (_minResidual, _maxResidual) = _minMaxResidual(_minMaxRes)
16 _minMaxPt = [5e-1, 1, 5, 1e1, 5e1, 1e2, 5e2, 1e3, 5e3, 1e4]
17 _minPull = [0, 0.5, 0.8, 0.9]
18 _maxPull = [1.1, 1.2, 1.5, 2]
19 _minVertexZ = range(-60,-10,10)
20 _maxVertexZ = range(20,70,10)
21 
22 _vertexNumberOfEventsHistogram = "DQMData/Run 1/Vertexing/Run summary/PrimaryVertexV/GenPV_Z"
23 
24 _common = {"xtitle": "Simulated interactions", "xmin": _minPU, "xmax": _maxPU, "ymin": _minVtx, "ymax": _maxVtx}
25 _recovsgen = PlotGroup("recovsgen", [
26  Plot("RecoVtx_vs_GenVtx", ytitle="Reco vertices", **_common),
27  Plot("MatchedRecoVtx_vs_GenVtx", ytitle="Matched reco vertices", **_common),
28  Plot("merged_vs_ClosestVertexInZ", xtitle="Closest distance in Z (cm)", ytitle="Merge rate", xlog=True, xmin=1e-3, ymax=_maxFake),
29  Plot("merged_vs_Z", xtitle="Z (cm)", ytitle="Merge rate", xmin=-20, xmax=20, ymax=_maxFake),
30 ],
31  legendDy=_legendDy_2rows, onlyForPileup=True,
32 )
33 _pvtagging = PlotGroup("pvtagging", [
34  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, ratioCoverageXrange=[-0.5, 0.5]),
35  Plot("TruePVLocationIndex", xtitle="Index of signal PV in reco collection", ytitle="Fraction of events", drawStyle="hist", normalizeToUnitArea=True, ylog=True, ymin=1e-5),
36  Plot("MisTagRate_vs_PU", xtitle="PU", ytitle="Mistag rate vs. PU", title="", xmax=_maxPU, ymax=_maxFake),
37  Plot("MisTagRate_vs_sum-pt2", xtitle="#Sigmap_{T}^{2}", ytitle="Mistag rate vs. #Sigmap_{T}^{2}", title="", xlog=True, ymax=_maxFake),
38 ],
39  legendDy=_legendDy_2rows
40 )
41 _effandfake = PlotGroup("effandfake", [
42  Plot("effic_vs_NumVertices", xtitle="Simulated interactions", ytitle="Efficiency vs. N sim vertices", xmin=_minPU, xmax=_maxPU, ymax=_maxEff),
43  Plot("fakerate_vs_PU", xtitle="Simulated interactions", ytitle="Fake rate vs. N sim vertices", xmin=_minPU, xmax=_maxPU, ymax=_maxFake),
44  Plot("effic_vs_NumTracks", xtitle="Tracks", ytitle="Efficiency vs. N tracks", title="", ymax=_maxEff),
45  Plot("fakerate_vs_NumTracks", xtitle="Tracks", ytitle="Fake rate vs. N tracks", title="", ymax=_maxFake),
46  Plot("effic_vs_Pt2", xtitle="Sum p_{T}^{2} ", ytitle="Efficiency vs. sum p_{T}^{2}", xlog=True, ymax=_maxEff),
47  Plot("fakerate_vs_Pt2", xtitle="Sum p_{T}^{2} ", ytitle="Fake rate vs. sum p_{T}^{2}", xlog=True, ymax=_maxFake),
48 ])
49 _common = {"title": "", "stat": True, "fit": True, "normalizeToUnitArea": True, "drawStyle": "hist", "drawCommand": "", "ylog": True, "ymin": [5e-7, 5e-6, 5e-5, 5e-4]}
50 _resolution = PlotGroup("resolution", [
51  Plot("RecoPVAssoc2GenPVMatched_ResolX", xtitle="Resolution in x (#mum) for PV", **_common),
52  Plot("RecoAllAssoc2GenMatched_ResolX", xtitle="Resolution in x (#mum)", **_common),
53  Plot("RecoAllAssoc2GenMatchedMerged_ResolX", xtitle="Resolution in x for merged vertices (#mum)", **_common),
54  #
55  Plot("RecoPVAssoc2GenPVMatched_ResolY", xtitle="Resolution in y (#mum)", **_common),
56  Plot("RecoAllAssoc2GenMatched_ResolY", xtitle="Resolution in y (#mum)", **_common),
57  Plot("RecoAllAssoc2GenMatchedMerged_ResolY", xtitle="Resolution in y for merged vertices (#mum)", **_common),
58  #
59  Plot("RecoPVAssoc2GenPVMatched_ResolZ", xtitle="Resolution in z (#mum)", **_common),
60  Plot("RecoAllAssoc2GenMatched_ResolZ", xtitle="Resolution in z (#mum)", **_common),
61  Plot("RecoAllAssoc2GenMatchedMerged_ResolZ", xtitle="Resolution in z for merged vertices (#mum)", **_common),
62 ], ncols=3)
63 _commonNumTracks = dict(title="", xtitle="Number of tracks", scale=1e4, ylog=True, ymin=_minMaxRes , ymax=_minMaxRes)
64 _resolutionNumTracks = PlotGroup("resolutionNumTracks", [
65  Plot("RecoPVAssoc2GenPVMatched_ResolX_vs_NumTracks_Sigma", ytitle="#sigma(#delta x) (#mum) for PV", **_commonNumTracks),
66  Plot("RecoAllAssoc2GenMatched_ResolX_vs_NumTracks_Sigma", ytitle="#sigma(#delta x) (#mum)", **_commonNumTracks),
67  Plot("RecoAllAssoc2GenMatchedMerged_ResolX_vs_NumTracks_Sigma", ytitle="#sigma(#delta x) x for merged vertices (#mum)", **_commonNumTracks),
68  #
69  Plot("RecoPVAssoc2GenPVMatched_ResolY_vs_NumTracks_Sigma", ytitle="#sigma(#delta y) (#mum) for PV", **_commonNumTracks),
70  Plot("RecoAllAssoc2GenMatched_ResolY_vs_NumTracks_Sigma", ytitle="#sigma(#delta y) (#mum)", **_commonNumTracks),
71  Plot("RecoAllAssoc2GenMatchedMerged_ResolY_vs_NumTracks_Sigma", ytitle="#sigma(#delta y) for merged vertices (#mum)", **_commonNumTracks),
72  #
73  Plot("RecoPVAssoc2GenPVMatched_ResolZ_vs_NumTracks_Sigma", ytitle="#sigma(#delta z) (#mum) for PV", **_commonNumTracks),
74  Plot("RecoAllAssoc2GenMatched_ResolZ_vs_NumTracks_Sigma", ytitle="#sigma(#delta z) (#mum)", **_commonNumTracks),
75  Plot("RecoAllAssoc2GenMatchedMerged_ResolZ_vs_NumTracks_Sigma", ytitle="#sigma(#delta z) for merged vertices (#mum)", **_commonNumTracks),
76 ], ncols=3)
77 _commonPt = copy.copy(_commonNumTracks)
78 _commonPt.update(dict(xtitle= "Sum of track p_{T} (GeV)", xlog=True, xmin=_minMaxPt, xmax=_minMaxPt))
79 _resolutionPt = PlotGroup("resolutionPt", [
80  Plot("RecoPVAssoc2GenPVMatched_ResolX_vs_Pt_Sigma", ytitle="#sigma(#delta x) (#mum) for PV", **_commonPt),
81  Plot("RecoAllAssoc2GenMatched_ResolX_vs_Pt_Sigma", ytitle="#sigma(#delta x) (#mum)", **_commonPt),
82  Plot("RecoAllAssoc2GenMatchedMerged_ResolX_vs_Pt_Sigma", ytitle="#sigma(#delta x) for merged vertices (#mum)", **_commonPt),
83  #
84  Plot("RecoPVAssoc2GenPVMatched_ResolY_vs_Pt_Sigma", ytitle="#sigma(#delta y) (#mum) for PV", **_commonPt),
85  Plot("RecoAllAssoc2GenMatched_ResolY_vs_Pt_Sigma", ytitle="#sigma(#delta y) (#mum)", **_commonPt),
86  Plot("RecoAllAssoc2GenMatchedMerged_ResolY_vs_Pt_Sigma", ytitle="#sigma(#delta y) for merged vertices (#mum)", **_commonPt),
87  #
88  Plot("RecoPVAssoc2GenPVMatched_ResolZ_vs_Pt_Sigma", ytitle="#sigma(#delta z) (#mum) for PV", **_commonPt),
89  Plot("RecoAllAssoc2GenMatched_ResolZ_vs_Pt_Sigma", ytitle="#sigma(#delta z) (#mum)", **_commonPt),
90  Plot("RecoAllAssoc2GenMatchedMerged_ResolZ_vs_Pt_Sigma", ytitle="#sigma(#delta z) for merged vertices (#mum)", **_commonPt),
91 ], ncols=3)
92 _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]}
93 _pull = PlotGroup("pull", [
94  Plot("RecoPVAssoc2GenPVMatched_PullX", xtitle="x", ytitle="Pull of x for PV", **_common),
95  Plot("RecoAllAssoc2GenMatched_PullX", xtitle="x", ytitle="Pull of x", **_common),
96  Plot("RecoAllAssoc2GenMatchedMerged_PullX", xtitle="x", ytitle="Pull of x for merged vertices", **_common),
97  #
98  Plot("RecoPVAssoc2GenPVMatched_PullY", xtitle="y", ytitle="Pull of y for PV", **_common),
99  Plot("RecoAllAssoc2GenMatched_PullY", xtitle="y", ytitle="Pull of y", **_common),
100  Plot("RecoAllAssoc2GenMatchedMerged_PullY", xtitle="y", ytitle="Pull of y for merged vertices", **_common),
101  #
102  Plot("RecoPVAssoc2GenPVMatched_PullZ", xtitle="z", ytitle="Pull of z for PV", **_common),
103  Plot("RecoAllAssoc2GenMatched_PullZ", xtitle="z", ytitle="Pull of z", **_common),
104  Plot("RecoAllAssoc2GenMatchedMerged_PullZ", xtitle="z", ytitle="Pull of z for merged vertices", **_common),
105 ], ncols=3)
106 _commonNumTracks.update(dict(scale=1, ylog=False, ymin=_minPull, ymax=_maxPull))
107 _pullNumTracks = PlotGroup("pullNumTracks", [
108  Plot("RecoPVAssoc2GenPVMatched_PullX_vs_NumTracks_Sigma", ytitle="Pull of x for PV", **_commonNumTracks),
109  Plot("RecoAllAssoc2GenMatched_PullX_vs_NumTracks_Sigma", ytitle="Pull of x", **_commonNumTracks),
110  Plot("RecoAllAssoc2GenMatchedMerged_PullX_vs_NumTracks_Sigma", ytitle="Pull of x for merged vertices", **_commonNumTracks),
111  #
112  Plot("RecoPVAssoc2GenPVMatched_PullY_vs_NumTracks_Sigma", ytitle="Pull of y for PV", **_commonNumTracks),
113  Plot("RecoAllAssoc2GenMatched_PullY_vs_NumTracks_Sigma", ytitle="Pull of y", **_commonNumTracks),
114  Plot("RecoAllAssoc2GenMatchedMerged_PullY_vs_NumTracks_Sigma", ytitle="Pull of y for merged vertices", **_commonNumTracks),
115  #
116  Plot("RecoPVAssoc2GenPVMatched_PullZ_vs_NumTracks_Sigma", ytitle="Pull of z for PV", **_commonNumTracks),
117  Plot("RecoAllAssoc2GenMatched_PullZ_vs_NumTracks_Sigma", ytitle="Pull of z", **_commonNumTracks),
118  Plot("RecoAllAssoc2GenMatchedMerged_PullZ_vs_NumTracks_Sigma", ytitle="Pull of z for merged vertices", **_commonNumTracks),
119 ], ncols=3)
120 _commonPt.update(dict(scale=1, ylog=False, ymin=_minPull, ymax=_maxPull))
121 _pullPt = PlotGroup("pullPt", [
122  Plot("RecoPVAssoc2GenPVMatched_PullX_vs_Pt_Sigma", ytitle="Pull of x for PV", **_commonPt),
123  Plot("RecoAllAssoc2GenMatched_PullX_vs_Pt_Sigma", ytitle="Pull of x", **_commonPt),
124  Plot("RecoAllAssoc2GenMatchedMerged_PullX_vs_Pt_Sigma", ytitle="Pull of x for merged vertices", **_commonPt),
125  #
126  Plot("RecoPVAssoc2GenPVMatched_PullY_vs_Pt_Sigma", ytitle="Pull of y for PV", **_commonPt),
127  Plot("RecoAllAssoc2GenMatched_PullY_vs_Pt_Sigma", ytitle="Pull of y", **_commonPt),
128  Plot("RecoAllAssoc2GenMatchedMerged_PullY_vs_Pt_Sigma", ytitle="Pull of y for merged vertices", **_commonPt),
129  #
130  Plot("RecoPVAssoc2GenPVMatched_PullZ_vs_Pt_Sigma", ytitle="Pull of z for PV", **_commonPt),
131  Plot("RecoAllAssoc2GenMatched_PullZ_vs_Pt_Sigma", ytitle="Pull of z", **_commonPt),
132  Plot("RecoAllAssoc2GenMatchedMerged_PullZ_vs_Pt_Sigma", ytitle="Pull of z for merged vertices", **_commonPt),
133 ], ncols=3)
134 
135 _common={"drawStyle": "HIST", "normalizeToUnitArea": True}
136 _puritymissing = PlotGroup("puritymissing", [
137  Plot("RecoPVAssoc2GenPVMatched_Purity", xtitle="Purity", ytitle="Number of reco PVs matched to gen PVs", ylog=True, ymin=1e-4, **_common),
138  Plot("RecoPVAssoc2GenPVNotMatched_Purity", xtitle="Purity", ytitle="Number of reco PVs not matcched to gen PVs", ylog=True, ymin=1e-3, **_common),
139  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),
140  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),
141 # Plot("fakerate_vs_Purity", xtitle="Purity", ytitle="Fake rate", ymax=_maxFake),
142 ])
143 # "xgrid": False, "ygrid": False,
144 _common={"drawStyle": "HIST", "xlog": True, "ylog": True, "ymin": 0.5}
145 _sumpt2 = PlotGroup("sumpt2", [
146  Plot("RecoAssoc2GenPVMatched_Pt2", xtitle="#sum^{}p_{T}^{2}", ytitle="Reco vertices matched to gen PV", **_common),
147  Plot("RecoAssoc2GenPVMatchedNotHighest_Pt2", xtitle="#sum^{}p_{T}^{2}", ytitle="Reco non-PV-vertices matched to gen PV", **_common),
148  Plot("RecoAssoc2GenPVNotMatched_Pt2", xtitle="#sum^{}p_{T}^{2}", ytitle="Reco vertices not matched to gen PV", **_common),
149  Plot("RecoAssoc2GenPVNotMatched_GenPVTracksRemoved_Pt2", xtitle="#sum^{}p_{T}^{2}, gen PV tracks removed", ytitle="Reco vertices not matched to gen PV", **_common),
150 ],
151  legendDy=_legendDy_2rows, onlyForPileup=True,
152 )
153 
154 _k0_effandfake = PlotGroup("effandfake", [
155  Plot("K0sEffVsPt", xtitle="p_{T} (GeV)", ytitle="Efficiency vs. p_{T}"),
156  Plot("K0sFakeVsPt", xtitle="p_{T} (GeV)", ytitle="Fake rate vs. p_{T}"),
157  Plot("K0sEffVsEta", xtitle="#eta", ytitle="Efficiency vs. #eta"),
158  Plot("K0sFakeVsEta", xtitle="#eta", ytitle="Fake rate vs. #eta"),
159  Plot("K0sEffVsR", xtitle="R (cm)", ytitle="Efficiency vs. R"),
160  Plot("K0sFakeVsR", xtitle="R (cm)", ytitle="Fake rate vs. R"),
161 ])
162 _k0_effandfakeTk = PlotGroup("effandfakeTk", [
163 # Plot("K0sTkEffVsPt"),
164  Plot("K0sTkFakeVsPt", xtitle="p_{T} (GeV)", ytitle="Fake rate vs. p_{T}"),
165 # Plot("K0sTkEffVsEta"),
166  Plot("K0sTkFakeVsEta", xtitle="#eta", ytitle="Fake rate vs. #eta"),
167 # Plot("K0sTkEffVsR"),
168  Plot("K0sTkFakeVsR", xtitle="R (cm)", ytitle="Fake rate vs. R"),
169 ],
170  legendDy=_legendDy_2rows
171 )
172 _common = dict(normalizeToUnitArea=True, drawStyle="HIST", stat=True)
173 _k0_mass = PlotGroup("mass", [
174  Plot("ksMassAll", xtitle="mass of all (GeV)", **_common),
175  Plot("ksMassGood", xtitle="mass of good (GeV)", **_common),
176  Plot("ksMassFake", xtitle="mass of fake (GeV)", **_common),
177 ],
178  legendDy=_legendDy_2rows
179 )
180 _lambda_effandfake = PlotGroup("effandfake", [
181  Plot("LamEffVsPt", xtitle="p_{T} (GeV)", ytitle="Efficiency vs. p_{T}"),
182  Plot("LamFakeVsPt", xtitle="p_{T} (GeV)", ytitle="Fake rate vs. p_{T}"),
183  Plot("LamEffVsEta", xtitle="#eta", ytitle="Efficiency vs. #eta"),
184  Plot("LamFakeVsEta", xtitle="#eta", ytitle="Fake rate vs. #eta"),
185  Plot("LamEffVsR", xtitle="R (cm)", ytitle="Efficiency vs. R"),
186  Plot("LamFakeVsR", xtitle="R (cm)", ytitle="Fake rate vs. R"),
187 ])
188 _lambda_effandfakeTk = PlotGroup("effandfakeTk", [
189 # Plot("LamTkEffVsPt"),
190  Plot("LamTkFakeVsPt", xtitle="p_{T} (GeV)", ytitle="Fake rate vs. p_{T}"),
191 # Plot("LamTkEffVsEta"),
192  Plot("LamTkFakeVsEta", xtitle="#eta", ytitle="Fake rate vs. #eta"),
193 # Plot("LamTkEffVsR"),
194  Plot("LamTkFakeVsR", xtitle="R (cm)", ytitle="Fake rate vs. R"),
195 ],
196  legendDy=_legendDy_2rows
197 )
198 _lambda_mass = PlotGroup("mass", [
199  Plot("lamMassAll", xtitle="mass of all (GeV)", **_common),
200  Plot("lamMassGood", xtitle="mass of good (GeV)", **_common),
201  Plot("lamMassFake", xtitle="mass of fake (GeV)", **_common),
202 ],
203  legendDy=_legendDy_2rows
204 )
205 
206 ## Extended set of plots
207 _common = dict(drawStyle = "HIST", stat=True)
208 _commonXY = dict(xmin=[x*0.1 for x in xrange(-6, 6, 1)], xmax=[x*0.1 for x in xrange(-5, 7, 1)])
209 _commonZ = dict(xmin=[-60,-30], xmax=[30,60])
210 _commonXY.update(_common)
211 _commonZ.update(_common)
212 _extGenpos = PlotGroup("genpos", [
213  Plot("GenAllV_X", xtitle="Gen AllV pos x (cm)", ytitle="N", **_commonXY),
214  Plot("GenPV_X", xtitle="Gen PV pos x (cm)", ytitle="N", **_commonXY),
215  Plot("GenAllV_Y", xtitle="Gen AllV pos y (cm)", ytitle="N", **_commonXY),
216  Plot("GenPV_Y", xtitle="Gen PV pos y (cm)", ytitle="N", **_commonXY),
217  Plot("GenAllV_Z", xtitle="Gen AllV pos z (cm)", ytitle="N", **_commonZ),
218  Plot("GenPV_Z", xtitle="Gen PV pos z (cm)", ytitle="N", **_commonZ),
219 ])
220 _extDist = PlotGroup("dist", [
221  Plot("RecoAllAssoc2Gen_X", xtitle="Reco vertex pos x (cm)", ytitle="N", **_commonXY),
222  Plot("RecoAllAssoc2Gen_Y", xtitle="Reco vertex pos y (cm)", ytitle="N", **_commonXY),
223  Plot("RecoAllAssoc2Gen_R", xtitle="Reco vertex pos r (cm)", ytitle="N", **_commonXY),
224  Plot("RecoAllAssoc2Gen_Z", xtitle="Reco vertex pos z (cm)", ytitle="N", **_commonZ),
225  Plot("RecoAllAssoc2Gen_NumVertices", xtitle="Number of reco vertices", ytitle="A.u.", normalizeToUnitArea=True, stat=True, drawStyle="hist", min=_minVtx, xmax=_maxVtx),
226  Plot("RecoAllAssoc2Gen_NumTracks", xtitle="Number of tracks in vertex fit", ytitle="N", stat=True, drawStyle="hist"),
227 ])
228 _commonZ = dict(title="", xtitle="Vertex z (cm)", scale=1e4, ylog=True, ymin=_minMaxRes , ymax=_minMaxRes, xmin=_minVertexZ, xmax=_maxVertexZ)
229 _extResolutionZ = PlotGroup("resolutionZ", [
230  Plot("RecoPVAssoc2GenPVMatched_ResolX_vs_Z_Sigma", ytitle="#sigma(#delta x) (#mum) for PV", **_commonZ),
231  Plot("RecoAllAssoc2GenMatched_ResolX_vs_Z_Sigma", ytitle="#sigma(#delta x) (#mum)", **_commonZ),
232  Plot("RecoAllAssoc2GenMatchedMerged_ResolX_vs_Z_Sigma", ytitle="#sigma(#delta x) for merged vertices (#mum)", **_commonZ),
233  #
234  Plot("RecoPVAssoc2GenPVMatched_ResolY_vs_Z_Sigma", ytitle="#sigma(#delta y) (#mum) for PV", **_commonZ),
235  Plot("RecoAllAssoc2GenMatched_ResolY_vs_Z_Sigma", ytitle="#sigma(#delta y) (#mum)", **_commonZ),
236  Plot("RecoAllAssoc2GenMatchedMerged_ResolY_vs_Z_Sigma", ytitle="#sigma(#delta y) for merged vertices (#mum)", **_commonZ),
237  #
238  Plot("RecoPVAssoc2GenPVMatched_ResolZ_vs_Z_Sigma", ytitle="#sigma(#delta z) (#mum) for PV", **_commonZ),
239  Plot("RecoAllAssoc2GenMatched_ResolZ_vs_Z_Sigma", ytitle="#sigma(#delta z) (#mum)", **_commonZ),
240  Plot("RecoAllAssoc2GenMatchedMerged_ResolZ_vs_Z_Sigma", ytitle="#sigma(#delta z) for merged vertices (#mum)", **_commonZ),
241 ], ncols=3)
242 _commonPU = copy.copy(_commonZ)
243 _commonPU.update(dict(xtitle="Simulated interactions", xmin=_minPU, xmax=_maxPU))
244 _extResolutionPU = PlotGroup("resolutionPU", [
245  Plot("RecoPVAssoc2GenPVMatched_ResolX_vs_PU_Sigma", ytitle="Resolution in x (#mum) for PV", **_commonPU),
246  Plot("RecoAllAssoc2GenMatched_ResolX_vs_PU_Sigma", ytitle="Resolution in x (#mum)", **_commonPU),
247  Plot("RecoAllAssoc2GenMatchedMerged_ResolX_vs_PU_Sigma", ytitle="Resolution in x for merged vertices (#mum)", **_commonPU),
248  #
249  Plot("RecoPVAssoc2GenPVMatched_ResolY_vs_PU_Sigma", ytitle="Resolution in y (#mum) for PV", **_commonPU),
250  Plot("RecoAllAssoc2GenMatched_ResolY_vs_PU_Sigma", ytitle="Resolution in y (#mum)", **_commonPU),
251  Plot("RecoAllAssoc2GenMatchedMerged_ResolY_vs_PU_Sigma", ytitle="Resolution in y for merged vertices (#mum)", **_commonPU),
252  #
253  Plot("RecoPVAssoc2GenPVMatched_ResolZ_vs_PU_Sigma", ytitle="Resolution in z (#mum) for PV", **_commonPU),
254  Plot("RecoAllAssoc2GenMatched_ResolZ_vs_PU_Sigma", ytitle="Resolution in z (#mum)", **_commonPU),
255  Plot("RecoAllAssoc2GenMatchedMerged_ResolZ_vs_PU_Sigma", ytitle="Resolution in z for merged vertices (#mum)", **_commonPU),
256 ], ncols=3)
257 _commonZ.update(dict(scale=1, ylog=False, ymin=_minPull, ymax=_maxPull))
258 _extPullZ = PlotGroup("pullZ", [
259  Plot("RecoPVAssoc2GenPVMatched_PullX_vs_Z_Sigma", ytitle="Pull of x for PV", **_commonZ),
260  Plot("RecoAllAssoc2GenMatched_PullX_vs_Z_Sigma", ytitle="Pull of x", **_commonZ),
261  Plot("RecoAllAssoc2GenMatchedMerged_PullX_vs_Z_Sigma", ytitle="Pull of x for merged vertices", **_commonZ),
262  #
263  Plot("RecoPVAssoc2GenPVMatched_PullY_vs_Z_Sigma", ytitle="Pull of y for PV", **_commonZ),
264  Plot("RecoAllAssoc2GenMatched_PullY_vs_Z_Sigma", ytitle="Pull of y", **_commonZ),
265  Plot("RecoAllAssoc2GenMatchedMerged_PullY_vs_Z_Sigma", ytitle="Pull of y for merged vertices", **_commonZ),
266  #
267  Plot("RecoPVAssoc2GenPVMatched_PullZ_vs_Z_Sigma", ytitle="Pull of z for PV", **_commonZ),
268  Plot("RecoAllAssoc2GenMatched_PullZ_vs_Z_Sigma", ytitle="Pull of z", **_commonZ),
269  Plot("RecoAllAssoc2GenMatchedMerged_PullZ_vs_Z_Sigma", ytitle="Pull of z for merged vertices", **_commonZ),
270 ], ncols=3)
271 _commonPU.update(dict(scale=1, ylog=False, ymin=_minPull, ymax=_maxPull))
272 _extPullPU = PlotGroup("pullPU", [
273  Plot("RecoPVAssoc2GenPVMatched_PullX_vs_PU_Sigma", ytitle="Pull of x for PV", **_commonPU),
274  Plot("RecoAllAssoc2GenMatched_PullX_vs_PU_Sigma", ytitle="Pull of x", **_commonPU),
275  Plot("RecoAllAssoc2GenMatchedMerged_PullX_vs_PU_Sigma", ytitle="Pull of x for merged vertices", **_commonPU),
276  #
277  Plot("RecoPVAssoc2GenPVMatched_PullY_vs_PU_Sigma", ytitle="Pull of y for PV", **_commonPU),
278  Plot("RecoAllAssoc2GenMatched_PullY_vs_PU_Sigma", ytitle="Pull of y", **_commonPU),
279  Plot("RecoAllAssoc2GenMatchedMerged_PullY_vs_PU_Sigma", ytitle="Pull of y for merged vertices", **_commonPU),
280  #
281  Plot("RecoPVAssoc2GenPVMatched_PullZ_vs_PU_Sigma", ytitle="Pull of z for PV", **_commonPU),
282  Plot("RecoAllAssoc2GenMatched_PullZ_vs_PU_Sigma", ytitle="Pull of z", **_commonPU),
283  Plot("RecoAllAssoc2GenMatchedMerged_PullZ_vs_PU_Sigma", ytitle="Pull of z for merged vertices", **_commonPU),
284 ], ncols=3)
285 _commonNumTracks.update(dict(scale=1e4, ymin=_minResidual, ymax=_maxResidual))
286 _extResidualNumTracks = PlotGroup("residualNumTracks", [
287  Plot("RecoPVAssoc2GenPVMatched_ResolX_vs_NumTracks_Mean", ytitle="< #delta x > (#mum) for PV", **_commonNumTracks),
288  Plot("RecoAllAssoc2GenMatched_ResolX_vs_NumTracks_Mean", ytitle="< #delta x > (#mum)", **_commonNumTracks),
289  Plot("RecoAllAssoc2GenMatchedMerged_ResolX_vs_NumTracks_Mean", ytitle="< #delta x > for merged vertices (#mum)", **_commonNumTracks),
290  #
291  Plot("RecoPVAssoc2GenPVMatched_ResolY_vs_NumTracks_Mean", ytitle="< #delta y > (#mum) for PV", **_commonNumTracks),
292  Plot("RecoAllAssoc2GenMatched_ResolY_vs_NumTracks_Mean", ytitle="< #delta y > (#mum)", **_commonNumTracks),
293  Plot("RecoAllAssoc2GenMatchedMerged_ResolY_vs_NumTracks_Mean", ytitle="< #delta y > for merged vertices (#mum)", **_commonNumTracks),
294  #
295  Plot("RecoPVAssoc2GenPVMatched_ResolZ_vs_NumTracks_Mean", ytitle="< #delta z > (#mum) for PV", **_commonNumTracks),
296  Plot("RecoAllAssoc2GenMatched_ResolZ_vs_NumTracks_Mean", ytitle="< #delta z > (#mum)", **_commonNumTracks),
297  Plot("RecoAllAssoc2GenMatchedMerged_ResolZ_vs_NumTracks_Mean", ytitle="< #delta z > for merged vertices (#mum)", **_commonNumTracks),
298 ], ncols=3)
299 _commonPt.update(dict(scale=1e4, ymin=_minResidual, ymax=_maxResidual))
300 _extResidualPt = PlotGroup("residualPt", [
301  Plot("RecoPVAssoc2GenPVMatched_ResolX_vs_Pt_Mean", ytitle="< #delta x > (#mum) for PV", **_commonPt),
302  Plot("RecoAllAssoc2GenMatched_ResolX_vs_Pt_Mean", ytitle="< #delta x > (#mum)", **_commonPt),
303  Plot("RecoAllAssoc2GenMatchedMerged_ResolX_vs_Pt_Mean", ytitle="< #delta x > for merged vertices (#mum)", **_commonPt),
304  #
305  Plot("RecoPVAssoc2GenPVMatched_ResolY_vs_Pt_Mean", ytitle="< #delta y > (#mum) for PV", **_commonPt),
306  Plot("RecoAllAssoc2GenMatched_ResolY_vs_Pt_Mean", ytitle="< #delta y > (#mum)", **_commonPt),
307  Plot("RecoAllAssoc2GenMatchedMerged_ResolY_vs_Pt_Mean", ytitle="< #delta y > for merged vertices (#mum)", **_commonPt),
308  #
309  Plot("RecoPVAssoc2GenPVMatched_ResolZ_vs_Pt_Mean", ytitle="< #delta z > (#mum) for PV", **_commonPt),
310  Plot("RecoAllAssoc2GenMatched_ResolZ_vs_Pt_Mean", ytitle="< #delta z > (#mum)", **_commonPt),
311  Plot("RecoAllAssoc2GenMatchedMerged_ResolZ_vs_Pt_Mean", ytitle="< #delta z > for merged vertices (#mum)", **_commonPt),
312 ], ncols=3)
313 _commonZ.update(dict(scale=1e4, ymin=_minResidual, ymax=_maxResidual))
314 _extResidualZ = PlotGroup("residualZ", [
315  Plot("RecoPVAssoc2GenPVMatched_ResolX_vs_Z_Mean", ytitle="< #delta x > (#mum) for PV", **_commonZ),
316  Plot("RecoAllAssoc2GenMatched_ResolX_vs_Z_Mean", ytitle="< #delta x > (#mum)", **_commonZ),
317  Plot("RecoAllAssoc2GenMatchedMerged_ResolX_vs_Z_Mean", ytitle="< #delta x > for merged vertices (#mum)", **_commonZ),
318  #
319  Plot("RecoPVAssoc2GenPVMatched_ResolY_vs_Z_Mean", ytitle="< #delta y > (#mum) for PV", **_commonZ),
320  Plot("RecoAllAssoc2GenMatched_ResolY_vs_Z_Mean", ytitle="< #delta y > (#mum)", **_commonZ),
321  Plot("RecoAllAssoc2GenMatchedMerged_ResolY_vs_Z_Mean", ytitle="< #delta y > for merged vertices (#mum)", **_commonZ),
322  #
323  Plot("RecoPVAssoc2GenPVMatched_ResolZ_vs_Z_Mean", ytitle="< #delta z > (#mum) for PV", **_commonZ),
324  Plot("RecoAllAssoc2GenMatched_ResolZ_vs_Z_Mean", ytitle="< #delta z > (#mum)", **_commonZ),
325  Plot("RecoAllAssoc2GenMatchedMerged_ResolZ_vs_Z_Mean", ytitle="< #delta z > for merged vertices (#mum)", **_commonZ),
326 ], ncols=3)
327 _commonPU.update(dict(scale=1e4, ymin=_minResidual, ymax=_maxResidual))
328 _extResidualPU = PlotGroup("residualPU", [
329  Plot("RecoPVAssoc2GenPVMatched_ResolX_vs_PU_Mean", ytitle="< #delta x > (#mum) for PV", **_commonPU),
330  Plot("RecoAllAssoc2GenMatched_ResolX_vs_PU_Mean", ytitle="< #delta x > (#mum)", **_commonPU),
331  Plot("RecoAllAssoc2GenMatchedMerged_ResolX_vs_PU_Mean", ytitle="< #delta x > for merged vertices (#mum)", **_commonPU),
332  #
333  Plot("RecoPVAssoc2GenPVMatched_ResolY_vs_PU_Mean", ytitle="< #delta y > (#mum) for PV", **_commonPU),
334  Plot("RecoAllAssoc2GenMatched_ResolY_vs_PU_Mean", ytitle="< #delta y > (#mum)", **_commonPU),
335  Plot("RecoAllAssoc2GenMatchedMerged_ResolY_vs_PU_Mean", ytitle="< #delta y > for merged vertices (#mum)", **_commonPU),
336  #
337  Plot("RecoPVAssoc2GenPVMatched_ResolZ_vs_PU_Mean", ytitle="< #delta z > (#mum) for PV", **_commonPU),
338  Plot("RecoAllAssoc2GenMatched_ResolZ_vs_PU_Mean", ytitle="< #delta z > (#mum)", **_commonPU),
339  Plot("RecoAllAssoc2GenMatchedMerged_ResolZ_vs_PU_Mean", ytitle="< #delta z > for merged vertices (#mum)", **_commonPU),
340 ], ncols=3)
341 _extDqm = PlotGroup("dqm", [
342  Plot("tagVtxTrksVsZ", xtitle="z_{vertex} - z_{beamspot} (cm)", ytitle="Tracks / selected PV"),
343  Plot("otherVtxTrksVsZ", xtitle="z_{vertex} - z_{beamspot} (cm)", ytitle="Tracks / pileup vertex"),
344  Plot("vtxNbr", xtitle="Reconstructed vertices", ytitle="Events", stat=True, drawStyle="hist", xmin=_minVtx, xmax=_maxVtx),
345 ])
346 _common = dict(ytitle="Vertices", stat=True)
347 _extDqmDiff = PlotGroup("dqmDiff", [
348  Plot("tagDiffX", xtitle="PV x_{vertex} - x_{beamspot} (#mum)", **_common),
349  Plot("otherDiffX", xtitle="Pileup vertex x_{vertex} - x_{beamspot} (#mum)", **_common),
350  #
351  Plot("tagDiffY", xtitle="PV y_{vertex} - y_{beamspot} (#mum)", **_common),
352  Plot("otherDiffY", xtitle="Pileup vertex y_{vertex} - y_{beamspot} (#mum)", **_common),
353 ])
354 _extDqmErr = PlotGroup("dqmErr", [
355  Plot("tagErrX", xtitle="PV uncertainty in x (um)", **_common),
356  Plot("otherErrX", xtitle="Pileup vertex uncertainty in x (um)", **_common),
357  #
358  Plot("otherErrY", xtitle="Pileup vertex uncertainty in y (um)", **_common),
359  Plot("tagErrY", xtitle="PV uncertainty in y (um)", **_common),
360  #
361  Plot("otherErrZ", xtitle="Pileup vertex uncertainty in z (um)", **_common),
362  Plot("tagErrZ", xtitle="PV uncertainty in z (um)", **_common),
363 ])
364 
366  def __init__(self, page="vertex"):
367  self._purpose = PlotPurpose.Vertexing
368  self._page = page
369 
370  def getPurpose(self):
371  return self._purpose
372 
373  def getPage(self):
374  return self._page
375 
376  def getSection(self, dqmSubFolder):
377  return dqmSubFolder
378 
379  def create(self, tdirectory):
380  def _formatOrNone(num, func):
381  if num is None:
382  return None
383  return func(num)
384 
385  ret = []
386  h = tdirectory.Get("TruePVLocationIndexCumulative")
387  if h:
388  n_events = h.GetEntries()
389  n_pvtagged = h.GetBinContent(2)
390  ret.extend([int(n_events), "%.4f"%(float(n_pvtagged)/float(n_events))])
391  else:
392  ret.extend([None, None])
393 
394  h = tdirectory.Get("globalEfficiencies")
395  if h:
396  d = {}
397  for i in xrange(1, h.GetNbinsX()+1):
398  d[h.GetXaxis().GetBinLabel(i)] = h.GetBinContent(i)
399  ret.extend([
400  _formatOrNone(d.get("effic_vs_Z", None), lambda n: "%.4f"%n),
401  _formatOrNone(d.get("fakerate_vs_Z", None), lambda n: "%.4f"%n),
402  _formatOrNone(d.get("merged_vs_Z", None), lambda n: "%.4f"%n),
403  _formatOrNone(d.get("duplicate_vs_Z", None), lambda n: "%.4f"%n),
404  ])
405  else:
406  ret.extend([None]*4)
407 
408  if ret.count(None) == len(ret):
409  return None
410 
411  return ret
412 
413  def headers(self):
414  return [
415  "Events",
416  "PV reco+tag efficiency",
417  "Efficiency",
418  "Fake rate",
419  "Merge rate",
420  "Duplicate rate",
421  ]
422 
423 _vertexFolders = [
424  "DQMData/Run 1/Vertexing/Run summary/PrimaryVertex",
425  "DQMData/Vertexing/PrimaryVertex",
426  "DQMData/Run 1/Vertexing/Run summary/PrimaryVertexV",
427  "DQMData/Vertexing/PrimaryVertexV",
428 ]
429 _vertexDqmFolders = [
430  "DQMData/Run 1/OfflinePV/Run summary/offlinePrimaryVertices",
431  "DQMData/OffinePV/offlinePrimaryVertices",
432 ]
433 _v0Folders = [
434  "DQMData/Run 1/Vertexing/Run summary/V0",
435  "DQMData/Vertexing/V0",
436  "DQMData/Run 1/Vertexing/Run summary/V0V",
437  "DQMData/Vertexing/V0V",
438 ]
439 plotter = Plotter()
440 plotterExt = Plotter()
441 plotter.append("", _vertexFolders, PlotFolder(
442  _recovsgen,
443  _pvtagging,
444  _effandfake,
445  _resolution,
446  _resolutionNumTracks,
447  _resolutionPt,
448  _pull,
449  _pullNumTracks,
450  _pullPt,
451  _puritymissing,
452  _sumpt2,
453  purpose=PlotPurpose.Vertexing,
454  page="vertex"
455 ))
456 plotter.appendTable("", _vertexFolders, VertexSummaryTable())
457 plotter.append("K0", [x+"/K0" for x in _v0Folders], PlotFolder(
458  _k0_effandfake,
459  _k0_effandfakeTk,
460  _k0_mass,
461  loopSubFolders=False,
462  purpose=PlotPurpose.Vertexing,
463  page="v0", section="k0"
464 ))
465 plotter.append("Lambda", [x+"/Lambda" for x in _v0Folders], PlotFolder(
466  _lambda_effandfake,
467  _lambda_effandfakeTk,
468  _lambda_mass,
469  loopSubFolders=False,
470  purpose=PlotPurpose.Vertexing,
471  page="v0", section="lambda"
472 ))
473 plotterExt.append("", _vertexFolders, PlotFolder(
474  _extDist,
475  _extResolutionZ,
476  _extResolutionPU,
477  _extPullZ,
478  _extPullPU,
479  _extResidualNumTracks,
480  _extResidualPt,
481  _extResidualZ,
482  _extResidualPU,
483  purpose=PlotPurpose.Vertexing,
484  page="vertex",
485  onlyForPileup=True,
486  numberOfEventsHistogram=_vertexNumberOfEventsHistogram
487 ))
488 plotterExt.append("dqm", _vertexDqmFolders, PlotFolder(
489  _extDqm,
490  _extDqmDiff,
491  _extDqmErr,
492  loopSubFolders=False,
493  purpose=PlotPurpose.Vertexing,
494  page="vertex",
495  section="offlinePrimaryVertices",
496  onlyForPileup=True
497 ))
498 plotterExt.append("gen", _vertexFolders, PlotFolder(
499  _extGenpos,
500  loopSubFolders=False,
501  purpose=PlotPurpose.Vertexing,
502  page="vertex",
503  section="genvertex",
504  onlyForPileup=True
505 ))
506 
508  def _init__(self, *args, **kwargs):
509  super(TrackingValidation, self).__init__(*args, **kwargs)
510 
511  def _getDirectoryName(self, quality, algo):
512  return algo
513 
514  def _getSelectionName(self, quality, algo):
515  if algo is None:
516  return ""
517  return "_"+algo
def getSection(self, dqmSubFolder)
Definition: vertexPlots.py:376
def _minMaxResidual(ma)
def __init__(self, fullsimSamples, fastsimSamples, refRelease, refRepository, newRelease, newRepository, newFileModifier=None, selectionName="")
Definition: validation.py:620
def _getSelectionName(self, quality, algo)
Definition: vertexPlots.py:514
def _getDirectoryName(self, quality, algo)
Definition: vertexPlots.py:511
def __init__(self, page="vertex")
Definition: vertexPlots.py:366
def _init__(self, args, kwargs)
Definition: vertexPlots.py:508
def create(self, tdirectory)
Definition: vertexPlots.py:379