예제 #1
0
legend.AddEntry(sm, 'SM Higgs Boson', 'L')
# legend.Draw()

l_off2 = 0.2 if split else 0.
legend2 = ROOT.TLegend(0.55, 0.16+l_off2, 0.93, 0.45+l_off2*0.7, '', 'NBNDC')
legend2.AddEntry(kappa_graph, 'ATLAS+CMS', 'EP')
legend2.AddEntry(sm, 'SM Higgs boson', 'L')
legend2.AddEntry(best_line, '[M, #varepsilon] fit', 'L')
# legend2.SetHeader('[M, #varepsilon] fit')
legend2.AddEntry(c68, '68% CL', 'F')
legend2.AddEntry(c95, '95% CL', 'F')

legend2.Draw()

plot.DrawTitle(pads[0], args.title_right, 3)
plot.DrawCMSLogo(pads[0], '#splitline{#it{ATLAS}#bf{ and }#it{CMS}}{#it{LHC} #bf{Run 1}}', '', 11, 0.045, 0.035, 1.2)

pads[0].RedrawAxis()


canv.Print('.pdf')
canv.Print('.png')

fout = ROOT.TFile('%s.root' % args.output, 'RECREATE')
fout.WriteTObject(c68, 'MepsFit68')
fout.WriteTObject(c95, 'MepsFit95')
fout.WriteTObject(kappa_graph, 'ReducedKappas')
fout.WriteTObject(sm, 'SMExpected')
fout.Close()

예제 #2
0
        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()

legend.Draw()

plot.DrawCMSLogo(pads[0], 'CMS', args.cms_sub, 11, 0.045, 0.035, 1.2, '', 0.8)
plot.DrawTitle(pads[0], args.title_right, 3)
plot.DrawTitle(pads[0], args.title_left, 1)

