Ejemplo n.º 1
0
    def get_thetas(self):
        histogram2D = self.to_hist()
        xs = []
        ys = []
        twodeltaNLLs = []
        for i_center, x in enumerate(histogram2D.x_bin_centers):
            all_deltaNNLs = histogram2D.H2_array[i_center][:]
            all_ys = histogram2D.y_bin_centers

            min_deltaNLL = 9999.
            for y, deltaNLL in zip(all_ys, all_deltaNNLs):
                y_on_line = -1. / 12. * x
                if y < 0.8 * y_on_line: continue
                if deltaNLL < min_deltaNLL:
                    min_deltaNLL = deltaNLL
                    min_y = y

            ys.append(min_y)
            xs.append(x)
            twodeltaNLLs.append(min_deltaNLL)
        thetas = [math.atan2(y, x) for x, y in zip(xs, ys)]
        thetas, twodeltaNLLs = [
            list(l) for l in zip(*sorted(zip(thetas, twodeltaNLLs)))
        ]

        graph = plotting.pywrappers.Graph(utils.get_unique_rootname(),
                                          'theta',
                                          thetas,
                                          twodeltaNLLs,
                                          color=self.color)
        return graph
Ejemplo n.º 2
0
    def make_spline(self):
        x = self.make_var_unique_name(self.x_var, self.x_min, self.x_max)
        y = self.make_var_unique_name(self.y_var, self.y_min, self.y_max)

        s = ROOT.RooArgList(x, y)
        ROOT.SetOwnership(s, False)

        spline = ROOT.RooSplineND(
            'spline_' + get_unique_rootname(), 'spline2D',
            s,
            self.tree,
            self.z_var,
            self.eps,
            True, # boolean rescale
            'deltaNLL>0 && deltaNLL<{0}'.format(self.deltaNLL_cutoff) + self.cutstring_addition,
            )
        splinewrapper = Spline2DWrapper(spline, x, y,
            x_min = self.x_min,
            x_max = self.x_max,
            y_min = self.y_min,
            y_max = self.y_max,
            )

        if self.filled_bestfit:
            splinewrapper.fill_bestfit(self.x_bestfit, self.y_bestfit)

        return splinewrapper
Ejemplo n.º 3
0
    def make_polyfit(self, graph=None):
        logging.info('Creating polyfit')
        fstring = self.compile_2d_fit_string()
        if graph is None:
            graph = self.get_graph()

        logging.info('fit string is: ' + fstring)

        f2D = ROOT.TF2(
            'f2D' + get_unique_rootname(), fstring,
            self.x_min, self.x_max,
            self.y_min, self.y_max
            )
        logging.info(
            'Fitting TGraph2D ({0} x {1} = {2} points) with TF2...'
            .format(graph.GetNpx(), graph.GetNpy(), graph.GetN())
            )
        graph.Fit(f2D.GetName())

        polyfit = PolyFit2DWrapper(f2D,
            x_min = self.x_min,
            x_max = self.x_max,
            y_min = self.y_min,
            y_max = self.y_max,
            )
        polyfit.multiply_by_two = True

        if self.filled_bestfit:
            polyfit.fill_bestfit(self.x_bestfit, self.y_bestfit)

        return polyfit
Ejemplo n.º 4
0
 def to_hist_smxs(self):
     histogram = plotting.pywrappers.Histogram(
         utils.get_unique_rootname(), core.standard_titles['SM_Vittorio'],
         self.binning(), self.smxs)
     # histogram.set_err_up([ s.unc.right_error * xs for s, xs in zip(self.scans, self.smxs) ])
     # histogram.set_err_down([ s.unc.left_error * xs for s, xs in zip(self.scans, self.smxs) ])
     self.process_overflow_and_underflow(histogram)
     histogram.add_stylesheet(self.style().copy(
         color=16, plot_priority=self.style().plot_priority - 5))
     return histogram
Ejemplo n.º 5
0
 def to_hist(self):
     histogram = plotting.pywrappers.Histogram(
         utils.get_unique_rootname(), self.title, self.binning(),
         [s.unc.x_min for s in self.scans])
     histogram.set_err_up([s.unc.right_error for s in self.scans])
     histogram.set_err_down([s.unc.left_error for s in self.scans])
     self.process_overflow_and_underflow(histogram)
     # if not(self.color is None): histogram.color = self.color
     histogram.add_stylesheet(self.style())
     return histogram
Ejemplo n.º 6
0
    def to_graph(self):
        name = utils.get_unique_rootname()
        graph = plotting.pywrappers.Graph(name, self.title, self.x(),
                                          self.two_times_deltaNLL())
        if hasattr(self, 'color'):
            # graph.color = self.color
            graph.style().color = self.color
        if hasattr(self, 'draw_style'):
            graph.draw_style = self.draw_style

        return graph
Ejemplo n.º 7
0
 def to_hist(self):
     histogram2D = plotting.pywrappers.Histogram2D(
         utils.get_unique_rootname(), getattr(self, 'title', ''),
         self.color)
     histogram2D.x_title = self.x_title
     histogram2D.y_title = self.y_title
     histogram2D.z_title = self.z_title
     if self._filled_bestfit:
         histogram2D.fill_bestfit(self.bestfit().x, self.bestfit().y)
     histogram2D.fill_from_entries(self.entries)
     if hasattr(self, 'contour_filter_method'):
         histogram2D.contour_filter_method = self.contour_filter_method
     return histogram2D
Ejemplo n.º 8
0
    def get_1d_y(self, histogram2D):
        xs = []
        deltaNLLs = []
        for i_center, center in enumerate(histogram2D.y_bin_centers):
            deltaNLL = min([row[i_center] for row in histogram2D.H2_array])
            xs.append(center)
            deltaNLLs.append(deltaNLL)

        graph = plotting.pywrappers.Graph(utils.get_unique_rootname(),
                                          self.y_variable,
                                          xs,
                                          deltaNLLs,
                                          color=self.color)
        return graph
Ejemplo n.º 9
0
 def name(self):
     return 'f2D_' + get_unique_rootname()
Ejemplo n.º 10
0
 def name(self):
     return get_unique_rootname()