コード例 #1
0
def test_expopspol2D() :
    
    logger.info ('Test ExpoPSPol2D_pdf: Exponential times phase space factor, modulated by positive polynomial in X and Y ')
    
    ## "fictive phase space"
    psy   = Ostap.Math.PhaseSpaceNL ( 0 , 10 , 2 , 10 )
    model = Models.ExpoPSPol2D_pdf ( 'EPS',
                                     m_x    , m_y  ,
                                     psy    , 
                                     nx = 2 , ny = 2 )
    
    with rooSilent() : 
        result, f = model.fitTo ( dataset ) 
        model.draw1 ( dataset )        
        model.draw2 ( dataset )
        
    result, f = model.fitTo ( dataset , silent = True )
        
    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 ( 'Bernstein Coefficients:\n%s' % model.pars() )  
            
       
    models.add ( model )
コード例 #2
0
def test_comp_2dSymfit():

    logger.info('Test  multi-component  2d Sym fit')

    model = Models.Fit2DSym(name='fit_comp',
                            signal_x=signal_x1,
                            signal_y=signal_y1,
                            bkg_1x=bkg_x,
                            components=[ss_cmp, sb_cmp, bb_cmp])

    with rooSilent():
        ## components
        model.SS.fix(5000)
        model.SB.fix(1000)
        model.BB.fix(1000)

        model.C[0].fix(5000)
        model.C[1].fix(1000)
        model.C[2].fix(1000)

        r = model.fitTo(dataset, ncpu=8)

        model.SS.release()
        model.SB.release()
        model.BB.release()

        model.C[0].release()
        model.C[1].release()
        model.C[2].release()

        r = model.fitTo(dataset, ncpu=8)

    logger.info('Model %s Fit result \n#%s ' % (model.name, r))
コード例 #3
0
def test_2gauss():
    logger.info('Test ResoGauss2:  double Gaussian resolution model')
    from ostap.fitting.resolution import ResoGauss2
    reso_2gauss = ResoGauss2('G2', mass, 0.1)
    reso_2gauss.sigma.release()
    reso_2gauss.scale.release()
    reso_2gauss.fraction.release()

    from ostap.logger.utils import rooSilent
    with rooSilent():
        result, frame = reso_2gauss.fitTo(dataset0)
        result, frame = reso_2gauss.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('ResoGauss2: RMS        %s ' % reso_2gauss.rms())
        logger.info('ResoGauss2: FWHM       %s ' % reso_2gauss.fwhm())
        logger.info('ResoGauss2: Resolution %s ' % result.sigma_G2.ve())
        logger.info('ResoGauss2: Scale      %s ' % result.SigmaScale_G2.ve())
        logger.info('ResoGauss2: Fraction   %s ' % result.CoreFraction_G2.ve())

    models.add(reso_2gauss)
コード例 #4
0
def test_losev():

    logger.info("Test  Losev: asymmetric hyperbilic secant distribution")
    model = Models.Fit1D(signal=Models.Losev_pdf('LOSEV',
                                                 xvar=mass,
                                                 mean=signal_gauss.mean),
                         background=Models.Bkg_pdf('BkgLOSEV',
                                                   xvar=mass,
                                                   power=0),
                         S=S,
                         B=B)

    signal = model.signal
    model.S.setVal(5000)
    model.B.setVal(500)

    with rooSilent():
        result, f = model.fitTo(dataset0)
        result, f = model.fitTo(dataset0)
        signal.mean.release()
        signal.alpha.release()
        signal.beta.release()
        result, f = model.fitTo(dataset0)

        model.draw(dataset0)

    if 0 != result.status() or 3 != result.covQual():
        logger.warning('Fit is not perfect MIGRAD=%d QUAL=%d ' %
                       (result.status(), result.covQual()))

    logger.info("Asymmetric hyperbolic secant/Losev distribution\n%s" %
                result.table(prefix="# "))

    models.add(model)
