## Loop over plots
for fitter in _fits[:]:
    ## Log the current fit configuration
    print "++ Processing", fitter.title
    print "++ Configuration:"
    print fitter.pydump()

    labels = fitter.labels[:]
    name = fitter.name

    ## Get the data
    fitter.getData(ws1)
    
    ## Load the initial paramter values
    ws1.loadSnapshot(fitter.pdf + '_init')

    ## Make initial fit to initialize various members
    fitter.fitToData(ws1)
    fitter.makePlot(ws1)

    param_init_data = ROOT.RooDataSet(
        '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
is_first_srecofit = True
is_first_struefit = True
is_first_sgenfit = True
is_first_shybfit = True

for plot in _fits:
    if not hasattr(plot, 'niter'):
        continue
    ## Extract the bare name w/o the appended iteration index
    m = re.search('(.*_iter)\d+', plot.name)
    if m:
        bareName = 'sFit_' + m.groups()[0]
    else:
        raise RuntimeError, "Failed to parse fit name `%s'" % plot.name
    for i in range (plot.niter-1, plot.niter):
        ws1.loadSnapshot( bareName + '%d' % i )
        if 'srecofit' in vars() and srecofit.title in plot.title:
            if is_first_srecofit:
                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
Ejemplo n.º 3
0
is_first_srecofit = True
is_first_struefit = True
is_first_sgenfit = True
is_first_shybfit = True

for plot in _fits:
    if not hasattr(plot, "niter"):
        continue
    ## Extract the bare name w/o the appended iteration index
    m = re.search("(.*_iter)\d+", plot.name)
    if m:
        bareName = "sFit_" + m.groups()[0]
    else:
        raise RuntimeError, "Failed to parse fit name `%s'" % plot.name
    for i in range(plot.niter - 1, plot.niter):
        ws1.loadSnapshot(bareName + "%d" % i)
        if "srecofit" in vars() and srecofit.title in plot.title:
            if is_first_srecofit:
                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
Ejemplo n.º 4
0
## Print an ASCII report
print '\nASCII report'
report = []

for plot in _fits:
    if not hasattr(plot, 'niter'):
        continue
    ## Extract the bare name w/o the appended iteration index
    m = re.search('(.*_iter)\d+', plot.name)
    if m:
        bareName = 'sFit_' + m.groups()[0]
    else:
        raise RuntimeError, "Failed to parse fit name `%s'" % plot.name
    for i in range(plot.niter - 1, plot.niter):
        ws1.loadSnapshot(bareName + '%d' % i)
        report.append([
            '%6.2f +/- %4.2f' %
            (ws1.var('#Deltas').getVal(), ws1.var('#Deltas').getError()),
            plot.title,
            str(i),
            "%.3g" % plot.chi2s[i]
        ])

for line in report:
    print ', '.join(line)

## <-- loop over plots

# ws1.writeToFile('test.root')
# ws1.writeToFile('mc_mmMass80_EB_lowR9_PhoEt_mmgMass87.2-95.2_cbShape.root')
Ejemplo n.º 5
0
            struefits.append(fit)

_fits = struefits

## Loop over plots
for fitter in _fits[:1]:
    ## Log the current fit configuration
    print "++ Processing", fitter.title
    print "++ Configuration:"
    print fitter.pydump()

    ## Get the data
    fitter.getData(ws1)

    ## Load the initial paramter values
    ws1.loadSnapshot(fitter.pdf + "_init")

    ## Make the fit
    fitter.fitToData(ws1)
    fitter.makePlot(ws1)

    ## Save the fit result in the workspace
    ws1.saveSnapshot("sFit_" + fitter.name, fitter.parameters, True)

    ## Make graphics
    if hasattr(fitter, "graphicsExtensions"):
        for ext in fitter.graphicsExtensions:
            fitter.canvas.Print(fitter.name + "." + ext)
## <-- loop over fitters