Skip to content

Commit

Permalink
Merge pull request cms-sw#21128 from makortel/trackingValidation_v11
Browse files Browse the repository at this point in the history
Update tracking MC validation scripts
  • Loading branch information
cmsbuild authored Nov 2, 2017
2 parents 70ca28e + 3be9be7 commit ce1cab6
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 39 deletions.
8 changes: 4 additions & 4 deletions Validation/RecoTrack/python/plotting/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ def _allToHP(s):
return s.replace("All", "High purity")
def _allToBTV(s):
return s.replace("All", "BTV-like")
def _byOriginalAlgo(s):
return s.replace("tracks", "tracks by originalAlgo")
def _ptCut(s):
return s.replace("Tracks", "Tracks pT > 0.9 GeV").replace("tracks", "tracks pT > 0.9 GeV")
_trackQualityNameOrder = collections.OrderedDict([
Expand All @@ -82,8 +80,10 @@ def _ptCut(s):
("highPurityByAlgoMask", _toAlgoMask(_toHP(_allName))),
("tpPtLess09_", _tpPtLess09Name),
("tpPtLess09_highPurity", _allToHP(_tpPtLess09Name)),
("tpPtLess09_ByOriginalAlgo", _byOriginalAlgo(_tpPtLess09Name)),
("tpPtLess09_highPurityByOriginalAlgo", _byOriginalAlgo(_allToHP(_tpPtLess09Name))),
("tpPtLess09_ByOriginalAlgo", _toOriAlgo(_tpPtLess09Name)),
("tpPtLess09_highPurityByOriginalAlgo", _toOriAlgo(_allToHP(_tpPtLess09Name))),
("tpPtLess09_ByAlgoMask", _toAlgoMask(_tpPtLess09Name)),
("tpPtLess09_highPurityByAlgoMask", _toAlgoMask(_allToHP(_tpPtLess09Name))),
("btvLike", _allToBTV(_allName)),
("ak4PFJets", "AK4 PF jets"),
("allTPEffic_", _allTPEfficName),
Expand Down
61 changes: 31 additions & 30 deletions Validation/RecoTrack/python/plotting/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1180,14 +1180,15 @@ def create(self, tdirectory):
_plotStylesColor = [4, 2, ROOT.kBlack, ROOT.kOrange+7, ROOT.kMagenta-3]
_plotStylesMarker = [21, 20, 22, 34, 33]

def _drawFrame(pad, bounds, xbinlabels=None, xbinlabelsize=None, xbinlabeloption=None, ybinlabels=None, suffix=""):
def _drawFrame(pad, bounds, zmax=None, xbinlabels=None, xbinlabelsize=None, xbinlabeloption=None, ybinlabels=None, suffix=""):
"""Function to draw a frame
Arguments:
pad -- TPad to where the frame is drawn
bounds -- List or 4-tuple for (xmin, ymin, xmax, ymax)
Keyword arguments:
zmax -- Maximum Z, needed for TH2 histograms
xbinlabels -- Optional list of strings for x axis bin labels
xbinlabelsize -- Optional number for the x axis bin label size
xbinlabeloption -- Optional string for the x axis bin options (passed to ROOT.TH1.LabelsOption())
Expand All @@ -1206,6 +1207,7 @@ def _drawFrame(pad, bounds, xbinlabels=None, xbinlabelsize=None, xbinlabeloption
else:
ybins = len(ybinlabels)
frame = ROOT.TH2F("hframe"+suffix, "", nbins,bounds[0],bounds[2], ybins,bounds[1],bounds[3])
frame.SetMaximum(zmax)

frame.SetBit(ROOT.TH1.kNoStats)
frame.SetBit(ROOT.kCanDelete)
Expand All @@ -1232,9 +1234,9 @@ def _drawFrame(pad, bounds, xbinlabels=None, xbinlabelsize=None, xbinlabeloption

class Frame:
"""Class for creating and managing a frame for a simple, one-pad plot"""
def __init__(self, pad, bounds, nrows, xbinlabels=None, xbinlabelsize=None, xbinlabeloption=None, ybinlabels=None):
def __init__(self, pad, bounds, zmax, nrows, xbinlabels=None, xbinlabelsize=None, xbinlabeloption=None, ybinlabels=None):
self._pad = pad
self._frame = _drawFrame(pad, bounds, xbinlabels, xbinlabelsize, xbinlabeloption, ybinlabels)
self._frame = _drawFrame(pad, bounds, zmax, xbinlabels, xbinlabelsize, xbinlabeloption, ybinlabels)

yoffsetFactor = 1
xoffsetFactor = 1
Expand Down Expand Up @@ -1305,15 +1307,15 @@ def redrawAxis(self):

class FrameRatio:
"""Class for creating and managing a frame for a ratio plot with two subpads"""
def __init__(self, pad, bounds, ratioBounds, ratioFactor, nrows, xbinlabels=None, xbinlabelsize=None, xbinlabeloption=None, ratioYTitle=_ratioYTitle):
def __init__(self, pad, bounds, zmax, ratioBounds, ratioFactor, nrows, xbinlabels=None, xbinlabelsize=None, xbinlabeloption=None, ratioYTitle=_ratioYTitle):
self._parentPad = pad
self._pad = pad.cd(1)
if xbinlabels is not None:
self._frame = _drawFrame(self._pad, bounds, [""]*len(xbinlabels))
self._frame = _drawFrame(self._pad, bounds, zmax, [""]*len(xbinlabels))
else:
self._frame = _drawFrame(self._pad, bounds)
self._frame = _drawFrame(self._pad, bounds, zmax)
self._padRatio = pad.cd(2)
self._frameRatio = _drawFrame(self._padRatio, ratioBounds, xbinlabels, xbinlabelsize, xbinlabeloption)
self._frameRatio = _drawFrame(self._padRatio, ratioBounds, zmax, xbinlabels, xbinlabelsize, xbinlabeloption)

self._frame.GetXaxis().SetLabelSize(0)
self._frame.GetXaxis().SetTitleSize(0)
Expand Down Expand Up @@ -1446,11 +1448,6 @@ def __init__(self, pad, bounds, histos, ratioOrig, ratioFactor):
self._pad.SetTopMargin(topMarginNew)
self._pad.SetBottomMargin(bottomMarginNew)

self._view = ROOT.TView.CreateView()
self._view.SetRange(bounds[0], bounds[1], 0, bounds[2], bounds[3], 20) # 20 is from Harrison-Stetson, may need tuning?
self._view.Top()
self._view.ShowAxis()

self._xtitleoffset = 1.8
self._ytitleoffset = 2.3

Expand Down Expand Up @@ -1507,28 +1504,26 @@ def setZTitleOffset(self, offset):
self._firstHisto.GetZaxis().SetTitleOffset(offset)

def redrawAxis(self):
# Disabling and enabled the 3D rulers somehow magically moves the axes to their proper places
ROOT.TAxis3D.ToggleRulers()
ROOT.TAxis3D.ToggleRulers()
axis = ROOT.TAxis3D.GetPadAxis()
axis.SetLabelColor(ROOT.kBlack);
axis.SetAxisColor(ROOT.kBlack);
# set top view
epsilon = 1e-7
self._pad.SetPhi(epsilon)
self._pad.SetTheta(90+epsilon)

axis.GetXaxis().SetTitleOffset(self._xtitleoffset)
axis.GetYaxis().SetTitleOffset(self._ytitleoffset)
self._firstHisto.GetXaxis().SetTitleOffset(self._xtitleoffset)
self._firstHisto.GetYaxis().SetTitleOffset(self._ytitleoffset)

if hasattr(self, "_xtitle"):
axis.GetXaxis().SetTitle(self._xtitle)
self._firstHisto.GetXaxis().SetTitle(self._xtitle)
if hasattr(self, "_xtitlesize"):
axis.GetXaxis().SetTitleSize(self._xtitlesize)
self._firstHisto.GetXaxis().SetTitleSize(self._xtitlesize)
if hasattr(self, "_xlabelsize"):
axis.GetXaxis().SetLabelSize(self._labelsize)
self._firstHisto.GetXaxis().SetLabelSize(self._labelsize)
if hasattr(self, "_ytitle"):
axis.GetYaxis().SetTitle(self._ytitle)
self._firstHisto.GetYaxis().SetTitle(self._ytitle)
if hasattr(self, "_ytitlesize"):
axis.GetYaxis().SetTitleSize(self._ytitlesize)
self._firstHisto.GetYaxis().SetTitleSize(self._ytitlesize)
if hasattr(self, "_ytitleoffset"):
axis.GetYaxis().SetTitleOffset(self._ytitleoffset)
self._firstHisto.GetYaxis().SetTitleOffset(self._ytitleoffset)

class PlotText:
"""Abstraction on top of TLatex"""
Expand Down Expand Up @@ -2087,6 +2082,9 @@ def _styleHist(h, msty, col):
bounds = _findBounds(histos, self._ylog,
xmin=self._xmin, xmax=self._xmax,
ymin=self._ymin, ymax=self._ymax)
zmax = None
if isinstance(histos[0], ROOT.TH2):
zmax = max([h.GetMaximum() for h in histos])

# need to keep these in memory
self._mainAdditional = []
Expand Down Expand Up @@ -2135,9 +2133,9 @@ def _styleHist(h, msty, col):
else:
if ratio:
ratioBounds = (bounds[0], ratioBoundsY[0], bounds[2], ratioBoundsY[1])
frame = FrameRatio(pad, bounds, ratioBounds, ratioFactor, nrows, xbinlabels, self._xbinlabelsize, self._xbinlabeloption)
frame = FrameRatio(pad, bounds, zmax, ratioBounds, ratioFactor, nrows, xbinlabels, self._xbinlabelsize, self._xbinlabeloption)
else:
frame = Frame(pad, bounds, nrows, xbinlabels, self._xbinlabelsize, self._xbinlabeloption, ybinlabels=ybinlabels)
frame = Frame(pad, bounds, zmax, nrows, xbinlabels, self._xbinlabelsize, self._xbinlabeloption, ybinlabels=ybinlabels)

# Set log and grid
frame.setLogx(self._xlog)
Expand Down Expand Up @@ -2187,8 +2185,11 @@ def _styleHist(h, msty, col):
if ratio:
frame._pad.cd()

for h in histos:
h.Draw(opt)
for i, h in enumerate(histos):
o = opt
if isTGraph2D and i == 0:
o = o.replace("sames", "")
h.Draw(o)

for addl in self._mainAdditional:
addl.Draw("same")
Expand Down
2 changes: 1 addition & 1 deletion Validation/RecoTrack/python/plotting/trackingPlots.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def _makeMVAPlots(num, hp=False):
_makeEffFakeDupPlots("pu" , "PU" , common=dict(xtitle="Pileup", xmin=_minPU, xmax=_maxPU)),
legendDy=_legendDy_4rows
)
_algos_common = dict(removeEmptyBins=True, xbinlabelsize=10, xinlabeloption="d")
_algos_common = dict(removeEmptyBins=True, xbinlabelsize=10, xbinlabeloption="d")
_duplicateAlgo = PlotOnSideGroup("duplicateAlgo", Plot("duplicates_oriAlgo_vs_oriAlgo", drawStyle="COLZ", adjustMarginLeft=0.1, adjustMarginRight=0.1, **_algos_common))

_dupandfakePtEtaPhi = PlotGroup("dupandfakePtEtaPhi", [
Expand Down
26 changes: 26 additions & 0 deletions Validation/RecoTrack/python/plotting/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,31 @@
"CMSSW_9_3_0_pre2_phase1": {"default": "92X_upgrade2017_realistic_v7",
"fullsim_25ns_PU50": "92X_upgrade2017_realistic_v7_highPU_AVE50_resub",
"Design": "92X_upgrade2017_design_IdealBS_v7"},
"CMSSW_9_3_0_pre3": {"default": "92X_mcRun2_asymptotic_v2"},
"CMSSW_9_3_0_pre3_phase1": {"default": "92X_upgrade2017_realistic_v10_resub",
"fullsim_25ns_PU50": "92X_upgrade2017_realistic_v10_highPU_AVE50_resub",
"Design": "92X_upgrade2017_design_IdealBS_v10_resub"},
"CMSSW_9_3_0_pre3_phase1_pmx": {"default": "92X_upgrade2017_realistic_v10_resub2"},
"CMSSW_9_3_0_pre4": {"default": "93X_mcRun2_asymptotic_v0"},
"CMSSW_9_3_0_pre4_phase1": {"default": "93X_mc2017_realistic_v1",
"fullsim_25ns_PU50": "93X_mc2017_realistic_v1_highPU_AVE50",
"Design": "93X_mc2017_design_IdealBS_v1"},
"CMSSW_9_3_0_pre5": {"default": "93X_mcRun2_asymptotic_v0"},
"CMSSW_9_3_0_pre5_phase1": {"default": "93X_mc2017_realistic_v2",
"fullsim_25ns_PU50": "93X_mc2017_realistic_v2_highPU_AVE50",
"Design": "93X_mc2017_design_IdealBS_v2"},
"CMSSW_9_4_0_pre1": {"default": "93X_mcRun2_asymptotic_v1"},
"CMSSW_9_4_0_pre1_phase1": {"default": "93X_mc2017_realistic_v3",
"fullsim_25ns_PU50": "93X_mc2017_realistic_v3_highPU_AVE50",
"Design": "93X_mc2017_design_IdealBS_v3"},
"CMSSW_9_4_0_pre2": {"default": "93X_mcRun2_asymptotic_v2"},
"CMSSW_9_4_0_pre2_phase1": {"default": "94X_mc2017_realistic_v1",
"fullsim_25ns_PU50": "94X_mc2017_realistic_v1_highPU_AVE50",
"Design": "94X_mc2017_design_IdealBS_v0"},
"CMSSW_9_4_0_pre3": {"default": "94X_mcRun2_asymptotic_v0"},
"CMSSW_9_4_0_pre3_phase1": {"default": "94X_mc2017_realistic_v4",
"fullsim_25ns_PU50": "94X_mc2017_realistic_v4_highPU_AVE50",
"Design": "94X_mc2017_design_IdealBS_v4"},
}

_releasePostfixes = ["_AlcaCSA14", "_PHYS14", "_TEST", "_v2", "_v3", "_pmx", "_Fall14DR", "_FIXGT", "_PU", "_PXbest", "_PXworst", "_hcal", "_tec", "_71XGENSIM", "_73XGENSIM", "_BS", "_GenSim_7113", "_extended",
Expand Down Expand Up @@ -369,6 +394,7 @@ def _getGlobalTag(sample, release):
"9_1_X": "https://cmsweb.cern.ch/dqm/relval/data/browse/ROOT/RelVal/CMSSW_9_1_x/",
"9_2_X": "https://cmsweb.cern.ch/dqm/relval/data/browse/ROOT/RelVal/CMSSW_9_2_x/",
"9_3_X": "https://cmsweb.cern.ch/dqm/relval/data/browse/ROOT/RelVal/CMSSW_9_3_x/",
"9_4_X": "https://cmsweb.cern.ch/dqm/relval/data/browse/ROOT/RelVal/CMSSW_9_4_x/",
}

_doElectronSamples = [
Expand Down
10 changes: 6 additions & 4 deletions Validation/RecoTrack/test/trackingPerformanceValidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
########### User Defined Variables (BEGIN) ##############

### Reference release
RefRelease='CMSSW_9_3_0_pre1_phase1'
RefRelease='CMSSW_9_4_0_pre2_phase1'

### Relval release (set if different from $CMSSW_VERSION)
NewRelease='CMSSW_9_3_0_pre2_phase1'
NewRelease='CMSSW_9_4_0_pre3_phase1'

### This is the list of IDEAL-conditions relvals
startupsamples_run1 = [
Expand Down Expand Up @@ -47,7 +47,7 @@
Sample('RelValSingleMuPt10', midfix="UP15"),
Sample('RelValSingleMuPt100', midfix="UP15")
]
if "CMSSW_9_1" in NewRelease or "CMSSW_9_2" in NewRelease or "CMSSW_9_3" in NewRelease:
if "CMSSW_9_1" in NewRelease or "CMSSW_9_2" in NewRelease or "CMSSW_9_3" in NewRelease or "CMSSW_9_4" in NewRelease:
startupsamples = [] # no phase0 in 91X
#startupsamples = []
#startupsamples = startupsamples_run1
Expand Down Expand Up @@ -182,7 +182,8 @@ def limitProcessing(algo, quality):
return algo in Algos and quality in Qualities

def limitRelVal(algo, quality):
return quality in ["", "highPurity"]
qual = quality.replace("ByOriginalAlgo", "") # include ByOriginalAlgo
return qual in ["", "highPurity"]

def ignore(a, q):
return False
Expand All @@ -191,6 +192,7 @@ def ignore(a, q):
"limitSubFoldersOnlyTo": {
# filter out the pT>0.9 GeV track selection
"": limitRelVal,
"tpPtLess09": limitRelVal,
"allTPEffic": limitRelVal,
"fromPV": limitRelVal,
"fromPVAllTP": limitRelVal,
Expand Down

0 comments on commit ce1cab6

Please sign in to comment.