Ejemplo n.º 1
0
        legend.AddEntry(graphs[-1], '', 'PL')

axis[0].GetYaxis().SetTitle('95%% CL limit on %s' % args.limit_on)
if args.y_title is not None:
    axis[0].GetYaxis().SetTitle(args.y_title)
axis[0].GetXaxis().SetTitle(args.x_title)
axis[0].GetXaxis().SetLabelOffset(axis[0].GetXaxis().GetLabelOffset() * 2)

if args.logy:
    axis[0].SetMinimum(0.1)  # we'll fix this later
    pads[0].SetLogy(True)
    # axis[0].GetYaxis().SetMoreLogLabels()
    # axis[0].SetNdivisions(50005, "X")

y_min, y_max = (plot.GetPadYMin(pads[0]), plot.GetPadYMax(pads[0]))
plot.FixBothRanges(pads[0], y_min if args.logy else 0,
                   0.05 if args.logy else 0, y_max, 0.25)

ratio_graph_sets = []
ratio_graphs = []

if args.ratio_to is not None:
    pads[1].cd()
    plot.SetupTwoPadSplitAsRatio(pads, axis[0], axis[1], 'Ratio_{}', True, 0.1,
                                 2.4)
    axis[1].SetNdivisions(506, 'Y')
    splitsrc = args.ratio_to.split(':')
    ref = plot.LimitTGraphFromJSONFile(splitsrc[0], splitsrc[1])
    for gr_set in graph_sets:
        ratio_set = {}
        for key in gr_set:
            ratio_set[key] = plot.GraphDivide(gr_set[key], ref)
Ejemplo n.º 2
0
some_presc_l1 = ROOT.TBox()
some_presc_l1.SetFillColorAlpha(ROOT.kYellow, 0.3)

boxes = []
pads[0].cd()
plot.Set(pads[0], Grid=(0, 1), Tickx=1, Ticky=1)
plot.Set(yield_hist,
         LineWidth=2,
         MarkerSize=2,
         LineColor=ROOT.kRed,
         MarkerColor=ROOT.kRed)
plot.Set(yield_hist.GetXaxis(), Title='', LabelSize=0)
plot.Set(yield_hist.GetYaxis(), Title='Yield / pb^{-1}')
yield_hist.Draw('P0')
plot.FixBothRanges(pads[0],
                   plot.GetAxisHist(pads[0]).GetMinimum(), 0.05,
                   plot.GetAxisHist(pads[0]).GetMaximum(), 0.05)
for i, run in enumerate(runs):
    if not prescale_ok[str(run)]:
        boxes.append(
            bad_trigger.DrawBox(float(i),
                                plot.GetAxisHist(pads[0]).GetMinimum(),
                                float(i + 1),
                                plot.GetAxisHist(pads[0]).GetMaximum()))
    elif not prescale_l1_ok[str(run)]:
        boxes.append(
            some_presc_l1.DrawBox(float(i),
                                  plot.GetAxisHist(pads[0]).GetMinimum(),
                                  float(i + 1),
                                  plot.GetAxisHist(pads[0]).GetMaximum()))
Ejemplo n.º 3
0
    splitsrc = args.ratio_to.split(':')
    ref = plot.LimitTGraphFromJSONFile(splitsrc[0], splitsrc[1])
    for gr_set in graph_sets:
        ratio_set = {}
        for key in gr_set:
            ratio_set[key] = plot.GraphDivide(gr_set[key], ref)
        ratio_graph_sets.append(ratio_set)
        plot.DrawLimitBand(pads[1], ratio_graph_sets[-1])
        pads[1].RedrawAxis()
        pads[1].RedrawAxis('g')
        pads[1].GetFrame().Draw()
    for gr in graphs:
        ratio_graphs.append(plot.GraphDivide(gr, ref))
        ratio_graphs[-1].Draw('LP')
    ry_min, ry_max = (plot.GetPadYMin(pads[1]), plot.GetPadYMax(pads[1]))
    plot.FixBothRanges(pads[1], ry_min, 0.1, ry_max, 0.1)

pads[0].cd()
if legend.GetNRows() == 1:
    legend.SetY1(legend.GetY2() - 0.5 * (legend.GetY2() - legend.GetY1()))
legend.Draw()

# line = ROOT.TLine()
# line.SetLineColor(ROOT.kBlue)
# line.SetLineWidth(2)
# plot.DrawHorizontalLine(pads[0], line, 1)

box = ROOT.TPave(pads[0].GetLeftMargin(), 0.81, 1 - pads[0].GetRightMargin(),
                 1 - pads[0].GetTopMargin(), 1, 'NDC')
box.Draw()
Ejemplo n.º 4
0
        newgr.GetEXlow()[i] = 0.5
        newgr.GetEXhigh()[i] = 0.5
        newgr.GetX()[i] = gr.GetX()[i]
        newgr.GetY()[i] = gr.GetY()[i]
    graphs[name] = newgr

axis = ROOT.TH1F('axis', '', 4, 0, 4)
pads[0].cd()
axis.Draw('AXIS')

plot.StyleLimitBand(graphs)
DrawLimitBand(pads[0], graphs, legend=legend)
legend.Draw()

y_min, y_max = (plot.GetPadYMin(pads[0]), plot.GetPadYMax(pads[0]))
plot.FixBothRanges(pads[0], 0, 0, y_max, 0.10)

axis.GetYaxis().SetTitle('95%% CL upper limit on %s' % '#mu_{ttH}')