canv.Print('.pdf')
canv.Print('.png')
# maketable.TablefromJson(args.table_vals, args.file, "TablefromJson.txt")
예제 #3
0
def MakeMultiHistPlot(name, outdir, hists, cfg, layout, ratios=None):
    js_workaround = False
    copyhists = {}
    for hname, h in hists.iteritems():
        if len(cfg['rebinvar']):
            copyhists[hname] = VariableRebin(h, cfg['rebinvar'])
        else:
            copyhists[hname] = h.Clone()
        if cfg['norm_to'] > 0.:
            copyhists[hname].Scale(cfg['norm_to'] /
                                   copyhists[hname].Integral())
        if cfg['divwidth']:
            copyhists[hname].Scale(1., 'width')

    hists = copyhists

    # Canvas and pads
    if cfg['pads'] is not None:
        pads = cfg['pads']
    elif cfg['ratio'] or cfg['fraction']:
        canv = ROOT.TCanvas(name, name)
        if cfg['purity']:
            pads = plot.MultiRatioSplit([0.27, 0.13], [0.005, 0.005],
                                        [0.005, 0.005])
        else:
            # if js_workaround:
            #     upper = ROOT.TPad('upper', 'upper', 0., cfg['ratio_pad_frac'], 1., 1.)
            #     upper.SetBottomMargin(0.01)
            #     # upper.SetFillStyle(4000)
            #     upper.Draw()
            #     lower = ROOT.TPad('lower', 'lower', 0., 0., 1., cfg['ratio_pad_frac'])
            #     lower.SetTopMargin(0.01)
            #     # lower.SetFillStyle(4000)
            #     lower.Draw()
            #     upper.cd()
            #     pads = [upper, lower]
            # else:
            #     pads = plot.TwoPadSplit(cfg['ratio_pad_frac'], 0.01, 0.01)
            pads = plot.TwoPadSplit(cfg['ratio_pad_frac'], 0.01, 0.01)

    else:
        canv = ROOT.TCanvas(name, name)
        pads = plot.OnePad()

    # Allow the user to skip specifying a list of entries for a given plot element.
    # If it's not been specified then we will add it manually
    for info in layout:
        if 'entries' not in info:
            info['entries'] = [info['name']]
        for opt in cfg['global_hist_opts']:
            if opt not in info:
                info[opt] = cfg['global_hist_opts'][opt]

    h_data = None
    if cfg['type'] == 'datamc':
        # Get the data and create axis hist
        h_data = hists[cfg['data_name']]
    else:
        h_data = hists[layout[0]['entries'][0]]

    if isinstance(h_data, ROOT.TH2):
        print 'TH2: aborting!'
        return

    h_axes = [h_data.Clone() for x in pads]
    for h in h_axes:
        h.SetTitle("")
        if len(cfg['x_range']):
            h.GetXaxis().SetRangeUser(*cfg['x_range'])
        h.Reset()

    build_h_tot = True
    h_tot = None
    if 'TotalProcs' in hists:
        h_tot = hists['TotalProcs']
        build_h_tot = False
    if cfg['type'] != 'datamc':
        build_h_tot = False

    if isinstance(cfg['x_title'], list) or isinstance(cfg['x_title'], tuple):
        x_title = cfg['x_title'][0]
        units = cfg['x_title'][1]
    else:
        x_title = cfg['x_title']
        units = ''

    if x_title == '' and h_data.GetXaxis().GetTitle() != '':
        x_title = h_data.GetXaxis().GetTitle()

    if ':' in x_title:
        units = x_title.split(':')[1]
        x_title = x_title.split(':')[0]

    if cfg['logy']:
        pads[0].SetLogy()
        h_axes[0].SetMinimum(cfg['logy_min'])

    rpad_idx = len(pads) - 1

    if cfg['ratio'] or cfg['fraction']:
        plot.StandardAxes(h_axes[rpad_idx].GetXaxis(), h_axes[0].GetYaxis(),
                          x_title, units)
    else:
        plot.StandardAxes(h_axes[0].GetXaxis(), h_axes[0].GetYaxis(), x_title,
                          units)
    h_axes[0].Draw()

    # A dict to keep track of the hists
    h_store = {}
    p_store = {}

    legend = ROOT.TLegend(*(cfg['legend_pos'] + ['', 'NBNDC']))
    stack = ROOT.THStack()
    purity_stack = ROOT.THStack()

    curr_auto_colour = 0
    for info in layout:
        hist = hists[info['entries'][0]]
        if 'color' in info:
            col = info['color']
        else:
            col = AUTO_COLOURS[curr_auto_colour]
            if curr_auto_colour == (len(AUTO_COLOURS) - 1):
                curr_auto_colour = 0
            else:
                curr_auto_colour += 1
        # col = info['color']
        if isinstance(col, list):
            col = ROOT.TColor.GetColor(*col)
        # print info['line_width']
        if cfg['type'] == 'multihist':
            plot.Set(hist,
                     FillColor=col,
                     MarkerColor=col,
                     LineColor=col,
                     Title=info['legend'],
                     MarkerSize=info['marker_size'],
                     LineWidth=info['line_width'])
        else:
            plot.Set(hist,
                     FillColor=col,
                     MarkerColor=col,
                     Title=info['legend'],
                     MarkerSize=info['marker_size'],
                     LineWidth=info['line_width'])
        if len(info['entries']) > 1:
            for other in info['entries'][1:]:
                hist.Add(hists[other])
        h_store[info['name']] = hist
        p_store[info['name']] = hist.Clone()
        if build_h_tot:
            if h_tot is None:
                h_tot = hist.Clone()
            else:
                h_tot.Add(hist)
        if cfg['type'] == 'datamc':
            stack.Add(hist)
        else:
            hist.Draw('SAME%s' % info['draw_opts'])

    # h_tot_purity = h_tot.Clone()
    for info in layout:
        p_store[info['name']].Divide(h_tot)
        purity_stack.Add(p_store[info['name']])

    if cfg['type'] == 'datamc':
        h_tot.SetFillColor(plot.CreateTransparentColor(12, 0.3))
        h_tot.SetMarkerSize(0)
        legend.AddEntry(h_data, 'Observed', 'PL')

    # Build overlays
    for info in cfg['overlays']:
        hist = None
        input_list = []
        if isinstance(info['entries'], str):
            input_list = list(all_input_hists)
        else:
            input_list = list(info['entries'])
        updated_list = []
        for xh in input_list:
            if xh + info['hist_postfix'] in hists:
                updated_list.append(xh + info['hist_postfix'])
            else:
                updated_list.append(xh)
        print updated_list
        hist = HistSum(hists, updated_list)
        col = info['color']
        if isinstance(col, list):
            col = ROOT.TColor.GetColor(*col)
        plot.Set(hist,
                 LineColor=col,
                 LineWidth=1,
                 MarkerSize=0,
                 Title=info['legend'])
        for ib in xrange(1, hist.GetNbinsX() + 1):
            hist.SetBinError(ib, 1E-7)
        h_store[info['name']] = hist

    if cfg['type'] == 'datamc':
        for ele in reversed(layout):
            legend.AddEntry(h_store[ele['name']], ele['legend'],
                            ele['legend_opts'])
    else:
        for ele in layout:
            leg_extra = ''
            if cfg['legend_show_yields']:
                leg_extra = ' (%.1f)' % h_store[ele['name']].Integral(
                    'width' if cfg['divwidth'] else '')
            legend.AddEntry(h_store[ele['name']], ele['legend'] + leg_extra,
                            ele['legend_opts'])

    if cfg['type'] == 'datamc':
        bkg_uncert_label = 'Stat. Uncertainty'
        if not build_h_tot:
            bkg_uncert_label = 'Uncertainty'
        legend.AddEntry(h_tot, bkg_uncert_label, 'F')

        stack.Draw('HISTSAME')
        h_tot.Draw("E2SAME")

        for info in cfg['overlays']:
            h_store[info['name']].Draw('HISTSAME')

        if not cfg['hide_data']:
            h_data.Draw('E0SAME')

    for info in cfg['overlays']:
        legend.AddEntry(h_store[info['name']], info['legend'], 'L')

    plot.FixTopRange(pads[0], plot.GetPadYMax(pads[0]), 0.35)
    legend.Draw()
    # if cfg['legend_padding'] > 0.:
    #     plot.FixBoxPadding(pads[0], legend, cfg['legend_padding'])

    # Do the ratio plot
    r_store = {}
    r_data = None
    r_tot = None
    if cfg['ratio'] or cfg['fraction']:
        pads[rpad_idx].cd()
        pads[rpad_idx].SetGrid(0, 1)
        h_axes[rpad_idx].Draw()

        if cfg['type'] == 'datamc' and cfg['ratio']:
            r_data = plot.MakeRatioHist(h_data, h_tot, True, False)
            r_tot = plot.MakeRatioHist(h_tot, h_tot, True, False)
            r_tot.Draw('E2SAME')
            for info in cfg['overlays']:
                r_store[info['name']] = plot.MakeRatioHist(
                    h_store[info['name']], h_tot, False, False)
                r_store[info['name']].Draw('SAME')
            if not cfg['hide_data']:
                r_data.Draw('SAME')

        if cfg['type'] == 'datamc' and cfg['fraction']:
            r_frac = plot.MakeRatioHist(h_tot, h_data, True, True)
            r_frac.Draw('SAME')
            plot.SetupTwoPadSplitAsRatio(pads, plot.GetAxisHist(pads[0]),
                                         plot.GetAxisHist(pads[rpad_idx]),
                                         'Exp/Obs', True, 0.0, 0.5)

        if ratios is not None:
            for info in ratios:
                if 'type' in info and info['type'] == 'binomial':
                    rhist = h_store[info['num']].Clone()
                    rhist.Divide(h_store[info['num']], h_store[info['den']],
                                 1., 1., "B")
                elif 'type' in info and info['type'] == 'noerror':
                    rhist = plot.MakeRatioHist(h_store[info['num']],
                                               h_store[info['den']], True,
                                               False)
                else:
                    rhist = plot.MakeRatioHist(h_store[info['num']],
                                               h_store[info['den']], True,
                                               True)
                r_store['%s_%s' % (info['num'], info['den'])] = rhist
                rhist.Draw('SAMEE0')

        plot.SetupTwoPadSplitAsRatio(pads, plot.GetAxisHist(pads[0]),
                                     plot.GetAxisHist(pads[rpad_idx]),
                                     cfg['ratio_y_title'], True,
                                     *(cfg['ratio_y_range']))
        if js_workaround:
            # This makes the ticks way too large
            plot.GetAxisHist(pads[rpad_idx]).GetYaxis().SetTickLength(
                ROOT.gStyle.GetTickLength())

    if cfg['purity']:
        pads[1].cd()
        h_axes[1].Draw()
        plot.SetupTwoPadSplitAsRatio(pads, plot.GetAxisHist(pads[0]),
                                     plot.GetAxisHist(pads[1]), 'f', True, 0,
                                     1)
        plot.Set(h_axes[1].GetXaxis(), TitleSize=0, LabelSize=0)
        plot.Set(h_axes[1].GetYaxis(), Ndivisions=(502, False))
        purity_stack.Draw('HISTSAME')
        # purity_stack.Print()
        h_axes[1].SetMinimum(0)
        h_axes[1].SetMaximum(1)
        pads[1].RedrawAxis()

    # Go back and tidy up the axes and frame
    pads[0].cd()
    if not js_workaround:
        pads[0].GetFrame().Draw()
        pads[0].RedrawAxis()

    # CMS logo
    plot.DrawCMSLogo(pads[0], cfg['main_logo'], cfg['sub_logo'], 11, 0.045,
                     0.05, 1.0, '', 1.0)
    plot.DrawTitle(pads[0], cfg['top_title_left'], 1)
    if cfg['auto_top_title_right']:
        title_right = h_data.GetTitle()
        if title_right.startswith('lumi:'):
            plot.DrawTitle(pads[0], title_right.replace('lumi:', ''), 3)

    latex = ROOT.TLatex()
    plot.Set(latex, NDC=None, TextFont=42, TextSize=0.03)
    # latex.DrawLatex(0.20, 0.75, args.title)
    # plot.DrawTitle(pads[0], args.title, 1)

    # ... and we're done
    if cfg['pads'] is None:
        canv.Print(outdir + '/' + cfg['prefix'] + name + cfg['postfix'] +
                   '.png')
        canv.Print(outdir + '/' + cfg['prefix'] + name + cfg['postfix'] +
                   '.pdf')
        # canv.Print(outdir + '/' + cfg['prefix'] + name + cfg['postfix'] + '.root')
        # canv.Print(outdir + '/' + cfg['prefix'] + name + cfg['postfix'] + '.svg')
        # canv.Print(outdir + '/' + cfg['prefix'] + name + cfg['postfix'] + '.json')

    outobjs = {}
    outobjs['axes'] = h_axes
    outobjs['hists'] = hists
    outobjs['stack'] = stack
    outobjs['purity_stack'] = purity_stack
    outobjs['h_tot'] = h_tot
    outobjs['legend'] = legend
    outobjs['r_store'] = r_store
    outobjs['p_store'] = p_store
    outobjs['r_data'] = r_data
    outobjs['r_tot'] = r_tot
    return outobjs
예제 #4
0
    legend2.SetNColumns(4)
if args.layout == 2:
    legend2 = ROOT.TLegend(0.14, 0.53, 0.34, 0.74, '', 'NBNDC')
if args.layout == 3:
    legend2 = ROOT.TLegend(0.57, 0.7, 0.82, 0.9, '', 'NBNDC')
    # legend2.SetNColumns(2)
