CMS 3D CMS Logo

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