示例#1
0
    def fitTo(self, dataset, silent=True, refit=2, args=(), **kwargs):
        """Fit it!

        >>> dataset = ...
        >>> eff     = Efficiency1D( ... ) 
        >>> result  = eff.fitTo ( dataset ) 
        """

        vargs = []  ##  i for i in args ]
        vargs.append(ROOT.RooFit.ConditionalObservables(self.vars))
        vargs = tuple(vargs)
        ##
        draw = kwargs.pop('draw', False)
        from ostap.logger.utils import roo_silent
        with roo_silent(silent):
            result, frame = self.pdf_fit.fitTo(dataset,
                                               draw=False,
                                               nbins=100,
                                               silent=silent,
                                               refit=refit,
                                               args=vargs,
                                               **kwargs)
            if draw: self.draw(dataset)
        self.__fit_result = result
        return result
示例#2
0
    def __init__(self,
                 histo,
                 xaxis=None,
                 yaxis=None,
                 density=True,
                 silent=False):
        #
        assert isinstance(histo, ROOT.TH2), "``histo'' is not ROOT.TH2"
        self.__histo = histo

        ## use mass-variable
        #
        name = histo.GetName()
        if not xaxis: xaxis = histo.xminmax()
        if not yaxis: yaxis = histo.yminmax()

        self.__xaxis = self.make_var(xaxis, 'x_%s' % name, 'x-axis(%s)' % name,
                                     xaxis, *(histo.xminmax()))
        self.__yaxis = self.make_var(yaxis, 'y_%s' % name, 'y-axis(%s)' % name,
                                     yaxis, *(histo.yminmax()))

        self.__density = True if density else False
        self.__silent = silent

        with roo_silent(silent):

            self.__vlst = ROOT.RooArgList(self.xaxis, self.yaxis)
            self.__vimp = ROOT.RooFit.Import(histo, density)
            self.__dset = ROOT.RooDataHist(
                rootID('hds_'),
                "Data set for histogram '%s'" % histo.GetTitle(), self.__vlst,
                self.__vimp)