示例#1
0
plot.ModTDRStyle(r=0.06 if args.hist is None else 0.17, l=0.12)
ROOT.gStyle.SetNdivisions(510, 'XYZ')
plot.SetBirdPalette()

file = ROOT.TFile(args.input)
types = args.contours.split(',')
CL = 1 - args.CL

# Object storage
graphs = {c: file.Get(c) for c in types}
hists = {}
contours = {}

h_proto = plot.TH2FromTGraph2D(graphs[types[0]],
                               method=args.bin_method,
                               force_x_width=args.force_x_width,
                               force_y_width=args.force_y_width)
h_axis = h_proto
h_axis = plot.TH2FromTGraph2D(graphs[types[0]])
# Create the debug output file if requested
if args.debug_output is not None:
    debug = ROOT.TFile(args.debug_output, 'RECREATE')
else:
    debug = None

# Fill TH2s by interpolating the TGraph2Ds, then extract contours
for c in types:
    print 'Filling histo for %s' % c
    hists[c] = h_proto.Clone(c)
    plot.fillTH2(hists[c], graphs[c])
    contours[c] = plot.contourFromTH2(hists[c], CL, 5, frameValue=1)
示例#2
0
    with open(args.translate) as jsonfile:
        name_translate = json.load(jsonfile)

infile = args.file

order = args.order.split(',')

graph_test = read('test', args.x_axis, args.y_axis, infile)[0]

if args.axis_hist is not None:
    hargs = args.axis_hist.split(',')
    axis = ROOT.TH2F('hist2d', '', int(hargs[0]), float(hargs[1]),
                     float(hargs[2]), int(hargs[3]), float(hargs[4]),
                     float(hargs[5]))
else:
    axis = plot.TH2FromTGraph2D(graph_test, method='BinCenterAligned')

# axis = None
x_axis = args.x_axis
if x_axis in name_translate:
    x_axis = name_translate[x_axis]
y_axis = args.y_axis
if y_axis in name_translate:
    y_axis = name_translate[y_axis]
axis.GetXaxis().SetTitle(x_axis)
axis.GetYaxis().SetTitle(y_axis)

canv = ROOT.TCanvas(args.output, args.output)
pads = plot.OnePad()
pads[0].SetGridx(False)
pads[0].SetGridy(False)
示例#3
0
####hists2 = plot.TH2FromTGraph2D(graph2, method='BinCenterAligned')
###hists.append( plot.TH2FromTGraph2D(graph2, method='BinCenterAligned') )
####plot.fastFillTH2(hists2, graph,interpolateMissing=True)
###if args.bg_exp:
###    limit_bg = plot.MakeTChain(args.bg_exp, 'limit')
###    best_bg = plot.TGraphFromTree(
###        limit_bg, "CV", "CF", 'deltaNLL == 0')
###    plot.RemoveGraphXDuplicates(best_bg)
limit = plot.MakeTChain(args.files, 'limit')
print limit
graph = plot.TGraph2DFromTree(
    limit, "CV", "CF", '2*deltaNLL',
    'quantileExpected > -0.5 && deltaNLL > 0 && deltaNLL < 1000')
best = plot.TGraphFromTree(limit, "CV", "CF", 'deltaNLL == 0')
plot.RemoveGraphXDuplicates(best)
hists = plot.TH2FromTGraph2D(graph, method='BinCenterAligned')
plot.fastFillTH2(hists, graph, interpolateMissing=True)
if args.bg_exp:
    limit_bg = plot.MakeTChain(args.bg_exp, 'limit')
    best_bg = plot.TGraphFromTree(limit_bg, "CV", "CF", 'deltaNLL == 0')
    plot.RemoveGraphXDuplicates(best_bg)

# If included just plot SM exp at 1,1
if args.sm_exp:
    limit_sm = plot.MakeTChain(args.sm_exp, 'limit')
    best_sm = ROOT.TGraph(1, array('d', [
        1,
    ]), array('d', [
        1,
    ]))
    plot.RemoveGraphXDuplicates(best_sm)
示例#4
0
hists = {}
conts68 = {}
conts95 = {}

outfile = ROOT.TFile(args.output + '.root', 'RECREATE')

for scan in order:
    if scan not in infiles:
        continue
    graphs[scan], bestfits[scan] = read(scan, SETTINGS[scan]['xvar'],
                                        SETTINGS[scan]['yvar'], infiles[scan])
    outfile.WriteTObject(graphs[scan], scan + '_graph')
    outfile.WriteTObject(bestfits[scan])
    # hists[scan] = makeHist(
    #     scan + '_hist', 40 * SETTINGS[scan]['multi'] * args.multi, graph_test)
    hists[scan] = plot.TH2FromTGraph2D(graphs[scan], method='BinCenterAligned')
    plot.fillTH2(hists[scan], graphs[scan])
    # fillTH2(hists[scan], graphs[scan])
    outfile.WriteTObject(hists[scan], hists[scan].GetName() + '_input')
    fixZeros(hists[scan])
    outfile.WriteTObject(hists[scan], hists[scan].GetName() + '_processed')
    conts68[scan] = plot.contourFromTH2(hists[scan],
                                        ROOT.Math.chisquared_quantile_c(
                                            1 - 0.68, 2),
                                        frameValue=10)
    if scan in ['cms', 'atlas', 'comb']:
        conts95[scan] = plot.contourFromTH2(
            hists[scan], ROOT.Math.chisquared_quantile_c(1 - 0.95, 2))
    for i, c in enumerate(conts68[scan]):
        if args.thin > 1:
            newgr = ROOT.TGraph(c.GetN() / args.thin)