labels = [
    'Combined', '#splitline{H#rightarrowleptons}{#scale[0.8]{ HIG-15-008}}',
    '#splitline{   H#rightarrowbb}{#scale[0.8]{ HIG-16-004}}',
    '#splitline{   H#rightarrow#gamma#gamma}{#scale[0.8]{HIG-15-005}}'
]
# labels = ['Combined', 'H#rightarrowleptons', 'H#rightarrowbb', 'H#rightarrow#gamma#gamma']
for i in xrange(len(labels)):
    axis.GetXaxis().SetBinLabel(i + 1, labels[i])
axis.GetXaxis().SetLabelSize(axis.GetXaxis().GetLabelSize() * 1.5)
# axis.GetXaxis().SetNdivisions(4, False)
# axis[0].GetXaxis().SetTitle(args.x_title)
# axis[0].GetXaxis().SetLabelOffset(axis[0].GetXaxis().GetLabelOffset()*2)
Ejemplo n.º 5
0
def Compare(w, output, SFname, fn1, fn2, bins, var, other_vars= {}, line_pos=None, ylims=None):
    label_vars = []
    for key, val in other_vars.iteritems():
        w.var(key).setVal(val)
        name = key
        particle = ""
        if name=="e_eta":
		name="#eta(e)"
		particle = "(e)"
	if name=="m_eta":
		name="#eta(#mu)"
		particle = "(#mu)"
        label_vars.append('%s=%g' % (name, val))
    h1 = w.function(fn1).createHistogram(fn1, w.var(var),
            ROOT.RooFit.Binning(*bins),
            ROOT.RooFit.Scaling(False)
        )
    h2 = w.function(fn2).createHistogram(fn2, w.var(var),
            ROOT.RooFit.Binning(*bins),
            ROOT.RooFit.Scaling(False)
        )
    herr = h1.Clone()
    canv = ROOT.TCanvas(output, output)
    pads = plot.TwoPadSplit(0.30, 0.01, 0.01)
    pads[0].cd()
    pads[0].SetGrid(1, 1)
    plot.Set(h1, LineColor=ROOT.kBlack, LineWidth=2)
    plot.Set(herr, FillColor=18, MarkerSize=0)
    plot.Set(herr.GetYaxis(), Title='Scale Factor')
    plot.Set(herr.GetXaxis(), Title='p_{T}%s' % (particle))
    plot.Set(h2, LineColor=ROOT.kRed, LineWidth=2)

    for i in xrange(1, h1.GetNbinsX()+1):
        h1.SetBinError(i, 0.)
        herr.SetBinError(i, herr.GetBinContent(i)*0.02)
    for i in xrange(1, h2.GetNbinsX()+1):
        h2.SetBinError(i, 0.)
    herr.Draw('E3')
    h1.Draw('LSAME')
    h2.Draw('LSAME')
    ratio = h2.Clone()
    ratio.Divide(h1)
    ratioerr = herr.Clone()
    ratioerr.Divide(h1)


    #legend = ROOT.TLegend(0.18, 0.82, 0.6, 0.93, '', 'NBNDC')
    #legend.AddEntry(h1, 'KIT + 2% error band', 'L')
    #legend.AddEntry(h2, 'DESY', 'L')
    #legend.Draw()
    print plot.GetPadYMax(pads[0])
    #plot.FixTopRange(pads[0], 1.5, 0) #plot.GetPadYMax(pads[0]), 0.25)
    #plot.FixBothRanges(pads[0], 0.0, 0, 1.5, 0)
    if ylims==None:
        upperlim=plot.GetPadYMax(pads[0])
        if upperlim>1.2:
            upperlim=1.2
        plot.FixTopRange(pads[0], upperlim, 0.25)
    else:
        plot.FixBothRanges(pads[0], ylims[0], 0, ylims[1], 0)
    plot.DrawTitle(pads[0], SFname, 1)
    plot.DrawTitle(pads[0], ','.join(label_vars), 3)
    
    canv.Update()
    box = ROOT.TBox()
    box.SetFillColor(1)
    box.SetFillStyle(3004)
    box.DrawBox(bins[1], pads[0].GetUymin(), line_pos, pads[0].GetUymax())

    line = ROOT.TLine()
    plot.Set(line, LineColor=12, LineStyle=4, LineWidth=2)
    if line_pos is not None:
        #plot.DrawVerticalLine(pads[0], line, line_pos)
        line.DrawLine(line_pos, pads[0].GetUymin(), line_pos, pads[0].GetUymax())

    legend = ROOT.TLegend(0.18, 0.82, 0.6, 0.93, '', 'NBNDC')
    legend.AddEntry(h1, 'KIT + 2% error band', 'L')
    legend.AddEntry(h2, 'DESY', 'L')
    legend.Draw()

    pads[1].cd()
    pads[1].SetGrid(1, 1)
    ratioerr.Draw('E3')
    ratio.Draw('LSAME')
    plot.SetupTwoPadSplitAsRatio(
        pads, plot.GetAxisHist(
            pads[0]), plot.GetAxisHist(pads[1]), 'KIT/DESY', True, 0.91, 1.09)
    canv.Update()
    box.DrawBox(bins[1], pads[1].GetUymin(), line_pos, pads[1].GetUymax())
    if line_pos is not None:
        #plot.DrawVerticalLine(pads[1], line, line_pos)
        line.DrawLine(line_pos, pads[1].GetUymin(), line_pos, pads[1].GetUymax())
    canv.Print('.pdf')
    canv.Print('.png')