コード例 #1
0
ファイル: rates.py プロジェクト: vcepaitis/cms-l1t-analysis
    def draw(self, with_fits=False):
        hists = []
        labels = []
        fits = []
        for (pile_up, ), hist in self.plots.flat_items_all():
            h = cumulative_hist(hist)
            h = normalise_to_collision_rate(h)
            if pile_up == bn.Base.everything:
                h.linestyle = "dashed"
                label = "Everything"
            elif isinstance(pile_up, int):
                h.drawstyle = "EP"
                label = "~ {:.0f}".format(
                    self.pileup_bins.get_bin_center(pile_up))
            else:
                continue
            h.SetMarkerSize(0.5)
            hists.append(h)
            labels.append(label)
            # if with_fits:
            #     fits.append(self.fits.get_bin_contents([pile_up]))
        self.__make_overlay(hists, fits, labels, "Number of events")

        normed_hists = list(normalise_to_unit_area(hists))
        self.__make_overlay(normed_hists, fits, labels, "Fraction of events",
                            "__shapes")
コード例 #2
0
    def draw(self, with_fits=False):
        hists = []
        labels = []
        fits = []
        for (pile_up, ), hist in self.plots.flat_items_all():
            if pile_up == bn.Base.everything:
                # hist.linestyle = "dashed"
                hist.drawstyle = ResolutionPlot.drawstyle
                label = "All PU"
            elif isinstance(pile_up, int):
                hist.drawstyle = ResolutionPlot.drawstyle
                if self.pileup_bins.get_bin_upper(pile_up) < 500:
                    label = "{:.0f} \\leq PU < {:.0f}".format(
                        self.pileup_bins.get_bin_lower(pile_up),
                        self.pileup_bins.get_bin_upper(pile_up),
                    )
                else:
                    label = "{:.0f} < PU".format(
                        self.pileup_bins.get_bin_lower(pile_up))
            else:
                continue
            hist.SetMarkerSize(0.5)
            hist.SetLineWidth(1)
            hists.append(hist)
            labels.append(label)
            # if with_fits:
            #     fits.append(self.fits.get_bin_contents([pile_up]))
        # self.__make_overlay(hists, fits, labels, "Number of events")

        normed_hists = list(normalise_to_unit_area(hists))
        for hist in normed_hists:
            hist.GetYaxis().SetRangeUser(-0.1, 1.1)
        self.__make_overlay(normed_hists, fits, labels, "a.u.")
コード例 #3
0
    def overlay(self, other_plotters=None, with_fits=False):
        hists = []
        labels = []
        fits = []
        suffix = '__emu_overlay'
        titles = ['Hw', 'Emu']
        if self.comp_title:
            suffix = '__comparison'
            titles = [
                other_plotter.comp_title for other_plotter in other_plotters
            ]
            titles.insert(0, self.comp_title)

        for (pile_up, ), hist in self.plots.flat_items_all():
            if pile_up == bn.Base.everything:
                hist.SetLineStyle(1)
                hist.drawstyle = ResolutionPlot.drawstyle
                label = 'L1 ' + titles[0]
            else:
                continue
            hists.append(hist)
            labels.append(label)

        for other_plotter in other_plotters:
            for (pile_up, ), hist in other_plotter.plots.flat_items_all():
                if pile_up == bn.Base.everything:
                    hist.SetLineStyle(1)
                    hist.drawstyle = ResolutionPlot.drawstyle
                    label = 'L1 ' + titles[other_plotters.index(other_plotter)
                                           + 1]
                else:
                    continue
                hists.append(hist)
                labels.append(label)

        # self.__make_overlay(hists, fits, labels,
        #                    "Number of events", "__Overlay_Emu")

        normed_hists = list(normalise_to_unit_area(hists))
        for hist in normed_hists:
            hist.GetYaxis().SetRangeUser(-0.1, 1.1)
        self.__make_overlay(normed_hists, fits, labels, "a.u.", suffix)
コード例 #4
0
    def overlay_with_emu(self, emu_plotter, with_fits=False):
        hists = []
        labels = []
        fits = []
        for (pile_up, ), hist in self.plots.flat_items_all():
            if pile_up == bn.Base.everything:
                hist.SetLineStyle(1)
                hist.drawstyle = ResolutionPlot.drawstyle
                label = "HW, all PU"
            else:
                continue
            hist.SetMarkerSize(0.5)
            hist.SetLineWidth(1)
            hists.append(hist)
            labels.append(label)

        for (pile_up, ), hist in emu_plotter.plots.flat_items_all():
            if pile_up == bn.Base.everything:
                hist.SetLineStyle(1)
                hist.drawstyle = ResolutionPlot.drawstyle
                label = "Emu, all PU"
            else:
                continue
            hist.SetMarkerSize(0.5)
            hist.SetLineWidth(1)
            hists.append(hist)
            labels.append(label)

        # self.__make_overlay(hists, fits, labels,
        #                    "Number of events", "__Overlay_Emu")

        normed_hists = list(normalise_to_unit_area(hists))
        for hist in normed_hists:
            hist.GetYaxis().SetRangeUser(-0.1, 1.1)
        self.__make_overlay(normed_hists, fits, labels,
                            "a.u.", "__Overlay_Emu")
コード例 #5
0
    def draw(self, with_fits=False):
        hists = []
        labels = []
        fits = []
        for (pile_up, ), hist in self.plots.flat_items_all():
            h = cumulative_hist(hist)
            h = normalise_to_collision_rate(h)
            if pile_up == bn.Base.everything:
                h.linestyle = "dashed"
                label = "L1 Rate"
            # elif isinstance(pile_up, int):
            #    h.drawstyle = "HIST"
            #    label = str(self.pileup_bins.bins[pile_up])
            else:
                continue
            hists.append(h)
            labels.append(label)
            # if with_fits:
            #     fits.append(self.fits.get_bin_contents([pile_up]))
        self.__make_overlay(hists, fits, labels, "Rate (kHz)", setlogy=True)

        normed_hists = list(normalise_to_unit_area(hists))
        self.__make_overlay(normed_hists, fits, labels, "Fraction of events",
                            "__shapes")