legend2.AddEntry(conts68['default'][0], '68% CL', 'L')
legend2.AddEntry(conts95['default'][0], '95% CL', 'L')
legend2.AddEntry(bestfits['default'], 'Best fit', 'P')
legend2.AddEntry(sm_point, 'Expected', 'P')
legend2.SetMargin(0.4)
legend2.Draw()

box = ROOT.TPave(0.15, 0.82, 0.41, 0.92, 0, 'NBNDC')
# box.Draw()
plot.DrawCMSLogo(pads[0], args.logo, args.logo_sub, 11, 0.025, 0.035, 1.1)
# plot.DrawCMSLogo(pads[0], args.logo, args.logo_sub, 11, 0.025, 0.035, 1.1, extraText2='#it{Internal}')
plot.DrawTitle(pads[0], args.title_right, 3)

axis.SetMinimum(0)
axis.SetMaximum(6)

axis.GetZaxis().SetTitleOffset(0)

pads[0].RedrawAxis()
# plot.DrawCMSLogo(pads[0], '#it{ATLAS}#bf{+}CMS', '#it{LHC Run 1}', 11, 0.02, 0.035, 1.1, extraText2='#it{Internal}')
# pads[0].RedrawAxis()
canv.Print('.pdf')
canv.Print('.png')
outfile.Close()
예제 #5
0
    for i in xrange(n_params):
        y1 = ROOT.gStyle.GetPadBottomMargin()
        y2 = 1. - ROOT.gStyle.GetPadTopMargin()
        h = (y2 - y1) / float(n_params)
        y1 = y1 + float(i) * h
        y2 = y1 + h
        box = ROOT.TPaveText(0, y1, 1, y2, 'NDC')
        #plot.Set(box, TextSize=0.02, BorderSize=0, FillColor=0, TextAlign=12, Margin=0.005)
        plot.Set(box, TextSize=0.02, BorderSize=0, FillColor=0, TextAlign=12, Margin=0.005)
        if i % 2 == 0:
            box.SetFillColor(18)
        box.AddText('%i' % (n_params - i + page * show))
        box.Draw()
        boxes.append(box)

    plot.DrawCMSLogo(ROOT.gPad, 'CMS', args.cms_label, 0, 0.15, 0.00, 0.00, padXleft=0.05)
    # Crate and style the pads
    pads = plot.TwoPadSplitColumns(0.7, 0., 0.)
    pads[0].SetGrid(1, 0)
    pads[0].SetTickx(1)
    pads[1].SetGrid(1, 0)
    pads[1].SetTickx(1)

    h_pulls = ROOT.TH2F("pulls", "pulls", 6, -2.9, 2.9, n_params, 0, n_params)
    g_pulls = ROOT.TGraphAsymmErrors(n_params)
    g_impacts_hi = ROOT.TGraphAsymmErrors(n_params)
    g_impacts_lo = ROOT.TGraphAsymmErrors(n_params)
    g_impacts_hi_overdrawn = ROOT.TGraphAsymmErrors(n_params)   # Only store hi impacts which will be overdrawn by larger lo impacts
    max_impact = 0.

    text_entries = []
예제 #6
0
                  outfile,
                  sort_keys=True,
                  indent=4,
                  separators=(',', ': '))

collab = 'CMS'
if 'cms_' in args.output:
    collab = 'CMS'
if 'atlas_' in args.output:
    collab = 'ATLAS'

subtext = 'Internal}'
if args.pub:
    subtext = '{#it{LHC} #bf{Run 1}}'
    # subtext = '#it{#splitline{LHC Run 1}{Internal}}'
plot.DrawCMSLogo(pads[0], 'CMS', '#it{Internal}', 11, 0.045, 0.035, 1.2, '',
                 0.9 if args.pub else 0.8)
# plot.DrawCMSLogo(pads[0], '#it{ATLAS}#bf{ and }CMS',
#                  '#it{LHC Run 1 Internal}', 11, 0.045, 0.035, 1.2)
# plot.DrawCMSLogo(pads[0], '#it{ATLAS}#bf{ and }CMS', '#it{LHC Run 1
# Preliminary}', 11, 0.025, 0.035, 1.1, cmsTextSize = 1.)

if args.POI_line is not None:
    if args.legend_pos == 5:
        POIs = args.POI_line.split()
    elif not args.no_sort:
        POIs = sorted(args.POI_line.split())
    else:
        POIs = args.POI_line.split()
    for i, P in enumerate(POIs):
        if P in name_translate:
            POIs[i] = name_translate[P]
예제 #7
0
for i in xrange(1, hist.GetYaxis().GetNbins() + 1):
    new_name = hist.GetYaxis().GetBinLabel(i)
    if new_name in name_translate:
        new_name = name_translate[new_name]
        new_name = ColorLabels(new_name)
    hist.GetYaxis().SetBinLabel(i, new_name)

hist.GetXaxis().LabelsOption('h')
hist.GetXaxis().SetLabelFont(62)
hist.GetYaxis().SetLabelFont(62)
hist.GetXaxis().SetLabelSize(0.04)
hist.GetYaxis().SetLabelSize(0.041)
if not args.cov:
    hist.SetMinimum(-1)
    hist.SetMaximum(+1)
hist.SetContour(255)

canv = ROOT.TCanvas(args.output, args.output)
pads = plot.OnePad()

hist.Draw('COLZTEXT')

plot.DrawCMSLogo(pads[0], '#it{ATLAS}#bf{ and }CMS', 'LHC Run 1 Internal', 0,
                 0.38, 0.035, 1.2)
if args.label is not None: plot.DrawTitle(pads[0], args.label, 3)

canv.Print('.pdf')
canv.Print('.png')
# canv.Print('.C')
예제 #8
0
h_dat_r.Draw('esamex0')

pads[0].cd()


axes[0].SetMaximum(8E6)
# plot.FixTopRange(pads[0], plot.GetPadYMax(pads[0]), 0.3)

legend = plot.PositionedLegend(0.30, 0.20, 3, 0.03)
legend.AddEntry(h_dat, "Observed", "pe")
legend.AddEntry(h_bkg, "Background", "f")
legend.AddEntry(h_err, "Uncertainty", "f")
legend.AddEntry(h_sig, "t#bar{t}H (#mu=1.26)", "f")
legend.AddEntry(h_sig_mu1, "t#bar{t}H (#mu=1.00)", "f")
# // legend->AddEntry(&sb_err, "Bkg. Uncertainty", "f");
legend.Draw()

for pad in pads:
    pad.cd()
    plot.FixOverlay()


# plot.DrawCMSLogo(pads[0], 'CMS', 'Preliminary', 0, 0.12, 0.035, 1.2)
plot.DrawCMSLogo(pads[0], 'CMS', 'Supplementary', 11, 0.045, 0.035, 1.2, '', 0.9)
plot.DrawTitle(pads[0], '5.1 fb^{-1} (7 TeV) + 19.7 fb^{-1} (8 TeV) + 35.9 fb^{-1} (13 TeV)' , 3)


