'param_init_data_' + fitter.name,
        'Initial values for for fits',
        fitter.parameters
        )

    param_fitted_data = ROOT.RooDataSet(
        'param_fitted_data_' + fitter.name,
        'Fit results for different initial values',
        fitter.parameters
        )

    ## Loop over extra fits to study the systematics
    for j in range(10):        
        ## Loop over parameters
        for pname in '#Deltas #sigmaL #sigmaR'.split():
            par = ws1.var(pname)
            ## Randomize it's value uniformly in range
            pmin = par.getMin()
            pmax = par.getMax()
            rand = ROOT.gRandom.Gaus(0.5*(pmin + pmax), (pmax-pmin)/10.)
            par.setVal(rand)

        param_init_data.add(fitter.parameters)

        ## Make the fit
        fitter.name = (name + '_fit%d' % j)
        fitter.doAutoFitRange = False
        fitter.fitToData(ws1)
        fitter.doAutoFitRange = True
        fitter.fitToData(ws1)
        fitter.labels = labels[:]
    ## Get mass window, only perform fit once for a given selection and
    cutsav = ' & '.join(fitter.cuts)
    if not fitter.massWindow:
        fitter.massWindow = mwindows.get(cutsav)
    fitter.getMassCut(ws1)
    ## Store the resulting mass window in mwindows
    mwindows[cutsav] = fitter.massWindow

    ## Get the data
    fitter.getData(ws1)
    try:
        fitScale = fitter.fitScale
    except AttributeError:
        fitScale = fSigma
    name = fitter.name
    Deltas = ws1.var('#Deltas')
    DeltasOld = Deltas.getVal()
    sigmaL = ws1.var('#sigmaL')
    sigmaR = ws1.var('#sigmaR')
    sigma = ws1.var('#sigma')
    k = ws1.function('k')
    m0 = ws1.function('m0')

    for iteration in range(maxIterations):
        print "++ begin iteration", iteration
        if iteration == 0:
            if not hasattr(fitter, 'fitRange'):
                ## Set the fit range automatically to include all data
                xlo = fitter.data.tree().GetMinimum(fitter.x.GetName())
                xhi = fitter.data.tree().GetMaximum(fitter.x.GetName())
Exemplo n.º 3
0
## Loop over plots
for fitter in _fits[:4]:
    ## Log the current fit configuration
    print "++ Processing", fitter.title
    print "++ Configuration:"
    print fitter.pydump()

    ## Get the data
    fitter.getData(ws1)
    try:
        fitScale = fitter.fitScale
    except AttributeError:
        fitScale = fSigma
    name = fitter.name
    Deltas = ws1.var('#Deltas')
    DeltasOld = Deltas.getVal()
    sigmaL = ws1.var('#sigmaL')
    sigmaR = ws1.var('#sigmaR')
    sigma = ws1.var('#sigma')
    k = ws1.function('k')
    m0 = ws1.function('m0')

    for iteration in range(maxIterations):
        print "++ begin iteration", iteration
        if iteration == 0:
            pass
            ## Set the fit range automatically to include all data
#             xlo = fitter.data.tree().GetMinimum(fitter.x.GetName())
#             xhi = fitter.data.tree().GetMaximum(fitter.x.GetName())
#
Exemplo n.º 4
0
    ## Get mass window, only perform fit once for a given selection and
    cutsav = " & ".join(fitter.cuts)
    if not fitter.massWindow:
        fitter.massWindow = mwindows.get(cutsav)
    fitter.getMassCut(ws1)
    ## Store the resulting mass window in mwindows
    mwindows[cutsav] = fitter.massWindow

    ## Get the data
    fitter.getData(ws1)
    try:
        fitScale = fitter.fitScale
    except AttributeError:
        fitScale = fSigma
    name = fitter.name
    Deltas = ws1.var("#Deltas")
    DeltasOld = Deltas.getVal()
    sigmaL = ws1.var("#sigmaL")
    sigmaR = ws1.var("#sigmaR")
    sigma = ws1.var("#sigma")
    k = ws1.function("k")
    m0 = ws1.function("m0")

    for iteration in range(maxIterations):
        print "++ begin iteration", iteration
        if iteration == 0:
            #             pass
            ## Set the fit range automatically to include all data
            xlo = fitter.data.tree().GetMinimum(fitter.x.GetName())
            xhi = fitter.data.tree().GetMaximum(fitter.x.GetName())
Exemplo n.º 5
0
## Loop over plots
for fitter in _fits[:9]:
    ## Log the current fit configuration
    print "++ Processing", fitter.title
    print "++ Configuration:"
    print fitter.pydump()

    ## Get the data
    fitter.getData(ws1)
    try:
        fitScale = fitter.fitScale
    except AttributeError:
        fitScale = fSigma
    name = fitter.name
    Deltas = ws1.var('#Deltas')
    DeltasOld = Deltas.getVal()
    sigmaL = ws1.var('#sigmaL')
    sigmaR = ws1.var('#sigmaR')
    sigma = ws1.var('#sigma')
    k = ws1.function('k')
    m0 = ws1.function('m0')

    for iteration in range(maxIterations):
        print "++ begin iteration", iteration
        if iteration == 0:
            pass
            ## Set the fit range automatically to include all data
#             xlo = fitter.data.tree().GetMinimum(fitter.x.GetName())
#             xhi = fitter.data.tree().GetMaximum(fitter.x.GetName())
#
Exemplo n.º 6
0
                is_first_srecofit = False
                print srecofit.title
        elif "struefit" in vars() and struefit.title in plot.title:
            if is_first_struefit:
                is_first_struefit = False
                print struefit.title
        elif "sgenfit" in vars() and sgenfit.title in plot.title:
            if is_first_sgenfit:
                is_first_sgenfit = False
                print sgenfit.title
        elif "shybfit" in vars() and shybfit.title in plot.title:
            if is_first_shybfit:
                is_first_shybfit = False
                print shybfit.title

        print "%6.2f +/- %4.2f" % (ws1.var("#Deltas").getVal(), ws1.var("#Deltas").getError()),

        if "srecofit" in vars() and srecofit.title in plot.title:
            print plot.title[len(srecofit.title) + 2 :],
        elif "struefit" in vars() and struefit.title in plot.title:
            print plot.title[len(struefit.title) + 2 :],
        elif "sgenfit" in vars() and sgenfit.title in plot.title:
            print plot.title[len(sgenfit.title) + 2 :],
        elif "shybfit" in vars() and shybfit.title in plot.title:
            print plot.title[len(shybfit.title) + 2 :],
        else:
            print plot.title,

        print i, "%.3g" % plot.chi2s[i]
## <-- loop over plots