Exemple #1
0
                        myc = ROOT.TCanvas('myc', '', 800, 500)
                        myc.cd()
                        obj.Draw()
                    else:
                        obj.Draw('same')
            if myc:
                myc.Print(fname)
            del myc

    # def _write(rfile, hists):
    #     for pair in hists:
    #         map(lambda h: rfile.WriteTObject(h) if h else None, pair)

    if options.dump:
        rfile = ROOT.TFile.Open('correlation_hists.root', 'recreate')

    for transform in transforms:
        plotter.draw_hist(hists[transform+'_corr'], opts)
        canvas.Update()
        if options.dump:
            # _write(rfile, hists[transform+'_corr'])
            _draw_match('{}_matched_corrln_{}.pdf'.format(prefix, transform),
                        hists[transform+'_corr'])
        if options.doprint:
            canvas.Print('{}_corrln_grid_{}.png'.format(prefix, transform))
            # canvas.Print('{}_correlation_grid.pdf'.format(prefix))

    # if options.doprint:
    #     canvas.Print('{}_correlation_grid.pdf]'.format(prefix))
    del plotter, canvas
Exemple #2
0
# axis titles
blabel, swlabel, ylabel = "B mass [MeV]", "#it{s}-weights", "Candidates"
titles = {hist_m4: (blabel, ylabel), hist_m5: (blabel, ylabel), hist_m6: (blabel, ylabel)}

from rplot.tselect import Tselect

selector = Tselect(tree)
selector.exprs = [
    ("lab0_MM>>hist_m4", "5310<lab0_MM && lab0_MM<5430"),
    ("lab0_MM>>hist_m5", "sw*(5310<lab0_MM && lab0_MM<5430)"),
    ("lab0_MM>>hist_m6", "(sw-0.113)*(5310<lab0_MM && lab0_MM<5430)"),
]
hists = selector.fill_hists()
map(lambda h: (h.GetXaxis().SetTitle(titles[h][0]), h.GetYaxis().SetTitle(titles[h][1])), hists)

from rplot.rplot import Rplot

plotter = Rplot(1, 1, 800, 500)

legend = ROOT.TLegend(0.65, 0.5, 0.9, 0.9)
legend.SetFillStyle(0)
legend.SetLineWidth(0)
plotter.add_legend(legend, "lep")

canvas = plotter.prep_canvas()
canvas.Print("sw-B-mass.pdf[")
plotter.draw_hist([hists], "e1")
canvas.Print("sw-B-mass.pdf")
canvas.Print("sw-B-mass.pdf]")
Exemple #3
0
    hist_m5: (blabel, ylabel),
    hist_m6: (blabel, ylabel),
}

from rplot.tselect import Tselect
selector = Tselect(tree)
selector.exprs = [
    ('lab0_MM>>hist_m4', '5310<lab0_MM && lab0_MM<5430'),
    ('lab0_MM>>hist_m5', 'sw*(5310<lab0_MM && lab0_MM<5430)'),
    ('lab0_MM>>hist_m6', '(sw-0.113)*(5310<lab0_MM && lab0_MM<5430)'),
]
hists = selector.fill_hists()
map(
    lambda h:
    (h.GetXaxis().SetTitle(titles[h][0]), h.GetYaxis().SetTitle(titles[h][1])),
    hists)

from rplot.rplot import Rplot
plotter = Rplot(1, 1, 800, 500)

legend = ROOT.TLegend(0.65, 0.5, 0.9, 0.9)
legend.SetFillStyle(0)
legend.SetLineWidth(0)
plotter.add_legend(legend, 'lep')

canvas = plotter.prep_canvas()
canvas.Print('sw-B-mass.pdf[')
plotter.draw_hist([hists], 'e1')
canvas.Print('sw-B-mass.pdf')
canvas.Print('sw-B-mass.pdf]')
                max_y_n = hpair[mode].GetMaximum() / hpair[mode].Integral()
        # set max Y so that histograms fit in pad
        for mode in modes:
            hpair[mode].SetMaximum(1.1 * max_y_n * hpair[mode].Integral())
        histograms.append(hpair)

hists = map(lambda hs: (hs['dsk'], hs['dspi']), histograms)

from rplot.rplot import Rplot
plotter = Rplot(1, 3, 1024, 1920)
canvas = plotter.prep_canvas()
plotfile = 'plots/timelt2ps_%s.pdf' % sanitise_str_src('_'.join(variables))
if doPrint:
    canvas.Print(plotfile + '[')

# create legend
legend = TLegend(0.6, 0.6, 0.95, 0.75)
legend.SetLineWidth(0)
legend.SetFillStyle(0)
legend.SetTextSize(0.035)
legend.SetHeader('%s ps'.format(sanitise_str(str(cuts['timelt2ps']))))
plotter.add_legend(legend, 'lep')

for i in xrange(0, len(hists), 3):
    plotter.draw_hist(hists[i:i+3], 'e1', normalised=True)
    if doPrint:
        canvas.Print(plotfile)
if doPrint:
    canvas.Print(plotfile + ']')
    del plotter
Exemple #5
0
    ROOT.gStyle.SetHatchesSpacing(2.5)
    for transform in transforms:
        def _style(l):
            # l.reverse()
            l[0].SetFillStyle(3345)
            l[1].SetFillStyle(3354)
        distributions[transform] = arrange(distributions[transform], 2,
                                           predicate=_style)

    plotter = Rplot(5, 3, 2000, 1200)
    plotter.alpha = 0.2
    canvas = plotter.prep_canvas()
    if doprint: canvas.Print('transforms.pdf[')

    for transform in transforms:
        plotter.draw_hist(distributions[transform], 'hist')
        canvas.Update()
        if doprint: canvas.Print('transforms.pdf')

    if doprint: canvas.Print('transforms.pdf]')
    del plotter, canvas


## correlation plots
if lcorrns or scatter:
    _filter = lambda string: lambda k: k.GetName().find(string) > 0
    sig_hists = get_hists(['{}_corr'.format(k) for k in transforms],
                          rfileconf, rpath_tool, robj_t = ROOT.TH1,
                          robj_p = _filter('Signal'))
    bkg_hists = get_hists(['{}_corr'.format(k) for k in transforms],
                          rfileconf, rpath_tool, robj_t = ROOT.TH1,
                max_y_n = hpair[mode].GetMaximum() / hpair[mode].Integral()
        # set max Y so that histograms fit in pad
        for mode in modes:
            hpair[mode].SetMaximum(1.1 * max_y_n * hpair[mode].Integral())
        histograms.append(hpair)

hists = map(lambda hs: (hs['dsk'], hs['dspi']), histograms)

from rplot.rplot import Rplot
plotter = Rplot(1, 3, 1024, 1920)
canvas = plotter.prep_canvas()
plotfile = 'plots/timelt2ps_%s.pdf' % sanitise_str_src('_'.join(variables))
if doPrint:
    canvas.Print(plotfile + '[')

# create legend
legend = TLegend(0.6, 0.6, 0.95, 0.75)
legend.SetLineWidth(0)
legend.SetFillStyle(0)
legend.SetTextSize(0.035)
legend.SetHeader('%s ps'.format(sanitise_str(str(cuts['timelt2ps']))))
plotter.add_legend(legend, 'lep')

for i in xrange(0, len(hists), 3):
    plotter.draw_hist(hists[i:i + 3], 'e1', normalised=True)
    if doPrint:
        canvas.Print(plotfile)
if doPrint:
    canvas.Print(plotfile + ']')
    del plotter