コード例 #5
0
def test_voigt():

    logger.info('Test Voigt_pdf: Breit-Wigner convoluted with Gauss')
    model = Models.Fit1D(signal=Models.Voigt_pdf('V',
                                                 xvar=mass,
                                                 m0=signal_gauss.mean,
                                                 sigma=signal_gauss.sigma),
                         background=Models.Bkg_pdf('BkgV', xvar=mass, power=0),
                         S=S,
                         B=B)

    signal = model.signal
    signal.sigma.fix(m.error())
    signal.gamma.fix(0.002)
    signal.m0.fix()

    model.B.setVal(500)
    model.S.setVal(5000)

    with rooSilent():
        result, frame = model.fitTo(dataset0)
        result, frame = model.fitTo(dataset0)
        signal.sigma.release()
        result, frame = model.fitTo(dataset0)
        model.draw(dataset0)

    if 0 != result.status() or 3 != result.covQual():
        logger.warning('Fit is not perfect MIGRAD=%d QUAL=%d ' %
                       (result.status(), result.covQual()))

    logger.info("Voigt function\n%s" % result.table(prefix="# "))

    models.add(model)
コード例 #6
0
def test_johnsonSU():

    logger.info("Test  JohnsonSU-Distribution")
    model = Models.Fit1D(signal=Models.JohnsonSU_pdf('JSU',
                                                     xvar=mass,
                                                     xi=signal_gauss.mean),
                         background=Models.Bkg_pdf('BkgJSU',
                                                   xvar=mass,
                                                   power=0),
                         S=S,
                         B=B)

    signal = model.signal

    model.S.setVal(5000)
    model.B.setVal(500)

    with rooSilent():
        result, f = model.fitTo(dataset0)
        result, f = model.fitTo(dataset0)
        signal.lambd.release()
        signal.delta.release()
        result, f = model.fitTo(dataset0)

        model.draw(dataset0)

    if 0 != result.status() or 3 != result.covQual():
        logger.warning('Fit is not perfect MIGRAD=%d QUAL=%d ' %
                       (result.status(), result.covQual()))

    logger.info("Johnson-SU function\n%s" % result.table(prefix="# "))

    models.add(model)
コード例 #7
0
def test_gauss():

    logger.info('Test Gauss_pdf:  simple Gaussian signal')

    ## release the sigma of signal:
    signal_gauss.mean.release()

    ## simple fit with gaussian only
    result = signal_gauss.fitTo(dataset0, silent=True)

    model_gauss.background.tau.fix(0)

    with rooSilent():
        result, frame = model_gauss.fitTo(dataset0)
        result, frame = model_gauss.fitTo(dataset0)

        model_gauss.draw(dataset0)

    if 0 != result.status() or 3 != result.covQual():
        logger.warning('Fit is not perfect MIGRAD=%d QUAL=%d ' %
                       (result.status(), result.covQual()))

    logger.info('Simple Gaussian model\n%s' % result.table(prefix="# "))

    models.add(model_gauss)
    signal_gauss.mean.fix(m.value())
コード例 #8
0
def test_hyperbolic():

    logger.info(
        'Test Hyperbolic_pdf: hyperbolic distribution (exponential tails)')
    model_hyperbolic = Models.Fit1D(signal=Models.Hyperbolic_pdf(
        name='HB',
        xvar=mass,
        mu=signal_gauss.mean,
        sigma=signal_gauss.sigma,
        zeta=(1, -1, 1e+6),
        kappa=(0, -1, 1)),
                                    background=Models.Bkg_pdf('BkgHB',
                                                              xvar=mass,
                                                              power=0),
                                    S=S,
                                    B=B)

    model_hyperbolic.S.value = 5000
    model_hyperbolic.B.value = 500

    with rooSilent():
        model_hyperbolic.signal.kappa.fix(0)
        result, frame = model_hyperbolic.fitTo(dataset0)
        model_hyperbolic.signal.kappa.release()
        result, frame = model_hyperbolic.fitTo(dataset0)
        model_hyperbolic.draw(dataset0)

    if 0 != result.status() or 3 != result.covQual():
        logger.warning('Fit is not perfect MIGRAD=%d QUAL=%d ' %
                       (result.status(), result.covQual()))

    logger.info('Hyperbolic  function\n%s' % result.table(prefix="# "))

    models.add(model_hyperbolic)
