Esempio n. 1
0
def main(args):
    # Get tree with scan values from all input files
    limit = plot.MakeTChain(args.files, 'limit')

    # Write Tree entries in TGraph to get structure for likelihood database
    graph = plot.TGraph2DFromTree(
        limit, args.x_var, args.y_var, 'deltaNLL',
        'quantileExpected > -0.5 && deltaNLL < 1000')
    # 'quantileExpected > -0.5 && deltaNLL > 0 && deltaNLL < 1000')

    # rezero the TGraph to have sensible values in the output file
    min_delta_nll = rezero_tgraph2d(graph)
    df = convert_graph_to_dataframe(graph)
    df.to_csv(args.output,
              sep=" ",
              float_format="%.6f",
              header=False,
              index=False,
              na_rep="NaN",
              columns=[args.x_var, args.y_var, "deltaNLL"])
    best = plot.TGraphFromTree(limit, args.x_var, args.y_var, 'deltaNLL == 0')
    plot.RemoveGraphXDuplicates(best)
    # Write back a root TTree with the modified contents.
    outfile = ROOT.TFile(args.output.replace(".txt", ".root"), "recreate")
    tree = convert_dataframe_to_tree(df, best, offset=min_delta_nll)
    # Add the best fit values from the limit trees
    outfile.Write()
    return
Esempio n. 2
0
def read(scan, param_x, param_y, file):
    # print files
    goodfiles = [f for f in [file] if plot.TFileIsGood(f)]
    limit = plot.MakeTChain(goodfiles, 'limit')
    graph = plot.TGraph2DFromTree(limit, param_x, param_y, '2*deltaNLL', 'quantileExpected > -0.5 && deltaNLL > 0')
    best = plot.TGraphFromTree(limit, param_x, param_y, 'quantileExpected > -0.5 && deltaNLL == 0')
    plot.RemoveGraphXDuplicates(best)
    assert(best.GetN() == 1)
    graph.SetName(scan)
    best.SetName(scan+'_best')
    # graph.Print()
    return (graph, best)
Esempio n. 3
0
###    limit2, "CV", "CF", '2*deltaNLL', 'quantileExpected > -0.5 && deltaNLL > 0 && deltaNLL < 1000')
###best2 = plot.TGraphFromTree(
###    limit2, "CV", "CF", 'deltaNLL == 0')
###plot.RemoveGraphXDuplicates(best2)
####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,
sigma_SM_HZZ = 290.58626
sigma_3_HZZ = 44.670158
sigma_13_int = 1937.15
sigma_13_intOnly = (sigma_13_int - 2. * sigma_SM_HTT) * math.sqrt(
    sigma_3_HTT / sigma_SM_HTT)
print " sigma_intOnly= ", sigma_13_intOnly
# muV->muV*(sigma_SM_HTT)/( (1.-abs(CMS_zz4l_fai1))*sigma_SM_HTT + abs(CMS_zz4l_fai1)*sigma_SM_HZZ*sigma_3_HTT/sigma_3_HZZ + sign(CMS_zz4l_fai1)*math.sqrt((1-abs(CMS_zz4l_fai1))*abs(CMS_zz4l_fai1)*sigma_SM_HTT/sigma_3_HTT)*sigma_13_intOnly )
# "muV"->"muV*(%s)/( (1.-abs(CMS_zz4l_fai1))*%s + abs(CMS_zz4l_fai1)*%s*%s/%s + sign(CMS_zz4l_fai1)*math.sqrt((1-abs(CMS_zz4l_fai1))*abs(CMS_zz4l_fai1)*%s/%s)*%s )" % (sigma_SM_HTT,sigma_SM_HTT,sigma_SM_HZZ,sigma_3_HTT,sigma_3_HZZ,sigma_SM_HTT,sigma_3_HTT,sigma_13_intOnly)

