Exemplo n.º 1
0
    ## 2) update weights
    plots = [WeightingPlot('y:x', 'weight', '2D-reweight', hdata, hmc)]
    if 2 < iter:
        plots = [
            WeightingPlot('x', 'weight', 'x-reweight', hxdata, hmcx),
            WeightingPlot('y', 'weight', 'y-reweight', hydata, hmcy),
            WeightingPlot('y:x', 'weight', '2D-reweight', hdata, hmc, 0.99),
        ]

    with timing('Make one reweighting iteration:', logger=logger):
        # =========================================================================
        ## 2a) the most important line: perform single iteration step
        more = makeWeights(
            mcds,  ## what to be reweighted
            plots,  ## reweighting plots/setup
            dbname,  ## DBASE with reweigting constant 
            delta=0.04,  ## stopping criteria
            minmax=0.08,  ## stopping criteria  
            power=2 if 1 != len(plots) else 1,  ## tune: effective power
            tag="Reweight/%d" % iter)  ## tag for printout

    with timing('Project weighted MC-dataset:', logger=logger):
        # =========================================================================
        ## 3) make MC-histograms
        mcds.project(hmcx, 'x', 'weight')
        mcds.project(hmcy, 'y', 'weight')
        mcds.project(hmc, 'y:x', 'weight')

    with timing('Compare DATA and MC distributions:', logger=logger):
        # ==============================================================================
        ## 4) compare "Data" and "MC"  after the reweighting on the given iteration
        logger.info('Compare DATA and MC for iteration #%d' % iter)
Exemplo n.º 2
0
    logger.info ('MCDATA: %s' %  mcds )
    
    #
    ## update weights
    #

    plots = [ WeightingPlot ( 'y:x' , 'weight' , '2D-reweight' , hdata  , hmc  ) ]
    if 5 <= iter: 
        plots  = [
            WeightingPlot ( 'x'   , 'weight' , 'x-reweight'  , hxdata , hmcx       ) ,  
            WeightingPlot ( 'y'   , 'weight' , 'y-reweight'  , hydata , hmcy       ) , 
            WeightingPlot ( 'y:x' , 'weight' , '2D-reweight' , hdata  , hmc  , 0.5 ) , 
            ]
    
    ## more iteration?  number of ``active'' reweightings    
    more = makeWeights ( mcds , plots , dbname , delta = 0.01 , power = 2 if 1 != len(plots) else 1 ) 
    
    ## make MC-histogram 
    mcds .project  ( hmcx , 'x'   , 'weight'  )
    mcds .project  ( hmcy , 'y'   , 'weight'  )
    mcds .project  ( hmc  , 'y:x' , 'weight'  )
    
    logger.info    ( 'Compare DATA and MC for iteration #%d' % iter )
    #
    ## compare the basic properties: mean, rms, skewness and kurtosis
    # 
    hxdata.cmp_prnt ( hmcx , 'DATA' , 'MC' , 'DATA(x) vs MC(x)' )
    hydata.cmp_prnt ( hmcy , 'DATA' , 'MC' , 'DATA(y) vs MC(y)' )
    
    #
    ## calculate the distances
Exemplo n.º 3
0
    selector = SelectorWithVars (
        variables ,
        '0<x && x<100 '
        )
    
    mctree.process ( selector )
    mcds = selector.data             ## new reweighted dataset

    #
    ## update weights
    #    
    plots    = [
        WeightingPlot( 'pt_x'   , 'weight' , 'x-reweight'  , hdata , hmc )  
        ]
    
    more = makeWeights ( mcds , plots , dbname , delta = 0.001 )

    ## make MC-histogram 
    mcds .project  ( hmc , 'pt_x' , 'weight'  )
    
    logger.info    ( 'Compare DATA and MC for iteration #%d' % iter )
    #
    ## compare the basic properties: mean, rms, skewness and kurtosis
    # 
    hdata.cmp_prnt ( hmc , 'DATA' , 'MC' , 'DATA vs MC' )
    #
    ## calculate the distances
    #
    dist = hdata.cmp_dist ( hmc , density = True )
    logger.info ('DATA-MC "distance"      %s' % dist )
    #
Exemplo n.º 4
0
    elif iter <= 10:
        power = lambda nactive: 1.5 / nactive if 1 < nactive else 0.90
    elif iter <= 15:
        power = lambda nactive: 1.3 / nactive if 1 < nactive else 0.90
    else:
        power = lambda nactive: 1.1 / nactive if 1 < nactive else 0.90

    with timing(tag + ': make actual reweighting:', logger=logger):

        # =========================================================================
        ## 2a) the most important line: perform single iteration step
        active = makeWeights(
            mcds,  ## what to be reweighted
            plots,  ## reweighting plots/setup
            dbname,  ## DBASE with reweigting constant 
            delta=0.01,  ## stopping criteria
            minmax=0.05,  ## stopping criteria  
            power=power,  ## tune: effective power
            make_plots=False,
            tag=tag)  ## tag for printout

    with timing(tag + ': project weighted MC-dataset:', logger=logger):
        # =========================================================================
        ## 3) make MC-histograms
        mcds.project(hmcx, 'x', 'weight')
        mcds.project(hmcy, 'y', 'weight')
        mcds.project(hmc, 'y:x', 'weight')

    rows = []
    with timing(tag + ': compare DATA and MC distributions:', logger=logger):
Exemplo n.º 5
0
        mcds = selector.data  ## dataset

    with timing('Add weight to MC-dataset', logger=logger):

        ## 1b) add "weight" variable to the dataset
        mcds.add_reweighting(weighter, name='weight')

        logger.info('MCDATA:\n%s' % mcds)

    with timing('Make one reweighting iteration:', logger=logger):
        # ==============================================================================
        ## 2) update weights
        plots = [WeightingPlot('x', 'weight', 'x-reweight', hdata, hmc)]
        more = makeWeights(mcds,
                           plots,
                           dbname,
                           delta=0.001,
                           tag='Reweight/%s' % iter)

    with timing('Project weighted MC-dataset:', logger=logger):
        # ==============================================================================
        ## 3) make MC-histogram
        mcds.project(hmc, 'x', 'weight')

    with timing('Compare DATA and MC distributions:', logger=logger):
        # ==============================================================================
        ## 4) compare "Data" and "MC"  after the reweighting on the given iteration
        logger.info('Compare DATA and MC for iteration #%d' % iter)

        hh = 'Iteration#%d: ' % iter
Exemplo n.º 6
0
    with timing(tag + ': add weight to MC-dataset', logger=logger):

        ## 1b) add "weight" variable to the dataset
        mcds.add_reweighting(weighter, name='weight')
        if 1 == iter % 10: logger.info((tag + ' MCDATA:\n%s') % mcds)

    with timing(tag + ': make actual reweighting:', logger=logger):
        # ==============================================================================
        ## 2) update weights
        plots = [WeightingPlot('x', 'weight', 'x-reweight', hdata, hmc)]
        more = makeWeights(
            mcds,
            plots,
            dbname,
            delta=0.005,
            minmax=0.01,
            power=1.05,  ## tiny ``overreweighting''
            make_plots=False,
            tag=tag)

    with timing(tag + ': project weighted MC-dataset:', logger=logger):
        # ==============================================================================
        ## 3) make MC-histogram
        mcds.project(hmc, 'x', 'weight')

    with timing(tag + ': compare DATA and MC distributions:', logger=logger):
        # ==============================================================================
        ## 4) compare "Data" and "MC"  after the reweighting on the given iteration
        logger.info(tag + ': compare DATA and MC for iteration #%d' % iter)