コード例 #1
0
def draw_canvas_1d(name):
    f_mc = TFile("plots/mc/%s_mcc7.root" % name)
    print(f_mc.ls())
    print(name)
    h_mc = gDirectory.Get("h_%s_reco" % name)
    h_mc.SetName("h_%s_reco" % name)
    h_mc.SetLineColor(kRed + 1)
    h_mc.SetFillColor(kRed + 1)
    h_mc.SetFillStyle(0)
    h_mc.GetYaxis().SetTitle("Efficiency")
    h_mc.GetYaxis().SetRangeUser(0.61, 1.04)
    f = TFile("plots/data/e_%s_pandoraCosmic.root" % name)
    h = gDirectory.Get("h_%s" % name)
    h.SetMarkerStyle(20)
    h.SetLineColor(1)
    f_sys = TFile("plots/data/e_%s_sys_pandoraCosmic.root" % name)
    h_sys = gDirectory.Get("h_%s_sys" % name)
    h_ratio = h_sys.Clone()
    h_ratio.Divide(h_mc)

    x_minbin = h_mc.FindFirstBinAbove()
    low = h_mc.GetXaxis().GetBinLowEdge(x_minbin)
    x_maxbin = h_mc.FindLastBinAbove()
    high = h_mc.GetXaxis().GetBinUpEdge(x_maxbin)
    h_mc.GetXaxis().SetRangeUser(low, high)
    h_mc.GetYaxis().SetTitleSize(0.08)
    h_mc.GetYaxis().SetLabelSize(0.065)
    h_mc.GetYaxis().SetTitleOffset(0.59)

    h_ratio.GetXaxis().SetRangeUser(low, high)

    g_stat = histo2graph(h)
    g_sys = histo2graph(h_sys)

    g_sys.SetMarkerStyle(20)
    g_sys.SetLineWidth(2)
    g_stat.SetFillStyle(3001)
    g_stat.SetFillColor(kGray + 2)
    g_stat.SetLineWidth(2)
    g_stat.SetLineColor(kGray + 2)

    pt = TPaveText(0.09, 0.855, 0.32, 0.98, "ndc")
    pt.AddText("MicroBooNE")
    pt.SetFillColor(0)
    pt.SetBorderSize(0)
    pt.SetShadowColor(0)

    leg = TLegend(0.55, 0.09, 0.86, 0.4)
    leg.AddEntry(g_sys, "Data - stat. #oplus sys.", "ep")
    leg.AddEntry(g_stat, "Data - stat. only", "f")
    leg.AddEntry(h_mc, "Monte Carlo", "f")

    canvas = draw_ratio("c_%s" % name, [h_mc, g_stat, g_sys, pt, leg],
                        [h_ratio], ["hist", "2", "p", "", ""], ["ep"])
    canvas.SaveAs("plots/%s.pdf" % name)
    canvas.SaveAs("plots/%s.C" % name)
コード例 #2
0
def draw_canvas_2d(name):

    f_mc = TFile("plots/mc/%s_mcc7.root" % name)
    h_mc = gDirectory.Get("h_%s_reco" % name)
    f = TFile("plots/data/e_%s_pandoraCosmic.root" % name)
    h = gDirectory.Get("h_%s" % name)
    h.Divide(h_mc)
    h.GetZaxis().SetRangeUser(0.5, 1.5)
    #h.GetZaxis().SetTitle("Data/Monte Carlo")
    #h.GetZaxis().RotateTitle()
    h.SetMarkerSize(2)
    x_minbin = h.FindFirstBinAbove(0, 1)
    low_x = h.GetXaxis().GetBinLowEdge(x_minbin)
    x_maxbin = h.FindLastBinAbove(0, 1)
    high_x = h.GetXaxis().GetBinUpEdge(x_maxbin)

    y_minbin = h.FindFirstBinAbove(0, 2)
    low_y = h.GetYaxis().GetBinLowEdge(y_minbin)
    y_maxbin = h.FindLastBinAbove(0, 2)
    high_y = h.GetYaxis().GetBinUpEdge(y_maxbin)

    h.GetXaxis().SetRangeUser(low_x, high_x)
    h.GetYaxis().SetRangeUser(low_y, high_y)

    c = TCanvas("c_%s" % name)
    h.SetMarkerSize(2.5)
    gPad.SetBottomMargin(0.17)
    gPad.SetLeftMargin(0.13)
    gPad.SetTopMargin(0.15)
    gPad.SetRightMargin(0.15)

    h.GetYaxis().SetTitleSize(0.07)
    h.GetXaxis().SetTitleSize(0.07)
    h.GetYaxis().SetTitleOffset(0.8)

    pt = TPaveText(0.13, 0.855, 0.42, 0.98, "ndc")
    pt.AddText("MicroBooNE")
    pt.SetFillColor(0)
    pt.SetBorderSize(0)
    pt.SetShadowColor(0)
    h.Draw("colz texte")

    pt.Draw()
    c.Update()
    c.SaveAs("plots/%s.pdf" % name)
    c.SaveAs("plots/%s.p" % name)

    return c