コード例 #9
0
def test_crystalball_RS():
    logger.info('Test CrystalBallRS_pdf:  right-side Crystal Ball function')
    model_cbrs = Models.Fit1D(signal=Models.CrystalBallRS_pdf(
        name='CBRS',
        xvar=mass,
        sigma=signal_gauss.sigma,
        alpha=(1.5, 0.5, 3.0),
        n=(5, 1, 10),
        mean=signal_gauss.mean),
                              background=Models.Bkg_pdf('BkgCBRS',
                                                        xvar=mass,
                                                        power=0),
                              S=S,
                              B=B)

    model_cbrs.S.value = 5000
    model_cbrs.B.value = 500

    with rooSilent():
        result, frame = model_cbrs.fitTo(dataset0)
        model_cbrs.signal.alpha.release()
        result, frame = model_cbrs.fitTo(dataset0)
        result, frame = model_cbrs.fitTo(dataset0)

        model_cbrs.draw(dataset0)

    if 0 != result.status() or 3 != result.covQual():
        logger.warning('Fit is not perfect MIGRAD=%d QUAL=%d ' %
                       (result.status(), result.covQual()))

    logger.info('right-side Crystal Ball function\n%s' %
                result.table(prefix="# "))

    models.add(model_cbrs)
コード例 #10
0
def test_crystalball():

    logger.info('Test CrystalBall_pdf: Crystal Ball  function')

    ## composite model: signal + background
    model_cb = Models.Fit1D(
        signal=Models.CrystalBall_pdf(
            name='CB',  ## the name 
            xvar=mass,  ## the variable   
            alpha=(2, 1, 5),  ## tail parameter
            n=(3, 1, 9),  ## tail parameter 
            sigma=signal_gauss.sigma,  ## reuse sigma from gauss
            mean=signal_gauss.mean),  ## reuse mean  from gauss 
        background=Models.Bkg_pdf('BkgCB', xvar=mass, power=0),
        S=S,
        B=B)

    model_cb.signal.n.fix(8)
    with rooSilent():
        result, frame = model_cb.fitTo(dataset0)
        model_cb.signal.alpha.release()
        result, frame = model_cb.fitTo(dataset0)
        result, frame = model_cb.fitTo(dataset0)

        model_cb.draw(dataset0)

    if 0 != result.status() or 3 != result.covQual():
        logger.warning('Fit is not perfect MIGRAD=%d QUAL=%d ' %
                       (result.status(), result.covQual()))

    logger.info('Crystal Ball function\n%s' % result.table(prefix="# "))

    models.add(model_cb)
コード例 #11
0
def test_rasingcosine():

    logger.info("Test RaisingCosine")
    model = Models.Fit1D(signal=Models.RaisingCosine_pdf(
        'RC', xvar=mass, mean=signal_gauss.mean),
                         background=1,
                         S=S,
                         B=B)

    signal = model.signal
    model.S.setVal(5000)
    model.B.setVal(500)

    with rooSilent():
        result, f = model.fitTo(dataset0)
        result, f = model.fitTo(dataset0)
        signal.mean.release()
        signal.scale.release()
        result, f = model.fitTo(dataset0)
        model.draw(dataset0)

    if 0 != result.status() or 3 != result.covQual():
        logger.warning('Fit is not perfect MIGRAD=%d QUAL=%d ' %
                       (result.status(), result.covQual()))

    logger.info("Raising cosine function\n%s" % result.table(prefix="# "))

    models.add(model)