canv.Print('.pdf')
canv.Print('.png')
# canv.Print('.C')
예제 #9
0
def MakePlot(name, outdir, hists, cfg, layouts):
    copyhists = {}
    for hname, h in hists.iteritems():
        if len(cfg['rebinvar']):
            copyhists[hname] = VariableRebin(h, cfg['rebinvar'])
        else:
            copyhists[hname] = h.Clone()
        if cfg['divwidth']:
            copyhists[hname].Scale(1., 'width')

    hists = copyhists

    # Canvas and pads
    canv = ROOT.TCanvas(name, name)
    if cfg['ratio'] or cfg['fraction']:
        pads = plot.TwoPadSplit(0.27, 0.01, 0.01)
    else:
        pads = plot.OnePad()

    # Get the data and create axis hist
    h_data = hists[cfg['data_name']]
    # h_data = Getter(file, '%s/data_obs' % target, True)
    if isinstance(h_data, ROOT.TH2):
        print 'TH2: aborting!'
        return

    h_axes = [h_data.Clone() for x in pads]
    for h in h_axes:
        if len(cfg['x_range']):
            h.GetXaxis().SetRangeUser(*cfg['x_range'])
        h.Reset()

    build_h_tot = True
    h_tot = None
    if 'TotalProcs' in hists:
        h_tot = hists['TotalProcs']
        build_h_tot = False

    x_title = cfg['x_title'][0]
    units = cfg['x_title'][1]

    if x_title == '' and h_data.GetXaxis().GetTitle() != '':
        x_title = h_data.GetXaxis().GetTitle()

    if ':' in x_title:
        units = x_title.split(':')[1]
        x_title = x_title.split(':')[0]

    if cfg['logy']:
        pads[0].SetLogy()
        h_axes[0].SetMinimum(0.001)

    if cfg['ratio'] or cfg['fraction']:
        plot.StandardAxes(h_axes[1].GetXaxis(), h_axes[0].GetYaxis(), x_title,
                          units)
    else:
        plot.StandardAxes(h_axes[0].GetXaxis(), h_axes[0].GetYaxis(), x_title,
                          units)
    h_axes[0].Draw()

    # A dict to keep track of the hists
    h_store = {}

    layout = layouts[cfg['layout']]

    stack = ROOT.THStack()
    legend = ROOT.TLegend(*(cfg['legend_pos'] + ['', 'NBNDC']))

    for info in layout:
        hist = hists[info['entries'][0]]
        col = info['color']
        if isinstance(col, list):
            col = ROOT.TColor.GetColor(*col)
        plot.Set(hist, FillColor=col, Title=info['legend'])
        if len(info['entries']) > 1:
            for other in info['entries'][1:]:
                hist.Add(hists[other])
        h_store[info['name']] = hist
        if build_h_tot:
            if h_tot is None:
                h_tot = hist.Clone()
            else:
                h_tot.Add(hist)
        stack.Add(hist)

    h_tot.SetFillColor(plot.CreateTransparentColor(12, 0.3))
    h_tot.SetMarkerSize(0)

    legend.AddEntry(h_data, 'Observed', 'PL')
    for ele in reversed(layout):
        legend.AddEntry(h_store[ele['name']], '', 'F')
    bkg_uncert_label = 'Stat. Uncertainty'
    if not build_h_tot:
        bkg_uncert_label = 'Uncertainty'
    legend.AddEntry(h_tot, bkg_uncert_label, 'F')

    stack.Draw('HISTSAME')
    h_tot.Draw("E2SAME")
    if not cfg['hide_data']:
        h_data.Draw('E0SAME')

    plot.FixTopRange(pads[0], plot.GetPadYMax(pads[0]), 0.35)
    legend.Draw()
    if cfg['legend_padding'] > 0.:
        print h_axes[0].GetMinimum(), h_axes[0].GetMaximum()
        if not h_axes[0].GetMaximum() == 0.:
            plot.FixBoxPadding(pads[0], legend, cfg['legend_padding'])

    # Do the ratio plot
    if cfg['ratio'] or cfg['fraction']:
        pads[1].cd()
        pads[1].SetGrid(0, 1)
        h_axes[1].Draw()

        if cfg['ratio']:
            r_data = plot.MakeRatioHist(h_data, h_tot, True, False)
            r_tot = plot.MakeRatioHist(h_tot, h_tot, True, False)
            r_tot.Draw('E2SAME')
            if not cfg['hide_data']:
                r_data.Draw('SAME')

            plot.SetupTwoPadSplitAsRatio(pads, plot.GetAxisHist(pads[0]),
                                         plot.GetAxisHist(pads[1]), 'Obs/Exp',
                                         True, 0.61, 1.69)
        if cfg['fraction']:
            r_frac = plot.MakeRatioHist(h_tot, h_data, True, True)
            r_frac.Draw('SAME')
            plot.SetupTwoPadSplitAsRatio(pads, plot.GetAxisHist(pads[0]),
                                         plot.GetAxisHist(pads[1]), 'Exp/Obs',
                                         True, 0.0, 0.5)

    # Go back and tidy up the axes and frame
    pads[0].cd()
    pads[0].GetFrame().Draw()
    pads[0].RedrawAxis()

    # CMS logo
    plot.DrawCMSLogo(pads[0], cfg['main_logo'], cfg['sub_logo'], 11, 0.045,
                     0.05, 1.0, '', 1.0)
    plot.DrawTitle(pads[0], cfg['top_title_left'], 1)
    if cfg['auto_top_title_right']:
        title_right = h_data.GetTitle()
        if title_right.startswith('lumi:'):
            plot.DrawTitle(pads[0], title_right.replace('lumi:', ''), 3)
    else:
        plot.DrawTitle(pads[0], cfg['top_title_right'], 3)

    latex = ROOT.TLatex()
    plot.Set(latex, NDC=None, TextFont=42, TextSize=0.03)
    latex.DrawLatex(0.20, 0.75, args.title)
    # plot.DrawTitle(pads[0], args.title, 1)

    # ... and we're done
    canv.Print(outdir + '/' + cfg['prefix'] + name + cfg['postfix'] + '.png')
    canv.Print(outdir + '/' + cfg['prefix'] + name + cfg['postfix'] + '.pdf')
예제 #10
0
    with open(args.json, 'w') as outfile:
        json.dump(js,
                  outfile,
                  sort_keys=True,
                  indent=4,
                  separators=(',', ': '))

collab = 'Combined'
if 'cms_' in args.output:
    collab = 'CMS'
if 'atlas_' in args.output:
    collab = 'ATLAS'

subtext = '#it{LHC Run 1 Internal}'
if args.pub: subtext = '#it{#splitline{LHC Run 1}{Internal}}'
plot.DrawCMSLogo(pads[0], '#it{ATLAS}#bf{ and }CMS', subtext, 11, 0.045, 0.035,
                 1.2, '', 0.9 if args.pub else 0.8)
# plot.DrawCMSLogo(pads[0], '#it{ATLAS}#bf{ and }CMS',
#                  '#it{LHC Run 1 Internal}', 11, 0.045, 0.035, 1.2)
# plot.DrawCMSLogo(pads[0], '#it{ATLAS}#bf{ and }CMS', '#it{LHC Run 1
# Preliminary}', 11, 0.025, 0.035, 1.1, cmsTextSize = 1.)

if args.POI_line is not None:
    POIs = sorted(args.POI_line.split())
    for i, P in enumerate(POIs):
        if P in name_translate:
            POIs[i] = name_translate[P]
    POI_line = '[' + ','.join(POIs) + ']'

if not args.no_input_label:
    plot.DrawTitle(pads[0], '#bf{Input:} %s' % collab, 3)
# legend_l = 0.70 if len(args) >= 4 else 0.73
예제 #11
0
    legend2.SetNColumns(4)
if args.layout == 2:
    legend2 = ROOT.TLegend(0.14, 0.53, 0.34, 0.74, '', 'NBNDC')
if args.layout == 3:
    legend2 = ROOT.TLegend(0.57, 0.7, 0.82, 0.9, '', 'NBNDC')
    # legend2.SetNColumns(2)
legend2.AddEntry(conts68['default'][0], '68% CL', 'L')
legend2.AddEntry(conts95['default'][0], '95% CL', 'L')
legend2.AddEntry(bestfits['default'], 'Best fit', 'P')
legend2.AddEntry(sm_point, 'SM expected', 'P')
legend2.SetMargin(0.4)
legend2.Draw()

