示例#1
0
    def process(self, jobid, nToys):

        import ROOT
        from ostap.logger.logger import logWarning
        with logWarning():
            import ostap.core.pyrouts
            import ostap.fitting.roofit
            import ostap.fitting.dataset
            import ostap.fitting.roofitresult
            import ostap.fitting.variables

        from ostap.core.ostap_types import integer_types
        assert isinstance ( nToys , integer_types ) and 0 < nToys,\
               'Jobid %s: Invalid "nToys" argument %s/%s' % ( jobid , nToys , type ( nToys ) )

        import ostap.fitting.toys as Toys
        results, stats = Toys.make_toys2(gen_pdf=self.gen_pdf,
                                         fit_pdf=self.fit_pdf,
                                         nToys=nToys,
                                         data=self.data,
                                         gen_config=self.gen_config,
                                         fit_config=self.fit_config,
                                         gen_pars=self.gen_pars,
                                         fit_pars=self.fit_pars,
                                         more_vars=self.more_vars,
                                         gen_fun=self.gen_fun,
                                         fit_fun=self.fit_fun,
                                         accept_fun=self.accept_fun,
                                         silent=self.silent,
                                         progress=self.progress)

        self.the_output = results, stats

        return self.results()
示例#2
0
    def process ( self , jobid , item ) :

        import ROOT
        from ostap.logger.logger import logWarning
        with logWarning() :
            import ostap.core.pyrouts            
            import ostap.trees.trees
            import ostap.fitting.roofit 

        
        ## reconstruct chain from the item 
        chain    = item.chain
        ll       = len ( chain )  
        
        first    = item.first
        nevents  = item.nevents 

        all = 0 == first and ( nevents < 0 or ll <= nevents )
        
        if self.trivial and all : 
            import ostap.fitting.pyselectors
            self.__output = chain.make_dataset ( self.variables , self.selection , silent = True ) 
            return self.__output 

        from   ostap.fitting.pyselectors import SelectorWithVars
        
        ## use selector  
        selector = SelectorWithVars ( variables = self.variables ,
                                      selection = self.selection ,
                                      roo_cuts  = self.roo_cuts  , 
                                      silence   = True           )
        
        args = ()  
        if not all : args  = nevents , first 
        
        dataset , stat  = chain.fill_dataset2 ( selector  ,
                                                *args     ,
                                                silent    = True                 , 
                                                shortcut  = all and self.trivial ,
                                                use_frame = self.use_frame       )
        
        ## self.__output = selector.data, selector.stat  
        self.__output = dataset, stat 
        
        ## if  num < 0 :
        ##   logger.warning ("Processing status %s (jobid #%s)"  %  ( num % jobid ) ) 
        
        ## del selector.data
        ## del      selector        
        logger.debug ( 'Processed %s and filled %d entries (jobid #%s)' % ( stat , len ( dataset ) , jobid ) )

        return self.__output 
示例#3
0
    def process(self, item):

        import ROOT
        from ostap.logger.logger import logWarning
        with logWarning():
            import ostap.core.pyrouts
            import ostap.trees.trees

        ## reconstruct chain from the item
        chain = item.chain
        ll = len(chain)

        first = item.first
        nevents = item.nevents

        all = 0 == first and (nevents < 0 or ll <= nevents)

        if self.trivial and all:
            import ostap.fitting.selectors
            self.output = chain.make_dataset(self.variables,
                                             self.selection,
                                             silent=True)
            return

        from ostap.fitting.selectors import SelectorWithVars

        ## use selector
        selector = SelectorWithVars(self.variables,
                                    self.selection,
                                    silence=True)

        args = ()
        if not all: args = nevents, first

        num = chain.process(selector, *args, shortcut=all and self.trivial)
        self.output = selector.data, selector.stat

        if num < 0:
            logger.warning("Processing status %s" % num)

        ##del selector.data
        ##del      selector
        logger.debug('Processed %s and filled %d entries ' %
                     (item, len(self.output)))

        del item