コード例 #12
0
def test_laplace():
    logger.info('Test Asymmetric Laplace shape')
    model = Models.Fit1D(
        signal=Models.AsymmetricLaplace_pdf(name='AL',
                                            xvar=mass,
                                            mean=signal_gauss.mean,
                                            slope=signal_gauss.sigma),
        background=None,
        S=S,
        B=B)

    signal = model.signal
    signal.slope.release()
    signal.mean.fix()

    model.S.setVal(5000)
    model.B.setVal(500)

    with rooSilent():
        result, frame = model.fitTo(dataset0)
        result, frame = model.fitTo(dataset0)
        model.draw(dataset0)

    if 0 != result.status() or 3 != result.covQual():
        logger.warning('Fit is not perfect MIGRAD=%d QUAL=%d ' %
                       (result.status(), result.covQual()))

    logger.info("asymmetric Laplace function\n%s" % result.table(prefix="# "))

    models.add(model)
コード例 #13
0
def test_polypos2D() :
    
    logger.info ('Test PolyPos2D_pdf: positive polynomial in 2D' )
    model = Models.PolyPos2D_pdf ( 'P2D'  ,
                                   m_x    ,
                                   m_y    ,
                                   nx = 2 ,
                                   ny = 2 )
    
    with rooSilent() : 
        result, f = model.fitTo ( dataset )
        
        model.draw1 ( dataset )        
        model.draw2 ( dataset )

    result, f = model.fitTo ( dataset , silent = True )
        
    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 ( 'Bernstein Coefficients:\n%s' % model.pars() )  
            
       
    models.add ( model ) 
コード例 #14
0
def test_spline2D() :
    
    logger.info ('Test Spline2D_pdf : 2D-spline')
    
    s1 = Ostap.Math.BSpline          ( m_x.xmin(), m_x.xmax() , 1 , 2 ) 
    s2 = Ostap.Math.BSpline          ( m_y.xmin(), m_y.xmax() , 1 , 2 ) 
    s3 = Ostap.Math.PositiveSpline2D ( s1 , s2 )
    
    model = Models.Spline2D_pdf ( 'S2D' , m_x , m_y, s3 )
    
    model = Models.ExpoPol2Dsym_pdf ( 'S2DS',
                                      m_x   ,
                                      m_y  ,
                                      n = 2 )
    
    with rooSilent() : 
        result, f = model.fitTo ( dataset ) 
        model.draw1 ( dataset )        
        model.draw2 ( dataset )
        
    result, f = model.fitTo ( dataset , silent = True )
        
    if 0 != result.status() or 3 != result.covQual() :
        logger.warning('Fit is not perfect MIGRAD=%d QUAL=%d ' % ( result.status() , result.covQual () ) )
        print(result)
       
    models.add ( model )
コード例 #15
0
def test_qgauss():
    logger.info('Test QGaussian_pdf: q-Gaussian')
    model_qgauss = Models.Fit1D(signal=Models.QGaussian_pdf(
        name='qG',
        xvar=mass,
        q=(1, 0.7, 1.2),
        mean=signal_gauss.mean,
        scale=signal_gauss.sigma),
                                background=Models.Bkg_pdf('BkgQG',
                                                          xvar=mass,
                                                          power=0),
                                S=S,
                                B=B)

    s = model_qgauss.signal
    s.scale = 0.015

    with rooSilent():
        result, frame = model_qgauss.fitTo(dataset0)
        model_qgauss.signal.scale.release()
        result, frame = model_qgauss.fitTo(dataset0)
        model_qgauss.signal.q.release()
        result, frame = model_qgauss.fitTo(dataset0)

    if 0 != result.status() or 3 != result.covQual():
        logger.warning('Fit is not perfect MIGRAD=%d QUAL=%d ' %
                       (result.status(), result.covQual()))

    logger.info('Q-Gaussian function\n%s' % result.table(prefix="# "))

    models.add(model_qgauss)
