示例#1
0
    def _plot(self):
        canvases = []

        '''
        loop over plots and draw them:

            1. all background channels stacked (MC channels + QCD)
            2. background error band (MC + QCD)
            3. data with errors
            4. ratio of data over background
        '''

        # loop over plots
        for plot_name, channels in self.loader.plots.items():
            background = None
            if "mc" in channels:
                background = channels["mc"].hist.Clone()

            if "qcd" in channels:
                if not background:
                    background = channels["qcd"].hist.Clone()
                else:
                    background.Add(channels["qcd"].hist)

            if not background:
                print("background is not avilable for", plot_name,
                      file=sys.stderr)

                continue

            background = calculate_efficiency(background)
            obj = self._create_obj("canvas_bg")
            obj.hist.append(background)
            background.Draw('hist 9')
            obj.legend.AddEntry(background, "background", "l")
            obj.legend.Draw('9')
            canvases.append(obj)

            bg_sqrt = background.Clone()
            sqrt_hist(bg_sqrt)
            obj = self._create_obj("canvas_sqrt_bg")
            obj.hist.append(bg_sqrt)
            bg_sqrt.Draw('hist 9')
            obj.legend.AddEntry(bg_sqrt, "sqrt(background)", "l")
            obj.legend.Draw('9')

            canvases.append(obj)

            # process Z'
            obj = None
            for channel_type, template in channels.items():
                if not channel_type.startswith("zp"):
                    continue

                hist = calculate_efficiency(template.hist)
                hist.SetFillStyle(0)

                obj = self._create_obj("canvas_chi2_{0}".format(channel_type))

                '''
                if '1000' in channel_type:
                    hist.Print('all')
                    background.Print('all')
                '''

                ratio = signal_over_background(hist, background,
                                               title="#frac{s}{b}")
                ratio.SetMaximum(5)
                ratio.SetMinimum(0.5)
                obj.hist.append(ratio)
                obj.legend.AddEntry(hist, channel_type, "l")

                ratio.Draw('hist 9')
                obj.legend.Draw('9')

                obj.canvas.cd(2)
                ratio = signal_over_background(hist, bg_sqrt,
                                               title="#frac{s}{#sqrt{b}}")
                obj.hist.append(ratio)

                ratio.SetMaximum(1.5)
                ratio.SetMinimum(0.5)
                ratio.Draw('hist 9')
                obj.legend.Draw('9')

                canvases.append(obj)

        return canvases
示例#2
0
    def _plot(self):
        canvases = []

        '''
        loop over plots and draw them:

            1. all background channels stacked (MC channels + QCD)
            2. background error band (MC + QCD)
            3. data with errors
            4. ratio of data over background
        '''

        # loop over plots
        for plot_name, channels in self.loader.plots.items():
            # process Z'
            obj = None
            for channel_type, template in channels.items():
                if not channel_type.startswith("zp"):
                    continue

                hist = calculate_efficiency(template.hist)
                hist.SetFillStyle(0)
                hist.SetMaximum(1.2)
                hist.SetMinimum(0)
                hist.GetXaxis().SetRangeUser(0, 20)

                if not obj:
                    obj = self._create_obj("canvas_signal_chi2")
                    hist.Draw('hist 9')
                else:
                    hist.Draw("hist 9 same")

                obj.legend.AddEntry(hist, channel_type, "l")

                obj.hist.append(hist)

            if obj:
                obj.legend.Draw('9')

                for label in obj.labels:
                    label.draw()

                canvases.append(obj)

            # take care of background
            obj = None
            for channel_type, template in channels.items():
                if (channel_type.startswith("zp") or
                    channel_type not in set(channels.keys()) -
                                        set(["data", "mc"])):
                    continue

                hist = calculate_efficiency(template.hist)
                hist.SetFillStyle(0)
                hist.SetMaximum(1.2)
                hist.SetMinimum(0)
                hist.GetXaxis().SetRangeUser(0, 20)

                if not obj:
                    obj = self._create_obj("canvas_background_chi2")
                    hist.Draw('hist 9')
                else:
                    hist.Draw("hist 9 same")

                obj.legend.AddEntry(hist, channel_type, "l")

                obj.hist.append(hist)

            if obj:
                obj.legend.Draw('9')

                for label in obj.labels:
                    label.draw()

                canvases.append(obj)

        return canvases