Ejemplo n.º 1
0
def test_gengauss_v2():
    logger.info('Test GenGaussV2_pdf: Generalized Gaussian function V2')
    model_gauss_gv2 = Models.Fit1D(signal=Models.GenGaussV2_pdf(
        name='Gv2', xvar=mass, mean=signal_gauss.mean),
                                   background=Models.Bkg_pdf('BkgGGV2',
                                                             xvar=mass,
                                                             power=0))

    model_gauss_gv2.signal.kappa.fix(0)

    with rooSilent():
        result, frame = model_gauss_gv2.fitTo(dataset0)
        model_gauss_gv2.signal.mean.release()
        model_gauss_gv2.S.setVal(5000)
        model_gauss_gv2.B.setVal(500)
        result, frame = model_gauss_gv2.fitTo(dataset0)
        ##model_gauss_gv2.signal.kappa.release()
        model_gauss_gv2.S.setVal(5000)
        model_gauss_gv2.B.setVal(500)
        result, frame = model_gauss_gv2.fitTo(dataset0)
        result, frame = model_gauss_gv2.fitTo(dataset0)
        model_gauss_gv2.S.setVal(5000)
        model_gauss_gv2.B.setVal(500)
        result, frame = model_gauss_gv2.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]))

    models.add(model_gauss_gv2)
Ejemplo n.º 2
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)
Ejemplo n.º 3
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 
            mass=mass,  ## the variable   
            alpha=3,  ## tail parameter
            n=3,  ## tail parameter 
            sigma=signal_gauss.sigma,  ## reuse sigma from gauss
            mean=signal_gauss.mean),  ## reuse mean  from gauss 
        background=Models.Bkg_pdf('BkgCB', mass=mass, power=0))

    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)

    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]))
        logger.info(
            'Alpha  & n          are: %-28s & %-28s ' %
            (result(model_cb.signal.alpha)[0], result(model_cb.signal.n)[0]))

    models.add(model_cb)
Ejemplo n.º 4
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)
Ejemplo n.º 5
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)
Ejemplo n.º 6
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)
Ejemplo n.º 7
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)
Ejemplo n.º 8
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))

    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)

    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                 is: %-28s ' % result(signal.mean)[0])
        logger.info('Sigma                is: %-28s ' %
                    result(signal.sigma)[0])

    models.add(model)
Ejemplo n.º 9
0
def test_pvoigt():

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

    signal = model.signal
    signal.mean.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)

    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                 is: %-28s ' % result(signal.mean)[0])
        logger.info('Sigma                is: %-28s ' %
                    result(signal.sigma)[0])
        logger.info('Gamma                is: %-28s ' %
                    result(signal.gamma)[0])

    models.add(model)
Ejemplo n.º 10
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)

    ## construct composite model: signal + background
    model_gauss = Models.Fit1D(signal=signal_gauss,
                               background=Models.Bkg_pdf('BkgGauss',
                                                         xvar=mass,
                                                         power=0))
    model_gauss.background.tau.fix(0)

    with rooSilent():
        result, frame = model_gauss.fitTo(dataset0)
        result, frame = model_gauss.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_gauss)
    signal_gauss.mean.fix(m.value())
Ejemplo n.º 11
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))

    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)

    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                 is: %-28s ' % result(signal.mean)[0])
        logger.info('Sigma                is: %-28s ' %
                    result(signal.sigma)[0])

    models.add(model)
Ejemplo n.º 12
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))

    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)

    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                is : %-28s ' %
                    result('mean_Gauss')[0])

    models.add(model_student)
Ejemplo n.º 13
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 = 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()))
        print result
    else:
        logger.info('Signal & Background are: %-28s & %-28s ' %
                    (result('S')[0], result('B')[0]))
        logger.info('Scale  & Q          are: %-28s & %-28s ' %
                    (result(s.scale)[0], result(s.q)[0]))

    models.add(model_qgauss)
Ejemplo n.º 14
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))

    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)

    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]))

    models.add(model_gauss_skew)
Ejemplo n.º 15
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)
Ejemplo n.º 16
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 ) ) 
Ejemplo n.º 17
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)
Ejemplo n.º 18
0
def test_nonextended1 () :
    
    logger.info ('Test non-extended multi-component fit')
    
    model = Models.Fit1D (
        name                = 'N1'                    , 
        signal              = signal_1                , 
        othersignals        = [ signal_2 , signal_3 ] ,
        background          = Models.Bkg_pdf ('P2' , xvar = mass , power = 0 , tau = 0 ) ,
        otherbackgrounds    = [ wide_1 , wide_2 ] ,
        others              = [ narrow_1 , narrow_2 ] , 
        extended            = False  ## ATTENTION! 
        )

    model.F[0].setVal ( 0.20 )
    model.F[1].setVal ( 0.25 )
    model.F[2].setVal ( 0.36 )

    model.F[3].setVal ( 0.65 )
    model.F[4].setVal ( 0.05 )
    model.F[5].setVal ( 0.25 )
    model.F[6].setVal ( 0.50 )
    
    r, f = model.fitTo ( dataset , draw = False , silent = True )
    logger.info ( 'Model %s Fit result \n#%s ' % ( model.name , r ) ) 
Ejemplo n.º 19
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)
Ejemplo n.º 20
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)
Ejemplo n.º 21
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)
Ejemplo n.º 22
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)
Ejemplo n.º 23
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)
Ejemplo n.º 24
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('BkgCBDS',
                                                        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)
Ejemplo n.º 25
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)
Ejemplo n.º 26
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)
Ejemplo n.º 27
0
def test_pvoigt():

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

    signal = model.signal
    signal.mean.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)
Ejemplo n.º 28
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)
Ejemplo n.º 29
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',
        mass=mass,
        sigma=signal_gauss.sigma,
        alpha=2,
        n=10,
        mean=signal_gauss.mean),
                              background=Models.Bkg_pdf('BkgCBRS',
                                                        mass=mass,
                                                        power=0))

    model_cbrs.s.setVal(5000)
    model_cbrs.b.setVal(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)

    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_cbrs)
Ejemplo n.º 30
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))

    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)

    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]))

    models.add(model_gauss_gv1)