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