Ejemplo n.º 1
0
    def __make_overlay(self, pileup, threshold, hists, fits, labels, header):
        with preserve_current_style():
            name = self.filename_format.format(pileup=pileup,
                                               threshold=threshold)

            xmin = hists[0].GetTotalHistogram().GetBinLowEdge(1)
            xmax = hists[0].GetTotalHistogram().GetBinLowEdge(
                hists[0].GetTotalHistogram().GetNbinsX() + 1)

            # Draw each efficiency (with fit)
            draw_args = {
                "xtitle": self.offline_title,
                "ytitle": "Efficiency",
                "xlimits": [xmin, xmax]
            }

            canvas = draw(hists, draw_args=draw_args)
            if len(fits) > 0:
                for fit, hist in zip(fits, hists):
                    fit["asymmetric"].linecolor = hist.GetLineColor()
                    fit["asymmetric"].Draw("same")

            # Add labels
            label_canvas()

            # Add a legend
            legend = Legend(
                len(hists),
                header=self.legend_title,
                topmargin=0.35,
                rightmargin=0.3,
                leftmargin=0.7,
                textsize=0.025,
                entryheight=0.028,
            )

            for hist, label in zip(hists, labels):
                legend.AddEntry(hist, label)

            legend.SetBorderSize(0)
            legend.Draw()

            for val in [0.25, 0.5, 0.75, 0.95, 1.]:
                line = ROOT.TLine(xmin, val, xmax, val)
                line.SetLineStyle("dashed")
                line.SetLineColor(15)
                line.Draw()

            for thresh in self.thresholds.bins:
                line = ROOT.TLine(thresh, 0., thresh, 1.)
                line.SetLineStyle("dashed")
                line.SetLineColor(15)
                line.Draw()

            # Save canvas to file
            self.save_canvas(canvas, name)
Ejemplo n.º 2
0
def draw_lines(params):
    lines = []
    line_100 = ROOT.TLine(params.xmin, 1, params.xmax, 1)
    line_95 = ROOT.TLine(params.xmin, 0.95, params.xmax, 0.95)
    line_100.SetLineWidth(2)
    line_95.SetLineWidth(2)
    line_95.SetLineStyle(2)
    line_100.Draw()
    line_95.Draw()
    lines.append(line_100)
    lines.append(line_95)
    return lines
Ejemplo n.º 3
0
    def __make_overlay(self, hists, fits, labels, ytitle, suffix=""):
        with preserve_current_style():
            # Draw each resolution (with fit)
            # TODO: this feels like it does not belong here
            for hist in hists:
                hist.GetYaxis().SetRangeUser(0, 0.1)
                hist.GetYaxis().SetTitleOffset(1.4)

            xtitle = self.resolution_method.label.format(
                on=self.online_title, off=self.offline_title)
            canvas = draw(hists,
                          draw_args={
                              "xtitle": xtitle,
                              "ytitle": ytitle
                          })
            if fits:
                for fit, hist in zip(fits, hists):
                    fit["asymmetric"].linecolor = hist.GetLineColor()
                    fit["asymmetric"].Draw("same")

            # Add labels
            label_canvas()

            # Add a legend
            legend = Legend(
                len(hists),
                header=self.legend_title,
                topmargin=0.35,
                rightmargin=0.3,
                leftmargin=0.7,
                textsize=0.03,
                entryheight=0.03,
            )

            for hist, label in zip(hists, labels):
                legend.AddEntry(hist, label)
            legend.SetBorderSize(0)
            legend.Draw()

            ymax = 1.2 * max([hist.GetMaximum() for hist in hists])
            line = ROOT.TLine(0., 0., 0., ymax)
            line.SetLineColor(15)

            # Save canvas to file
            name = self.filename_format.format(pileup="all")
            self.save_canvas(canvas, name + suffix)
Ejemplo n.º 4
0
    def __make_overlay(self, pileup, threshold, hists, fits, labels, header):
        with preserve_current_style():
            name = self.filename_format.format(pileup=pileup,
                                               threshold=threshold)
            # Draw each efficiency (with fit)
            draw_args = {"xtitle": self.offline_title, "ytitle": "Efficiency"}
            # TODO: special case should not be implemented here!
            if 'Jet' in name and 'HiRange' in name:
                draw_args['xlimits'] = [20, 2000]

            canvas = draw(hists, draw_args=draw_args)
            if len(fits) > 0:
                for fit, hist in zip(fits, hists):
                    fit["asymmetric"].linecolor = hist.GetLineColor()
                    fit["asymmetric"].Draw("same")

            # Add labels
            label_canvas()

            # Add a legend
            legend = Legend(
                len(hists),
                header=self.legend_title,
                topmargin=0.35,
                rightmargin=0.3,
                leftmargin=0.7,
                textsize=0.025,
                entryheight=0.028,
            )
            for hist, label in zip(hists, labels):
                legend.AddEntry(hist, label)
            legend.SetBorderSize(0)
            legend.Draw()

            xmin = 0
            xmax = self.x_max
            # TODO: also specialisation, needs removal
            if ("HT" in name):
                xmax = 800
                xmin = 30
            if ("MET" in name):
                xmin = 0
                xmax = 400
            if ("Jet" in name):
                xmin = 20
                xmax = 400
            if ("HiRange" in name):
                xmax = 2000

            for val in [0.25, 0.5, 0.75, 0.95, 1.]:
                line = ROOT.TLine(xmin, val, xmax, val)
                line.SetLineStyle("dashed")
                line.SetLineColor(15)
                line.Draw()

            for val in range(100, xmax, 100):
                line = ROOT.TLine(val, 0., val, 1.)
                line.SetLineStyle("dashed")
                line.SetLineColor(15)
                line.Draw()

            # Save canvas to file
            self.save_canvas(canvas, name)
Ejemplo n.º 5
0
    fitted.SetY2(-0.075)
fitted.Draw(fitdrawopts)  #'' if args.conly else 'P SAME')
canvas.SaveAs('%s/fail.png' % indir)
canvas.SaveAs('%s/fail.pdf' % indir)

ROOT.TColor.CreateGradientColorTable(3, array('d', [0., 0.682, 1.]),
                                     array('d', [0., .95, 1.]),
                                     array('d', [0., .95, 0.]),
                                     array('d', [1., .95, 0.]), 255)
ccover.Draw(hdrawopts)  #'HIST' if args.conly else 'colz text')
getattr(ccover, axis).range_user = (0., 1)
add = None
if args.conly:
    fitted.SetY1(0.175)
    fitted.SetY2(0.025)
    add = ROOT.TLine(ccover[1].x.low, 0.682, ccover[-1].x.low, 0.682)
    add.SetLineWidth(2)
    add.SetLineColor(ROOT.kRed)
    add.SetLineStyle(2)
    add.Draw()
fitted.Draw(fitdrawopts)  #'' if args.conly else 'P SAME')
canvas.SaveAs('%s/ccover.png' % indir)
canvas.SaveAs('%s/ccover.pdf' % indir)

if args.systematic:
    ccover_p.Draw(hdrawopts)  #'HIST' if args.conly else 'colz text')
    getattr(ccover_p, axis).range_user = (0., 1)
    if add is not None:
        add.Draw()
    fitted.Draw(fitdrawopts)
    canvas.SaveAs('%s/ccover_p.png' % indir)