def doPlotMu(name, graphs, styleList, limits, xlabel): objs = [] ll = {} for gr, mu in graphs: objs.append(histograms.HistoGraph(gr, "Obs%d"%mu, drawStyle="LP", legendStyle="lp")) ll["Obs%d"%mu] = "Observed, #mu=%d %s" % (mu, limit.massUnit()) plot = plots.PlotBase(objs) plot.histoMgr.forEachHisto(styles.Generator(styleList)) plot.histoMgr.setHistoLegendLabelMany(ll) plot.setLegend(histograms.moveLegend(histograms.createLegend(0.57, 0.155, 0.87, 0.355), dx=-0.1)) plot.createFrame(name, opts={"ymin": 0, "ymax": tanbMax}) plot.frame.GetXaxis().SetTitle(xlabel) plot.frame.GetYaxis().SetTitle(limit.tanblimit) plot.draw() plot.setLuminosity(limits.getLuminosity()) plot.addStandardTexts() size = 20 x = 0.2 histograms.addText(x, 0.9, limit.process, size=size) histograms.addText(x, 0.863, limits.getFinalstateText(), size=size) histograms.addText(x, 0.815, "MSSM m_{h}^{max}", size=size) histograms.addText(x, 0.775, limit.BRassumption, size=size) plot.save()
def doPlotMu(name, graphs, styleList, limits, xlabel): objs = [] ll = {} for gr, mu in graphs: objs.append( histograms.HistoGraph(gr, "Obs%d" % mu, drawStyle="LP", legendStyle="lp")) ll["Obs%d" % mu] = "Observed, #mu=%d %s" % (mu, limit.massUnit()) plot = plots.PlotBase(objs) plot.histoMgr.forEachHisto(styles.Generator(styleList)) plot.histoMgr.setHistoLegendLabelMany(ll) plot.setLegend( histograms.moveLegend(histograms.createLegend(0.57, 0.155, 0.87, 0.355), dx=-0.1)) plot.createFrame(name, opts={"ymin": 0, "ymax": tanbMax}) plot.frame.GetXaxis().SetTitle(xlabel) plot.frame.GetYaxis().SetTitle(limit.tanblimit) plot.draw() plot.setLuminosity(limits.getLuminosity()) plot.addStandardTexts() size = 20 x = 0.2 histograms.addText(x, 0.9, limit.process, size=size) histograms.addText(x, 0.863, limits.getFinalstateText(), size=size) histograms.addText(x, 0.815, "MSSM m_{h}^{max}", size=size) histograms.addText(x, 0.775, limit.BRassumption, size=size) plot.save()
def doPlot(name, graphs, limits, xlabel): if "obs" in graphs.keys(): obs = graphs["obs"] excluded = ROOT.TGraph(obs) excluded.SetName("ExcludedArea") excluded.SetFillColor(ROOT.kGray) excluded.SetPoint(excluded.GetN(), obs.GetX()[obs.GetN() - 1], tanbMax) excluded.SetPoint(excluded.GetN(), obs.GetX()[0], tanbMax) excluded.SetFillColor(ROOT.kGray) excluded.SetFillStyle(3354) excluded.SetLineWidth(0) excluded.SetLineColor(ROOT.kWhite) plot = None if "obs" in graphs.keys(): plot = plots.PlotBase([ histograms.HistoGraph(graphs["obs"], "Observed", drawStyle="PL", legendStyle="lp"), histograms.HistoGraph(graphs["obs_th_plus"], "ObservedPlus", drawStyle="L", legendStyle="l"), histograms.HistoGraph(graphs["obs_th_minus"], "ObservedMinus", drawStyle="L"), histograms.HistoGraph(excluded, "Excluded", drawStyle="F", legendStyle="f"), histograms.HistoGraph(graphs["exp"], "Expected", drawStyle="L"), histograms.HistoGraph(graphs["exp1"], "Expected1", drawStyle="F", legendStyle="fl"), histograms.HistoGraph(graphs["exp2"], "Expected2", drawStyle="F", legendStyle="fl"), ]) plot.histoMgr.setHistoLegendLabelMany({ "ObservedPlus": "Observed #pm1#sigma (th.)", "ObservedMinus": None, "Expected": None, "Expected1": "Expected median #pm 1#sigma", "Expected2": "Expected median #pm 2#sigma" }) else: plot = plots.PlotBase([ histograms.HistoGraph(graphs["exp"], "Expected", drawStyle="L"), histograms.HistoGraph(graphs["exp1"], "Expected1", drawStyle="F", legendStyle="fl"), histograms.HistoGraph(graphs["exp2"], "Expected2", drawStyle="F", legendStyle="fl"), ]) plot.histoMgr.setHistoLegendLabelMany({ "Expected": None, "Expected1": "Expected median #pm 1#sigma", "Expected2": "Expected median #pm 2#sigma" }) plot.setLegend(histograms.createLegend(0.57, 0.155, 0.87, 0.355)) plot.createFrame(name, opts={"ymin": 0, "ymax": tanbMax}) plot.frame.GetXaxis().SetTitle(xlabel) plot.frame.GetYaxis().SetTitle(limit.tanblimit) plot.draw() plot.setLuminosity(limits.getLuminosity()) plot.addStandardTexts() size = 20 x = 0.2 histograms.addText(x, 0.9, limit.process, size=size) histograms.addText(x, 0.863, limits.getFinalstateText(), size=size) histograms.addText(x, 0.815, "MSSM m_{h}^{max}", size=size) histograms.addText(x, 0.775, limit.BRassumption, size=size) histograms.addText(x, 0.735, "#mu=%d %s" % (mu, limit.massUnit()), size=size) plot.save()
def doPlot(rootfile): f = ROOT.TFile.Open(rootfile) basename = rootfile.replace(".root", "") match = name_re.search(rootfile) if not match: raise Exception("Assert: the file name regex did not match") mass = match.group("mass") name = match.group("name") canvas = f.Get("c1") primitives = canvas.GetListOfPrimitives() # Suppress the warning message of missing dictionary for some iterator backup = ROOT.gErrorIgnoreLevel ROOT.gErrorIgnoreLevel = ROOT.kError primiter = primitives.MakeIterator() ROOT.gErrorIgnoreLevel = backup graph = None expoFit = None lines = [] obj = primiter.Next() while obj: # print obj, obj.GetName() if isinstance(obj, ROOT.TGraph): if graph != None: raise Exception("Assert: graph was already found") graph = obj elif isinstance(obj, ROOT.TF1): if expoFit != None: raise Exception("Assert: expoFit was already found") expoFit = obj elif isinstance(obj, ROOT.TLine): lines.append(obj) obj = primiter.Next() if graph == None: raise Exception("Assert: did not find any TGraph") if expoFit == None: raise Exception("Assert: did not find any TF1") plot = plots.PlotBase( [histograms.HistoGraph(graph, "CLs", drawStyle="PE")]) plot.createFrame(basename, opts={ "xmin": 0, "ymin": 0, "ymaxfactor": 1.1, "xmaxlist": [0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.15, 0.2] }) plot.frame.GetXaxis().SetTitle("#mu") plot.frame.GetXaxis().SetNdivisions(1005) plot.frame.GetYaxis().SetTitle("CL_{s}") expoFit.SetLineColor(ROOT.kBlue - 9) # skip the vertical non-solid lines lines = filter(lambda l: l.GetLineStyle() == 1 or l.GetX1() != l.GetX2(), lines) plot.prependPlotObject(expoFit) for l in lines: plot.appendPlotObject(l) plot.draw() labelName = { "observed": "Observed", "median": "Expected median", "1sigma": "Expected +1#sigma", "2sigma": "Expected +2#sigma", "-1sigma": "Expected .1#sigma", "-2sigma": "Expected -2#sigma" }[name] size = 20 x = 0.62 histograms.addText(x, 0.85, "m_{H^{+}} = %s %s" % (mass, limit.massUnit()), size=size) histograms.addText(x, 0.81, labelName, size=size) plot.save() f.Close() f.Delete()
def doPlotMu(name, graphs, styleList, limits, xlabel, xvarName, legendVariable): objs = [] ll = {} cutValue = 100 # for cutting a slice +- cutValue around 0 from the (mu,tanb) plot for gr, mu in graphs: if xvarName == "mu": histo = histograms.HistoGraph(gr, "Obs%d"%mu, drawStyle="LP", legendStyle="lp") plus = gr.Clone() minus = gr.Clone() N = gr.GetN() for i in range(0,N): j = N - 1 - i x = gr.GetX()[j] if x > -cutValue: minus.RemovePoint(j) if x < cutValue: plus.RemovePoint(0) objs.append(histograms.HistoGraph(minus, "Obs%d"%mu, drawStyle="LP", legendStyle="lp")) objs.append(histograms.HistoGraph(plus, "ObsCopy%d"%mu, drawStyle="LP", legendStyle="lp")) ll["ObsCopy%d"%mu] = None else: objs.append(histograms.HistoGraph(gr, "Obs%d"%mu, drawStyle="LP", legendStyle="lp")) ll["Obs%d"%mu] = "Observed, "+legendVariable+"=%d %s" % (mu, limit.massUnit()) # N = gr.GetN() # for i in range(0,N): # j = N - 1 - i # if gr.GetY()[j] == 1: # gr.RemovePoint(j) plot = plots.PlotBase(objs) if xvarName == "mu": doubleStyleList = [] for style in styleList: doubleStyleList.append(style) doubleStyleList.append(style) plot.histoMgr.forEachHisto(styles.Generator(doubleStyleList)) else: plot.histoMgr.forEachHisto(styles.Generator(styleList)) plot.histoMgr.setHistoLegendLabelMany(ll) plot.setLegend(histograms.moveLegend(histograms.createLegend(0.57, 0.155, 0.87, 0.355), dx=-0.1)) plot.createFrame(name, opts={"ymin": 0, "ymax": tanbMax}) plot.frame.GetXaxis().SetTitle(xlabel) plot.frame.GetXaxis().SetLabelSize(20) plot.frame.GetYaxis().SetTitle(limit.tanblimit) plot.draw() plot.setLuminosity(limits.getLuminosity()) plot.addStandardTexts() size = 20 x = 0.2 histograms.addText(x, 0.9, limit.process, size=size) histograms.addText(x, 0.863, limits.getFinalstateText(), size=size) histograms.addText(x, 0.815, "MSSM m_{h}^{max}", size=size) # histograms.addText(x, 0.775, limit.BRassumption, size=size) histograms.addText(x, 0.72, "FeynHiggs 2.9.4", size=size) histograms.addText(x, 0.65, "Derived from", size=size) histograms.addText(x, 0.6, "CMS HIG-12-052", size=size) # histograms.addText(x, 0.6, "CMS HIG-11-019", size=size) # histograms.addText(x, 0.55, "JHEP07(2012)143", size=size) #Adding a LHC label: ROOT.LHCHIGGS_LABEL(0.97,0.72,1) plot.save() print print "Plotting",name print
def doPlot(mass, mu, mul=None): f = openFile(mass) tree_obs = f.Get("TESTED_R%s"%mu) if not tree_obs: print "Did not find TESTED_R%s TTree in file %s" % (mu, f.GetName()) listMu(mass, f) f.Close() return tree_sb = f.Get("SAMPLING_SB_TESTED_R%s" % mu) if not tree_sb: raise Exception("Did not find SAMPLING_SB_TESTED_R%s from file %s" % (mu, f.GetName())) tree_b = f.Get("SAMPLING_B_TESTED_R%s" % mu) if not tree_b: raise Exception("Did not find SAMPLING_B_TESTED_R%s from file %s" % (mu, f.GetName())) xmin = min(tree_sb.GetMinimum("brT"), tree_b.GetMinimum("brT")) xmax = max(tree_sb.GetMaximum("brT"), tree_b.GetMaximum("brT")) obsval = tree_obs.GetMinimum("brT") # Get the distributions tree_sb.Draw("brT >>hsb(%d, %f, %f)" % (nbins, xmin, xmax), "", "goff") h_sb = tree_sb.GetHistogram() tree_b.Draw("brT >>hb(%d, %f, %f)" % (nbins, xmin, xmax), "", "goff") h_b = tree_b.GetHistogram() # Set obsval to bin boundary obsval_bin = obsval for bin in xrange(0, h_sb.GetNbinsX()+1): edge = h_sb.GetBinLowEdge(bin) if obsval > edge: obsval_bin = edge # Normalize the distributions to unit area dataset._normalizeToOne(h_sb) dataset._normalizeToOne(h_b) plot = plots.PlotBase([ histograms.Histo(h_b, "B"), histograms.Histo(h_sb, "SB") ]) mulegend = mul if mul == None: mulegend = mu plot.histoMgr.setHistoLegendLabelMany({ "B": "f(#tilde{q}_{#mu=%s} | #mu=0, #hat{#bf{#theta}}_{0}^{obs})" % mulegend, "SB": "f(#tilde{q}_{#mu=%s} | #mu=%s, #hat{#bf{#theta}}_{#mu=%s}^{obs})" % (mulegend, mulegend, mulegend), }) plot.setLegend(histograms.moveLegend(histograms.createLegend(0.6, 0.8, 0.9, 0.9), dy=0.02, dx=-0.05)) plot.histoMgr.forEachHisto(styles.generator()) fname = "teststat_m%s_mu%s" % (mass, mu) plot.createFrame(fname.replace(".", "_"), opts={"ymin": 1e-6, "ymaxfactor": 2}) plot.frame.GetXaxis().SetTitle("Test statistic #tilde{q}_{#mu}") plot.frame.GetYaxis().SetTitle("Arbitrary units") plot.getPad().SetLogy(True) area_sb = h_sb.Clone("AreaSB") area_sb.SetFillColor(area_sb.GetLineColor()) area_sb.SetFillStyle(3005) area_sb.SetLineWidth(0) area_b = h_b.Clone("AreaB") area_b.SetFillColor(area_b.GetLineColor()) area_b.SetFillStyle(3004) area_b.SetLineWidth(0) for bin in xrange(0, area_sb.GetNbinsX()+1): if area_sb.GetBinLowEdge(bin) < obsval_bin: area_sb.SetBinContent(bin, 0) if area_b.GetBinLowEdge(bin) >= obsval_bin: area_b.SetBinContent(bin, 0) plot.appendPlotObject(area_b, "HIST ][") plot.appendPlotObject(area_sb, "HIST ][") plot.addCutBoxAndLine(box=False, cutValue=obsval_bin) plot.draw() size = 26 histograms.addText(0.35, 0.4, "CL_{s+b}", size=size) histograms.addText(0.18, 0.4, "1-CL_{b}", size=size) size = 20 # x = obsval_bin/(plot.frame.GetXaxis().GetXmax() - plot.frame.GetXaxis().GetXmin())+0.02 x = (obsval_bin - plot.getPad().GetX1()) / (plot.getPad().GetX2() - plot.getPad().GetX1()) x += 0.01 histograms.addText(x, 0.88, "Observed", size=size) histograms.addText(x, 0.85, "value", size=size) histograms.addText(0.62, 0.78, "m_{H^{+}} = %s %s" % (mass, limit.massUnit()), size=size) # size = 20 # x = 0.2 # histograms.addText(x, 0.88, brlimit.process, size=size) # histograms.addText(x, 0.84, brlimit._finalstateLabels["taujets"], size=size) # histograms.addText(x, 0.79, brlimit.BRassumption, size=size) plot.save() f.Close()
def doPlot(name, graphs, limits, xlabel): if "obs" in graphs.keys(): obs = graphs["obs"] excluded = ROOT.TGraph(obs) excluded.SetName("ExcludedArea") excluded.SetFillColor(ROOT.kGray) excluded.SetPoint(excluded.GetN(), obs.GetX()[obs.GetN()-1], tanbMax) excluded.SetPoint(excluded.GetN(), obs.GetX()[0], tanbMax) excluded.SetFillColor(ROOT.kGray) excluded.SetFillStyle(3354) excluded.SetLineWidth(0) excluded.SetLineColor(ROOT.kWhite) plot = None if "obs" in graphs.keys(): plot = plots.PlotBase([ histograms.HistoGraph(graphs["obs"], "Observed", drawStyle="PL", legendStyle="lp"), histograms.HistoGraph(graphs["obs_th_plus"], "ObservedPlus", drawStyle="L", legendStyle="l"), histograms.HistoGraph(graphs["obs_th_minus"], "ObservedMinus", drawStyle="L"), histograms.HistoGraph(excluded, "Excluded", drawStyle="F", legendStyle="f"), histograms.HistoGraph(graphs["exp"], "Expected", drawStyle="L"), histograms.HistoGraph(graphs["exp1"], "Expected1", drawStyle="F", legendStyle="fl"), histograms.HistoGraph(graphs["exp2"], "Expected2", drawStyle="F", legendStyle="fl"), ]) plot.histoMgr.setHistoLegendLabelMany({ "ObservedPlus": "Observed #pm1#sigma (th.)", "ObservedMinus": None, "Expected": None, "Expected1": "Expected median #pm 1#sigma", "Expected2": "Expected median #pm 2#sigma" }) else: plot = plots.PlotBase([ histograms.HistoGraph(graphs["exp"], "Expected", drawStyle="L"), histograms.HistoGraph(graphs["exp1"], "Expected1", drawStyle="F", legendStyle="fl"), histograms.HistoGraph(graphs["exp2"], "Expected2", drawStyle="F", legendStyle="fl"), ]) plot.histoMgr.setHistoLegendLabelMany({ "Expected": None, "Expected1": "Expected median #pm 1#sigma", "Expected2": "Expected median #pm 2#sigma" }) plot.setLegend(histograms.createLegend(0.57, 0.155, 0.87, 0.355)) plot.createFrame(name, opts={"ymin": 0, "ymax": tanbMax}) plot.frame.GetXaxis().SetTitle(xlabel) plot.frame.GetYaxis().SetTitle(limit.tanblimit) plot.draw() plot.setLuminosity(limits.getLuminosity()) plot.addStandardTexts() size = 20 x = 0.2 histograms.addText(x, 0.9, limit.process, size=size) histograms.addText(x, 0.863, limits.getFinalstateText(), size=size) histograms.addText(x, 0.815, "MSSM m_{h}^{max}", size=size) histograms.addText(x, 0.775, limit.BRassumption, size=size) histograms.addText(x, 0.735, "#mu=%d %s"%(mu, limit.massUnit()), size=size) plot.save()
def doPlot(rootfile): f = ROOT.TFile.Open(rootfile) basename = rootfile.replace(".root", "") match = name_re.search(rootfile) if not match: raise Exception("Assert: the file name regex did not match") mass = match.group("mass") name = match.group("name") canvas = f.Get("c1") primitives = canvas.GetListOfPrimitives() # Suppress the warning message of missing dictionary for some iterator backup = ROOT.gErrorIgnoreLevel ROOT.gErrorIgnoreLevel = ROOT.kError primiter = primitives.MakeIterator() ROOT.gErrorIgnoreLevel = backup graph = None expoFit = None lines = [] obj = primiter.Next() while obj: # print obj, obj.GetName() if isinstance(obj, ROOT.TGraph): if graph != None: raise Exception("Assert: graph was already found") graph = obj elif isinstance(obj, ROOT.TF1): if expoFit != None: raise Exception("Assert: expoFit was already found") expoFit = obj elif isinstance(obj, ROOT.TLine): lines.append(obj) obj = primiter.Next() if graph == None: raise Exception("Assert: did not find any TGraph") if expoFit == None: raise Exception("Assert: did not find any TF1") plot = plots.PlotBase([ histograms.HistoGraph(graph, "CLs", drawStyle="PE") ]) plot.createFrame(basename, opts={"xmin": 0, "ymin": 0, "ymaxfactor": 1.1, "xmaxlist": [0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.15, 0.2] }) plot.frame.GetXaxis().SetTitle("#mu") plot.frame.GetXaxis().SetNdivisions(1005) plot.frame.GetYaxis().SetTitle("CL_{s}") expoFit.SetLineColor(ROOT.kBlue-9) # skip the vertical non-solid lines lines = filter(lambda l: l.GetLineStyle() == 1 or l.GetX1() != l.GetX2(), lines) plot.prependPlotObject(expoFit) for l in lines: plot.appendPlotObject(l) plot.draw() labelName = {"observed": "Observed", "median": "Expected median", "1sigma": "Expected +1#sigma", "2sigma": "Expected +2#sigma", "-1sigma": "Expected .1#sigma", "-2sigma": "Expected -2#sigma"}[name] size = 20 x = 0.62 histograms.addText(x, 0.85, "m_{H^{+}} = %s %s" % (mass, limit.massUnit()), size=size) histograms.addText(x, 0.81, labelName, size=size) plot.save() f.Close() f.Delete()
def doPlotMu(name, graphs, styleList, limits, xlabel, xvarName, legendVariable): objs = [] ll = {} cutValue = 100 # for cutting a slice +- cutValue around 0 from the (mu,tanb) plot for gr, mu in graphs: if xvarName == "mu": histo = histograms.HistoGraph(gr, "Obs%d" % mu, drawStyle="LP", legendStyle="lp") plus = gr.Clone() minus = gr.Clone() N = gr.GetN() for i in range(0, N): j = N - 1 - i x = gr.GetX()[j] if x > -cutValue: minus.RemovePoint(j) if x < cutValue: plus.RemovePoint(0) objs.append( histograms.HistoGraph(minus, "Obs%d" % mu, drawStyle="LP", legendStyle="lp")) objs.append( histograms.HistoGraph(plus, "ObsCopy%d" % mu, drawStyle="LP", legendStyle="lp")) ll["ObsCopy%d" % mu] = None else: objs.append( histograms.HistoGraph(gr, "Obs%d" % mu, drawStyle="LP", legendStyle="lp")) ll["Obs%d" % mu] = "Observed, " + legendVariable + "=%d %s" % (mu, limit.massUnit()) # N = gr.GetN() # for i in range(0,N): # j = N - 1 - i # if gr.GetY()[j] == 1: # gr.RemovePoint(j) plot = plots.PlotBase(objs) if xvarName == "mu": doubleStyleList = [] for style in styleList: doubleStyleList.append(style) doubleStyleList.append(style) plot.histoMgr.forEachHisto(styles.Generator(doubleStyleList)) else: plot.histoMgr.forEachHisto(styles.Generator(styleList)) plot.histoMgr.setHistoLegendLabelMany(ll) plot.setLegend( histograms.moveLegend(histograms.createLegend(0.57, 0.155, 0.87, 0.355), dx=-0.1)) plot.createFrame(name, opts={"ymin": 0, "ymax": tanbMax}) plot.frame.GetXaxis().SetTitle(xlabel) plot.frame.GetXaxis().SetLabelSize(20) plot.frame.GetYaxis().SetTitle(limit.tanblimit) plot.draw() plot.setLuminosity(limits.getLuminosity()) plot.addStandardTexts() size = 20 x = 0.2 histograms.addText(x, 0.9, limit.process, size=size) histograms.addText(x, 0.863, limits.getFinalstateText(), size=size) histograms.addText(x, 0.815, "MSSM m_{h}^{max}", size=size) # histograms.addText(x, 0.775, limit.BRassumption, size=size) histograms.addText(x, 0.72, "FeynHiggs 2.9.4", size=size) histograms.addText(x, 0.65, "Derived from", size=size) histograms.addText(x, 0.6, "CMS HIG-12-052", size=size) # histograms.addText(x, 0.6, "CMS HIG-11-019", size=size) # histograms.addText(x, 0.55, "JHEP07(2012)143", size=size) #Adding a LHC label: ROOT.LHCHIGGS_LABEL(0.97, 0.72, 1) plot.save() print print "Plotting", name print
def doPlot(mass, mu, mul=None): f = openFile(mass) tree_obs = f.Get("TESTED_R%s" % mu) if not tree_obs: print "Did not find TESTED_R%s TTree in file %s" % (mu, f.GetName()) listMu(mass, f) f.Close() return tree_sb = f.Get("SAMPLING_SB_TESTED_R%s" % mu) if not tree_sb: raise Exception("Did not find SAMPLING_SB_TESTED_R%s from file %s" % (mu, f.GetName())) tree_b = f.Get("SAMPLING_B_TESTED_R%s" % mu) if not tree_b: raise Exception("Did not find SAMPLING_B_TESTED_R%s from file %s" % (mu, f.GetName())) xmin = min(tree_sb.GetMinimum("brT"), tree_b.GetMinimum("brT")) xmax = max(tree_sb.GetMaximum("brT"), tree_b.GetMaximum("brT")) obsval = tree_obs.GetMinimum("brT") # Get the distributions tree_sb.Draw("brT >>hsb(%d, %f, %f)" % (nbins, xmin, xmax), "", "goff") h_sb = tree_sb.GetHistogram() tree_b.Draw("brT >>hb(%d, %f, %f)" % (nbins, xmin, xmax), "", "goff") h_b = tree_b.GetHistogram() # Set obsval to bin boundary obsval_bin = obsval for bin in xrange(0, h_sb.GetNbinsX() + 1): edge = h_sb.GetBinLowEdge(bin) if obsval > edge: obsval_bin = edge # Normalize the distributions to unit area dataset._normalizeToOne(h_sb) dataset._normalizeToOne(h_b) plot = plots.PlotBase( [histograms.Histo(h_b, "B"), histograms.Histo(h_sb, "SB")]) mulegend = mul if mul == None: mulegend = mu plot.histoMgr.setHistoLegendLabelMany({ "B": "f(#tilde{q}_{#mu=%s} | #mu=0, #hat{#bf{#theta}}_{0}^{obs})" % mulegend, "SB": "f(#tilde{q}_{#mu=%s} | #mu=%s, #hat{#bf{#theta}}_{#mu=%s}^{obs})" % (mulegend, mulegend, mulegend), }) plot.setLegend( histograms.moveLegend(histograms.createLegend(0.6, 0.8, 0.9, 0.9), dy=0.02, dx=-0.05)) plot.histoMgr.forEachHisto(styles.generator()) fname = "teststat_m%s_mu%s" % (mass, mu) plot.createFrame(fname.replace(".", "_"), opts={ "ymin": 1e-6, "ymaxfactor": 2 }) plot.frame.GetXaxis().SetTitle("Test statistic #tilde{q}_{#mu}") plot.frame.GetYaxis().SetTitle("Arbitrary units") plot.getPad().SetLogy(True) area_sb = h_sb.Clone("AreaSB") area_sb.SetFillColor(area_sb.GetLineColor()) area_sb.SetFillStyle(3005) area_sb.SetLineWidth(0) area_b = h_b.Clone("AreaB") area_b.SetFillColor(area_b.GetLineColor()) area_b.SetFillStyle(3004) area_b.SetLineWidth(0) for bin in xrange(0, area_sb.GetNbinsX() + 1): if area_sb.GetBinLowEdge(bin) < obsval_bin: area_sb.SetBinContent(bin, 0) if area_b.GetBinLowEdge(bin) >= obsval_bin: area_b.SetBinContent(bin, 0) plot.appendPlotObject(area_b, "HIST ][") plot.appendPlotObject(area_sb, "HIST ][") plot.addCutBoxAndLine(box=False, cutValue=obsval_bin) plot.draw() size = 26 histograms.addText(0.35, 0.4, "CL_{s+b}", size=size) histograms.addText(0.18, 0.4, "1-CL_{b}", size=size) size = 20 # x = obsval_bin/(plot.frame.GetXaxis().GetXmax() - plot.frame.GetXaxis().GetXmin())+0.02 x = (obsval_bin - plot.getPad().GetX1()) / (plot.getPad().GetX2() - plot.getPad().GetX1()) x += 0.01 histograms.addText(x, 0.88, "Observed", size=size) histograms.addText(x, 0.85, "value", size=size) histograms.addText(0.62, 0.78, "m_{H^{+}} = %s %s" % (mass, limit.massUnit()), size=size) # size = 20 # x = 0.2 # histograms.addText(x, 0.88, brlimit.process, size=size) # histograms.addText(x, 0.84, brlimit._finalstateLabels["taujets"], size=size) # histograms.addText(x, 0.79, brlimit.BRassumption, size=size) plot.save() f.Close()