예제 #1
0
def test_apolonios2():

    logger.info(
        'Test Apolonios2_pdf: modified Gaussian with exponential tails')
    model_apolonios2 = Models.Fit1D(signal=Models.Apolonios2_pdf(
        name='AP2',
        mass=mass,
        mean=signal_gauss.mean,
        sigma=signal_gauss.sigma,
        asymmetry=0),
                                    background=Models.Bkg_pdf('BkgAPO2',
                                                              mass=mass,
                                                              power=0))

    model_apolonios2.signal.mean.fix(m.value())
    model_apolonios2.s.setVal(5000)
    model_apolonios2.b.setVal(500)

    with rooSilent():
        result, frame = model_apolonios2.fitTo(dataset0)
        model_apolonios2.signal.asym.release()
        result, frame = model_apolonios2.fitTo(dataset0)

    if 0 != result.status() or 3 != result.covQual():
        logger.warning('Fit is not perfect MIGRAD=%d QUAL=%d ' %
                       (result.status(), result.covQual()))
        print result
    else:
        logger.info('Signal & Background are: %-28s & %-28s ' %
                    (result('S')[0], result('B')[0]))
        logger.info('Mean   & Sigma      are: %-28s & %-28s ' %
                    (result('mean_Gauss')[0], result('sigma_Gauss')[0]))

    models.add(model_apolonios2)
예제 #2
0
#-------------------------------------------------------------------------------
import ostap.fitting.models as Models
from   ostap.utils.timing import timing
from   ostap.histos.histos  import h1_axis
from Functions import *
#-------------------------------------------------------------------------------
im = ROOT.RooRealVar ('im'   , 'im'                 ,  2.240 , 2.330 )
pk = ROOT.RooRealVar ('pk'   , 'peak   '   , 2.2875 ,  2.286 , 2.289 )
sg = ROOT.RooRealVar ('sg'   , 'sigma'     , 0.0045 ,  0.003 , 0.010 )
am = ROOT.RooRealVar ('am'   , 'asymmetry' , 0.0000 , -0.300 , 0.300 )
bt = ROOT.RooRealVar ('bt'   , 'beta'      , 1.0000 ,  0.500 , 9.999 )
#-------------------------------------------------------------------------------
sig_ap = Models.Apolonios2_pdf( 'sig_ap', xvar=im,   mean=pk, sigma=sg, asymmetry=am, beta=bt)
bkg0  = Models.Bkg_pdf ( 'bkg0' , xvar = im , power = 0 )
#
#-------------------------------------------------------------------------------
#
if __name__=="__main__":
    #-------------------------------------------------------------------------------
    model = Models.Fit1D   ( signal = sig_ap , background = bkg0 )
    #-------------------------------------------------------------------------------
    rfile = ROOT.TFile("test_file.root","READ")
    ds = rfile["ds"]
    dh = ( ds.reduce( ROOT.RooArgSet( im ) , "im>0" ) ).binnedClone()
    with timing():
        r, w = model.fitTo( dh )
        r, w = model.fitTo(ds, draw=True, nbins=100, ncpu=4)
    #-------------------------------------------------------------------------------
    print(r)
    #-------------------------------------------------------------------------------
    h = w.pullHist()