コード例 #16
0
def test_needham():

    logger.info('Test Needham_pdf: Crystal Ball with alpha=f(sigma)')
    model_matt = Models.Fit1D(signal=Models.Needham_pdf(
        name='Matt',
        xvar=mass,
        sigma=signal_gauss.sigma,
        mean=signal_gauss.mean),
                              background=Models.Bkg_pdf('BkgMATT',
                                                        xvar=mass,
                                                        power=0),
                              S=S,
                              B=B)

    with rooSilent():
        result, frame = model_matt.fitTo(dataset0)
        model_matt.signal.mean.release()
        model_matt.signal.sigma.release()
        result, frame = model_matt.fitTo(dataset0)
        result, frame = model_matt.fitTo(dataset0)

    if 0 != result.status() or 3 != result.covQual():
        logger.warning('Fit is not perfect MIGRAD=%d QUAL=%d ' %
                       (result.status(), result.covQual()))

    logger.info('Needham function\n%s' % result.table(prefix="# "))

    models.add(model_matt)
コード例 #17
0
def test_studentT():

    logger.info('Test StudentT_pdf: Student-t distribution')
    model_student = Models.Fit1D(signal=Models.StudentT_pdf(
        name='ST', xvar=mass, mean=signal_gauss.mean),
                                 background=Models.Bkg_pdf('BkgST',
                                                           xvar=mass,
                                                           power=0),
                                 S=S,
                                 B=B)

    model_student.signal.n.setVal(20)
    model_student.signal.sigma.setVal(0.013)
    model_student.S.setVal(5000)
    model_student.B.setVal(500)

    with rooSilent():
        result, frame = model_student.fitTo(dataset0)
        result, frame = model_student.fitTo(dataset0)
        model_student.draw(dataset0)

    if 0 != result.status() or 3 != result.covQual():
        logger.warning('Fit is not perfect MIGRAD=%d QUAL=%d ' %
                       (result.status(), result.covQual()))

    logger.info("Student's t-function\n%s" % result.table(prefix="# "))

    models.add(model_student)
コード例 #18
0
def test_apollonios():

    logger.info(
        'Test Apollonios_pdf: Modified gaussian with power-law and exponential tails'
    )
    model_apollonios = Models.Fit1D(signal=Models.Apollonios_pdf(
        name='APO',
        xvar=mass,
        mean=signal_gauss.mean,
        sigma=signal_gauss.sigma,
        b=1,
        n=10,
        alpha=3),
                                    background=Models.Bkg_pdf('BkgAPO',
                                                              xvar=mass,
                                                              power=0),
                                    S=S,
                                    B=B)

    model_apollonios.S.setVal(5000)
    model_apollonios.B.setVal(500)

    with rooSilent():
        result, frame = model_apollonios.fitTo(dataset0)
        result, frame = model_apollonios.fitTo(dataset0)
        model_apollonios.draw(dataset0)

    if 0 != result.status() or 3 != result.covQual():
        logger.warning('Fit is not perfect MIGRAD=%d QUAL=%d ' %
                       (result.status(), result.covQual()))

    logger.info('Apollonios function\n%s' % result.table(prefix="# "))

    models.add(model_apollonios)
コード例 #19
0
def test_atlas():

    logger.info("Test  ATLAS: Modified Gaussian, used by ATLAS/Zeus")
    model = Models.Fit1D(signal=Models.Atlas_pdf('ATLAS',
                                                 xvar=mass,
                                                 mean=signal_gauss.mean),
                         background=Models.Bkg_pdf('BkgATLAS',
                                                   xvar=mass,
                                                   power=0),
                         S=S,
                         B=B)

    signal = model.signal
    model.S.setVal(5000)
    model.B.setVal(500)

    with rooSilent():
        result, f = model.fitTo(dataset0)
        result, f = model.fitTo(dataset0)
        signal.mean.release()
        signal.sigma.release()
        result, f = model.fitTo(dataset0)

        model.draw(dataset0)

    if 0 != result.status() or 3 != result.covQual():
        logger.warning('Fit is not perfect MIGRAD=%d QUAL=%d ' %
                       (result.status(), result.covQual()))

    logger.info("ATLAS function\n%s" % result.table(prefix="# "))

    models.add(model)
