예제 #1
0
## variable distributions
if options.distribs:
    # histogram order: signal, background (repeat for diff transforms)
    distributions = get_hists(transforms, rfileconf, pathtool, robj_t=ROOT.TH1)

    ROOT.gStyle.SetHatchesLineWidth(1)
    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(3, 3, 2000, 1200)
    plotter.alpha = 0.2
    canvas = plotter.prep_canvas()
    if options.doprint:
        canvas.Print('{}_transforms.pdf['.format(prefix))

    def _plot_n_print(hlist, plotter=plotter, canvas=canvas):
        plotter.draw_hist(hlist, 'hist')
        canvas.Update()
        if options.doprint:
            canvas.Print('{}_transforms.pdf'.format(prefix))

    for transform in transforms:
        if len(distributions[transform]) > plotter.nplots:
            for hists in partition(distributions[transform], plotter.nplots):
                _plot_n_print(hists)
예제 #2
0
    matches  = ['MVA_{}{}'.format(cl, string) for cl in classifiers]
    return lambda k: k.GetName() in matches

_filter1 = lambda string: lambda k: _filter(string+'_S')(k) or _filter(string+'_B')(k)
_filter2 = lambda str1, str2: lambda k: _filter1(str1)(k) or _filter1(str2)(k)

distribs = get_hists(classifiers, rfileconf, rpath_tool,
                     robj_t = ROOT.TH1, robj_p = _filter2('', '_Train'))
if rarity:
    rarity = get_hists(classifiers, rfileconf, rpath_tool,
                       robj_t = ROOT.TH1, robj_p = _filter1('_Rarity'))
if probab:
    probab = get_hists(classifiers, rfileconf, rpath_tool,
                       robj_t = ROOT.TH1, robj_p = _filter1('_Proba'))

plotter = Rplot(1, 1, 800, 600)
plotter.alpha = 0.2
plotter.fill_colours = (ROOT.kAzure,   ROOT.kRed,   ROOT.kAzure,   ROOT.kRed)
plotter.line_colours = (ROOT.kAzure-6, ROOT.kRed+2, ROOT.kAzure-6, ROOT.kRed+2)
plotter.markers = (ROOT.kPlus, ROOT.kPlus, ROOT.kPlus, ROOT.kPlus)
canvas = plotter.prep_canvas()
if doprint: canvas.Print('overtraining.pdf[')

ROOT.gStyle.SetHatchesLineWidth(1)
ROOT.gStyle.SetHatchesSpacing(1)
def _style(l):
    l[0].SetFillStyle(3345)
    l[1].SetFillStyle(3354)

def _plot(plots, opts):
    plotter.draw_hist(plots, opts)
예제 #3
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]")
예제 #4
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]')
예제 #5
0
                else:
                    print 'Unknown permutation of cuts, weird things will happen.'
            sel = trees[mode].Draw('{}>>{}'.format(var, hist.GetName()), cut, 'goff')
            hpair[mode] = hist
            # determine max Y for normalised histograms
            if max_y_n < hpair[mode].GetMaximum()/hpair[mode].Integral():
                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)
예제 #6
0
                    print 'Unknown permutation of cuts, weird things will happen.'
            sel = trees[mode].Draw('{}>>{}'.format(var, hist.GetName()), cut,
                                   'goff')
            hpair[mode] = hist
            # determine max Y for normalised histograms
            if max_y_n < hpair[mode].GetMaximum() / hpair[mode].Integral():
                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)
예제 #7
0
                       rfileconf,
                       rpath_tool,
                       robj_t=ROOT.TH1,
                       robj_p=_filter1('_Rarity'))
else:
    rarity = None
if options.probab:
    probab = get_hists(classifiers,
                       rfileconf,
                       rpath_tool,
                       robj_t=ROOT.TH1,
                       robj_p=_filter1('_Proba'))
else:
    probab = None

plotter = Rplot(1, 1, 800, 600)
plotter.alpha = 0.2
plotter.fill_colours = (ROOT.kAzure, ROOT.kRed, ROOT.kAzure, ROOT.kRed)
plotter.line_colours = (ROOT.kAzure - 6, ROOT.kRed + 2, ROOT.kAzure - 6,
                        ROOT.kRed + 2)
plotter.markers = (ROOT.kPlus, ROOT.kPlus, ROOT.kPlus, ROOT.kPlus)
canvas = plotter.prep_canvas()
if options.doprint:
    canvas.Print('{}_overtraining.pdf['.format(prefix))

ROOT.gStyle.SetHatchesLineWidth(1)
ROOT.gStyle.SetHatchesSpacing(1)


def _style(l):
    l[0].SetFillStyle(3345)