box = ROOT.TPave(0.15, 0.82, 0.41, 0.92, 0, 'NBNDC')
# box.Draw()
plot.DrawCMSLogo(pads[0], '#it{ATLAS}#bf{ and }CMS', '#it{LHC Run 1}', 11, 0.025, 0.035, 1.1, extraText2='#it{Internal}')
plot.DrawTitle(pads[0], args.title_right, 3)

axis.SetMinimum(0)
axis.SetMaximum(6)

axis.GetZaxis().SetTitleOffset(0)

pads[0].RedrawAxis()
# plot.DrawCMSLogo(pads[0], '#it{ATLAS}#bf{+}CMS', '#it{LHC Run 1}', 11, 0.02, 0.035, 1.1, extraText2='#it{Internal}')
# pads[0].RedrawAxis()
canv.Print('.pdf')
canv.Print('.png')
outfile.Close()

        #plot.Set(h_impacts.GetXaxis(), LabelSize=0.03, TitleSize=0.04, Ndivisions=505, Title='B hyp (#hat{#theta}-#theta_{0})/#Delta#theta')
        plot.Set(h_impacts.GetXaxis(),
                 TitleSize=0.04,
                 LabelSize=0.03,
                 Title='B hyp (#hat{#theta}-#theta_{0})/#Delta#theta')
        plot.Set(h_impacts.GetYaxis(), LabelSize=0.022, TickLength=0.0)

        h_impacts.GetYaxis().SetLabelOffset(999)
        h_impacts.GetYaxis().SetLabelSize(0)
        h_impacts.Draw()

        # the first pad to draw the pulls graph in the signal + background hypothesis
        pads[0].cd()
        plot.Set(g_pulls, MarkerSize=0.8, LineWidth=2)
        g_pulls.Draw('PSAME')

        # the second pad to draw the pulls graph in the background hypothesis
        pads[1].cd()
        plot.Set(g_pulls_b, MarkerSize=0.8, LineWidth=2)
        g_pulls_b.Draw('PSAME')
        pads[1].RedrawAxis()

        plot.DrawCMSLogo(pads[0], 'CMS', 'Internal', 0, 0.25, 0.00, 0.00)

        extra = ''
        if page == 0:
            extra = '('
        if page == n - 1:
            extra = ')'
        canv.Print('.pdf%s' % extra)
예제 #13
0
graph_m1.Draw(" F SAME ")
graph_p1.Draw(" F SAME ")
graph_p2.Draw(" F SAME  ")

graph_exp.Draw(" L SAME ")
graph_obs.Draw(" FL SAME ")

legend = ROOT.TLegend(0.6,0.5,0.85,0.725)
legend.SetBorderSize(0)
legend.AddEntry(graph_obs,"Observed","F")
legend.AddEntry(graph_exp,"Expected","L")
legend.AddEntry(graph_m1,"68% expected","F")
legend.AddEntry(graph_m2,"95% expected","F")
legend.AddEntry(graph_excluded,"m_{h}+m_{h_{S}} > m_{H}","F")
legend.Draw("SAME")
plot.DrawCMSLogo(c1, 'CMS', "", 3, 0.045, 0.035, 1.2, '', 0.6)
# plot.DrawTitle(c1,"               #splitline{95% CL exclusion on maximally allowed}{cross section times branching fractions in NMSSM}",1,0.3,0.35)
plot.DrawTitle(c1, "#scale[0.8]{137 fb^{-1} (13 TeV)}", 3)

text = ROOT.TText(0.35,0.8,"95% CL exclusion on maximally allowed")
text2 = ROOT.TText(0.35,0.755,"cross section times branching fractions in NMSSM")
text.SetNDC()
text.SetTextFont(42)
# text.SetFillColor(0)
text.SetTextSize(0.036)
text.Draw("SAME")
text2.SetNDC()
text2.SetTextFont(42)
text2.SetTextSize(0.036)

text2.Draw("SAME")
예제 #14
0
                    js_extra['2sig_ValidOtherLimit%sHi' % breakdown[oi+1]] = interval['valid_hi']
        js[args.model][args.POI].update(js_extra)

    with open(args.json, 'w') as outfile:
        json.dump(js, outfile, sort_keys=True, indent=4, separators=(',', ': '))

collab = 'Combined'
if 'cms_' in args.output:
    collab = 'CMS'
if 'atlas_' in args.output:
    collab = 'ATLAS'

subtext = '{#bf{Run 1 Internal}}'
    # subtext = '#it{#splitline{LHC Run 1}{Internal}}'
if args.decorate_signif or args.paper:
    plot.DrawCMSLogo(pads[0], 'CMS',
                    '', 11, 0.045, 0.035, 1.2, '', 1.1 if args.pub else 0.8)
else:
    plot.DrawCMSLogo(pads[0], 'CMS',
                    'Preliminary', 11, 0.045, 0.035, 1.2, '', 0.9 if args.pub else 0.8)

# plot.DrawCMSLogo(pads[0], '#it{ATLAS}#bf{ and }CMS',
#                  '#it{LHC Run 1 Internal}', 11, 0.045, 0.035, 1.2)
# plot.DrawCMSLogo(pads[0], '#it{ATLAS}#bf{ and }CMS', '#it{LHC Run 1
# Preliminary}', 11, 0.025, 0.035, 1.1, cmsTextSize = 1.)

if args.POI_line is not None:
    if args.legend_pos == 5:
        POIs = args.POI_line.split()
    elif not args.no_sort:
        POIs = sorted(args.POI_line.split())
    else:
예제 #15
0
hist.GetXaxis().SetTitle(x_title)
hist.GetYaxis().SetTitle(y_title)
hist.GetZaxis().SetTitle(z_title)
hist.GetXaxis().SetLabelFont(42)
hist.GetYaxis().SetLabelFont(42)
hist.GetXaxis().SetTickLength(0)
hist.GetYaxis().SetTickLength(0)
hist.GetXaxis().SetLabelSize(args.label_size)
hist.GetYaxis().SetLabelSize(args.label_size)
hist.GetZaxis().SetLabelSize(0.045)
# hist.GetZaxis().SetTitle('#rho')
hist.SetContour(255)

canv = ROOT.TCanvas(args.output, args.output)
pads = plot.OnePad()

ROOT.gStyle.SetTextFont(42)
hist.SetMarkerSize(args.marker_size)
hist.Draw(args.draw_opt)

plot.FixOverlay()

plot.DrawCMSLogo(pads[0], 'CMS', args.subline, 0, 0.17, 0.035, 1.2)

if args.label is not None:
    plot.DrawTitle(pads[0], args.label, 3)

canv.Print('.pdf')
canv.Print('.png')
예제 #16
0
    # latex.DrawLatex(16, x_offset, '[850, 1200]')

    plot.Set(latex, TextAngle=90)

    y_offset = -2.4
    latex.DrawLatex(y_offset, 1, '[150, 200]')
    latex.DrawLatex(y_offset, 4, '[200, 300]')
    latex.DrawLatex(y_offset, 7, '[300, 500]')
    latex.DrawLatex(y_offset, 10, '[500, 800]')
    latex.DrawLatex(y_offset, 13, '[800, 1200]')
    # latex.DrawLatex(y_offset, 16, '[850, 1200]')

plot.Set(latex, TextAngle=0, TextSize=0.03, TextAlign=21)
if args.selection == 'eft_region':
    latex.DrawLatex(12, -3.7, 'Gen. p_{T}^{#gamma} [GeV] x |#phi_{f}| bin')
if args.selection == 'fid_region':
    latex.DrawLatex(7.0, -2.4, 'Gen. p_{T}^{#gamma} [GeV] bin')