コード例 #20
0
def test_apollonios2():

    logger.info(
        'Test Apollonios2_pdf: modified Gaussian with exponential tails')
    model_apollonios2 = Models.Fit1D(signal=Models.Apollonios2_pdf(
        name='AP2',
        xvar=mass,
        mean=signal_gauss.mean,
        sigma=signal_gauss.sigma,
        beta=(0.5, 2),
        asymmetry=0),
                                     background=Models.Bkg_pdf('BkgAPO2',
                                                               xvar=mass,
                                                               power=0),
                                     S=S,
                                     B=B)

    model_apollonios2.signal.mean.fix(m.value())
    model_apollonios2.S.value = 5000
    model_apollonios2.B.value = 500
    model_apollonios2.signal.sigma.release()

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

    if 0 != result.status() or 3 != result.covQual():
        logger.warning('Fit is not perfect MIGRAD=%d QUAL=%d ' %
                       (result.status(), result.covQual()))

    logger.info('Apollonios2 function\n%s' % result.table(prefix="# "))

    models.add(model_apollonios2)
コード例 #21
0
def test_sech():

    logger.info("Test  SECH:  Sech(1/cosh) distribution")
    model = Models.Fit1D(signal=Models.Sech_pdf('SECH',
                                                xvar=mass,
                                                mean=signal_gauss.mean),
                         background=Models.Bkg_pdf('BkgSECH',
                                                   xvar=mass,
                                                   power=0),
                         S=S,
                         B=B)

    signal = model.signal
    model.S.setVal(5000)
    model.B.setVal(500)

    with rooSilent():
        result, f = model.fitTo(dataset0)
        result, f = model.fitTo(dataset0)
        signal.mean.release()
        signal.sigma.release()
        result, f = model.fitTo(dataset0)

        model.draw(dataset0)

    if 0 != result.status() or 3 != result.covQual():
        logger.warning('Fit is not perfect MIGRAD=%d QUAL=%d ' %
                       (result.status(), result.covQual()))

    logger.info("Hyperbolic secant/sech function\n%s" %
                result.table(prefix="# "))

    models.add(model)
コード例 #22
0
def test_bifurcated():

    logger.info('Test BifurcatedGauss_pdf: Bifurcated Gaussian')

    signal_bifurcated = Models.BifurcatedGauss_pdf(name='BfGau',
                                                   mean=signal_gauss.mean,
                                                   sigma=signal_gauss.sigma,
                                                   xvar=mass)
    signal_bifurcated.asym.setVal(0)

    model_bifurcated = Models.Fit1D(signal=signal_bifurcated,
                                    background=Models.Bkg_pdf('BkgBFG',
                                                              xvar=mass,
                                                              power=0),
                                    S=S,
                                    B=B)

    model_bifurcated.B.setVal(500)
    model_bifurcated.S.setVal(6000)
    with rooSilent():
        result, frame = model_bifurcated.fitTo(dataset0)
        result, frame = model_bifurcated.fitTo(dataset0)
        model_bifurcated.draw(dataset0)

    if 0 != result.status() or 3 != result.covQual():
        logger.warning('Fit is not perfect MIGRAD=%d QUAL=%d ' %
                       (result.status(), result.covQual()))

    logger.info('Bifurcated Gaussian function\n%s' % result.table(prefix="# "))

    models.add(model_bifurcated)
コード例 #23
0
def test_logistic():

    logger.info("Test  LOGISTIC: Logistic distribution")
    model = Models.Fit1D(signal=Models.Logistic_pdf('LOGI',
                                                    xvar=mass,
                                                    mean=signal_gauss.mean),
                         background=Models.Bkg_pdf('BkgLOGI',
                                                   xvar=mass,
                                                   power=0),
                         S=S,
                         B=B)

    signal = model.signal
    model.S.setVal(5000)
    model.B.setVal(500)

    with rooSilent():
        result, f = model.fitTo(dataset0)
        result, f = model.fitTo(dataset0)
        signal.mean.release()
        signal.sigma.release()
        result, f = model.fitTo(dataset0)

        model.draw(dataset0)

    if 0 != result.status() or 3 != result.covQual():
        logger.warning('Fit is not perfect MIGRAD=%d QUAL=%d ' %
                       (result.status(), result.covQual()))

    logger.info("Logistic distribution\n%s" % result.table(prefix="# "))

    models.add(model)