コード例 #3
0
g_reco_eff_data.SetMarkerStyle(30)
g_reco_eff_data.SetMarkerSize(1.5)
g_reco_eff_data.SetLineStyle(2)

l = TLegend(0.46, 0.16, 0.85, 0.425)
l.SetBorderSize(0)
l.SetShadowColor(0)

l.AddEntry(g_purity, "Purity #it{P}", "lp")
l.AddEntry(g_acceptance, "Acceptance #it{A}", "lp")

l.AddEntry(g_eff, "MuCS-MC tagging efficiency #it{#epsilon}_{tag}^{MuCS-MC}",
           "lp")
l.AddEntry(g_data_eff, "Data tagging efficiency #it{#epsilon}_{tag}^{data}",
           "lp")

l.AddEntry(g_reco_eff,
           "MuCS-MC reconstruction efficiency #it{#epsilon}_{MuCS-MC}", "lp")
l.AddEntry(g_reco_eff_data,
           "Data reconstruction efficiency #it{#epsilon}_{data}", "lp")

l.Draw()
pt = TPaveText(0.09, 0.91, 0.34, 0.98, "ndc")
pt.AddText("MicroBooNE")
pt.SetFillColor(0)
pt.SetBorderSize(0)
pt.SetShadowColor(0)
pt.Draw()
c.Update()
input()
コード例 #4
0
ファイル: correctsc.py プロジェクト: soleti/mucs_efficiency
h_theta_res_xy_corr.SetLineColor(kBlack)
h_theta_res_xy.SetMarkerStyle(4)
h_theta_res_xy.SetLineColor(kBlack)
print("no_corr", h_theta_res_xy.GetMean() - h_theta_res_xy_mc.GetMean())
print("corr", h_theta_res_xy_corr.GetMean() - h_theta_res_xy_mc.GetMean())

l.AddEntry(h_theta_res_xy_mc, "Monte Carlo", "l")
l.AddEntry(h_theta_res_xy, "Data", "ep")
l.AddEntry(h_theta_res_xy_corr, "Data - SCE corrected", "ep")
l.SetTextFont(43)
l.SetShadowColor(0)
l.SetBorderSize(0)
l.SetTextSize(14)
l.Draw()
preliminary2 = TPaveText(0.13, 0.78, 0.46, 0.86, "NDC")
preliminary2.SetShadowColor(0)
preliminary2.SetBorderSize(0)
preliminary2.SetFillStyle(0)
preliminary2.AddText("MicroBooNE Preliminary")
preliminary2.Draw()
c_res_xy.Update()
c_res_xy.SaveAs(output + "/xy_" + algo + "_res.pdf")

c_res_yz = TCanvas("c_res_yz")
f_eff_yz = TFile("yz_mc_pandoraCosmic_eff.root")
eff_yz = gDirectory.Get("e_yz_mc")
h_theta_res_yz_corr.Scale(h_theta_res_yz_mc.Integral() /
                          h_theta_res_yz.Integral())
h_theta_res_yz.Scale(h_theta_res_yz_mc.Integral() / h_theta_res_yz.Integral())
h_theta_res_yz_mc.SetLineColor(kRed + 1)
h_theta_res_yz_mc.Draw("hist")