def create_histograms(self,
                          online_title,
                          thresholds,
                          n_bins,
                          low,
                          high,
                          legend_title=""):
        """ This is not in an init function so that we can by-pass this in the
        case where we reload things from disk """
        self.online_title = online_title
        self.thresholds = thresholds
        self.thresholds = bn.GreaterThan(thresholds, "threshold", True)
        self.legend_title = legend_title
        name = ["rate_vs_pileup", self.online_name]
        name += ["thresh_{threshold}"]
        name = "__".join(name)
        title = " ".join([
            self.online_name, " rate vs pileup",
            "passing threshold: {threshold}"
        ])
        self.plots = HistogramCollection([self.thresholds],
                                         "Hist1D",
                                         n_bins,
                                         low,
                                         high,
                                         name=name,
                                         title=title)

        self.filename_format = name
Ejemplo n.º 2
0
    def create_histograms(self,
                          online_title,
                          offline_title,
                          pileup_bins,
                          thresholds,
                          n_bins,
                          low,
                          high=400,
                          legend_title=""):
        """ This is not in an init function so that we can by-pass this in the
        case where we reload things from disk """
        self.online_title = online_title
        self.offline_title = offline_title
        self.pileup_bins = bn.Sorted(pileup_bins,
                                     "pileup",
                                     use_everything_bin=True)
        self.thresholds = bn.GreaterThan(thresholds, "threshold")
        self.legend_title = legend_title

        name = ["efficiency", self.online_name, self.offline_name]
        name += ["thresh_{threshold}", "pu_{pileup}"]
        name = "__".join(name)
        title = " ".join([
            self.online_name, " in PU bin: {pileup}",
            "and passing threshold: {threshold}"
        ])
        self.filename_format = name

        def make_efficiency(labels):
            this_name = "efficiency" + name.format(**labels)
            this_title = title.format(**labels)
            '''Checking type of 'low' to see whether it's int (x-range minimum)
                    or array (bin edges) for constructing TEfficiency'''
            if isinstance(low, np.ndarray):
                eff = asrootpy(
                    ROOT.TEfficiency(this_name, this_title, n_bins, low))
                self.x_max = 2000
            else:
                eff = asrootpy(
                    ROOT.TEfficiency(this_name, this_title, n_bins, low, high))
                self.x_max = high
            eff.drawstyle = EfficiencyPlot.drawstyle
            return eff

        self.efficiencies = HistogramCollection(
            [self.pileup_bins, self.thresholds], make_efficiency)