コード例 #24
0
def test_2gauss():

    logger.info('Test DoubleGauss_pdf: Double Gaussian')

    signal_2gauss = Models.DoubleGauss_pdf(name='Gau2',
                                           mean=signal_gauss.mean,
                                           sigma=signal_gauss.sigma,
                                           xvar=mass,
                                           fraction=0.9,
                                           scale=1.2)

    model_2gauss = Models.Fit1D(signal=signal_2gauss,
                                background=Models.Bkg_pdf('Bkg22G',
                                                          xvar=mass,
                                                          power=0),
                                S=S,
                                B=B)

    model_2gauss.B.setVal(500)
    model_2gauss.S.setVal(6000)
    with rooSilent():
        result, frame = model_2gauss.fitTo(dataset0)
        signal_2gauss.fraction.release()
        result, frame = model_2gauss.fitTo(dataset0)
        model_2gauss.draw(dataset0)

    if 0 != result.status() or 3 != result.covQual():
        logger.warning('Fit is not perfect MIGRAD=%d QUAL=%d ' %
                       (result.status(), result.covQual()))

    logger.info('double Gaussian function\n%s' % result.table(prefix="# "))

    models.add(model_2gauss)
コード例 #25
0
def test_pvoigt():

    logger.info('Test PSeudoVoigt_pdf: fast approximation to Voigt profile')
    model = Models.Fit1D(
        signal=Models.PseudoVoigt_pdf('PV',
                                      xvar=mass,
                                      m0=signal_gauss.mean,
                                      sigma=signal_gauss.sigma),
        background=Models.Bkg_pdf('BkgPV', xvar=mass, power=0),
        S=S,
        B=B)

    signal = model.signal
    signal.m0.fix()
    signal.sigma.fix(m.error())
    signal.gamma.fix(0.002)

    model.B.setVal(500)
    model.S.setVal(5000)

    with rooSilent():
        result, frame = model.fitTo(dataset0)
        result, frame = model.fitTo(dataset0)
        model.signal.sigma.release()
        result, frame = model.fitTo(dataset0)
        model.draw(dataset0)

    if 0 != result.status() or 3 != result.covQual():
        logger.warning('Fit is not perfect MIGRAD=%d QUAL=%d ' %
                       (result.status(), result.covQual()))

    logger.info("pseudo-Voigt function\n%s" % result.table(prefix="# "))

    models.add(model)
コード例 #26
0
def test_gengauss_v1():
    logger.info('Test GenGaussV1_pdf: Generalized Gaussian V1')
    model_gauss_gv1 = Models.Fit1D(signal=Models.GenGaussV1_pdf(
        name='Gv1', xvar=mass, mean=signal_gauss.mean),
                                   background=Models.Bkg_pdf('BkgGGV1',
                                                             xvar=mass,
                                                             power=0),
                                   S=S,
                                   B=B)

    model_gauss_gv1.signal.beta.fix(2)
    model_gauss_gv1.signal.mean.fix(m.value())
    model_gauss_gv1.S.setVal(5000)
    model_gauss_gv1.B.setVal(500)

    with rooSilent():
        result, frame = model_gauss_gv1.fitTo(dataset0)
        model_gauss_gv1.signal.alpha.release()
        result, frame = model_gauss_gv1.fitTo(dataset0)
        model_gauss_gv1.signal.mean.release()
        result, frame = model_gauss_gv1.fitTo(dataset0)
        model_gauss_gv1.draw(dataset0)

    if 0 != result.status() or 3 != result.covQual():
        logger.warning('Fit is not perfect MIGRAD=%d QUAL=%d ' %
                       (result.status(), result.covQual()))

    logger.info('generalized Gaussian(v1) function\n%s' %
                result.table(prefix="# "))

    models.add(model_gauss_gv1)