plot.Set(latex, TextAngle=90, TextSize=0.03, TextAlign=21)
if args.selection == 'eft_region':
    latex.DrawLatex(-3.2, 12, 'Reco. p_{T}^{#gamma} [GeV] x |#phi_{f}| bin')
if args.selection == 'fid_region':
    latex.DrawLatex(-2.0, 7.0, 'Reco. p_{T}^{#gamma} [GeV] bin')

plot.FixOverlay()

plot.DrawCMSLogo(pads[0], 'CMS', 'Internal', 0, 0.12, 0.035, 1.2)
plot.DrawTitle(pads[0], args.label, 3)

canv.Print('.pdf')
canv.Print('.png')
예제 #17
0
#      expected->SetLineStyle(2);
#      }
graph_exp.Draw("L")

if not args.expected_only:
    graph_obs.SetMarkerColor(ROOT.kBlack)
    graph_obs.SetMarkerSize(1.0)
    graph_obs.SetMarkerStyle(20)
    graph_obs.SetLineWidth(3)
    graph_obs.Draw("PLsame")

pads[0].cd()
legend = plot.PositionedLegend(0.5, 0.9, 2, 0.03)
legend.SetNColumns(2)
legend.SetFillStyle(1001)
legend.SetTextSize(0.15)
legend.SetTextFont(62)
legend.SetHeader("95% CL Excluded:")
if not args.expected_only:
    legend.AddEntry(graph_obs, "Observed", "L")
legend.AddEntry(innerBand, "#pm 1#sigma Expected", "F")
legend.AddEntry(graph_exp, "Expected", "L")
legend.AddEntry(outerBand, "#pm 2#sigma Expected", "F")
legend.Draw("same")

plot.DrawCMSLogo(pads[1], '', '', 11, 0.045, 0.035, 1.2)
plot.DrawTitle(pads[1], '%s' % args.title, 3)
plot.FixOverlay()
c1.SaveAs("%s.pdf" % args.outname)
c1.SaveAs("%s.png" % args.outname)
예제 #18
0
    axis.SetMaximum(float(args.y_range.split(',')[1]))
    pads[0].SetGrid(1, 1)
    pads[0].SetLogx(True)
    latex.SetTextSize(0.04)

    text.AddText(args.title)
    text.AddText(bin_label)
    text.SetTextAlign(13)
    text.SetBorderSize(0)
    text.Draw()
    legend.Draw()

    plot.DrawCMSLogo(pads[0],
                     'CMS',
                     'Internal',
                     0,
                     0.16,
                     0.035,
                     1.2,
                     cmsTextSize=0.9)
    plot.DrawTitle(pads[0], args.title_right, 3)

    if args.ratio_to is not None:
        pads[1].cd()
        pads[1].SetLogx(True)
        ratios = []
        for slice in slices:
            ratios.append(slice.Clone())
            ratios[-1].Divide(slices[args.ratio_to])
            ratios[-1].Print("range")
        ratios[0].Draw('AXIS')
        plot.SetupTwoPadSplitAsRatio(pads, plot.GetAxisHist(pads[0]),
예제 #19
0
 def PlotTestStat(self, result, name, opts, poi_vals):
     null_vals = [
         x * -2.
         for x in result.GetNullDistribution().GetSamplingDistribution()
     ]
     alt_vals = [
         x * -2.
         for x in result.GetAltDistribution().GetSamplingDistribution()
     ]
     if len(null_vals) == 0 or len(alt_vals) == 0:
         print '>> Errror in PlotTestStat for %s, null and/or alt distributions are empty'
         return
     plot.ModTDRStyle()
     canv = ROOT.TCanvas(name, name)
     pad = plot.OnePad()[0]
     min_val = min(min(alt_vals), min(null_vals))
     max_val = max(max(alt_vals), max(null_vals))
     min_plot_range = min_val - 0.05 * (max_val - min_val)
     if opts['one_sided']:
         min_plot_range = 0.
         pad.SetLogy(True)
     max_plot_range = max_val + 0.05 * (max_val - min_val)
     hist_null = ROOT.TH1F('null', 'null', 40, min_plot_range,
                           max_plot_range)
     hist_alt = ROOT.TH1F('alt', 'alt', 40, min_plot_range, max_plot_range)
     for val in null_vals:
         hist_null.Fill(val)
     for val in alt_vals:
         hist_alt.Fill(val)
     hist_alt.SetLineColor(ROOT.TColor.GetColor(4, 4, 255))
     hist_alt.SetFillColor(
         plot.CreateTransparentColor(ROOT.TColor.GetColor(4, 4, 255), 0.4))
     hist_alt.GetXaxis().SetTitle('-2 #times ln(^{}L_{%s}/^{}L_{%s})' %
                                  (opts['alt_label'], opts['null_label']))
     hist_alt.GetYaxis().SetTitle('Pseudo-experiments')
     hist_alt.Draw()
     hist_null.SetLineColor(ROOT.TColor.GetColor(252, 86, 11))
     hist_null.SetFillColor(
         plot.CreateTransparentColor(ROOT.TColor.GetColor(254, 195, 40),
                                     0.4))
     hist_null.Draw('SAME')
     val_obs = result.GetTestStatisticData() * -2.
     obs = ROOT.TArrow(val_obs, 0, val_obs,
                       hist_alt.GetMaximum() * 0.3, 0.05, '<-|')
     obs.SetLineColor(ROOT.kRed)
     obs.SetLineWidth(3)
     obs.Draw()
     plot.FixTopRange(pad, plot.GetPadYMax(pad), 0.25)
     leg = plot.PositionedLegend(0.22, 0.2, 3, 0.02)
     leg.AddEntry(hist_alt, opts['alt_label'], 'F')
     leg.AddEntry(hist_null, opts['null_label'], 'F')
     leg.AddEntry(obs, 'Observed', 'L')
     leg.Draw()
     plot.DrawCMSLogo(pad, 'CMS', opts['cms_subtitle'], 0, 0.15, 0.035, 1.2)
     pt_l = ROOT.TPaveText(0.23, 0.75, 0.33, 0.9, 'NDCNB')
     pt_l.AddText('Model:')
     pt_l.AddText('Toys:')
     pt_l.AddText('CLs+b:')
     pt_l.AddText('CLb:')
     pt_l.AddText('CLs:')
     plot.Set(pt_l, TextAlign=11, TextFont=62, BorderSize=0)
     pt_l.Draw()
     pt_r = ROOT.TPaveText(0.33, 0.75, 0.63, 0.9, 'NDCNB')
     pt_r.AddText('%s [%s = %.1f, %s = %.1f]' %
                  (opts['model_label'], opts['poi_labels'][0], poi_vals[0],
                   opts['poi_labels'][1], poi_vals[1]))
     pt_r.AddText(
         '%i (%s) + %i (%s)' %
         (result.GetNullDistribution().GetSize(), opts['null_label'],
          result.GetAltDistribution().GetSize(), opts['alt_label']))
     pt_r.AddText('%.3f #pm %.3f' %
                  (result.CLsplusb(), result.CLsplusbError()))
     pt_r.AddText('%.3f #pm %.3f' % (result.CLb(), result.CLbError()))
     pt_r.AddText('%.3f #pm %.3f' % (result.CLs(), result.CLsError()))
     plot.Set(pt_r, TextAlign=11, TextFont=42, BorderSize=0)
     pt_r.Draw()
     pad.GetFrame().Draw()
     pad.RedrawAxis()
     for fmt in opts['formats']:
         canv.SaveAs(fmt)
예제 #20
0
            else:
                lo = math.sqrt(v_lo[i] * v_lo[i] - v_lo[i + 1] * v_lo[i + 1])
        else:
            hi = v_hi[i]
            lo = v_lo[i]
        textfit += '{}^{#plus %.3f}_{#minus %.3f}(%s)' % (hi, abs(lo), br)
    pt.AddText(textfit)

pt.SetTextAlign(11)
pt.SetTextFont(42)
pt.Draw()

plot.DrawCMSLogo(pads[0],
                 args.logo,
                 args.logo_sub,
                 11,
                 0.045,
                 0.035,
                 1.2,
                 cmsTextSize=1.)

legend_l = 0.69
if len(other_scans) > 0:
    legend_l = legend_l - len(other_scans) * 0.04
legend = ROOT.TLegend(0.15, legend_l, 0.45, 0.78, '', 'NBNDC')
if len(other_scans) >= 3:
    legend = ROOT.TLegend(0.46, 0.83, 0.95, 0.93, '', 'NBNDC')
    legend.SetNColumns(2)

legend.AddEntry(main_scan['func'], args.main_label, 'L')
for i, other in enumerate(other_scans):
    legend.AddEntry(other['func'], other_scans_opts[i][1], 'L')
예제 #21
0
    h_axes[1].Draw()

    r_data = plot.MakeRatioHist(h_data, h_tot, True, False)
    r_tot = plot.MakeRatioHist(h_tot, h_tot, True, False)
    r_tot.Draw('E2SAME')
    r_data.Draw('SAME')

    plot.SetupTwoPadSplitAsRatio(
        pads, plot.GetAxisHist(
            pads[0]), plot.GetAxisHist(pads[1]), 'Obs/Exp', True, 0.61, 1.39)

    # Go back and tidy up the axes and frame
    pads[0].cd()
    pads[0].GetFrame().Draw()
    pads[0].RedrawAxis()

    # CMS logo
    plot.DrawCMSLogo(pads[0], 'CMS', 'Internal', 11, 0.045, 0.05, 1.0, '', 1.0)
    plot.DrawTitle(pads[0], '12.9 fb^{-1} (13 TeV)', 3)

    latex = ROOT.TLatex()
    plot.Set(latex, NDC=None, TextFont=42, TextSize=0.03)
    latex.DrawLatex(0.20, 0.75, args.title)
    # plot.DrawTitle(pads[0], args.title, 1)

    # ... and we're done
    canv.Print('.png')
    canv.Print('.pdf')


예제 #22
0
        line[i].Draw()

        latex.append(ROOT.TLatex())
        #latex[i].SetNDC()
        latex[i].SetTextAngle(0)
        latex[i].SetTextAlign(12)
        latex[i].SetTextSize(0.04)
        latex[i].SetTextColor(13)
        t = c.GetTopMargin()
        b = c.GetBottomMargin()
        r = c.GetRightMargin()
        #latex[i].DrawLatex(1.01-r,-b+((1-math.log(y[i])/math.log(0.001)*(1-t-b))),str(i+1) + "#sigma")
        latex[i].DrawLatex(3800., y[i], str(i + 1) + "#sigma")

    plot.DrawTitle(c, '138 fb^{-1} (13 TeV)', 3)
    plot.DrawCMSLogo(c, 'CMS', 'Supplementary', 0, 0.15, 0, 0, '', 0.9)
    #plot.DrawCMSLogo(c, 'CMS', 'Preliminary', 0, 0.15, 0, 0, '', 0.9)

    line2 = ROOT.TLine(225., limit_dict["lowmass"]["p_value"].GetMinimum(),
                       225, 1.)
    line2.Draw()
    latex2 = ROOT.TLatex()
    latex2.SetNDC()
    latex2.SetTextAngle(0)
    latex2.SetTextAlign(12)
    latex2.SetTextFont(42)
    latex2.SetTextSize(0.04)
    latex2.DrawLatex(0.19, 0.91, 'Low-mass')
    latex2.DrawLatex(0.45, 0.91, 'High-mass')

    latex2.SetTextSize(0.05)
예제 #23
0
                  outfile,
                  sort_keys=True,
                  indent=4,
                  separators=(',', ': '))

