def PlotSignalBackground(datasetsMgr, hG, hF, intLumi): kwargs = {} _kwargs = {} if opts.normaliseToOne: pG = plots.MCPlot(datasetsMgr, hG, normalizeToOne=True, saveFormats=[], **_kwargs) pF = plots.MCPlot(datasetsMgr, hF, normalizeToOne=True, saveFormats=[], **_kwargs) else: pG = plots.MCPlot(datasetsMgr, hG, normalizeToLumi=intLumi, saveFormats=[], **_kwargs) pF = plots.MCPlot(datasetsMgr, hF, normalizeToLumi=intLumi, saveFormats=[], **_kwargs) # Draw the histograms _cutBox = None _rebinX = 1 _format = "%0.2f" _xlabel = None logY = False _opts = {"ymin": 0, "ymaxfactor": 1.1} if "mass" in hG.lower(): _units = "GeV/c^{2}" _format = "%0.0f " + _units _xlabel = "M (%s)" % _units if "trijetmass" in hG.lower(): _units = "GeV/c^{2}" _format = "%0.0f " + _units _xlabel = "m_{top} (%s)" % _units #_cutBox = {"cutValue": 173.21, "fillColor": 16, "box": False, "line": True, "greaterThan": True} _opts["xmax"] = 805 #1005 _opts = {"xmin": 0.0, "xmax": 805} if "bjetmass" in hG.lower(): _xlabel = "m_{b-tagged jet} (%s)" % _units _opts["xmax"] = 50 if "bjetldgjet_mass" in hG.lower(): _xlabel = "m_{b, ldg jet} (%s)" % _units _opts["xmax"] = 705 if "bjetsubldgjet_mass" in hG.lower(): _xlabel = "m_{b-tagged, subldg jet} (%s)" % _units _opts["xmax"] = 705 if "jet_mass" in hG.lower(): _opts["xmax"] = 750 if "mult" in hG.lower(): _format = "%0.0f" if "ldg" in hG.lower(): _xlabel = "Leading jet mult" if "subldg" in hG.lower(): _xlabel = "Subleading jet mult" if "avg" in hG.lower(): _xlabel = "avg CvsL" if "cvsl" in hG.lower(): _format = "%0.2f" if "ldg" in hG.lower(): _xlabel = "Leading jet CvsL" if "subldg" in hG.lower(): _xlabel = "Subleading jet CvsL" if "avg" in hG.lower(): _xlabel = "avg CvsL" if "axis2" in hG.lower(): _format = "%0.3f" if "ldg" in hG.lower(): _xlabel = "Leading jet axis2" if "subldg" in hG.lower(): _xlabel = "Subleading jet axis2" if "avg" in hG.lower(): _xlabel = "avg axis2" if "dijetmass" in hG.lower(): _units = "GeV/c^{2}" _format = "%0.0f " + _units _xlabel = "m_{W} (%s)" % _units _opts["xmax"] = 600 _opts = {"xmin": 0.0, "xmax": 605, "ymin": 1e-3, "ymaxfactor": 1.0} if "trijetptdr" in hG.lower(): _opts["xmax"] = 800 _format = "%0.0f" _xlabel = "p_{T}#Delta R_{t}" if "dijetptdr" in hG.lower(): _opts["xmax"] = 800 _format = "%0.0f" _xlabel = "p_{T}#Delta R_{W}" if "dgjetptd" in hG.lower(): _format = "%0.2f" _xlabel = "Leading jet p_{T}D" if "subldg" in hG.lower(): _xlabel = "Subleading jet p_{T}D" if "bdisc" in hG.lower(): _format = "%0.2f" if "subldg" in hG.lower(): _xlabel = "Subleading jet CSV" _opts = {"ymin": 1e-3, "ymax": 0.06} elif "ldg" in hG.lower(): _xlabel = "Leading jet CSV" _opts = {"ymin": 1e-3, "ymax": 0.06} else: _xlabel = "b-tagged jet CSV" _opts = {"ymin": 1e-3, "ymax": 0.35} if "over" in hG.lower(): _format = "%0.2f " _xlabel = "m_{W}/m_{t}" _opts["xmax"] = 1 _opts["xmin"] = 0 if "likelihood" in hG.lower(): _format = "%0.2f" if "ldg" in hG.lower(): _xlabel = "Leading jet QGL" if "subldg" in hG.lower(): _xlabel = "Subleading jet QGL" if "avg" in hG.lower(): _xlabel = "avg QGL" else: pass ''' if "bdisc" in hG.lower(): _format = "%0.2f" if "subldg" in hG.lower(): _xlabel = "Subleading jet CSV" elif "ldg" in hG.lower(): _xlabel = "Leading jet CSV" else: _xlabel = "b-tagged jet CSV" ''' if logY: yMaxFactor = 2.0 else: yMaxFactor = 1.2 _opts["ymaxfactor"] = yMaxFactor if opts.normaliseToOne: _opts["ymin"] = 1e-3 else: _opts["ymin"] = 1e0 myList = [] # Customise styling pG.histoMgr.forEachHisto( lambda h: h.getRootHisto().SetLineStyle(ROOT.kSolid)) pF.histoMgr.forEachHisto( lambda h: h.getRootHisto().SetLineStyle(ROOT.kSolid)) #Dataset: ttbar dataset = datasetsMgr.getDataset(opts.dataset) #soti #dataset = datasetsMgr.getDataset("ChargedHiggs_HplusTB_HplusToTB_M_1000") #Get Genuine-top histogram h = dataset.getDatasetRootHisto(hG) h.normalizeToOne() HG = h.getHistogram() #Get Fake-top histogram h = dataset.getDatasetRootHisto(hF) h.normalizeToOne() HF = h.getHistogram() #Define Signal style altSignalBDTGStyle = styles.StyleCompound([ styles.StyleMarker(markerSize=1.2, markerColor=ROOT.kAzure + 9, markerSizes=None, markerStyle=ROOT.kFullDiamond), styles.StyleLine(lineColor=ROOT.kAzure + 9, lineStyle=ROOT.kSolid, lineWidth=3), styles.StyleFill(fillColor=ROOT.kAzure + 9) ]) #Define Background style altBackgroundBDTGStyle = styles.StyleCompound([ styles.StyleMarker(markerSize=1.2, markerColor=ROOT.kRed - 4, markerSizes=None, markerStyle=ROOT.kFullDiamond), styles.StyleLine(lineColor=ROOT.kRed - 4, lineStyle=ROOT.kSolid, lineWidth=3), styles.StyleFill(fillColor=ROOT.kRed - 4, fillStyle=3001) ]) signalBDTGStyle = styles.StyleCompound([ styles.StyleMarker(markerSize=1.2, markerColor=ROOT.kTeal + 2, markerSizes=None, markerStyle=ROOT.kFullTriangleUp), styles.StyleLine(lineColor=ROOT.kTeal + 2, lineStyle=ROOT.kSolid, lineWidth=3), styles.StyleFill(fillColor=ROOT.kTeal + 2) ]) #, fillStyle=3001)]) signalGrayStyle = styles.StyleCompound([ styles.StyleMarker(markerSize=1.2, markerColor=ROOT.kGray + 1, markerSizes=None, markerStyle=ROOT.kFullDiamond), styles.StyleLine(lineColor=ROOT.kGray + 1, lineStyle=ROOT.kSolid, lineWidth=3), styles.StyleFill(fillColor=ROOT.kGray + 1) ]) backgroundGrayStyle = styles.StyleCompound([ styles.StyleMarker(markerSize=1.2, markerColor=ROOT.kGray + 3, markerSizes=None, markerStyle=ROOT.kFullDiamond), styles.StyleLine(lineColor=ROOT.kGray + 3, lineStyle=ROOT.kSolid, lineWidth=3), styles.StyleFill(fillColor=ROOT.kGray + 3, fillStyle=3001) ]) #Comparison Plot p = plots.ComparisonPlot( histograms.Histo(HF, "Fake", "p", "P"), histograms.Histo(HG, "Genuine", "pl", "PL"), ) #Set labels p.histoMgr.setHistoLegendLabelMany({ "Fake": "Unmatched", "Genuine": "Truth-matched" }) #Set Draw style p.histoMgr.forHisto("Fake", altBackgroundBDTGStyle) p.histoMgr.setHistoDrawStyle("Fake", "LP") p.histoMgr.setHistoLegendStyle("Fake", "LP") #F p.histoMgr.forHisto("Genuine", altSignalBDTGStyle) p.histoMgr.setHistoDrawStyle("Genuine", "HIST") p.histoMgr.setHistoLegendStyle("Genuine", "LP") #LP if "avg" in hG.lower() or "likelihood" in hG.lower() or "over" in hG.lower( ): p.histoMgr.forHisto("Genuine", signalBDTGStyle) p.histoMgr.setHistoDrawStyle("Genuine", "HIST") p.histoMgr.setHistoLegendStyle("Genuine", "LP") #LP if "Gray" in opts.mcrab: p.histoMgr.forHisto("Fake", backgroundGrayStyle) p.histoMgr.forHisto("Genuine", signalGrayStyle) histoG = histograms.Histo(HG, "TT", "Signal") histoG.setIsDataMC(isData=False, isMC=True) histoF = histograms.Histo(HF, "QCD", "Signal") histoF.setIsDataMC(isData=False, isMC=True) styleG = styles.ttStyle styleF = styles.signalStyleHToTB1000 styleG.apply(HG) styleF.apply(HF) myList.append(histoG) myList.append(histoF) _kwargs = { "xlabel": _xlabel, "ylabel": "Arbitrary Units / %s" % (_format), "ratioYlabel": "Ratio ", "ratio": False, "ratioInvert": False, "stackMCHistograms": False, "addMCUncertainty": False, "addLuminosityText": False, "addCmsText": True, "cmsExtraText": "Preliminary", #"opts" : {"ymin": 0.0, "ymaxfactor": 1.1}, "opts": _opts, "opts2": { "ymin": 0.6, "ymax": 1.5 }, "log": False, #"createLegend" : {"x1": 0.5, "y1": 0.75, "x2": 0.9, "y2": 0.9}, "createLegend": { "x1": 0.58, "y1": 0.65, "x2": 0.92, "y2": 0.82 }, } # Save plot in all formats saveName = hG.split("/")[-1] #plots.drawPlot(p, saveName, **_kwargs) savePath = os.path.join(opts.saveDir + ANALYSISNAME, "HplusMasses", hG.split("/")[0], opts.optMode) plots.drawPlot(p, savePath, **_kwargs) SavePlot(p, saveName, os.path.join(opts.saveDir + opts.mcrab, opts.optMode), saveFormats=[".png"]) return
def PlotSignalBackground(datasetsMgr, hG, hF, intLumi): kwargs = {} _kwargs = {} #kwargs = GetHistoKwargs(hG, opts) if opts.normaliseToOne: pG = plots.MCPlot(datasetsMgr, hG, normalizeToOne=True, saveFormats=[], **_kwargs) pF = plots.MCPlot(datasetsMgr, hF, normalizeToOne=True, saveFormats=[], **_kwargs) else: pG = plots.MCPlot(datasetsMgr, hG, normalizeToLumi=intLumi, saveFormats=[], **_kwargs) pF = plots.MCPlot(datasetsMgr, hF, normalizeToLumi=intLumi, saveFormats=[], **_kwargs) # Draw the histograms _cutBox = None _rebinX = 1 _format = "%0.2f" _xlabel = None logY = False _opts = {"ymin": 1e-3, "ymaxfactor": 1.0} if "mass" in hG.lower(): _units = "GeV/c^{2}" _format = "%0.0f " + _units _xlabel = "M (%s)" % _units if "trijetmass" in hG.lower(): _units = "GeV/c^{2}" _format = "%0.0f " + _units _xlabel = "m_{top} (%s)" % _units #_cutBox = {"cutValue": 173.21, "fillColor": 16, "box": False, "line": True, "greaterThan": True} _opts["xmax"] = 805 #1005 if "bjetmass" in hG.lower(): _xlabel = "m_{b-tagged jet} (%s)" % _units _opts["xmax"] = 50 if "bjetldgjet_mass" in hG.lower(): _xlabel = "m_{b, ldg jet} (%s)" % _units if "bjetsubldgjet_mass" in hG.lower(): _xlabel = "m_{b-tagged, subldg jet} (%s)" % _units if "jet_mass" in hG.lower(): _opts["xmax"] = 750 if "mult" in hG.lower(): _format = "%0.0f" _xlabel = "Leading jet mult" if "subldg" in hG.lower(): _xlabel = "Subleading jet mult" if "cvsl" in hG.lower(): _format = "%0.2f" _xlabel = "Leading jet CvsL" if "subldg" in hG.lower(): _xlabel = "Subleading jet CvsL" if "axis2" in hG.lower(): _format = "%0.3f" _xlabel = "Leading jet axis2" if "subldg" in hG.lower(): _xlabel = "Subleading jet axis2" if "dijetmass" in hG.lower(): _units = "GeV/c^{2}" _format = "%0.0f " + _units _xlabel = "m_{W} (%s)" % _units _opts["xmax"] = 600 if "trijetptdr" in hG.lower(): _opts["xmax"] = 800 _format = "%0.0f" _xlabel = "p_{T}#Delta R_{t}" if "dijetptdr" in hG.lower(): _opts["xmax"] = 800 _format = "%0.0f" _xlabel = "p_{T}#Delta R_{W}" if "dgjetptd" in hG.lower(): _format = "%0.2f" _xlabel = "Leading jet p_{T}D" if "subldg" in hG.lower(): _xlabel = "Subleading jet p_{T}D" else: pass ''' if "bdisc" in hG.lower(): _format = "%0.2f" if "subldg" in hG.lower(): _xlabel = "Subleading jet CSV" elif "ldg" in hG.lower(): _xlabel = "Leading jet CSV" else: _xlabel = "b-tagged jet CSV" ''' if logY: yMaxFactor = 2.0 else: yMaxFactor = 1.2 _opts["ymaxfactor"] = yMaxFactor if opts.normaliseToOne: _opts["ymin"] = 1e-3 else: _opts["ymin"] = 1e0 if "bdisc" in hG.lower(): _format = "%0.2f" if "subldg" in hG.lower(): _xlabel = "Subleading jet CSV" _opts = {"ymin": 1e-3, "ymax": 0.06} elif "ldg" in hG.lower(): _xlabel = "Leading jet CSV" _opts = {"ymin": 1e-3, "ymax": 0.06} else: _xlabel = "b-tagged jet CSV" _opts = {"ymin": 1e-3, "ymax": 0.35} myList = [] # Customise styling pG.histoMgr.forEachHisto( lambda h: h.getRootHisto().SetLineStyle(ROOT.kSolid)) pF.histoMgr.forEachHisto( lambda h: h.getRootHisto().SetLineStyle(ROOT.kSolid)) ''' plots.drawPlot(pG, hG, xlabel = _xlabel, ylabel = "Arbitrary Units / %s" % (_format), log = logY, rebinX = _rebinX, cmsExtraText = "Preliminary", createLegend = {"x1": 0.58, "y1": 0.65, "x2": 0.92, "y2": 0.92}, opts = _opts, opts2 = {"ymin": 0.6, "ymax": 1.4}, cutBox = _cutBox, ) plots.drawPlot(pF, hF, xlabel = _xlabel, ylabel = "Arbitrary Units / %s" % (_format), log = logY, rebinX = _rebinX, cmsExtraText = "Preliminary", createLegend = {"x1": 0.58, "y1": 0.65, "x2": 0.92, "y2": 0.92}, opts = _opts, opts2 = {"ymin": 0.6, "ymax": 1.4}, cutBox = _cutBox, ) ''' dataset = datasetsMgr.getDataset("TT") h = dataset.getDatasetRootHisto(hG) h.normalizeToOne() HG = h.getHistogram() h = dataset.getDatasetRootHisto(hF) h.normalizeToOne() HF = h.getHistogram() altSignalBDTGStyle = styles.StyleCompound([ styles.StyleMarker(markerSize=1.2, markerColor=ROOT.kAzure + 9, markerSizes=None, markerStyle=ROOT.kFullDiamond), styles.StyleLine(lineColor=ROOT.kAzure + 9, lineStyle=ROOT.kSolid, lineWidth=3), styles.StyleFill(fillColor=ROOT.kAzure + 9) ]) altBackgroundBDTGStyle = styles.StyleCompound([ styles.StyleMarker(markerSize=1.2, markerColor=ROOT.kRed - 4, markerSizes=None, markerStyle=ROOT.kFullDiamond), styles.StyleLine(lineColor=ROOT.kRed - 4, lineStyle=ROOT.kSolid, lineWidth=3), styles.StyleFill(fillColor=ROOT.kRed - 4, fillStyle=3001) ]) p = plots.ComparisonPlot( histograms.Histo(HF, "Fake", "p", "P"), histograms.Histo(HG, "Genuine", "pl", "PL"), ) p.histoMgr.setHistoLegendLabelMany({ "Fake": "Unmatched", "Genuine": "Truth-matched" }) p.histoMgr.forHisto("Fake", altBackgroundBDTGStyle) p.histoMgr.setHistoDrawStyle("Fake", "LP") p.histoMgr.setHistoLegendStyle("Fake", "LP") #F p.histoMgr.forHisto("Genuine", altSignalBDTGStyle) p.histoMgr.setHistoDrawStyle("Genuine", "HIST") p.histoMgr.setHistoLegendStyle("Genuine", "LP") #LP #HF = dataset.getDatasetRootHisto(hF).getHistogram() #HG = dataset.getDatasetRootHisto(hG).getHistogram() histoG = histograms.Histo(HG, "TT", "Signal") histoG.setIsDataMC(isData=False, isMC=True) histoF = histograms.Histo(HF, "QCD", "Signal") histoF.setIsDataMC(isData=False, isMC=True) styleG = styles.ttStyle styleF = styles.signalStyleHToTB1000 #hG = histograms.Histo(histoBkg3, legNameBkg3, "F", "HIST9" ) #background3_histo = histograms.Histo(histoBkg3, legNameBkg3, "F", "HIST9" ) styleG.apply(HG) styleF.apply(HF) myList.append(histoG) myList.append(histoF) #myList.append(HF) #myList.append(HG) # p = plots.PlotBase(datasetRootHistos=myList, saveFormats=[]) _kwargs = { "xlabel": _xlabel, "ylabel": "Arbitrary Units / %s" % (_format), "ratioYlabel": "Ratio ", "ratio": False, "ratioInvert": False, "stackMCHistograms": False, "addMCUncertainty": False, "addLuminosityText": False, "addCmsText": True, "cmsExtraText": "Preliminary", "opts": { "ymin": 0.0, "ymaxfactor": 1.1 }, "opts2": { "ymin": 0.6, "ymax": 1.5 }, "log": False, #"createLegend" : {"x1": 0.5, "y1": 0.75, "x2": 0.9, "y2": 0.9}, "createLegend": { "x1": 0.58, "y1": 0.65, "x2": 0.92, "y2": 0.82 }, } ''' plots.drawPlot(p, hG, xlabel = _xlabel, ylabel = "Arbitrary Units / %s" % (_format), log = logY, rebinX = _rebinX, cmsExtraText = "Preliminary", createLegend = {"x1": 0.58, "y1": 0.65, "x2": 0.92, "y2": 0.82}, opts = _opts, opts2 = {"ymin": 0.6, "ymaxfactor": 1.1}, cutBox = _cutBox, ) ''' # Save plot in all formats saveName = hG.split("/")[-1] #plots.drawPlot(p, saveName, **_kwargs) savePath = os.path.join(opts.saveDir, "HplusMasses", hG.split("/")[0], opts.optMode) plots.drawPlot(p, savePath, **_kwargs) SavePlot(p, saveName, os.path.join(opts.saveDir, opts.optMode), saveFormats=[".png", ".pdf", ".C"]) #SavePlot(p, saveName, savePath) #p = plots.DataMCPlot2( myList, saveFormats=[]) #p.setLuminosity(opts.intLumi) #p.setDefaultStyles() # Draw the plot and save it #hName = hG #plots.drawPlot(p, hName, **_kwargs) #SavePlot(p, hName, os.path.join(opts.saveDir, opts.optMode), saveFormats = [".png"]) return
def Plot_Comparisons(datasetsMgr, datasetsMgrRef, hT, hR, intLumi): #kwargs = {} _kwargs = {} #kwargs = GetHistoKwargs(hG, opts) print if opts.normaliseToOne: pT = plots.MCPlot(datasetsMgr, hT, normalizeToOne=True, saveFormats=[], **_kwargs) pR = plots.MCPlot(datasetsMgrRef, hR, normalizeToOne=True, saveFormats=[], **_kwargs) else: pT = plots.MCPlot(datasetsMgr, hT, normalizeToLumi=intLumi, saveFormats=[], **_kwargs) pR = plots.MCPlot(datasetsMgrRef, hR, normalizeToLumi=intLumi, saveFormats=[], **_kwargs) # Draw the histograms _cutBox = None _rebinX = 1 _format = "%0.2f" _xlabel = None logY = False _opts = {"ymin": 1e-3, "ymaxfactor": 1.0} print "HT", hT xMax = 200 _kwargs = { "xlabel": _xlabel, "ylabel": "Events / %s" % (_format), "ratioYlabel": "Ratio ", "ratio": False, "ratioInvert": False, "stackMCHistograms": False, "addMCUncertainty": False, "addLuminosityText": False, "addCmsText": True, "cmsExtraText": "Preliminary", #"opts" : {"ymin": 0.1, "ymaxfactor": 1.2}, "opts": { "ymin": 0.1, "ymaxfactor": 1.2, "xmin": 0, "xmax": xMax }, "opts2": { "ymin": 0.6, "ymax": 1.5 }, "log": True, #"createLegend" : {"x1": 0.5, "y1": 0.75, "x2": 0.9, "y2": 0.9}, "createLegend": { "x1": 0.58, "y1": 0.65, "x2": 0.92, "y2": 0.82 }, "rebinX": 1, } if "counters" in hT.lower(): print "HERE" ROOT.gStyle.SetLabelSize(16.0, "X") _kwargs["opts"] = { "ymin": 0.1, "ymaxfactor": 1.2, "xmin": 0, "xmax": 6 } _kwargs["createLegend"] = { "x1": 0.65, "y1": 0.6, "x2": 0.90, "y2": 0.77 }, if "pt" in hT.lower(): _units = "GeV/c" _format = "%0.0f " + _units _xlabel = "p_{T} (%s)" % _units _kwargs["xmax"] = 800 _kwargs["opts"] = { "ymin": 0.1, "ymaxfactor": 1.2, "xmin": 0, "xmax": 800 } if "mass" in hT.lower(): _units = "GeV/c^{2}" _format = "%0.0f " + _units _xlabel = "M (%s)" % _units _kwargs["xmax"] = 800 _kwargs["opts"] = { "ymin": 0.1, "ymaxfactor": 1.2, "xmin": 0, "xmax": 800 } if "tetrajet" in hT.lower(): _kwargs["opts"] = { "ymin": 0.1, "ymaxfactor": 1.2, "xmin": 0, "xmax": 2000 } _kwargs["rebinX"] = 8 if "trijetmass" in hT.lower(): print "mass" _units = "GeV/c^{2}" _format = "%0.0f " + _units _xlabel = "m_{top} (%s)" % _units #_cutBox = {"cutValue": 173.21, "fillColor": 16, "box": False, "line": True, "greaterThan": True} _kwargs["xmax"] = 400 #1005 _kwargs["opts"] = { "ymin": 0.1, "ymaxfactor": 1.2, "xmin": 0, "xmax": 400 } if "eta" in hT.lower(): _units = "" _format = "%0.1f " + _units _xlabel = "#eta (%s)" % _units _kwargs["opts"] = { "ymin": 0.1, "ymaxfactor": 1.2, "xmin": -5.0, "xmax": +5.0 } if "mult" in hT.lower(): _format = "%0.0f" if "cleaned" in hT.lower(): _kwargs["xmax"] = 10 _kwargs["opts"] = { "ymin": 0.1, "ymaxfactor": 1.2, "xmin": 0, "xmax": 10 } else: _kwargs["xmax"] = 60 _kwargs["opts"] = { "ymin": 0.1, "ymaxfactor": 1.2, "xmin": 0, "xmax": 60 } if "bdisc" in hT.lower(): _format = "%0.2f" _kwargs["xmax"] = 1 _kwargs["opts"] = { "ymin": 0.1, "ymaxfactor": 1.2, "xmin": 0, "xmax": 1 } if "topbdt" in hT.lower(): _format = "%0.2f" _kwargs["xmax"] = 1 _kwargs["xmin"] = 0.3 _kwargs["opts"] = { "ymin": 0.1, "ymaxfactor": 1.2, "xmin": 0.3, "xmax": 1.0 } if "dijetmass" in hT.lower(): print "dijet-mass" _units = "GeV/c^{2}" _format = "%0.0f " + _units _xlabel = "m_{W} (%s)" % _units _opts["xmax"] = 600 _kwargs["opts"] = { "ymin": 0.1, "ymaxfactor": 1.2, "xmin": 0, "xmax": 300 } else: pass if logY: yMaxFactor = 2.0 else: yMaxFactor = 1.5 _opts["ymaxfactor"] = yMaxFactor if opts.normaliseToOne: _opts["ymin"] = 1e-3 else: _opts["ymin"] = 1e0 myList = [] # Customise styling pT.histoMgr.forEachHisto( lambda h: h.getRootHisto().SetLineStyle(ROOT.kSolid)) pR.histoMgr.forEachHisto( lambda h: h.getRootHisto().SetLineStyle(ROOT.kSolid)) datasetTarg = datasetsMgr.getDataset( "QCD") #ChargedHiggs_HplusTB_HplusToTB_M_500 datasetRef = datasetsMgrRef.getDataset( "QCD") #ChargedHiggs_HplusTB_HplusToTB_M_500 h = datasetTarg.getDatasetRootHisto(hT) #h.normalizeToOne() h.normalizeToLuminosity(intLumi) HT = h.getHistogram() h = datasetRef.getDatasetRootHisto(hR) #h.normalizeToOne() h.normalizeToLuminosity(intLumi) HR = h.getHistogram() altSignalBDTGStyle = styles.StyleCompound([ styles.StyleMarker(markerSize=1.2, markerColor=ROOT.kAzure + 9, markerSizes=None, markerStyle=ROOT.kFullDiamond), styles.StyleLine(lineColor=ROOT.kAzure + 9, lineStyle=ROOT.kSolid, lineWidth=3), styles.StyleFill(fillColor=ROOT.kAzure + 9, fillStyle=3001) ]) altBackgroundBDTGStyle = styles.StyleCompound([ styles.StyleMarker(markerSize=1.2, markerColor=ROOT.kRed - 4, markerSizes=None, markerStyle=ROOT.kFullDiamond), styles.StyleLine(lineColor=ROOT.kRed - 4, lineStyle=ROOT.kSolid, lineWidth=3), #styles.StyleFill(fillColor=ROOT.kRed-4) ]) signalStyle = styles.StyleCompound([ styles.StyleMarker(markerSize=1.2, markerColor=ROOT.kTeal + 2, markerSizes=None, markerStyle=ROOT.kFullTriangleUp), styles.StyleLine(lineColor=ROOT.kTeal + 2, lineStyle=ROOT.kSolid, lineWidth=3), styles.StyleFill(fillColor=ROOT.kTeal + 2, fillStyle=3001) ]) p = plots.ComparisonPlot( histograms.Histo(HT, "Target", "pl", "PL"), histograms.Histo(HR, "Reference", "pl", "PL"), ) p.histoMgr.setHistoLegendLabelMany({ "Target": "bug fixed", "Reference": "bug" }) if ("TT" in datasetTarg.getName()): p.histoMgr.forHisto("Target", altBackgroundBDTGStyle) p.histoMgr.forHisto("Reference", altSignalBDTGStyle) elif ("QCD" in datasetTarg.getName()): p.histoMgr.forHisto( "Target", altBackgroundBDTGStyle) #styles.getABCDStyle("VR")) p.histoMgr.forHisto("Reference", styles.qcdFillStyle) elif ("Charged" in datasetTarg.getName()): p.histoMgr.forHisto("Target", altBackgroundBDTGStyle) p.histoMgr.forHisto("Reference", signalStyle) p.histoMgr.setHistoDrawStyle("Target", "HIST") p.histoMgr.setHistoLegendStyle("Target", "LP") #F p.histoMgr.setHistoDrawStyle("Reference", "HIST") p.histoMgr.setHistoLegendStyle("Reference", "F") #LP ''' histoG = histograms.Histo(HT, "TT", "Signal") histoG.setIsDataMC(isData=False, isMC=True) histoF = histograms.Histo(HR, "QCD", "Signal") histoF.setIsDataMC(isData=False, isMC=True) ''' #styleT = styles.ttStyle #styleR = styles.signalStyleHToTB1000 #styleT.apply(HT) #styleR.apply(HR) ''' myList.append(histoT) myList.append(histoR) ''' # Save plot in all formats #saveName = hT.split("/")[-1] #plots.drawPlot(p, saveName, **_kwargs) #savePath = os.path.join(opts.saveDir, "HplusMasses", hT.split("/")[0], opts.optMode) #plots.drawPlot(p, savePath, **_kwargs) #SavePlot(p, saveName, os.path.join(opts.saveDir, opts.optMode), saveFormats = [".png", ".pdf", ".C"]) dName = datasetTarg.getName() dName = dName.replace("ChargedHiggs_HplusTB_HplusToTB_", "") saveName = hT.split("/")[-1] + "_" + dName #print saveName, hT, opts.saveDir savePath = os.path.join(opts.saveDir, hT.split("/")[0], opts.optMode) print "TYPE", type(hT), type(savePath), type(p) plots.drawPlot(p, savePath, **_kwargs) #leg = ROOT.TLegend(0.2, 0.8, 0.81, 0.87) leg = ROOT.TLegend(0.2, 0.8, 0.51, 0.87) leg.SetFillStyle(0) leg.SetFillColor(0) leg.SetBorderSize(0) #{"dx": -0.55, "dy": -0.55, "dh": -0.08} datasetName = datasetTarg.getName() datasetName = datasetName.replace("TT", "t#bar{t}") if "ChargedHiggs" in datasetName: datasetName = datasetName.replace("ChargedHiggs_HplusTB_HplusToTB_M_", "m_{H+} = ") datasetName = datasetName + "GeV" #leg.SetHeader("t#bar{t}") leg.SetHeader(datasetName) leg.Draw() #print savePath #savePath = os.path.join(opts.saveDir, opts.optMode) SavePlot(p, saveName, savePath) return
def PlotMC(datasetsMgr, histo, intLumi): kwargs = {} if opts.normaliseToOne: p = plots.MCPlot(datasetsMgr, histo, normalizeToOne=True, saveFormats=[], **kwargs) else: p = plots.MCPlot(datasetsMgr, histo, normalizeToLumi=intLumi, saveFormats=[], **kwargs) # Draw the histograms _cutBox = None _rebinX = 1 _format = "%0.0f" _xlabel = None _opts = {"ymin": 1e-3, "ymaxfactor": 1.0} #_opts = {"ymin": 1e-3, "ymax": 60} if "pt" in histo.lower(): _rebinX = 2 _units = "GeV/c" _format = "%0.0f " + _units _xlabel = "p_{T} (%s)" % _units _cutBox = {"cutValue": 173.21, "fillColor": 16, "box": False, "line": False, "greaterThan": True} #_opts["xmax"] = 505 #1005 if "ht" in histo.lower(): _rebinX = 2 _units = "GeV/c" _format = "%0.0f " + _units _xlabel = "H_{T} (%s)" % _units _opts["xmax"] = 2000 #_cutBox = {"cutValue": 173.21, "fillColor": 16, "box": False, "line": False, "greaterThan": True} #_opts["xmax"] = 505 #1005 if "eta" in histo.lower(): _units = "" _format = "%0.1f " + _units _xlabel = "#eta %s" % _units _cutBox = {"cutValue": 173.21, "fillColor": 16, "box": False, "line": False, "greaterThan": True} _opts["xmax"] = 2.5 _opts["xmin"] = -2.5 if "trijetmass" in histo.lower(): _rebinX = 2 _units = "GeV/c^{2}" _format = "%0.0f " + _units _xlabel = "m_{jjb} (%s)" % _units _cutBox = {"cutValue": 173.21, "fillColor": 16, "box": False, "line": True, "greaterThan": True} _opts["xmax"] = 505 #1005 if "ldg" in histo.lower(): _xlabel = "m_{jjb}^{ldg} (%s)" % _units elif "tetrajetmass" in histo.lower(): _rebinX = 10 #5 #10 #4 _units = "GeV/c^{2}" _format = "%0.0f " + _units _xlabel = "m_{jjbb} (%s)" % (_units) _format = "%0.0f " + _units _opts["xmax"] = 2500 #3500.0 elif "tetrajetpt" in histo.lower(): _rebinX = 2 #5 #10 #4 _units = "GeV/c" _format = "%0.0f " + _units _xlabel = "p_{T,jjbb} (%s)" % (_units) _format = "%0.0f " + _units _opts["xmax"] = 1000 #3500.0 elif "dijetmass" in histo.lower(): _rebinX = 2 #5 #10 #4 _units = "GeV/c^{2}" _format = "%0.0f " + _units _xlabel = "m_{jj} (%s)" % (_units) _format = "%0.0f " + _units _opts["xmax"] = 800 #3500.0 _cutBox = {"cutValue": 80.4, "fillColor": 16, "box": False, "line": True, "greaterThan": True} _opts["xmax"] = 300 if "ldg" in histo.lower(): _xlabel = "m_{jj}^{ldg} (%s)" % (_units) elif "tetrajetbjetpt" in histo.lower(): _rebinX = 2 _units = "GeV/c" _format = "%0.0f " + _units _xlabel = "p_{T,bjet} (%s)" % (_units) _format = "%0.0f " + _units _opts["xmax"] = 800 elif "ldgtrijetpt" in histo.lower(): _rebinX = 2 # logY = False _units = "GeV/c" _format = "%0.0f " + _units _xlabel = "p_{T,jjb}^{ldg} (%s)" % (_units) _format = "%0.0f " + _units _opts["xmax"] = 800 elif "ldgtrijetdijetpt" in histo.lower(): _rebinX = 2 # logY = False _units = "GeV/c" _format = "%0.0f " + _units _xlabel = "p_{T,jj}^{ldg} (%s)" % (_units) _format = "%0.0f " + _units _opts["xmax"] = 800 elif "topbdt_" in histo.lower(): _format = "%0.1f" _cutBox = {"cutValue": +0.40, "fillColor": 16, "box": False, "line": False, "greaterThan": True} _xlabel = "BDTG discriminant" if "gentop_pt" in histo.lower(): _rebinX = 1 if "genquark_pt" in histo.lower(): _rebinX = 1 _opts["xmax"] = 500 else: pass if "delta" in histo.lower(): _format = "%0.1f " if "phi" in histo.lower(): _xlabel = "#Delta #phi" if "deltar" in histo.lower(): _rebinX = 2 if "DiBjetMaxMass_Mass" in histo: _units = "GeV" _rebinX = 4 _xlabel = "m_{max}(bb) (%s)" % (_units) _format = "%0.0f " + _units if "DiJetDeltaRmin_Mass" in histo: _units = "GeV" _format = "%0.0f " + _units _xlabel = "m_{#DeltaR_{min}(jj)}(jj) (%s)" % (_units) _opts["xmax"] = 200 if "DiBjetDeltaRmin_Mass" in histo: _units = "GeV" _format = "%0.0f " + _units _rebinX= 2 _xlabel = "m_{#DeltaR_{min}(bb)}(bb) (%s)" % (_units) _opts["xmax"] = 600 if "LdgBjet_SubldgBjet_Mass" in histo: _units = "GeV" _format = "%0.0f " + _units _rebinX= 4 _xlabel = "m(b_{ldg}b_{sldg}) (%s)" % (_units) if "DeltaR_LdgTop_DiBjetDeltaRmin" in histo: _rebinX= 2 _format = "%0.1f " _xlabel = "#DeltaR (top_{ldg}, bb_{#Delta Rmin})" if "DeltaR_SubldgTop_DiBjetDeltaRmin" in histo: _rebinX= 2 _format = "%0.1f " _xlabel = "#DeltaR (top_{sldg}, bb_{#Delta Rmin})" if "over" in histo.lower(): _opts["xmax"] = 15 _opts["xmax"] = +0.8 _opts["xmin"] = -0.8 _xlabel = "#Delta p_{T}(j-q)/p_{T,q}" _cutBox = {"cutValue": +0.32, "fillColor": 16, "box": False, "line": True, "greaterThan": True} if "within" in histo.lower(): _opts["xmax"] = +0.8 _opts["xmin"] = -0.8 _xlabel = "#Delta p_{T}(j-q)/p_{T,q}" _cutBox = {"cutValue": +0.32, "fillColor": 16, "box": False, "line": True, "greaterThan": True} if "axis2" in histo.lower(): _opts["xmax"] = +0.2 _opts["xmin"] = 0.0 _xlabel = "axis2" _units = "" _format = "%0.1f "+_units if "axis2" in histo.lower(): _opts["xmax"] = +0.2 _opts["xmin"] = 0.0 _xlabel = "axis2" _units = "" _format = "%0.2f "+_units if "mass" in histo.lower(): _xlabel = "M (GeV/c^{2})" _units = "GeV/c^{2}" _format = "%0.0f "+_units if "mult" in histo.lower(): _xlabel = "mult" _units = "" _format = "%0.0f "+_units if "BQuarkFromH_Pt" in histo: _opts["xmax"] = 200 _rebinX= 1 if "order" in histo.lower(): _opts["xmax"] = 15 _rebinX= 1 if "pt" in histo.lower(): _xlabel = "indx_{p_{T}}" if "csv" in histo.lower(): _xlabel = "indx_{csv}" if "phi_alpha" in histo.lower() or "phi_beta" in histo.lower() or "r_alpha" in histo.lower() or "r_beta" in histo.lower(): _format = "%0.1f " _opts["xmin"] = 0.0 if "phi" in histo.lower(): _xlabel = "#phi" _opts["xmax"] = 5.5 else: _xlabel = "r" _opts["xmax"] = 6.5 if "alpha" in histo.lower(): _xlabel = _xlabel+"_{#alpha}" else: _xlabel = _xlabel+"_{#beta}" if opts.normaliseToOne: logY = False Ylabel = "Arbitrary Units / %s" % (_format) else: logY = True Ylabel = "Events / %s" % (_format) if logY: yMaxFactor = 2.0 else: yMaxFactor = 1.2 _opts["ymaxfactor"] = yMaxFactor if opts.normaliseToOne: _opts["ymin"] = 1e-3 #_opts = {"ymin": 1e-3, "ymaxfactor": yMaxFactor, "xmax": None} else: _opts["ymin"] = 1e0 if "order" in histo.lower(): _opts["ymin"] = 1e-3 #_opts["ymaxfactor"] = yMaxFactor #_opts = {"ymin": 1e0, "ymaxfactor": yMaxFactor, "xmax": None} # Customise styling p.histoMgr.forEachHisto(lambda h: h.getRootHisto().SetLineStyle(ROOT.kSolid)) if "QCD" in datasetsMgr.getAllDatasetNames(): p.histoMgr.forHisto("QCD", styles.getQCDLineStyle()) #getQCDFillStyle() ) p.histoMgr.setHistoDrawStyle("QCD", "HIST") p.histoMgr.setHistoLegendStyle("QCD", "F") if "TT" in datasetsMgr.getAllDatasetNames(): TTStyle = styles.StyleCompound([styles.StyleFill(fillColor=ROOT.kMagenta-2), styles.StyleLine(lineColor=ROOT.kMagenta-2, lineStyle=ROOT.kSolid, lineWidth=3), styles.StyleMarker(markerSize=1.2, markerColor=ROOT.kMagenta-2, markerSizes=None, markerStyle=ROOT.kFullTriangleUp)]) p.histoMgr.forHisto("TT", TTStyle) p.histoMgr.setHistoDrawStyle("TT", "HIST") #AP p.histoMgr.setHistoLegendStyle("TT", "F") #LP # Customise style signalM = [] for m in signalMass: signalM.append(m.rsplit("M_")[-1]) for m in signalM: p.histoMgr.forHisto("ChargedHiggs_HplusTB_HplusToTB_M_%s" %m, styles.getSignalStyleHToTB_M(m)) plots.drawPlot(p, histo, xlabel = _xlabel, ylabel = Ylabel, log = logY, rebinX = _rebinX, cmsExtraText = "Preliminary", #createLegend = {"x1": 0.59, "y1": 0.65, "x2": 0.92, "y2": 0.92}, createLegend = {"x1": 0.59, "y1": 0.70, "x2": 0.92, "y2": 0.92}, #createLegend = {"x1": 0.73, "y1": 0.85, "x2": 0.97, "y2": 0.77}, opts = _opts, opts2 = {"ymin": 0.6, "ymax": 1.4}, cutBox = _cutBox, ) # Save plot in all formats saveName = histo.split("/")[-1] savePath = os.path.join(opts.saveDir, histo.split("/")[0], opts.optMode) ''' if opts.normaliseToOne: save_path = savePath + opts.MVAcut if opts.noQCD: save_path = savePath + opts.MVAcut + "/noQCD/" else: save_path = savePath + opts.MVAcut + "/normToLumi/" if opts.noQCD: save_path = savePath + opts.MVAcut + "/noQCD/" ''' SavePlot(p, saveName, savePath) return
def main(opts, signalMass): # Apply TDR style style = tdrstyle.TDRStyle() style.setGridX(False) style.setGridY(False) # Do the topSelection histos folder = "" #=== Define styles: Fixme: Put in function #styles_S = styles.StyleCompound([styles.StyleMarker(markerSize=0.4, markerColor=928, markerSizes=None, markerStyle=ROOT.kFullDiamond), # styles.StyleLine(lineColor=928, lineStyle=ROOT.kSolid, lineWidth=3), # styles.StyleFill(fillColor=38)]) styles_S = styles.StyleCompound([styles.StyleMarker(markerSize=0.4, markerColor=928, markerSizes=None, markerStyle=ROOT.kFullDiamond), styles.StyleLine(lineColor=928, lineStyle=ROOT.kSolid, lineWidth=3)]) styles_B = styles.StyleCompound([styles.StyleMarker(markerSize=0.4, markerColor=2, markerSizes=None, markerStyle=ROOT.kFullDiamond), styles.StyleLine(lineColor=2, lineStyle=ROOT.kSolid, lineWidth=3), styles.StyleFill(fillColor=2, fillStyle=3005)]) styles_SEff = styles.StyleCompound([styles.StyleMarker(markerSize=0.4, markerColor=ROOT.kBlue, markerSizes=None, markerStyle=ROOT.kFullDiamond), styles.StyleLine(lineColor=ROOT.kBlue, lineStyle=ROOT.kSolid, lineWidth=3),]) styles_BEff = styles.StyleCompound([styles.StyleMarker(markerSize=0.4, markerColor=ROOT.kRed, markerSizes=None, markerStyle=ROOT.kFullDiamond), styles.StyleLine(lineColor=ROOT.kRed, lineStyle=ROOT.kSolid, lineWidth=3),]) styles_Signif = styles.StyleCompound([styles.StyleMarker(markerSize=0.4, markerColor=ROOT.kGreen+2, markerSizes=None, markerStyle=ROOT.kFullDiamond), styles.StyleLine(lineColor=ROOT.kGreen+2, lineStyle=ROOT.kSolid, lineWidth=3),]) styles_pur = styles.StyleCompound([styles.StyleMarker(markerSize=0.4, markerColor=ROOT.kOrange+7, markerSizes=None, markerStyle=ROOT.kFullDiamond), styles.StyleLine(lineColor=ROOT.kOrange+7, lineStyle=ROOT.kSolid, lineWidth=3),]) styles_pureff = styles.StyleCompound([styles.StyleMarker(markerSize=0.4, markerColor=ROOT.kOrange, markerSizes=None, markerStyle=ROOT.kFullDiamond), styles.StyleLine(lineColor=ROOT.kOrange, lineStyle=ROOT.kSolid, lineWidth=3),]) #=== Histo Names ============================================ hN_SignalEff = "sigEffi" hN_BgdEff = "bgdEffi" hN_signif = "significance_BDTG" hN_purS = "purS_BDTG" hN_effpurS = "effpurS_BDTG" hN_BDTs = "MVA_BDTG_S" hN_BDTb = "MVA_BDTG_B" #=== Directories ============================================ inpfile_eff = ROOT.TFile(opts.effFile, "R") inpfile = ROOT.TFile(opts.rootfile, "R") #To be fixed! inpfile_dir = inpfile.Get("Method_BDT/BDTG") #=== Get histograms from directories========================= h_SignalEffi = inpfile_eff.Get(hN_SignalEff) h_BgdEffi = inpfile_eff.Get(hN_BgdEff) h_signif = inpfile_eff.Get(hN_signif) h_purS = inpfile_eff.Get(hN_purS) h_effpurS = inpfile_eff.Get(hN_effpurS) h_BDTs = inpfile_dir.Get(hN_BDTs) h_BDTb = inpfile_dir.Get(hN_BDTb) #=== Scale Significance h_signifScaled = h_signif.Clone("signif") maxSignif = h_signif.GetMaximum() h_signifScaled.Scale(1/maxSignif) histo_signalEff = histograms.Histo(h_SignalEffi, "sEff", legendStyle = "LP", drawStyle="LP") histo_bgdEff = histograms.Histo(h_BgdEffi, "bEff", legendStyle = "LP", drawStyle="LP") histo_signifScaled = histograms.Histo(h_signifScaled, "signif", legendStyle = "LP", drawStyle="LP") histo_purS = histograms.Histo(h_purS, "purity", legendStyle = "LP", drawStyle="LP") histo_effpurS = histograms.Histo(h_effpurS, "pureff", legendStyle = "LP", drawStyle="LP") histo_BDTs = histograms.Histo(h_BDTs, "bdtS", legendStyle = "LP", drawStyle="LP") histo_BDTb = histograms.Histo(h_BDTb, "bdtB", legendStyle = "LP", drawStyle="LP") #=== Efficiency - Purity - Significance================================= histoList_Eff = [histo_bgdEff, histo_signifScaled, histo_purS, histo_effpurS] p_Eff = plots.ComparisonManyPlot(histo_signalEff, histoList_Eff, saveFormats=[]) p_Eff.histoMgr.setHistoLegendLabelMany({"sEff": "Signal efficiency", "bEff": "Bkg efficiency", "signif": "S/#sqrt{S+B}", #"signif": "#frac{S}{#sqrt{S+B}}", "purity": "Signal purity", "pureff": "Signal eff*purity",}) # Define Right Axis (Significance) signifColor = ROOT.kGreen+2 #rightAxis = ROOT.TGaxis(0.5, 0.17, 0.97, 0.34, 0, 1.1*maxSignif, 510, "+L") ''' TGaxis::TGaxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax, Double_t wmin, Double_t wmax, Int_t ndiv, Option_t *chopt, Double_t gridlength) ''' rightAxis = ROOT.TGaxis(1, 0, 1, 1.1, 0, 1.1*maxSignif, 510, "+L") rightAxis.SetWmax(1.1*maxSignif) rightAxis.SetLineColor ( signifColor ) rightAxis.SetLabelColor( signifColor ) rightAxis.SetTitleColor( signifColor ) # rightAxis.SetTitleSize( info->sSig->GetXaxis()->GetTitleSize() ) # rightAxis.SetLabelOffset(0.9) # This will only be be visible if we use a wide canvas (but we don't want that) if 0: style.setWide(True, 0.15) #to make way for significane label rightAxis.SetTitle( "Significance" ) # rightAxis.SetTitleOffset(1.1) #=== BDTG output ======================================================== histo_BDTs = histograms.Histo(h_BDTs, "bdtS", legendStyle = "LP", drawStyle="LP") histo_BDTb = histograms.Histo(h_BDTb, "bdtB", legendStyle = "F", drawStyle="LP") #p_BDT = plots.ComparisonPlot(histo_BDTb, histo_BDTs, saveFormats=[]) p_BDT = plots.ComparisonPlot(histo_BDTs, histo_BDTb, saveFormats=[]) p_BDT.histoMgr.setHistoLegendLabelMany({"bdtS": "Signal", "bdtB": "Background"}) p_Eff.histoMgr.forHisto("sEff", styles_SEff) p_Eff.histoMgr.setHistoDrawStyle("sEff", "L") p_Eff.histoMgr.setHistoLegendStyle("sEff", "L") p_Eff.histoMgr.forHisto("bEff", styles_BEff) p_Eff.histoMgr.setHistoDrawStyle("bEff", "L") p_Eff.histoMgr.setHistoLegendStyle("bEff", "L") p_Eff.histoMgr.forHisto("signif", styles_Signif) p_Eff.histoMgr.setHistoDrawStyle("signif", "L") p_Eff.histoMgr.setHistoLegendStyle("signif", "L") p_Eff.histoMgr.forHisto("purity", styles_pur) p_Eff.histoMgr.setHistoDrawStyle("purity", "L") p_Eff.histoMgr.setHistoLegendStyle("purity", "L") p_Eff.histoMgr.forHisto("pureff", styles_pureff) p_Eff.histoMgr.setHistoDrawStyle("pureff", "L") p_Eff.histoMgr.setHistoLegendStyle("pureff", "L") p_BDT.histoMgr.forHisto("bdtS", styles_S) p_BDT.histoMgr.setHistoDrawStyle("bdtS", "HIST") p_BDT.histoMgr.setHistoLegendStyle("bdtS", "L") p_BDT.histoMgr.forHisto("bdtB", styles_B) p_BDT.histoMgr.setHistoDrawStyle("bdtB", "HIST") p_BDT.histoMgr.setHistoLegendStyle("bdtB", "F") saveName_eff = "mvaeff" saveName = "mva" savePath = os.path.join(opts.saveDir, opts.optMode) _kwargs = { "xlabel" : "BDTG", #"Cut value applied on BDTG output", "ylabel" : "Efficiency (Purity)", "ratioYlabel" : "Ratio ", "ratio" : False, "ratioInvert" : False, "stackMCHistograms": False, "addMCUncertainty" : False, "addLuminosityText": False, "addCmsText" : True, "cmsExtraText" : "Preliminary", "opts" : {"xmin": -1.0, "xmax": 1.01, "ymin": 0.0, "ymax": 1.1}, "opts2" : {"ymin": 0.6, "ymax": 1.5}, "log" : False, "createLegend" : {"x1": 0.45, "y1": 0.45, "x2": 0.70, "y2": 0.70}, } ROOT.gStyle.SetNdivisions(6 + 100*5 + 10000*2, "X") #ROOT.gStyle.SetNdivisions(8, "X") plots.drawPlot(p_Eff, savePath, **_kwargs) rightAxis.Draw() saveDir = opts.rootfile.split("/")[-1] saveDir = saveDir.replace(".root","") SavePlot(p_Eff, saveName_eff, os.path.join(opts.saveDir, saveDir, opts.optMode), saveFormats = [".png", ".pdf", ".C"]) _kwargs["log"] = True _kwargs["opts"]["ymin"] = 3e-2 _kwargs["opts"]["ymax"] = 20 _kwargs["xlabel"] = "BDTG"# response" _kwargs["ylabel"] = "(1/N) dN/dx" _kwargs["createLegend"] = {"x1": 0.25, "y1": 0.75, "x2": 0.50, "y2": 0.9} style.setWide(False, 0.15) ROOT.gStyle.SetNdivisions(6 + 100*5 + 10000*2, "X") plots.drawPlot(p_BDT, savePath, **_kwargs) SavePlot(p_BDT, saveName, os.path.join(opts.saveDir, saveDir, opts.optMode), saveFormats = [".png", ".pdf", ".C"]) return
def PlotMC(datasetsMgr, histo, intLumi): kwargs = {} if opts.normaliseToOne: p = plots.MCPlot(datasetsMgr, histo, normalizeToOne=True, saveFormats=[], **kwargs) else: p = plots.MCPlot(datasetsMgr, histo, normalizeToLumi=intLumi, saveFormats=[], **kwargs) # Draw the histograms _cutBox = None _rebinX = 1 _format = "%0.0f" _xlabel = None _opts = {"ymin": 1e-3, "ymaxfactor": 1.0} if "pt" in histo.lower(): _rebinX = 2 _units = "GeV/c" _format = "%0.0f " + _units _xlabel = "p_{T} (%s)" % _units _cutBox = {"cutValue": 173.21, "fillColor": 16, "box": False, "line": False, "greaterThan": True} _opts["xmax"] = 805 #1005 if "bdisc" in histo.lower(): _rebinX = 2 _units = "" _format = "%0.2f " + _units _xlabel = "b-discriminator" #(%s)" % _units _cutBox = {"cutValue": 173.21, "fillColor": 16, "box": False, "line": False, "greaterThan": True} _opts["xmax"] = 1.2 if "ht" in histo.lower(): _rebinX = 2 _units = "GeV/c" _format = "%0.0f " + _units _xlabel = "H_{T} (%s)" % _units _cutBox = {"cutValue": 173.21, "fillColor": 16, "box": False, "line": False, "greaterThan": True} _opts["xmax"] = 1505 #1005 if "met" in histo.lower(): _rebinX = 1 _units = "GeV" _format = "%0.0f " + _units _xlabel = "E_{T,missing} (%s)" % _units _cutBox = {"cutValue": 173.21, "fillColor": 16, "box": False, "line": False, "greaterThan": True} _opts["xmax"] = 205 #1005 if "mult" in histo.lower(): _units = "" _format = "%0.0f " + _units _xlabel = "jet multiplicity" _opts["xmax"] = 10 if "mass" in histo.lower(): _rebinX = 2 _units = "GeV/c^{2}" _format = "%0.0f " + _units _xlabel = "m_{jjb} (%s)" % _units _cutBox = {"cutValue": 173.21, "fillColor": 16, "box": False, "line": True, "greaterThan": True} _opts["xmax"] = 350 #1005 elif "tetrajetmass" in histo.lower(): _rebinX = 5 #5 #10 #4 _units = "GeV/c^{2}" _format = "%0.0f " + _units _xlabel = "m_{jjbb} (%s)" % (_units) _format = "%0.0f " + _units _opts["xmax"] = 1500 #3500.0 elif "dijetmass" in histo.lower(): _rebinX = 1 #5 #10 #4 _units = "GeV/c^{2}" _format = "%0.0f " + _units _xlabel = "m_{W} (%s)" % (_units) _format = "%0.0f " + _units _opts["xmax"] = 800 #3500.0 _cutBox = {"cutValue": 80.4, "fillColor": 16, "box": False, "line": True, "greaterThan": True} _opts["xmax"] = 300 elif "tetrajetbjetpt" in histo.lower(): _rebinX = 2 _units = "GeV/c" _format = "%0.0f " + _units _xlabel = "p_{T} (%s)" % (_units) _format = "%0.0f " + _units _opts["xmax"] = 800 elif "ldgtrijetpt" in histo.lower(): _rebinX = 2 # logY = False _units = "GeV/c" _format = "%0.0f " + _units _xlabel = "p_{T} (%s)" % (_units) _format = "%0.0f " + _units _opts["xmax"] = 800 elif "tau" in histo.lower(): _format = "%0.2f " elif "deltar" in histo.lower(): _format = "%0.2f " elif "bdtvalue" in histo.lower(): _format = "%0.1f" else: pass if opts.normaliseToOne: logY = False Ylabel = "Arbitrary Units / %s" % (_format) else: logY = True Ylabel = "Events / %s" % (_format) if logY: yMaxFactor = 2.0 else: yMaxFactor = 1.2 _opts["ymaxfactor"] = yMaxFactor if opts.normaliseToOne: _opts["ymin"] = 1e-3 #_opts = {"ymin": 1e-3, "ymaxfactor": yMaxFactor, "xmax": None} else: _opts["ymin"] = 1e0 #_opts["ymaxfactor"] = yMaxFactor #_opts = {"ymin": 1e0, "ymaxfactor": yMaxFactor, "xmax": None} # Customise styling p.histoMgr.forEachHisto(lambda h: h.getRootHisto().SetLineStyle(ROOT.kSolid)) if "QCD" in datasetsMgr.getAllDatasetNames(): p.histoMgr.forHisto("QCD", styles.getQCDFillStyle() ) p.histoMgr.setHistoDrawStyle("QCD", "HIST") p.histoMgr.setHistoLegendStyle("QCD", "F") if "TT" in datasetsMgr.getAllDatasetNames(): TTStyle = styles.StyleCompound([styles.StyleFill(fillColor=ROOT.kMagenta-2), styles.StyleLine(lineColor=ROOT.kMagenta-2, lineStyle=ROOT.kSolid, lineWidth=3), styles.StyleMarker(markerSize=1.2, markerColor=ROOT.kMagenta-2, markerSizes=None, markerStyle=ROOT.kFullTriangleUp)]) p.histoMgr.forHisto("TT", TTStyle) p.histoMgr.setHistoDrawStyle("TT", "HIST") #AP p.histoMgr.setHistoLegendStyle("TT", "F") #LP # Customise style signalM = [] for m in signalMass: signalM.append(m.rsplit("M_")[-1]) for m in signalM: p.histoMgr.forHisto("ChargedHiggs_HplusTB_HplusToTB_M_%s" %m, styles.getSignalStyleHToTB_M(m)) plots.drawPlot(p, histo, xlabel = _xlabel, ylabel = Ylabel, log = logY, rebinX = _rebinX, cmsExtraText = "Preliminary", createLegend = {"x1": 0.68, "y1": 0.82, "x2": 1.0, "y2": 0.92}, #createLegend = {"x1": 0.73, "y1": 0.85, "x2": 0.97, "y2": 0.77}, opts = _opts, opts2 = {"ymin": 0.6, "ymax": 1.4}, cutBox = _cutBox, ) # Save plot in all formats saveName = histo.split("/")[-1] savePath = os.path.join(opts.saveDir, histo.split("/")[0], opts.optMode) ''' if opts.normaliseToOne: save_path = savePath + opts.MVAcut if opts.noQCD: save_path = savePath + opts.MVAcut + "/noQCD/" else: save_path = savePath + opts.MVAcut + "/normToLumi/" if opts.noQCD: save_path = savePath + opts.MVAcut + "/noQCD/" ''' SavePlot(p, saveName, savePath) return
def Plot_LostEvents(datasetsMgr, datasetsMgrRef, hT, hR, intLumi): #kwargs = {} _kwargs = {} #kwargs = GetHistoKwargs(hG, opts) if opts.normaliseToOne: pT = plots.MCPlot(datasetsMgr, hT, normalizeToOne=True, saveFormats=[], **_kwargs) pR = plots.MCPlot(datasetsMgrRef, hR, normalizeToOne=True, saveFormats=[], **_kwargs) else: pT = plots.MCPlot(datasetsMgr, hT, normalizeToLumi=intLumi, saveFormats=[], **_kwargs) pR = plots.MCPlot(datasetsMgrRef, hR, normalizeToLumi=intLumi, saveFormats=[], **_kwargs) #Soti datasetTarg = datasetsMgr.getDataset( "TT") #ChargedHiggs_HplusTB_HplusToTB_M_500 datasetRef = datasetsMgrRef.getDataset( "TT") #ChargedHiggs_HplusTB_HplusToTB_M_500 p0T = plots.MCPlot(datasetsMgr, hT, normalizeToLumi=opts.intLumi, saveFormats=[], **_kwargs) HT_ = p0T.histoMgr.getHisto( datasetTarg.getName()).getRootHisto().Clone("target") p0R = plots.MCPlot(datasetsMgr, hR, normalizeToLumi=opts.intLumi, saveFormats=[], **_kwargs) HR_ = p0R.histoMgr.getHisto( datasetRef.getName()).getRootHisto().Clone("reference") # Draw the histograms _cutBox = None _rebinX = 1 _format = "%0.2f" _xlabel = None logY = False _opts = {"ymin": 1e-3, "ymaxfactor": 1.0} print "HT", hT xMax = 200 _kwargs = { "xlabel": _xlabel, "ylabel": "Events / %s" % (_format), "ratioYlabel": "Ratio ", "ratio": False, "ratioInvert": False, "stackMCHistograms": False, "addMCUncertainty": False, "addLuminosityText": False, "addCmsText": False, "cmsExtraText": "Preliminary", #"opts" : {"ymin": 0.1, "ymaxfactor": 1.2}, "opts": { "ymin": 0.1, "ymaxfactor": 1.2, "xmin": 0, "xmax": xMax }, "opts2": { "ymin": 0.6, "ymax": 1.5 }, "log": True, #"createLegend" : {"x1": 0.5, "y1": 0.75, "x2": 0.9, "y2": 0.9}, "createLegend": { "x1": 0.58, "y1": 0.65, "x2": 0.92, "y2": 0.82 }, "rebinX": 1, } _units = "units" if "counters" in hT.lower(): ROOT.gStyle.SetLabelSize(16.0, "X") _kwargs["opts"] = { "ymin": 0.1, "ymaxfactor": 1.2, "xmin": 0, "xmax": 6 } _kwargs["createLegend"] = { "x1": 0.65, "y1": 0.6, "x2": 0.90, "y2": 0.77 }, if "pt" in hT.lower(): _units = "GeV/c" _format = "%0.0f " + _units _xlabel = "p_{T} (%s)" % _units _kwargs["xmax"] = 800 _kwargs["opts"] = { "ymin": 0.1, "ymaxfactor": 1.2, "xmin": 0, "xmax": 800 } if "mass" in hT.lower(): _units = "GeV/c^{2}" _format = "%0.0f " + _units _xlabel = "M (%s)" % _units _kwargs["xmax"] = 800 _kwargs["opts"] = { "ymin": 0.1, "ymaxfactor": 1.2, "xmin": 0, "xmax": 800 } if "tetrajet" in hT.lower(): _kwargs["opts"] = { "ymin": 0.1, "ymaxfactor": 1.2, "xmin": 0, "xmax": 2000 } _kwargs["rebinX"] = 8 if "trijetmass" in hT.lower(): print "mass" _units = "GeV/c^{2}" _format = "%0.0f " + _units _xlabel = "m_{top} (%s)" % _units #_cutBox = {"cutValue": 173.21, "fillColor": 16, "box": False, "line": True, "greaterThan": True} _kwargs["xmax"] = 400 #1005 _kwargs["opts"] = { "ymin": 0.1, "ymaxfactor": 1.2, "xmin": 0, "xmax": 400 } if "eta" in hT.lower(): _units = "" _format = "%0.1f " + _units _xlabel = "#eta (%s)" % _units _kwargs["opts"] = { "ymin": 0.1, "ymaxfactor": 1.2, "xmin": -5.0, "xmax": +5.0 } if "mult" in hT.lower(): _format = "%0.0f" if "cleaned" in hT.lower(): _kwargs["xmax"] = 10 _kwargs["opts"] = { "ymin": 0.1, "ymaxfactor": 1.2, "xmin": 0, "xmax": 10 } else: _kwargs["xmax"] = 60 _kwargs["opts"] = { "ymin": 0.1, "ymaxfactor": 1.2, "xmin": 0, "xmax": 60 } if "bdisc" in hT.lower(): _format = "%0.2f" _kwargs["xmax"] = 1 _kwargs["opts"] = { "ymin": 0.1, "ymaxfactor": 1.2, "xmin": 0, "xmax": 1 } if "topbdt" in hT.lower(): _format = "%0.2f" _kwargs["xmax"] = 1 _kwargs["xmin"] = 0.3 _kwargs["opts"] = { "ymin": 0.1, "ymaxfactor": 1.2, "xmin": 0.3, "xmax": 1.0 } if "dijetmass" in hT.lower(): print "dijet-mass" _units = "GeV/c^{2}" _format = "%0.0f " + _units _xlabel = "m_{W} (%s)" % _units _opts["xmax"] = 600 _kwargs["opts"] = { "ymin": 0.1, "ymaxfactor": 1.2, "xmin": 0, "xmax": 300 } else: pass if logY: yMaxFactor = 2.0 else: yMaxFactor = 1.5 _opts["ymaxfactor"] = yMaxFactor if opts.normaliseToOne: _opts["ymin"] = 1e-3 else: _opts["ymin"] = 1e0 myList = [] # Customise styling pT.histoMgr.forEachHisto( lambda h: h.getRootHisto().SetLineStyle(ROOT.kSolid)) pR.histoMgr.forEachHisto( lambda h: h.getRootHisto().SetLineStyle(ROOT.kSolid)) h = datasetTarg.getDatasetRootHisto(hT) #h.normalizeToOne() h.normalizeToLuminosity(intLumi) HT = h.getHistogram() h = datasetRef.getDatasetRootHisto(hR) #h.normalizeToOne() h.normalizeToLuminosity(intLumi) HR = h.getHistogram() myHisto = HT.Clone("h_target-h_ref") myHisto.Add(HR, -1) if (HT.Integral() == HR.Integral()): return #Define Styles altSignalBDTGStyle = styles.StyleCompound([ styles.StyleMarker(markerSize=1.2, markerColor=ROOT.kAzure + 9, markerSizes=None, markerStyle=ROOT.kFullDiamond), styles.StyleLine(lineColor=ROOT.kAzure + 9, lineStyle=ROOT.kSolid, lineWidth=3), styles.StyleFill(fillColor=ROOT.kAzure + 9, fillStyle=3001) ]) altBackgroundBDTGStyle = styles.StyleCompound([ styles.StyleMarker(markerSize=1.2, markerColor=ROOT.kRed - 4, markerSizes=None, markerStyle=ROOT.kFullDiamond), styles.StyleLine(lineColor=ROOT.kRed - 4, lineStyle=ROOT.kSolid, lineWidth=3), #styles.StyleFill(fillColor=ROOT.kRed-4) ]) signalStyle = styles.StyleCompound([ styles.StyleMarker(markerSize=1.2, markerColor=ROOT.kTeal + 2, markerSizes=None, markerStyle=ROOT.kFullTriangleUp), styles.StyleLine(lineColor=ROOT.kTeal + 2, lineStyle=ROOT.kSolid, lineWidth=3), styles.StyleFill(fillColor=ROOT.kTeal + 2, fillStyle=3001) ]) #signalStyle.apply(myHisto) #altSignalBDTGStyle.apply(myHisto) myHisto.SetFillStyle(3001) myHisto.SetLineStyle(ROOT.kSolid) #p0 = plots.PlotBase([Histo], saveFormats=[".png"]) #histograms.Histo(HT,"Target", "pl", "PL") print "name", datasetTarg.getName() if ("TT" in datasetTarg.getName()): print "here1" #p0.histoMgr.forHisto("h_target-h_ref", altBackgroundBDTGStyle ) altBackgroundBDTGStyle.apply(myHisto) elif ("QCD" in datasetTarg.getName()): print "here2" #p0.histoMgr.forHisto("h_target-h_ref", styles.qcdFillStyle) styles.qcdFillStyle.apply(myHisto) elif ("Charged" in datasetTarg.getName()): print "here3" #p0.histoMgr.forHisto("h_target-h_ref", signalStyle) signalStyle.apply(myHisto) #p0.histoMgr.setHistoDrawStyle("Target", "HIST") p0 = plots.PlotBase( [histograms.Histo(myHisto, "h_target-h_ref", "pl", "PL")], saveFormats=[]) p0.histoMgr.setHistoLegendStyle("h_target-h_ref", "LP") #F p0.histoMgr.setHistoDrawStyle("h_target-h_ref", "HIST") #p0.histoMgr.setHistoDrawStyle("Reference" , "HIST") #p0.histoMgr.setHistoLegendStyle("Reference", "F") #LP # Save plot dName = datasetTarg.getName() dName = dName.replace("ChargedHiggs_HplusTB_HplusToTB_", "") saveName = hT.split("/")[-1] + "_" + dName + "_TopBug" savePath = os.path.join(opts.saveDir, hT.split("/")[0], opts.optMode) #plots.drawPlot(p0, savePath, **_kwargs) plots.drawPlot( p0, saveName, xlabel="label (%s)" % (_units), ylabel="yLabel", log=True, rebinX=2, #2, 5 cmsExtraText="Preliminary", #createLegend = _leg, createLegend={ "x1": 0.58, "y1": 0.65, "x2": 0.92, "y2": 0.82 }, #opts = {"xmin": 0.0, "xmax": xMax, "ymin": 0.1, "ymaxfactor": 1.3}, opts={ "ymin": 0.1, "ymaxfactor": 1.3 }, opts2={ "ymin": 0.6, "ymax": 1.4 }, cutBox={ "cutValue": 0, "fillColor": 16, "box": False, "line": True, "greaterThan": True }) leg = ROOT.TLegend(0.2, 0.8, 0.51, 0.87) leg.SetFillStyle(0) leg.SetFillColor(0) leg.SetBorderSize(0) datasetName = datasetTarg.getName() datasetName = datasetName.replace("TT", "t#bar{t}") if "ChargedHiggs" in datasetName: datasetName = datasetName.replace("ChargedHiggs_HplusTB_HplusToTB_M_", "m_{H+} = ") datasetName = datasetName + "GeV" leg.SetHeader(datasetName) #leg.Draw() SavePlot(p0, saveName, savePath) return
def PlotHistograms(datasetsMgr, dName, var): # Definitions kwargs = {} histos = [] # For-loop: All histos in list #dName = "ChargedHiggs_HplusTB_HplusToTB_M_%s" % (opts.signalMass) hPathName = "hplus2tb_/AllCleanedTop_" + var hPathName_noSF = "hplus2tb_/AllCleanedTop_" + var + "_noSF" hPathName_noSF = hPathName_noSF.replace("AllCleanedTop_Pt_noSF", "AllCleanedTop_Pt_noSFt") # SF applied p0 = plots.MCPlot(datasetsMgr, hPathName, normalizeToLumi=opts.intLumi, saveFormats=[], **kwargs) hTopSF = p0.histoMgr.getHisto(dName).getRootHisto().Clone("wSF") histos.append(hTopSF) # no SF applied p1 = plots.MCPlot(datasetsMgr, hPathName_noSF, normalizeToLumi=opts.intLumi, saveFormats=[], **kwargs) hTop_noSF = p1.histoMgr.getHisto(dName).getRootHisto().Clone("noSF") histos.append(hTop_noSF) #if opts.normaliseToOne: # hTopSF = hTopSF.Scale(1/hTopSF.Integral()) # hTop_noSF = hTop_noSF.Scale(1/hTop_noSF.Integral()) # Make comparison plot ''' nTotal = hInclusive.Integral() align = "{:>25} {:>25}" title = align.format("Histogram", "Percentage (%)") hLine = 50*"=" table = [] table.append(hLine) table.append(title) table.append(hLine) for h in histos: n = h.Integral() perc = (n/nTotal)*100 table.append(align.format(h.GetName(), " %.1f" % (perc) )) if opts.normaliseToOne: h = h.Scale(1/h.Integral()) # Print table info table.append(hLine) for row in table: print row ''' # Make comparison plot #p = plots.ComparisonManyPlot(hTop_noSF, [hTopSF], saveFormats=[]) p = plots.ComparisonManyPlot(hTopSF, [hTop_noSF], saveFormats=[]) p.setLuminosity(opts.intLumi) # Overwite signal style? style = [200, 500, 800, 1000, 2000, 5000] lstyle = [ ROOT.kSolid, ROOT.kDashed, ROOT.kDashDotted, ROOT.kDotted, ROOT.kDotted, ROOT.kSolid ] altSignalBDTGStyle = styles.StyleCompound([ styles.StyleMarker(markerSize=1.2, markerColor=ROOT.kAzure + 9, markerSizes=None, markerStyle=ROOT.kFullDiamond), styles.StyleLine(lineColor=ROOT.kAzure + 9, lineStyle=ROOT.kSolid, lineWidth=3), styles.StyleFill(fillColor=ROOT.kAzure + 9, fillStyle=3001) ]) altBackgroundBDTGStyle = styles.StyleCompound([ styles.StyleMarker(markerSize=1.2, markerColor=ROOT.kRed - 4, markerSizes=None, markerStyle=ROOT.kFullDiamond), styles.StyleLine(lineColor=ROOT.kRed - 4, lineStyle=ROOT.kSolid, lineWidth=3), #styles.StyleFill(fillColor=ROOT.kRed-4) ]) signalStyle = styles.StyleCompound([ styles.StyleMarker(markerSize=1.2, markerColor=ROOT.kTeal + 2, markerSizes=None, markerStyle=ROOT.kFullTriangleUp), styles.StyleLine(lineColor=ROOT.kTeal + 2, lineStyle=ROOT.kSolid, lineWidth=3), styles.StyleFill(fillColor=ROOT.kTeal + 2, fillStyle=3001) ]) if ("TT" in dName): p.histoMgr.forHisto("wSF", altBackgroundBDTGStyle) p.histoMgr.forHisto("noSF", altSignalBDTGStyle) elif ("QCD" in dName): p.histoMgr.forHisto( "wSF", altBackgroundBDTGStyle) #styles.getABCDStyle("VR")) p.histoMgr.forHisto("noSF", styles.qcdFillStyle) elif ("Charged" in dName): p.histoMgr.forHisto("wSF", altBackgroundBDTGStyle) p.histoMgr.forHisto("noSF", signalStyle) #p.histoMgr.forHisto("wSF" , styles.getFakeBLineStyle()) #styles.getFakeBStyle()) #p.histoMgr.forHisto("noSF" , styles.mcStyle) #getInvertedLineStyle()) # Set draw style p.histoMgr.setHistoDrawStyle("noSF", "HIST") p.histoMgr.setHistoDrawStyle("wSF", "HIST") #p.histoMgr.setHistoDrawStyle("Matched-LdgTrijet", "HIST") #p.histoMgr.setHistoDrawStyle("Matched-LdgTrijet-Bjet", "HIST") #p.histoMgr.setHistoDrawStyle("Unmatched", "HIST") # Set legend style p.histoMgr.setHistoLegendStyle("noSF", "LP") p.histoMgr.setHistoLegendStyle("wSF", "LP") #p.histoMgr.setHistoLegendStyle("Matched-LdgTrijet", "F") #p.histoMgr.setHistoLegendStyle("Matched-LdgTrijet-Bjet", "L") #p.histoMgr.setHistoLegendStyle("Unmatched", "F") p.histoMgr.setHistoLegendLabelMany({ "noSF": "no SF applied", "wSF": "SF applied", #"Matched-LdgTrijet" : "top match", #"Matched-LdgTrijet-Bjet" : "full match", #"top + b-jet match", #"Unmatched" : "Combinatoric", }) # Draw customised plot saveName = "AllCleanedTop_" + var _units = "GeV/c^{2}" if opts.signalMass > 500: _leg = {"x1": 0.70, "y1": 0.75, "x2": 0.5, "y2": 0.97} #_leg = {"x1": 0.60, "y1": 0.65, "x2": 0.85, "y2": 0.87} else: #_leg = {"x1": 0.60, "y1": 0.65, "x2": 0.85, "y2": 0.87} _leg = {"x1": 0.68, "y1": 0.78, "x2": 0.93, "y2": 0.9} if opts.normaliseToOne: yLabel = "Arbitrary Units / %0.1f " + _units else: yLabel = "Events / %0.1f " + _units if opts.logY: ymin = 1e-3 ymaxf = 5 else: ymin = 1e-3 ymaxf = 1.2 ROOT.gStyle.SetNdivisions(6 + 100 * 5 + 10000 * 2, "X") if "AllCleanedTop_M" in hPathName: plots.drawPlot( p, saveName, #xlabel = "m_{jjbb} (%s)" % (_units), ylabel=yLabel, log=opts.logY, rebinX=2, #2, 5 cmsExtraText="Preliminary", ratio=True, ratioType="errorPropagation", #"errorScale", "binomial" divideByBinWidth=False, ratioErrorOptions={ "numeratorStatSyst": False, "denominatorStatSyst": True }, ratioMoveLegend={ "dx": +0.21, "dy": 0.03, "dh": -0.08 }, ratioYlabel="Ratio ", ratioInvert=True, createLegend=_leg, #opts = {"ymin": ymin, "ymaxfactor": ymaxf}, opts={ "xmin": 0.0, "xmax": 400.0, "ymin": ymin, "ymaxfactor": ymaxf }, opts2={ "ymin": 0.6, "ymax": 1.4 }, cutBox={ "cutValue": opts.signalMass, "fillColor": 16, "box": False, "line": False, "greaterThan": True }) else: plots.drawPlot( p, saveName, #xlabel = "m_{jjbb} (%s)" % (_units), ylabel=yLabel, log=opts.logY, rebinX=2, #2, 5 cmsExtraText="Preliminary", ratio=True, ratioType="errorPropagation", #"errorScale", "binomial" divideByBinWidth=False, ratioErrorOptions={ "numeratorStatSyst": False, "denominatorStatSyst": True }, ratioMoveLegend={ "dx": +0.21, "dy": 0.03, "dh": -0.08 }, ratioYlabel="Ratio ", ratioInvert=True, createLegend=_leg, opts={ "ymin": ymin, "ymaxfactor": ymaxf }, #opts = {"xmin": 0.0, "xmax": 1400.0, "ymin": ymin, "ymaxfactor": ymaxf}, opts2={ "ymin": 0.6, "ymax": 1.4 }, cutBox={ "cutValue": opts.signalMass, "fillColor": 16, "box": False, "line": False, "greaterThan": True }) # Save plot in all formats savePath = os.path.join(opts.saveDir, opts.optMode) SavePlot(p, saveName + "_" + dName, savePath) return