コード例 #27
0
def test_cb2():

    logger.info(
        'Test ResoCB2: symmetric double-sided Crystal Ball resolution model')
    from ostap.fitting.resolution import ResoCB2
    reso_cb2 = ResoCB2('CB', mass, 0.1)
    reso_cb2.sigma.release()
    reso_cb2.alpha.release()
    reso_cb2.n.release()

    from ostap.logger.utils import rooSilent
    with rooSilent():
        result, frame = reso_cb2.fitTo(dataset0)
        result, frame = reso_cb2.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('ResoCB2:    RMS        %s ' % reso_cb2.rms())
        logger.info('ResoCB2:    FWHM       %s ' % reso_cb2.fwhm())
        logger.info('ResoCB2:    Resolution %s ' % result.sigma_CB.ve())
        logger.info('ResoCB2:    Alpha      %s ' % result.ResoAlpha_CB.ve())
        logger.info('ResoCB2:    N          %s ' % result.ResoN_CB.ve())

    models.add(reso_cb2)
コード例 #28
0
def test_skewgauss():

    logger.info('Test SkewGauss_pdf: Skew Gaussian function')
    model_gauss_skew = Models.Fit1D(signal=Models.SkewGauss_pdf(
        name='GSk', xvar=mass, mean=signal_gauss.mean),
                                    background=Models.Bkg_pdf('BkgSkG',
                                                              xvar=mass,
                                                              power=0),
                                    S=S,
                                    B=B)

    model_gauss_skew.signal.alpha.fix(0)
    model_gauss_skew.S.setVal(5000)
    model_gauss_skew.B.setVal(500)

    with rooSilent():
        result, frame = model_gauss_skew.fitTo(dataset0)
        result, frame = model_gauss_skew.fitTo(dataset0)
        model_gauss_skew.draw(dataset0)

    if 0 != result.status() or 3 != result.covQual():
        logger.warning('Fit is not perfect MIGRAD=%d QUAL=%d ' %
                       (result.status(), result.covQual()))

    logger.info('skew Gaussian function\n%s' % result.table(prefix="# "))

    models.add(model_gauss_skew)
コード例 #29
0
def test_extended2():

    logger.info('Test     extended combined multi-component fit')

    model = Models.Fit1D(
        name='E2',
        signal=signal_1,
        othersignals=[signal_2, signal_3],
        background=Models.Bkg_pdf('P1', xvar=mass, power=0, tau=0),
        otherbackgrounds=[wide_1, wide_2],
        others=[narrow_1, narrow_2],
        combine_signals=True,  ## ATTENTION!
        combine_others=True,  ## ATTENTION! 
        combine_backgrounds=True,  ## ATTENTION!   
    )

    with rooSilent():
        model.S.fix(15000)
        model.B.fix(7000)
        model.C.fix(2000)
        r, f = model.fitTo(dataset, draw=False, silent=True)

    model.S.release()
    model.B.release()
    model.C.release()
    r, f = model.fitTo(dataset, draw=False, silent=True)

    logger.info('Model %s Fit result \n#%s ' % (model.name, r))
コード例 #30
0
def test_const():

    logger.info(
        'Simplest (factorized) fit model:  ( Gauss + const ) x ( Gauss + const ) '
    )
    model = Models.Fit2D(
        signal_x=signal1,
        signal_y=signal2s,
    )

    ## fit with fixed mass and sigma
    with rooSilent():
        result, frame = model.fitTo(dataset)
        model.signal_x.sigma.release()
        model.signal_y.sigma.release()
        model.signal_x.mean.release()
        model.signal_y.mean.release()
        result, frame = model.fitTo(dataset)
        model.draw1(dataset)
        model.draw2(dataset)

    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('S1xS2 : %20s' % result(model.SS)[0])
        logger.info('S1xB2 : %20s' % result(model.SB)[0])
        logger.info('B1xS2 : %20s' % result(model.BS)[0])
        logger.info('B1xB2 : %20s' % result(model.BB)[0])

    models.add(model)