collab = 'Combined'
if 'cms_' in args.output:
    collab = 'CMS'
if 'atlas_' in args.output:
    collab = 'ATLAS'

subtext = '{#it{LHC} #bf{Run 1 Internal}}'
if args.pub:
    subtext = '{#it{LHC} #bf{Run 1}}'
    # subtext = '#it{#splitline{LHC Run 1}{Internal}}'
plot.DrawCMSLogo(pads[0], '#splitline{#it{ATLAS}#bf{ and }#it{CMS}}' + subtext,
                 '', 11, 0.045, 0.035, 1.2, '', 0.9 if args.pub else 0.8)
# plot.DrawCMSLogo(pads[0], '#it{ATLAS}#bf{ and }CMS',
#                  '#it{LHC Run 1 Internal}', 11, 0.045, 0.035, 1.2)
# plot.DrawCMSLogo(pads[0], '#it{ATLAS}#bf{ and }CMS', '#it{LHC Run 1
# Preliminary}', 11, 0.025, 0.035, 1.1, cmsTextSize = 1.)

if args.POI_line is not None:
    if args.legend_pos == 5:
        POIs = args.POI_line.split()
    elif not args.no_sort:
        POIs = sorted(args.POI_line.split())
    else:
        POIs = args.POI_line.split()
    for i, P in enumerate(POIs):
        if P in name_translate:
            POIs[i] = name_translate[P]
예제 #24
0
for legi, hists in enumerate(bkg_histos):
    legend.AddEntry(hists, background_schemes[channel][legi]['leg_text'], "f")
legend.AddEntry(bkghist, "Background uncertainty", "f")
legend.AddEntry(blind_datahist, "Observation", "P")
legend.Draw("same")
latex = ROOT.TLatex()
latex.SetNDC()
latex.SetTextAngle(0)
latex.SetTextColor(ROOT.kBlack)
latex.SetTextSize(0.026)
#latex.DrawLatex(0.61,0.53,"m_{h}^{mod+}, m_{A}=%(mA)s GeV, tan#beta=%(tb)s"%vars())

#CMS and lumi labels
plot.FixTopRange(pads[0], plot.GetPadYMax(pads[0]),
                 extra_pad if extra_pad > 0 else 0.15)
plot.DrawCMSLogo(pads[0], 'CMS', 'Preliminary', 11, 0.045, 0.05, 1.0, '', 1.0)
plot.DrawTitle(pads[0], "35.9 fb^{-1} (13 TeV)", 3)

#Add ratio plot if required
if args.ratio:
    ratio_bkghist = bkghist.Clone()
    ratio_bkghist.Divide(bkghist)
    blind_datahist.Divide(bkghist)
    pads[1].cd()
    pads[1].SetGrid(0, 1)
    axish[1].Draw("axis")
    axish[1].SetMinimum(0.7)
    axish[1].SetMaximum(1.3)
    ratio_bkghist.SetMarkerSize(0)
    ratio_bkghist.Draw("e2same")
    blind_datahist.DrawCopy("psame")
예제 #25
0
if 'cms_' in args.output:
    collab = 'CMS'
if 'atlas_' in args.output:
    collab = 'ATLAS'

subtext = '{#it{Supplementary}}'
# subtext = '}'
if args.pub:
    subtext = '{#it{LHC} #bf{Run 1}}'
    # subtext = '#it{#splitline{LHC Run 1}{Internal}}'
plot.DrawCMSLogo(
    pads[0],
    'CMS',
    'Supplementary',
    # plot.DrawCMSLogo(pads[0], 'CMS','',
    11,
    0.045,
    0.035,
    1.2,
    '',
    0.9 if args.pub else 0.8)
