Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:34:21

0001 from builtins import range
0002 import copy
0003 
0004 from Validation.RecoTrack.plotting.plotting import Plot, PlotGroup, PlotFolder, Plotter
0005 import Validation.RecoTrack.plotting.validation as validation
0006 from Validation.RecoTrack.plotting.html import PlotPurpose
0007 from Validation.RecoTrack.plotting.trackingPlots import _legendDy_1row, _legendDy_2rows, _legendDy_2rows_3cols, _legendDy_4rows, _minMaxResidual
0008 
0009 _minPU = [0, 10, 20, 40, 80, 120]
0010 _maxPU = [60, 80, 100, 150, 200, 250]
0011 _minVtx = [0, 80, 120]
0012 _maxVtx = [60, 100, 150, 200, 250]
0013 _maxEff = 1.025
0014 _maxFake = [0.05, 0.1, 0.2, 0.5, 0.7, 1.025]
0015 _minMaxRes = [0.1, 0.5, 1, 5, 10, 50, 100, 200, 500, 1000, 2000, 5000]
0016 (_minResidual, _maxResidual) = _minMaxResidual(_minMaxRes)
0017 _minMaxPt = [5e-1, 1, 5, 1e1, 5e1, 1e2, 5e2, 1e3, 5e3, 1e4]
0018 _minPull = [0, 0.5, 0.8, 0.9]
0019 _maxPull = [1.1, 1.2, 1.5, 2]
0020 _minVertexZ = list(range(-60,-10,10))
0021 _maxVertexZ = list(range(20,70,10))
0022 
0023 _vertexNumberOfEventsHistogram = "DQMData/Run 1/Vertexing/Run summary/PrimaryVertexV/GenPV_Z"
0024 
0025 _common = {"xtitle": "Simulated interactions", "xmin": _minPU, "xmax": _maxPU, "ymin": _minVtx, "ymax": _maxVtx}
0026 _recovsgen = PlotGroup("recovsgen", [
0027     Plot("RecoVtx_vs_GenVtx", ytitle="Reco vertices", **_common),
0028     Plot("MatchedRecoVtx_vs_GenVtx", ytitle="Matched reco vertices", **_common),
0029     Plot("merged_vs_ClosestVertexInZ", xtitle="Closest distance in Z (cm)", ytitle="Merge rate", xlog=True, xmin=1e-3, ymax=_maxFake),
0030     Plot("merged_vs_Z", xtitle="Z (cm)", ytitle="Merge rate", xmin=-20, xmax=20, ymax=_maxFake),
0031 ],
0032                        legendDy=_legendDy_2rows, onlyForPileup=True,
0033 )
0034 _pvtagging = PlotGroup("pvtagging", [
0035     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]),
0036     Plot("TruePVLocationIndex", xtitle="Index of signal PV in reco collection", ytitle="Fraction of events", drawStyle="hist", normalizeToUnitArea=True, ylog=True, ymin=1e-5),
0037     Plot("MisTagRate_vs_PU", xtitle="PU", ytitle="Mistag rate vs. PU", title="", xmax=_maxPU, ymax=_maxFake),
0038     Plot("MisTagRate_vs_sum-pt2", xtitle="#Sigmap_{T}^{2}", ytitle="Mistag rate vs. #Sigmap_{T}^{2}", title="", xlog=True, ymax=_maxFake),
0039 ],
0040                        legendDy=_legendDy_2rows
0041 )
0042 _effandfake = PlotGroup("effandfake", [
0043     Plot("effic_vs_NumVertices", xtitle="Simulated interactions", ytitle="Efficiency vs. N sim vertices", xmin=_minPU, xmax=_maxPU, ymax=_maxEff),
0044     Plot("fakerate_vs_PU", xtitle="Simulated interactions", ytitle="Fake rate vs. N sim vertices", xmin=_minPU, xmax=_maxPU, ymax=_maxFake),
0045     Plot("effic_vs_NumTracks", xtitle="Tracks", ytitle="Efficiency vs. N tracks", title="", ymax=_maxEff),
0046     Plot("fakerate_vs_NumTracks", xtitle="Tracks", ytitle="Fake rate vs. N tracks", title="", ymax=_maxFake),
0047     Plot("effic_vs_Pt2", xtitle="Sum p_{T}^{2}    ", ytitle="Efficiency vs. sum p_{T}^{2}", xlog=True, ymax=_maxEff),
0048     Plot("fakerate_vs_Pt2", xtitle="Sum p_{T}^{2}    ", ytitle="Fake rate vs. sum p_{T}^{2}", xlog=True, ymax=_maxFake),
0049 ])
0050 _common = {"title": "", "stat": True, "fit": True, "normalizeToUnitArea": True, "drawStyle": "hist", "drawCommand": "", "ylog": True, "ymin": [5e-7, 5e-6, 5e-5, 5e-4]}
0051 _resolution = PlotGroup("resolution", [
0052     Plot("RecoPVAssoc2GenPVMatched_ResolX", xtitle="Resolution in x (#mum) for PV", **_common),
0053     Plot("RecoAllAssoc2GenMatched_ResolX", xtitle="Resolution in x (#mum)", **_common),
0054     Plot("RecoAllAssoc2GenMatchedMerged_ResolX", xtitle="Resolution in x for merged vertices (#mum)", **_common),
0055     #
0056     Plot("RecoPVAssoc2GenPVMatched_ResolY", xtitle="Resolution in y (#mum)", **_common),
0057     Plot("RecoAllAssoc2GenMatched_ResolY", xtitle="Resolution in y (#mum)", **_common),
0058     Plot("RecoAllAssoc2GenMatchedMerged_ResolY", xtitle="Resolution in y for merged vertices (#mum)", **_common),
0059     #
0060     Plot("RecoPVAssoc2GenPVMatched_ResolZ", xtitle="Resolution in z (#mum)", **_common),
0061     Plot("RecoAllAssoc2GenMatched_ResolZ", xtitle="Resolution in z (#mum)", **_common),
0062     Plot("RecoAllAssoc2GenMatchedMerged_ResolZ", xtitle="Resolution in z for merged vertices (#mum)", **_common),
0063 ], ncols=3)
0064 _commonNumTracks = dict(title="", xtitle="Number of tracks", scale=1e4, ylog=True, ymin=_minMaxRes , ymax=_minMaxRes)
0065 _resolutionNumTracks = PlotGroup("resolutionNumTracks", [
0066     Plot("RecoPVAssoc2GenPVMatched_ResolX_vs_NumTracks_Sigma", ytitle="#sigma(#delta x) (#mum) for PV", **_commonNumTracks),
0067     Plot("RecoAllAssoc2GenMatched_ResolX_vs_NumTracks_Sigma", ytitle="#sigma(#delta x) (#mum)", **_commonNumTracks),
0068     Plot("RecoAllAssoc2GenMatchedMerged_ResolX_vs_NumTracks_Sigma", ytitle="#sigma(#delta x) x for merged vertices (#mum)", **_commonNumTracks),
0069     #
0070     Plot("RecoPVAssoc2GenPVMatched_ResolY_vs_NumTracks_Sigma", ytitle="#sigma(#delta y) (#mum) for PV", **_commonNumTracks),
0071     Plot("RecoAllAssoc2GenMatched_ResolY_vs_NumTracks_Sigma", ytitle="#sigma(#delta y) (#mum)", **_commonNumTracks),
0072     Plot("RecoAllAssoc2GenMatchedMerged_ResolY_vs_NumTracks_Sigma", ytitle="#sigma(#delta y) for merged vertices (#mum)", **_commonNumTracks),
0073     #
0074     Plot("RecoPVAssoc2GenPVMatched_ResolZ_vs_NumTracks_Sigma", ytitle="#sigma(#delta z) (#mum) for PV", **_commonNumTracks),
0075     Plot("RecoAllAssoc2GenMatched_ResolZ_vs_NumTracks_Sigma", ytitle="#sigma(#delta z) (#mum)", **_commonNumTracks),
0076     Plot("RecoAllAssoc2GenMatchedMerged_ResolZ_vs_NumTracks_Sigma", ytitle="#sigma(#delta z) for merged vertices (#mum)", **_commonNumTracks),
0077 ], ncols=3)
0078 _commonPt = copy.copy(_commonNumTracks)
0079 _commonPt.update(dict(xtitle= "Sum of track p_{T} (GeV)", xlog=True, xmin=_minMaxPt, xmax=_minMaxPt))
0080 _resolutionPt = PlotGroup("resolutionPt", [
0081     Plot("RecoPVAssoc2GenPVMatched_ResolX_vs_Pt_Sigma", ytitle="#sigma(#delta x) (#mum) for PV", **_commonPt),
0082     Plot("RecoAllAssoc2GenMatched_ResolX_vs_Pt_Sigma", ytitle="#sigma(#delta x) (#mum)", **_commonPt),
0083     Plot("RecoAllAssoc2GenMatchedMerged_ResolX_vs_Pt_Sigma", ytitle="#sigma(#delta x) for merged vertices (#mum)", **_commonPt),
0084     #
0085     Plot("RecoPVAssoc2GenPVMatched_ResolY_vs_Pt_Sigma", ytitle="#sigma(#delta y) (#mum) for PV", **_commonPt),
0086     Plot("RecoAllAssoc2GenMatched_ResolY_vs_Pt_Sigma", ytitle="#sigma(#delta y) (#mum)", **_commonPt),
0087     Plot("RecoAllAssoc2GenMatchedMerged_ResolY_vs_Pt_Sigma", ytitle="#sigma(#delta y) for merged vertices (#mum)", **_commonPt),
0088     #
0089     Plot("RecoPVAssoc2GenPVMatched_ResolZ_vs_Pt_Sigma", ytitle="#sigma(#delta z) (#mum) for PV", **_commonPt),
0090     Plot("RecoAllAssoc2GenMatched_ResolZ_vs_Pt_Sigma", ytitle="#sigma(#delta z) (#mum)", **_commonPt),
0091     Plot("RecoAllAssoc2GenMatchedMerged_ResolZ_vs_Pt_Sigma", ytitle="#sigma(#delta z) for merged vertices (#mum)", **_commonPt),
0092 ], ncols=3)
0093 _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]}
0094 _pull = PlotGroup("pull", [
0095     Plot("RecoPVAssoc2GenPVMatched_PullX", xtitle="x", ytitle="Pull of x for PV", **_common),
0096     Plot("RecoAllAssoc2GenMatched_PullX", xtitle="x", ytitle="Pull of x", **_common),
0097     Plot("RecoAllAssoc2GenMatchedMerged_PullX", xtitle="x", ytitle="Pull of x  for merged vertices", **_common),
0098     #
0099     Plot("RecoPVAssoc2GenPVMatched_PullY", xtitle="y", ytitle="Pull of y for PV", **_common),
0100     Plot("RecoAllAssoc2GenMatched_PullY", xtitle="y", ytitle="Pull of y", **_common),
0101     Plot("RecoAllAssoc2GenMatchedMerged_PullY", xtitle="y", ytitle="Pull of y for merged vertices", **_common),
0102     #
0103     Plot("RecoPVAssoc2GenPVMatched_PullZ", xtitle="z", ytitle="Pull of z for PV", **_common),
0104     Plot("RecoAllAssoc2GenMatched_PullZ", xtitle="z", ytitle="Pull of z", **_common),
0105     Plot("RecoAllAssoc2GenMatchedMerged_PullZ", xtitle="z", ytitle="Pull of z for merged vertices", **_common),
0106 ], ncols=3)
0107 _commonNumTracks.update(dict(scale=1, ylog=False, ymin=_minPull, ymax=_maxPull))
0108 _pullNumTracks = PlotGroup("pullNumTracks", [
0109     Plot("RecoPVAssoc2GenPVMatched_PullX_vs_NumTracks_Sigma", ytitle="Pull of x for PV", **_commonNumTracks),
0110     Plot("RecoAllAssoc2GenMatched_PullX_vs_NumTracks_Sigma", ytitle="Pull of x", **_commonNumTracks),
0111     Plot("RecoAllAssoc2GenMatchedMerged_PullX_vs_NumTracks_Sigma", ytitle="Pull of x for merged vertices", **_commonNumTracks),
0112     #
0113     Plot("RecoPVAssoc2GenPVMatched_PullY_vs_NumTracks_Sigma", ytitle="Pull of y for PV", **_commonNumTracks),
0114     Plot("RecoAllAssoc2GenMatched_PullY_vs_NumTracks_Sigma", ytitle="Pull of y", **_commonNumTracks),
0115     Plot("RecoAllAssoc2GenMatchedMerged_PullY_vs_NumTracks_Sigma", ytitle="Pull of y for merged vertices", **_commonNumTracks),
0116     #
0117     Plot("RecoPVAssoc2GenPVMatched_PullZ_vs_NumTracks_Sigma", ytitle="Pull of z for PV", **_commonNumTracks),
0118     Plot("RecoAllAssoc2GenMatched_PullZ_vs_NumTracks_Sigma", ytitle="Pull of z", **_commonNumTracks),
0119     Plot("RecoAllAssoc2GenMatchedMerged_PullZ_vs_NumTracks_Sigma", ytitle="Pull of z for merged vertices", **_commonNumTracks),
0120 ], ncols=3)
0121 _commonPt.update(dict(scale=1, ylog=False, ymin=_minPull, ymax=_maxPull))
0122 _pullPt = PlotGroup("pullPt", [
0123     Plot("RecoPVAssoc2GenPVMatched_PullX_vs_Pt_Sigma", ytitle="Pull of x for PV", **_commonPt),
0124     Plot("RecoAllAssoc2GenMatched_PullX_vs_Pt_Sigma", ytitle="Pull of x", **_commonPt),
0125     Plot("RecoAllAssoc2GenMatchedMerged_PullX_vs_Pt_Sigma", ytitle="Pull of x for merged vertices", **_commonPt),
0126     #
0127     Plot("RecoPVAssoc2GenPVMatched_PullY_vs_Pt_Sigma", ytitle="Pull of y for PV", **_commonPt),
0128     Plot("RecoAllAssoc2GenMatched_PullY_vs_Pt_Sigma", ytitle="Pull of y", **_commonPt),
0129     Plot("RecoAllAssoc2GenMatchedMerged_PullY_vs_Pt_Sigma", ytitle="Pull of y for merged vertices", **_commonPt),
0130     #
0131     Plot("RecoPVAssoc2GenPVMatched_PullZ_vs_Pt_Sigma", ytitle="Pull of z for PV", **_commonPt),
0132     Plot("RecoAllAssoc2GenMatched_PullZ_vs_Pt_Sigma", ytitle="Pull of z", **_commonPt),
0133     Plot("RecoAllAssoc2GenMatchedMerged_PullZ_vs_Pt_Sigma", ytitle="Pull of z for merged vertices", **_commonPt),
0134 ], ncols=3)
0135 
0136 _common={"drawStyle": "HIST", "normalizeToUnitArea": True}
0137 _puritymissing = PlotGroup("puritymissing", [
0138     Plot("RecoPVAssoc2GenPVMatched_Purity", xtitle="Purity", ytitle="Number of reco PVs matched to gen PVs", ylog=True, ymin=1e-4, **_common),
0139     Plot("RecoPVAssoc2GenPVNotMatched_Purity", xtitle="Purity", ytitle="Number of reco PVs not matcched to gen PVs", ylog=True, ymin=1e-3, **_common),
0140     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),
0141     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),
0142 #    Plot("fakerate_vs_Purity", xtitle="Purity", ytitle="Fake rate", ymax=_maxFake),
0143 ])
0144 # "xgrid": False, "ygrid": False,
0145 _common={"drawStyle": "HIST", "xlog": True, "ylog": True, "ymin": 0.5}
0146 _sumpt2 = PlotGroup("sumpt2", [
0147     Plot("RecoAssoc2GenPVMatched_Pt2", xtitle="#sum^{}p_{T}^{2}", ytitle="Reco vertices matched to gen PV", **_common),
0148     Plot("RecoAssoc2GenPVMatchedNotHighest_Pt2", xtitle="#sum^{}p_{T}^{2}", ytitle="Reco non-PV-vertices matched to gen PV", **_common),
0149     Plot("RecoAssoc2GenPVNotMatched_Pt2", xtitle="#sum^{}p_{T}^{2}", ytitle="Reco vertices not matched to gen PV", **_common),
0150     Plot("RecoAssoc2GenPVNotMatched_GenPVTracksRemoved_Pt2", xtitle="#sum^{}p_{T}^{2}, gen PV tracks removed", ytitle="Reco vertices not matched to gen PV", **_common),
0151 ],
0152                     legendDy=_legendDy_2rows, onlyForPileup=True,
0153 )
0154 
0155 _k0_effandfake = PlotGroup("effandfake", [
0156     Plot("K0sEffVsPt", xtitle="p_{T} (GeV)", ytitle="Efficiency vs. p_{T}"),
0157     Plot("K0sFakeVsPt", xtitle="p_{T} (GeV)", ytitle="Fake rate vs. p_{T}"),
0158     Plot("K0sEffVsEta", xtitle="#eta", ytitle="Efficiency vs. #eta"),
0159     Plot("K0sFakeVsEta", xtitle="#eta", ytitle="Fake rate vs. #eta"),
0160     Plot("K0sEffVsR", xtitle="R (cm)", ytitle="Efficiency vs. R"),
0161     Plot("K0sFakeVsR", xtitle="R (cm)", ytitle="Fake rate vs. R"),
0162 ])
0163 _k0_effandfakeTk = PlotGroup("effandfakeTk", [
0164 #    Plot("K0sTkEffVsPt"),
0165     Plot("K0sTkFakeVsPt", xtitle="p_{T} (GeV)", ytitle="Fake rate vs. p_{T}"),
0166 #    Plot("K0sTkEffVsEta"),
0167     Plot("K0sTkFakeVsEta", xtitle="#eta", ytitle="Fake rate vs. #eta"),
0168 #    Plot("K0sTkEffVsR"),
0169     Plot("K0sTkFakeVsR", xtitle="R (cm)", ytitle="Fake rate vs. R"),
0170 ],
0171                              legendDy=_legendDy_2rows
0172 )
0173 _common = dict(normalizeToUnitArea=True, drawStyle="HIST", stat=True)
0174 _k0_mass = PlotGroup("mass", [
0175     Plot("ksMassAll", xtitle="mass of all (GeV)", **_common),
0176     Plot("ksMassGood", xtitle="mass of good (GeV)", **_common),
0177     Plot("ksMassFake", xtitle="mass of fake (GeV)", **_common),
0178 ],
0179                      legendDy=_legendDy_2rows
0180 )
0181 _lambda_effandfake = PlotGroup("effandfake", [
0182     Plot("LamEffVsPt", xtitle="p_{T} (GeV)", ytitle="Efficiency vs. p_{T}"),
0183     Plot("LamFakeVsPt", xtitle="p_{T} (GeV)", ytitle="Fake rate vs. p_{T}"),
0184     Plot("LamEffVsEta", xtitle="#eta", ytitle="Efficiency vs. #eta"),
0185     Plot("LamFakeVsEta", xtitle="#eta", ytitle="Fake rate vs. #eta"),
0186     Plot("LamEffVsR", xtitle="R (cm)", ytitle="Efficiency vs. R"),
0187     Plot("LamFakeVsR", xtitle="R (cm)", ytitle="Fake rate vs. R"),
0188 ])
0189 _lambda_effandfakeTk = PlotGroup("effandfakeTk", [
0190 #    Plot("LamTkEffVsPt"),
0191     Plot("LamTkFakeVsPt", xtitle="p_{T} (GeV)", ytitle="Fake rate vs. p_{T}"),
0192 #    Plot("LamTkEffVsEta"),
0193     Plot("LamTkFakeVsEta", xtitle="#eta", ytitle="Fake rate vs. #eta"),
0194 #    Plot("LamTkEffVsR"),
0195     Plot("LamTkFakeVsR", xtitle="R (cm)", ytitle="Fake rate vs. R"),
0196 ],
0197                                  legendDy=_legendDy_2rows
0198 )
0199 _lambda_mass = PlotGroup("mass", [
0200     Plot("lamMassAll", xtitle="mass of all (GeV)", **_common),
0201     Plot("lamMassGood", xtitle="mass of good (GeV)", **_common),
0202     Plot("lamMassFake", xtitle="mass of fake (GeV)", **_common),
0203 ],
0204                          legendDy=_legendDy_2rows
0205 )
0206 
0207 ## Extended set of plots
0208 _common = dict(drawStyle = "HIST", stat=True)
0209 _commonXY = dict(xmin=[x*0.1 for x in range(-6, 6, 1)], xmax=[x*0.1 for x in range(-5, 7, 1)])
0210 _commonZ = dict(xmin=[-60,-30], xmax=[30,60])
0211 _commonXY.update(_common)
0212 _commonZ.update(_common)
0213 _extGenpos = PlotGroup("genpos", [
0214     Plot("GenAllV_X", xtitle="Gen AllV pos x (cm)", ytitle="N", **_commonXY),
0215     Plot("GenPV_X",   xtitle="Gen PV pos x (cm)",   ytitle="N", **_commonXY),
0216     Plot("GenAllV_Y", xtitle="Gen AllV pos y (cm)", ytitle="N", **_commonXY),
0217     Plot("GenPV_Y",   xtitle="Gen PV pos y (cm)",   ytitle="N", **_commonXY),
0218     Plot("GenAllV_Z", xtitle="Gen AllV pos z (cm)", ytitle="N", **_commonZ),
0219     Plot("GenPV_Z",   xtitle="Gen PV pos z (cm)",   ytitle="N", **_commonZ),
0220 ])
0221 _extDist = PlotGroup("dist", [
0222     Plot("RecoAllAssoc2Gen_X", xtitle="Reco vertex pos x (cm)", ytitle="N", **_commonXY),
0223     Plot("RecoAllAssoc2Gen_Y", xtitle="Reco vertex pos y (cm)", ytitle="N", **_commonXY),
0224     Plot("RecoAllAssoc2Gen_R", xtitle="Reco vertex pos r (cm)", ytitle="N", **_commonXY),
0225     Plot("RecoAllAssoc2Gen_Z", xtitle="Reco vertex pos z (cm)", ytitle="N", **_commonZ),
0226     Plot("RecoAllAssoc2Gen_NumVertices", xtitle="Number of reco vertices", ytitle="A.u.", normalizeToUnitArea=True, stat=True, drawStyle="hist", min=_minVtx, xmax=_maxVtx),
0227     Plot("RecoAllAssoc2Gen_NumTracks", xtitle="Number of tracks in vertex fit", ytitle="N", stat=True, drawStyle="hist"),
0228 ])
0229 _commonZ = dict(title="", xtitle="Vertex z (cm)", scale=1e4, ylog=True, ymin=_minMaxRes , ymax=_minMaxRes, xmin=_minVertexZ, xmax=_maxVertexZ)
0230 _extResolutionZ = PlotGroup("resolutionZ", [
0231     Plot("RecoPVAssoc2GenPVMatched_ResolX_vs_Z_Sigma", ytitle="#sigma(#delta x) (#mum) for PV", **_commonZ),
0232     Plot("RecoAllAssoc2GenMatched_ResolX_vs_Z_Sigma", ytitle="#sigma(#delta x) (#mum)", **_commonZ),
0233     Plot("RecoAllAssoc2GenMatchedMerged_ResolX_vs_Z_Sigma", ytitle="#sigma(#delta x) for merged vertices (#mum)", **_commonZ),
0234     #
0235     Plot("RecoPVAssoc2GenPVMatched_ResolY_vs_Z_Sigma", ytitle="#sigma(#delta y) (#mum) for PV", **_commonZ),
0236     Plot("RecoAllAssoc2GenMatched_ResolY_vs_Z_Sigma", ytitle="#sigma(#delta y) (#mum)", **_commonZ),
0237     Plot("RecoAllAssoc2GenMatchedMerged_ResolY_vs_Z_Sigma", ytitle="#sigma(#delta y) for merged vertices (#mum)", **_commonZ),
0238     #
0239     Plot("RecoPVAssoc2GenPVMatched_ResolZ_vs_Z_Sigma", ytitle="#sigma(#delta z) (#mum) for PV", **_commonZ),
0240     Plot("RecoAllAssoc2GenMatched_ResolZ_vs_Z_Sigma", ytitle="#sigma(#delta z) (#mum)", **_commonZ),
0241     Plot("RecoAllAssoc2GenMatchedMerged_ResolZ_vs_Z_Sigma", ytitle="#sigma(#delta z) for merged vertices (#mum)", **_commonZ),
0242 ], ncols=3)
0243 _commonPU = copy.copy(_commonZ)
0244 _commonPU.update(dict(xtitle="Simulated interactions", xmin=_minPU, xmax=_maxPU))
0245 _extResolutionPU = PlotGroup("resolutionPU", [
0246     Plot("RecoPVAssoc2GenPVMatched_ResolX_vs_PU_Sigma", ytitle="Resolution in x (#mum) for PV", **_commonPU),
0247     Plot("RecoAllAssoc2GenMatched_ResolX_vs_PU_Sigma", ytitle="Resolution in x (#mum)", **_commonPU),
0248     Plot("RecoAllAssoc2GenMatchedMerged_ResolX_vs_PU_Sigma", ytitle="Resolution in x for merged vertices (#mum)", **_commonPU),
0249     #
0250     Plot("RecoPVAssoc2GenPVMatched_ResolY_vs_PU_Sigma", ytitle="Resolution in y (#mum) for PV", **_commonPU),
0251     Plot("RecoAllAssoc2GenMatched_ResolY_vs_PU_Sigma", ytitle="Resolution in y (#mum)", **_commonPU),
0252     Plot("RecoAllAssoc2GenMatchedMerged_ResolY_vs_PU_Sigma", ytitle="Resolution in y for merged vertices (#mum)", **_commonPU),
0253     #
0254     Plot("RecoPVAssoc2GenPVMatched_ResolZ_vs_PU_Sigma", ytitle="Resolution in z (#mum) for PV", **_commonPU),
0255     Plot("RecoAllAssoc2GenMatched_ResolZ_vs_PU_Sigma", ytitle="Resolution in z (#mum)", **_commonPU),
0256     Plot("RecoAllAssoc2GenMatchedMerged_ResolZ_vs_PU_Sigma", ytitle="Resolution in z for merged vertices (#mum)", **_commonPU),
0257 ], ncols=3)
0258 _commonZ.update(dict(scale=1, ylog=False, ymin=_minPull, ymax=_maxPull))
0259 _extPullZ = PlotGroup("pullZ", [
0260     Plot("RecoPVAssoc2GenPVMatched_PullX_vs_Z_Sigma", ytitle="Pull of x for PV", **_commonZ),
0261     Plot("RecoAllAssoc2GenMatched_PullX_vs_Z_Sigma", ytitle="Pull of x", **_commonZ),
0262     Plot("RecoAllAssoc2GenMatchedMerged_PullX_vs_Z_Sigma", ytitle="Pull of x for merged vertices", **_commonZ),
0263     #
0264     Plot("RecoPVAssoc2GenPVMatched_PullY_vs_Z_Sigma", ytitle="Pull of y for PV", **_commonZ),
0265     Plot("RecoAllAssoc2GenMatched_PullY_vs_Z_Sigma", ytitle="Pull of y", **_commonZ),
0266     Plot("RecoAllAssoc2GenMatchedMerged_PullY_vs_Z_Sigma", ytitle="Pull of y for merged vertices", **_commonZ),
0267     #
0268     Plot("RecoPVAssoc2GenPVMatched_PullZ_vs_Z_Sigma", ytitle="Pull of z for PV", **_commonZ),
0269     Plot("RecoAllAssoc2GenMatched_PullZ_vs_Z_Sigma", ytitle="Pull of z", **_commonZ),
0270     Plot("RecoAllAssoc2GenMatchedMerged_PullZ_vs_Z_Sigma", ytitle="Pull of z for merged vertices", **_commonZ),
0271 ], ncols=3)
0272 _commonPU.update(dict(scale=1, ylog=False, ymin=_minPull, ymax=_maxPull))
0273 _extPullPU = PlotGroup("pullPU", [
0274     Plot("RecoPVAssoc2GenPVMatched_PullX_vs_PU_Sigma", ytitle="Pull of x for PV", **_commonPU),
0275     Plot("RecoAllAssoc2GenMatched_PullX_vs_PU_Sigma", ytitle="Pull of x", **_commonPU),
0276     Plot("RecoAllAssoc2GenMatchedMerged_PullX_vs_PU_Sigma", ytitle="Pull of x for merged vertices", **_commonPU),
0277     #
0278     Plot("RecoPVAssoc2GenPVMatched_PullY_vs_PU_Sigma", ytitle="Pull of y for PV", **_commonPU),
0279     Plot("RecoAllAssoc2GenMatched_PullY_vs_PU_Sigma", ytitle="Pull of y", **_commonPU),
0280     Plot("RecoAllAssoc2GenMatchedMerged_PullY_vs_PU_Sigma", ytitle="Pull of y for merged vertices", **_commonPU),
0281     #
0282     Plot("RecoPVAssoc2GenPVMatched_PullZ_vs_PU_Sigma", ytitle="Pull of z for PV", **_commonPU),
0283     Plot("RecoAllAssoc2GenMatched_PullZ_vs_PU_Sigma", ytitle="Pull of z", **_commonPU),
0284     Plot("RecoAllAssoc2GenMatchedMerged_PullZ_vs_PU_Sigma", ytitle="Pull of z for merged vertices", **_commonPU),
0285 ], ncols=3)
0286 _commonNumTracks.update(dict(scale=1e4, ymin=_minResidual, ymax=_maxResidual))
0287 _extResidualNumTracks = PlotGroup("residualNumTracks", [
0288     Plot("RecoPVAssoc2GenPVMatched_ResolX_vs_NumTracks_Mean", ytitle="< #delta x > (#mum) for PV", **_commonNumTracks),
0289     Plot("RecoAllAssoc2GenMatched_ResolX_vs_NumTracks_Mean", ytitle="< #delta x > (#mum)", **_commonNumTracks),
0290     Plot("RecoAllAssoc2GenMatchedMerged_ResolX_vs_NumTracks_Mean", ytitle="< #delta x > for merged vertices (#mum)", **_commonNumTracks),
0291     #
0292     Plot("RecoPVAssoc2GenPVMatched_ResolY_vs_NumTracks_Mean", ytitle="< #delta y > (#mum) for PV", **_commonNumTracks),
0293     Plot("RecoAllAssoc2GenMatched_ResolY_vs_NumTracks_Mean", ytitle="< #delta y > (#mum)", **_commonNumTracks),
0294     Plot("RecoAllAssoc2GenMatchedMerged_ResolY_vs_NumTracks_Mean", ytitle="< #delta y > for merged vertices (#mum)", **_commonNumTracks),
0295     #
0296     Plot("RecoPVAssoc2GenPVMatched_ResolZ_vs_NumTracks_Mean", ytitle="< #delta z > (#mum) for PV", **_commonNumTracks),
0297     Plot("RecoAllAssoc2GenMatched_ResolZ_vs_NumTracks_Mean", ytitle="< #delta  z > (#mum)", **_commonNumTracks),
0298     Plot("RecoAllAssoc2GenMatchedMerged_ResolZ_vs_NumTracks_Mean", ytitle="< #delta z > for merged vertices (#mum)", **_commonNumTracks),
0299 ], ncols=3)
0300 _commonPt.update(dict(scale=1e4, ymin=_minResidual, ymax=_maxResidual))
0301 _extResidualPt = PlotGroup("residualPt", [
0302     Plot("RecoPVAssoc2GenPVMatched_ResolX_vs_Pt_Mean", ytitle="< #delta x > (#mum) for PV", **_commonPt),
0303     Plot("RecoAllAssoc2GenMatched_ResolX_vs_Pt_Mean", ytitle="< #delta x > (#mum)", **_commonPt),
0304     Plot("RecoAllAssoc2GenMatchedMerged_ResolX_vs_Pt_Mean", ytitle="< #delta x > for merged vertices (#mum)", **_commonPt),
0305     #
0306     Plot("RecoPVAssoc2GenPVMatched_ResolY_vs_Pt_Mean", ytitle="< #delta y > (#mum) for PV", **_commonPt),
0307     Plot("RecoAllAssoc2GenMatched_ResolY_vs_Pt_Mean", ytitle="< #delta y > (#mum)", **_commonPt),
0308     Plot("RecoAllAssoc2GenMatchedMerged_ResolY_vs_Pt_Mean", ytitle="< #delta y > for merged vertices (#mum)", **_commonPt),
0309     #
0310     Plot("RecoPVAssoc2GenPVMatched_ResolZ_vs_Pt_Mean", ytitle="< #delta z > (#mum) for PV", **_commonPt),
0311     Plot("RecoAllAssoc2GenMatched_ResolZ_vs_Pt_Mean", ytitle="< #delta z > (#mum)", **_commonPt),
0312     Plot("RecoAllAssoc2GenMatchedMerged_ResolZ_vs_Pt_Mean", ytitle="< #delta z > for merged vertices (#mum)", **_commonPt),
0313 ], ncols=3)
0314 _commonZ.update(dict(scale=1e4, ymin=_minResidual, ymax=_maxResidual))
0315 _extResidualZ = PlotGroup("residualZ", [
0316     Plot("RecoPVAssoc2GenPVMatched_ResolX_vs_Z_Mean", ytitle="< #delta x > (#mum) for PV", **_commonZ),
0317     Plot("RecoAllAssoc2GenMatched_ResolX_vs_Z_Mean", ytitle="< #delta x > (#mum)", **_commonZ),
0318     Plot("RecoAllAssoc2GenMatchedMerged_ResolX_vs_Z_Mean", ytitle="< #delta x > for merged vertices (#mum)", **_commonZ),
0319     #
0320     Plot("RecoPVAssoc2GenPVMatched_ResolY_vs_Z_Mean", ytitle="< #delta y > (#mum) for PV", **_commonZ),
0321     Plot("RecoAllAssoc2GenMatched_ResolY_vs_Z_Mean", ytitle="< #delta y > (#mum)", **_commonZ),
0322     Plot("RecoAllAssoc2GenMatchedMerged_ResolY_vs_Z_Mean", ytitle="< #delta y > for merged vertices (#mum)", **_commonZ),
0323     #
0324     Plot("RecoPVAssoc2GenPVMatched_ResolZ_vs_Z_Mean", ytitle="< #delta z > (#mum) for PV", **_commonZ),
0325     Plot("RecoAllAssoc2GenMatched_ResolZ_vs_Z_Mean", ytitle="< #delta z > (#mum)", **_commonZ),
0326     Plot("RecoAllAssoc2GenMatchedMerged_ResolZ_vs_Z_Mean", ytitle="< #delta z > for merged vertices (#mum)", **_commonZ),
0327 ], ncols=3)
0328 _commonPU.update(dict(scale=1e4, ymin=_minResidual, ymax=_maxResidual))
0329 _extResidualPU = PlotGroup("residualPU", [
0330     Plot("RecoPVAssoc2GenPVMatched_ResolX_vs_PU_Mean", ytitle="< #delta x > (#mum) for PV", **_commonPU),
0331     Plot("RecoAllAssoc2GenMatched_ResolX_vs_PU_Mean", ytitle="< #delta x > (#mum)", **_commonPU),
0332     Plot("RecoAllAssoc2GenMatchedMerged_ResolX_vs_PU_Mean", ytitle="< #delta x > for merged vertices (#mum)", **_commonPU),
0333     #
0334     Plot("RecoPVAssoc2GenPVMatched_ResolY_vs_PU_Mean", ytitle="< #delta y > (#mum) for PV", **_commonPU),
0335     Plot("RecoAllAssoc2GenMatched_ResolY_vs_PU_Mean", ytitle="< #delta y > (#mum)", **_commonPU),
0336     Plot("RecoAllAssoc2GenMatchedMerged_ResolY_vs_PU_Mean", ytitle="< #delta y > for merged vertices (#mum)", **_commonPU),
0337     #
0338     Plot("RecoPVAssoc2GenPVMatched_ResolZ_vs_PU_Mean", ytitle="< #delta z > (#mum) for PV", **_commonPU),
0339     Plot("RecoAllAssoc2GenMatched_ResolZ_vs_PU_Mean", ytitle="< #delta z > (#mum)", **_commonPU),
0340     Plot("RecoAllAssoc2GenMatchedMerged_ResolZ_vs_PU_Mean", ytitle="< #delta z > for merged vertices (#mum)", **_commonPU),
0341 ], ncols=3)
0342 _extDqm = PlotGroup("dqm", [
0343     Plot("tagVtxTrksVsZ", xtitle="z_{vertex} - z_{beamspot} (cm)", ytitle="Tracks / selected PV"),
0344     Plot("otherVtxTrksVsZ", xtitle="z_{vertex} - z_{beamspot} (cm)", ytitle="Tracks / pileup vertex"),
0345     Plot("vtxNbr", xtitle="Reconstructed vertices", ytitle="Events", stat=True, drawStyle="hist", xmin=_minVtx, xmax=_maxVtx),
0346 ])
0347 _common = dict(ytitle="Vertices", stat=True)
0348 _extDqmDiff = PlotGroup("dqmDiff", [
0349     Plot("tagDiffX", xtitle="PV x_{vertex} - x_{beamspot} (#mum)", **_common),
0350     Plot("otherDiffX", xtitle="Pileup vertex x_{vertex} - x_{beamspot} (#mum)", **_common),
0351     #
0352     Plot("tagDiffY", xtitle="PV y_{vertex} - y_{beamspot} (#mum)", **_common),
0353     Plot("otherDiffY", xtitle="Pileup vertex y_{vertex} - y_{beamspot} (#mum)", **_common),
0354 ])
0355 _extDqmErr = PlotGroup("dqmErr", [
0356     Plot("tagErrX", xtitle="PV uncertainty in x (um)", **_common),
0357     Plot("otherErrX", xtitle="Pileup vertex uncertainty in x (um)", **_common),
0358     #
0359     Plot("otherErrY", xtitle="Pileup vertex uncertainty in y (um)", **_common),
0360     Plot("tagErrY", xtitle="PV uncertainty in y (um)", **_common),
0361     #
0362     Plot("otherErrZ", xtitle="Pileup vertex uncertainty in z (um)", **_common),
0363     Plot("tagErrZ", xtitle="PV uncertainty in z (um)", **_common),
0364 ])
0365 
0366 class VertexSummaryTable:
0367     def __init__(self, page="vertex"):
0368         self._purpose = PlotPurpose.Vertexing
0369         self._page = page
0370 
0371     def getPurpose(self):
0372         return self._purpose
0373 
0374     def getPage(self):
0375         return self._page
0376 
0377     def getSection(self, dqmSubFolder):
0378         return dqmSubFolder
0379 
0380     def create(self, tdirectory):
0381         def _formatOrNone(num, func):
0382             if num is None:
0383                 return None
0384             return func(num)
0385 
0386         ret = []
0387         h = tdirectory.Get("TruePVLocationIndexCumulative")
0388         if h:
0389             n_events = h.GetEntries()
0390             n_pvtagged = h.GetBinContent(2)
0391             ret.extend([int(n_events), "%.4f"%(float(n_pvtagged)/float(n_events))])
0392         else:
0393             ret.extend([None, None])
0394 
0395         h = tdirectory.Get("globalEfficiencies")
0396         if h:
0397             d = {}
0398             for i in range(1, h.GetNbinsX()+1):
0399                 d[h.GetXaxis().GetBinLabel(i)] = h.GetBinContent(i)
0400             ret.extend([
0401                 _formatOrNone(d.get("effic_vs_Z", None), lambda n: "%.4f"%n),
0402                 _formatOrNone(d.get("fakerate_vs_Z", None), lambda n: "%.4f"%n),
0403                 _formatOrNone(d.get("merged_vs_Z", None), lambda n: "%.4f"%n),
0404                 _formatOrNone(d.get("duplicate_vs_Z", None), lambda n: "%.4f"%n),
0405             ])
0406         else:
0407             ret.extend([None]*4)
0408 
0409         if ret.count(None) == len(ret):
0410             return None
0411 
0412         return ret
0413 
0414     def headers(self):
0415         return [
0416             "Events",
0417             "PV reco+tag efficiency",
0418             "Efficiency",
0419             "Fake rate",
0420             "Merge rate",
0421             "Duplicate rate",
0422         ]
0423 
0424 _vertexFolders = [
0425     "DQMData/Run 1/Vertexing/Run summary/PrimaryVertex",
0426     "DQMData/Vertexing/PrimaryVertex",
0427     "DQMData/Run 1/Vertexing/Run summary/PrimaryVertexV",
0428     "DQMData/Vertexing/PrimaryVertexV",
0429 ]
0430 _vertexDqmFolders = [
0431     "DQMData/Run 1/OfflinePV/Run summary/offlinePrimaryVertices",
0432     "DQMData/OffinePV/offlinePrimaryVertices",
0433 ]
0434 _v0Folders = [
0435     "DQMData/Run 1/Vertexing/Run summary/V0",
0436     "DQMData/Vertexing/V0",
0437     "DQMData/Run 1/Vertexing/Run summary/V0V",
0438     "DQMData/Vertexing/V0V",
0439 ]
0440 plotter = Plotter()
0441 plotterExt = Plotter()
0442 plotter.append("", _vertexFolders, PlotFolder(
0443     _recovsgen,
0444     _pvtagging,
0445     _effandfake,
0446     _resolution,
0447     _resolutionNumTracks,
0448     _resolutionPt,
0449     _pull,
0450     _pullNumTracks,
0451     _pullPt,
0452     _puritymissing,
0453     _sumpt2,
0454     purpose=PlotPurpose.Vertexing,
0455     page="vertex"
0456 ))
0457 plotter.appendTable("", _vertexFolders, VertexSummaryTable())
0458 plotter.append("K0", [x+"/K0" for x in _v0Folders], PlotFolder(
0459     _k0_effandfake,
0460     _k0_effandfakeTk,
0461     _k0_mass,
0462     loopSubFolders=False,
0463     purpose=PlotPurpose.Vertexing,
0464     page="v0", section="k0"
0465 ))
0466 plotter.append("Lambda", [x+"/Lambda" for x in _v0Folders], PlotFolder(
0467     _lambda_effandfake,
0468     _lambda_effandfakeTk,
0469     _lambda_mass,
0470     loopSubFolders=False,
0471     purpose=PlotPurpose.Vertexing,
0472     page="v0", section="lambda"
0473 ))
0474 plotterExt.append("", _vertexFolders, PlotFolder(
0475     _extDist,
0476     _extResolutionZ,
0477     _extResolutionPU,
0478     _extPullZ,
0479     _extPullPU,
0480     _extResidualNumTracks,
0481     _extResidualPt,
0482     _extResidualZ,
0483     _extResidualPU,
0484     purpose=PlotPurpose.Vertexing,
0485     page="vertex",
0486     onlyForPileup=True,
0487     numberOfEventsHistogram=_vertexNumberOfEventsHistogram
0488 ))
0489 plotterExt.append("dqm", _vertexDqmFolders, PlotFolder(
0490     _extDqm,
0491     _extDqmDiff,
0492     _extDqmErr,
0493     loopSubFolders=False,
0494     purpose=PlotPurpose.Vertexing,
0495     page="vertex",
0496     section="offlinePrimaryVertices",
0497     onlyForPileup=True
0498 ))
0499 plotterExt.append("gen", _vertexFolders, PlotFolder(
0500     _extGenpos,
0501     loopSubFolders=False,
0502     purpose=PlotPurpose.Vertexing,
0503     page="vertex",
0504     section="genvertex",
0505     onlyForPileup=True
0506 ))
0507 
0508 class VertexValidation(validation.Validation):
0509     def _init__(self, *args, **kwargs):
0510         super(TrackingValidation, self).__init__(*args, **kwargs)
0511 
0512     def _getDirectoryName(self, quality, algo):
0513         return algo
0514 
0515     def _getSelectionName(self, quality, algo):
0516         if algo is None:
0517             return ""
0518         return "_"+algo