limit = plot.MakeTChain(args.files, 'limit')
graph = plot.TGraph2DFromTree(
    #    limit, "muV", "CMS_zz4l_fai1", '2*deltaNLL', 'quantileExpected > -0.5 && deltaNLL > 0 && deltaNLL < 10000000000000000')
    #    limit, "muV", "CMS_zz4l_fai1", '2*deltaNLL', 'quantileExpected > -0.5')
    limit,
    "muV*( (1.-abs(CMS_zz4l_fai1))*%s + abs(CMS_zz4l_fai1)*%s*%s/%s + sign(CMS_zz4l_fai1)*sqrt((1-abs(CMS_zz4l_fai1))*abs(CMS_zz4l_fai1)*%s/%s)*%s )/(%s)"
    % (sigma_SM_HTT, sigma_SM_HZZ, sigma_3_HTT, sigma_3_HZZ, sigma_SM_HTT,
       sigma_3_HTT, sigma_13_intOnly, sigma_SM_HTT),
    "CMS_zz4l_fai1",
    '2*deltaNLL',
    'quantileExpected > -0.5')
best = plot.TGraphFromTree(
    #    limit, "muV", "CMS_zz4l_fai1", 'deltaNLL == 0')
    limit,
    "muV*( (1.-abs(CMS_zz4l_fai1))*%s + abs(CMS_zz4l_fai1)*%s*%s/%s + sign(CMS_zz4l_fai1)*sqrt((1-abs(CMS_zz4l_fai1))*abs(CMS_zz4l_fai1)*%s/%s)*%s )/(%s)"
    % (sigma_SM_HTT, sigma_SM_HZZ, sigma_3_HTT, sigma_3_HZZ, sigma_SM_HTT,
       sigma_3_HTT, sigma_13_intOnly, sigma_SM_HTT),
    "CMS_zz4l_fai1",
    'deltaNLL == 0')
plot.RemoveGraphXDuplicates(best)
hists = plot.TH2FromTGraph2D(graph, method='BinCenterAligned')
plot.fastFillTH2(hists, graph, interpolateMissing=True)
Esempio n. 5
0
#Create canvas and TH2D for each component
plot.ModTDRStyle(width=600, l=0.12)
ROOT.gStyle.SetNdivisions(510, 'XYZ')
plot.SetBirdPalette()
canv = ROOT.TCanvas(args.output, args.output)
pads = plot.OnePad()

if args.debug_output is not None:
    debug = ROOT.TFile(args.debug_output, 'RECREATE')
else:
    debug = None

limit = plot.MakeTChain(args.files, 'limit')
graph = plot.TGraph2DFromTree(
    limit, "muV", "CMS_zz4l_fai1", '2*deltaNLL',
    'quantileExpected > -0.5 && deltaNLL > 0 && deltaNLL < 1000')
best = plot.TGraphFromTree(limit, "muV", "CMS_zz4l_fai1", '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, "muV", "CMS_zz4l_fai1",
                                  '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', [
Esempio n. 6
0
#Create canvas and TH2D for each component
plot.ModTDRStyle(width=600, l=0.12)
ROOT.gStyle.SetNdivisions(510, 'XYZ')
plot.SetBirdPalette()
canv = ROOT.TCanvas(args.output, args.output)
pads = plot.OnePad()

if args.debug_output is not None:
    debug = ROOT.TFile(args.debug_output, 'RECREATE')
else:
    debug = None

limit = plot.MakeTChain(args.files, 'limit')
if args.CPodd:
    graph = plot.TGraph2DFromTree(
        limit, "Yt_A", "Yb_A", '2*deltaNLL',
        'quantileExpected > -0.5 && deltaNLL > 0 && deltaNLL < 1000')
    best = plot.TGraphFromTree(limit, "Yt_A", "Yb_A", 'deltaNLL == 0')
else:
    graph = plot.TGraph2DFromTree(
        limit, "Yt_H", "Yb_H", '2*deltaNLL',
        'quantileExpected > -0.5 && deltaNLL > 0 && deltaNLL < 1000')
    best = plot.TGraphFromTree(limit, "Yt_H", "Yb_H", '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, "alpha", "muF", 'deltaNLL == 0')
    plot.RemoveGraphXDuplicates(best_bg)