# plot.DrawCMSLogo(pads[0], '#it{ATLAS}#bf{ and }CMS',
#                  '#it{LHC Run 1 Internal}', 11, 0.045, 0.035, 1.2)
# plot.DrawCMSLogo(pads[0], '#it{ATLAS}#bf{ and }CMS', '#it{LHC Run 1
# Preliminary}', 11, 0.025, 0.035, 1.1, cmsTextSize = 1.)

if args.POI_line is not None:
    if args.legend_pos == 5:
        POIs = args.POI_line.split()
    elif not args.no_sort:
        POIs = sorted(args.POI_line.split())
예제 #26
0
    legend.AddEntry(g_impacts_lo, '-1#sigma Impact', 'F')
    legend.Draw()

    leg_width = pads[0].GetLeftMargin() - 0.01
    if args.color_groups is not None:
        legend2 = ROOT.TLegend(0.01, 0.94, leg_width, 0.99, '', 'NBNDC')
        legend2.SetNColumns(2)
        for name, h in color_group_hists.iteritems():
            legend2.AddEntry(h, Translate(name, translate), 'F')
        legend2.Draw()
    elif len(seen_types) > 1:
        legend2 = ROOT.TLegend(0.01, 0.94, leg_width, 0.99, '', 'NBNDC')
        legend2.SetNColumns(2)
        for name, h in color_hists.iteritems():
            if name == 'Unrecognised': continue
            legend2.AddEntry(h, name, 'F')
        legend2.Draw()

    plot.DrawCMSLogo(pads[0], 'CMS', args.cms_label, 0, 0.25, 0.00, 0.00)
    s_nom, s_hi, s_lo = GetRounded(POI_fit[1], POI_fit[2] - POI_fit[1], POI_fit[1] - POI_fit[0])
    if not args.blind:
        plot.DrawTitle(pads[1], '#hat{%s} = %s^{#plus%s}_{#minus%s}%s' % (
            Translate(POI, translate), s_nom, s_hi, s_lo,
            '' if args.units is None else ' '+args.units), 3, 0.27)
    extra = ''
    if page == 0:
        extra = '('
    if page == n - 1:
        extra = ')'
    canv.Print('.pdf%s' % extra)
예제 #27
0
arr.SetFillStyle(1001)
arr.SetLineWidth(6)
arr.SetLineStyle(1)
arr.SetAngle(60)
arr.Draw("<|same")

pt = ROOT.TPaveText(0.6, 0.7, 0.8, 0.9, "NDCNB")
pt.AddText("num. toys : %i" % int(nToys))
pt.AddText("#lambda_{0} : %.2f" % float(obs))
pt.AddText("p-value : %.2f" % pval)
pt.Draw('same')

plot.DrawCMSLogo(pads[0],
                 "CMS",
                 "Preliminary",
                 11,
                 0.045,
                 0.035,
                 1.2,
                 cmsTextSize=1.)

canvas.SaveAs(boson + "_" + channel + "_" + year + "_" + "p_value.pdf")

output_file = open(boson + "_" + channel + "_" + year + "_" + "p_value.txt",
                   "w")

output_file.write("Number of toys  : %i\n" % int(nToys))
output_file.write("Lambda_0        : %f\n" % float(obs))
output_file.write("p-value for obs : %f\n" % float(pval))

output_file.close()
예제 #28
0
    legend.AddEntry(cont_minus1sigma[0], "#pm 1#sigma Expected", "F")
if cont_exp[0]: legend.AddEntry(cont_exp[0], "Expected", "L")
if cont_minus2sigma[0]:
    legend.AddEntry(cont_minus2sigma[0], "#pm 2#sigma Expected", "F")
legend.Draw("same")

# ROOT is just the worst - ARC requested the observed symbol in the legend be changed to this
if (cont_obs[0]):
    legline = ROOT.TLine(605, 13, 680, 13)
    legline.SetLineWidth(3)
    legline.SetLineColor(ROOT.kBlack)
    legline.DrawLineNDC(legend.GetX1() + 0.0106,
                        legend.GetY2() - 0.36,
                        legend.GetX1() + 0.0516,
                        legend.GetY2() - 0.36)

if args.custom_y_range:
    axis.GetYaxis().SetRangeUser(float(args.y_axis_min),
                                 float(args.y_axis_max))
axis.GetXaxis().SetTitle("m_{A} (GeV)")
if args.custom_x_range:
    axis.GetXaxis().SetRangeUser(float(args.x_axis_min),
                                 float(args.x_axis_max))
plot.DrawCMSLogo(pads[1], 'Combine Harvester', scenario_label, 11, 0.045,
                 0.035, 1.2)
plot.DrawTitle(pads[1], args.lumi_label, 3)
plot.FixOverlay()
c1.SaveAs(args.ana_label + "_" + args.scenario + ".pdf")
c1.SaveAs(args.ana_label + "_" + args.scenario + ".png")
c1.SaveAs(args.ana_label + "_" + args.scenario + ".C")
예제 #29
0
         Header='#bf{%.0f%% CL Excluded:}' % (args.CL * 100.))
if 'obs' in contours:
    legend.AddEntry(contours['obs'][0], "Observed", "F")
if 'exp-1' in contours and 'exp+1' in contours:
    legend.AddEntry(contours['exp-1'][0], "#pm 1#sigma Expected", "F")
if 'exp0' in contours:
    if 'obs' in contours:
        legend.AddEntry(contours['exp0'][0], "Expected", "L")
    else:
        legend.AddEntry(contours['exp0'][0], "Expected", "F")
if 'exp-2' in contours and 'exp+2' in contours:
    legend.AddEntry(contours['exp-2'][0], "#pm 2#sigma Expected", "F")
legend.Draw()

# Draw logos and titles
plot.DrawCMSLogo(pads[0], 'CMS', args.cms_sub, 11, 0.045, 0.15, 1.0, '', 1.0)
plot.DrawTitle(pads[0], args.title_right, 3)
plot.DrawTitle(pads[0], args.title_left, 1)

# Redraw the frame because it usually gets covered by the filled areas
pads[1].cd()
pads[1].GetFrame().Draw()
pads[1].RedrawAxis()

# Draw the scenario label
latex = ROOT.TLatex()
latex.SetNDC()
latex.SetTextSize(0.04)
latex.DrawLatex(0.155, 0.75, args.scenario_label)

canv.Print('.pdf')
예제 #30
0
if args.layout == 2:
    legend2 = ROOT.TLegend(0.14, 0.53, 0.38, 0.74, '', 'NBNDC')
    legend2.SetFillStyle(0)
    # legend2.SetNColumns(2)
legend2.AddEntry(conts68['comb'][0], '68% CL', 'L')
legend2.AddEntry(conts95['comb'][0], '95% CL', 'L')
legend2.AddEntry(bestfits['comb'], 'Best fit', 'P')
legend2.AddEntry(sm_point, 'SM expected', 'P')
legend2.SetMargin(0.4)
legend2.Draw()

box = ROOT.TPave(0.15, 0.82, 0.41, 0.92, 0, 'NBNDC')
box.Draw()
if args.pub:
    plot.DrawCMSLogo(
        pads[0],
        '#splitline{#it{ATLAS}#bf{ and }#it{CMS}}{#it{LHC} #bf{Run 1}}', '',
        11, 0.025, 0.035, 1.1)
else:
    plot.DrawCMSLogo(pads[0],
                     '#it{ATLAS}#bf{ and }#it{CMS}',
                     '#it{LHC Run 1}',
                     11,
                     0.025,
                     0.035,
                     1.1,
                     extraText2='#it{Internal}')
# plot.DrawCMSLogo(pads[0], '#it{ATLAS}#bf{+}CMS', '#it{LHC Run 1}', 11, 0.02, 0.035, 1.1, extraText2='#it{Internal}')
pads[0].RedrawAxis()
canv.Print('.pdf')
canv.Print('.png')
canv.Print('.C')