Exemple #1
0
def read(scan, param, files, chop, remove_near_min, rezero,
         remove_delta=None, improve=False, remove_dups=True):
    # print files
    goodfiles = [f for f in files if plot.TFileIsGood(f)]
    limit = plot.MakeTChain(goodfiles, 'limit')
    graph = plot.TGraphFromTree(
        limit, param, '2*%s' % DELTANLL, 'quantileExpected > -1.5')
    # print 'INPUT'
    # graph.Print()
    graph.SetName(scan)
    graph.Sort()
    if remove_dups:
        plot.RemoveGraphXDuplicates(graph)
    if remove_delta is not None:
        plot.RemoveSmallDelta(graph, remove_delta)
    plot.RemoveGraphYAbove(graph, chop)
    plot.ReZeroTGraph(graph, rezero)
    if remove_near_min is not None:
        plot.RemoveNearMin(graph, remove_near_min)
    if improve:
        global NAMECOUNTER
        spline = ROOT.TSpline3("spline3", graph)
        func = ROOT.TF1('splinefn' + str(NAMECOUNTER), partial(Eval, spline),
                        graph.GetX()[0], graph.GetX()[graph.GetN() - 1], 1)
        func.SetNpx(NPX)
        NAMECOUNTER += 1
        plot.ImproveMinimum(graph, func, True)
    # graph.Print()
    if FILTER is not None:
        plot.FilterGraph(graph, FILTER)
    if REMOVE_X_RANGES is not None:
        for remove_x in REMOVE_X_RANGES:
            plot.RemoveInXRange(graph, remove_x[0], remove_x[1])
    return graph
def read(scan,
         param,
         files,
         chop,
         remove_near_min,
         rezero,
         remove_delta=None,
         improve=False):
    # print files
    goodfiles = [f for f in files if plot.TFileIsGood(f)]
    limit = plot.MakeTChain(goodfiles, 'limit')
    # require quantileExpected > -0.5 to avoid the final point which is always committed twice
    # (even if the fit fails)
    graph = plot.TGraphFromTree(limit, param, '2*deltaNLL',
                                'quantileExpected > -0.5')
    graph.SetName(scan)
    graph.Sort()
    plot.RemoveGraphXDuplicates(graph)
    if remove_delta is not None: plot.RemoveSmallDelta(graph, remove_delta)
    plot.RemoveGraphYAbove(graph, chop)
    plot.ReZeroTGraph(graph, rezero)
    if remove_near_min is not None: plot.RemoveNearMin(graph, remove_near_min)
    if improve:
        global NAMECOUNTER
        spline = ROOT.TSpline3("spline3", graph)
        func = ROOT.TF1('splinefn' + str(NAMECOUNTER), partial(Eval, spline),
                        graph.GetX()[0],
                        graph.GetX()[graph.GetN() - 1], 1)
        NAMECOUNTER += 1
        plot.ImproveMinimum(graph, func, True)
    # graph.Print()
    return graph
                      args.POI, [splitargs[0]],
                      int(splitargs[2]),
                      yvals,
                      args.chop,
                      args.remove_near_min if args.envelope is False else None,
                      args.rezero,
                      args.envelope and i < n_env,
                      remove_delta=args.remove_delta,
                      improve=args.improve,
                      pregraph=tmp_gr))

if args.envelope and args.breakdown:
    for i in xrange(n_env):
        print '>> Correcting breakdown offsets for envelope index %i' % i
        gr = other_scans[i]['graph'].Clone()
        plot.RemoveSmallDelta(gr, 1E-6)
        bf = other_scans[i + n_env]['val'][0]
        y_off = other_scans[i]['func'].Eval(bf)
        print '>> Evaluating for offset at best-fit of %f gives %f' % (bf,
                                                                       y_off)
        for j in xrange(1, n_brk):
            oth = other_scans[i + j * n_env]
            print '>> Applying shift of %f to graph %s' % (
                y_off, other_scans_opts[i + j * n_env][0])
            plot.ApplyGraphYOffset(oth['graph'], y_off)
            color = oth['func'].GetLineColor()
            oth['spline'] = ROOT.TSpline3("spline3", oth['graph'])
            oth['func'] = ROOT.TF1(
                'splinefn' + str(NAMECOUNTER), partial(Eval, oth['spline']),
                oth['graph'].GetX()[0],
                oth['graph'].GetX()[oth['graph'].GetN() - 1], 1)