Beispiel #1
0
def pdf_logPt2_prelim():

    #PDF fit to log_10(pT^2) for preliminary figure

    #tree_in = tree_incoh
    tree_in = tree

    #ptbin = 0.04
    ptbin = 0.12
    ptmin = -5.
    ptmax = 1.

    mmin = 2.8
    mmax = 3.2

    #fitran = [-5., 1.]
    fitran = [-0.9, 0.1]

    binned = False

    #gamma-gamma 131 evt for pT<0.18

    #input data
    pT = RooRealVar("jRecPt", "pT", 0, 10)
    m = RooRealVar("jRecM", "mass", 0, 10)
    dataIN = RooDataSet("data", "data", tree_in, RooArgSet(pT, m))
    strsel = "jRecM>{0:.3f} && jRecM<{1:.3f}".format(mmin, mmax)
    data = dataIN.reduce(strsel)
    #x is RooRealVar for log(Pt2)
    draw = "TMath::Log10(jRecPt*jRecPt)"
    draw_func = RooFormulaVar(
        "x", "Dielectron log_{10}( #it{p}_{T}^{2} ) ((GeV/c)^{2})", draw,
        RooArgList(pT))
    x = data.addColumn(draw_func)
    x.setRange("fitran", fitran[0], fitran[1])

    #binned data
    nbins, ptmax = ut.get_nbins(ptbin, ptmin, ptmax)
    hPt = TH1D("hPt", "hPt", nbins, ptmin, ptmax)
    hPtCoh = ut.prepare_TH1D("hPtCoh", ptbin, ptmin, ptmax)
    hPtCoh.SetLineWidth(2)
    #fill in binned data
    tree_in.Draw(draw + " >> hPt", strsel)
    tree_coh.Draw(draw + " >> hPtCoh", strsel)
    dataH = RooDataHist("dataH", "dataH", RooArgList(x), hPt)

    #range for plot
    x.setMin(ptmin)
    x.setMax(ptmax)
    x.setRange("plotran", ptmin, ptmax)

    #create the pdf
    b = RooRealVar("b", "b", 5., 0., 10.)
    pdf_func = "log(10.)*pow(10.,x)*exp(-b*pow(10.,x))"
    pdf_logPt2 = RooGenericPdf("pdf_logPt2", pdf_func, RooArgList(x, b))

    #make the fit
    if binned == True:
        r1 = pdf_logPt2.fitTo(dataH, rf.Range("fitran"), rf.Save())
    else:
        r1 = pdf_logPt2.fitTo(data, rf.Range("fitran"), rf.Save())

    #calculate norm to number of events
    xset = RooArgSet(x)
    ipdf = pdf_logPt2.createIntegral(xset, rf.NormSet(xset),
                                     rf.Range("fitran"))
    print "PDF integral:", ipdf.getVal()
    if binned == True:
        nevt = tree_incoh.Draw(
            "", strsel + " && " + draw + ">{0:.3f}".format(fitran[0]) +
            " && " + draw + "<{1:.3f}".format(fitran[0], fitran[1]))
    else:
        nevt = data.sumEntries("x", "fitran")

    print "nevt:", nevt
    pdf_logPt2.setNormRange("fitran")
    print "PDF norm:", pdf_logPt2.getNorm(RooArgSet(x))

    #a = nevt/ipdf.getVal()
    a = nevt / pdf_logPt2.getNorm(RooArgSet(x))
    print "a =", a

    #gamma-gamma contribution
    hPtGG = ut.prepare_TH1D("hPtGG", ptbin, ptmin, ptmax)
    tree_gg.Draw(draw + " >> hPtGG", strsel)
    #ut.norm_to_data(hPtGG, hPt, rt.kGreen, -5., -2.9)
    ut.norm_to_num(hPtGG, 131., rt.kGreen + 1)

    print "Int GG:", hPtGG.Integral()

    #sum of all contributions
    hSum = ut.prepare_TH1D("hSum", ptbin, ptmin, ptmax)
    hSum.SetLineWidth(3)
    #add ggel to the sum
    hSum.Add(hPtGG)
    #add incoherent contribution
    func_logPt2 = TF1("pdf_logPt2",
                      "[0]*log(10.)*pow(10.,x)*exp(-[1]*pow(10.,x))", -10.,
                      10.)
    func_logPt2.SetParameters(a, b.getVal())
    hInc = ut.prepare_TH1D("hInc", ptbin, ptmin, ptmax)
    ut.fill_h1_tf(hInc, func_logPt2)
    hSum.Add(hInc)
    #add coherent contribution
    ut.norm_to_data(hPtCoh, hPt, rt.kBlue, -5., -2.2)  # norm for coh
    hSum.Add(hPtCoh)
    #set to draw as a lines
    ut.line_h1(hSum, rt.kBlack)

    #create canvas frame
    can = ut.box_canvas()
    ut.set_margin_lbtr(gPad, 0.11, 0.1, 0.01, 0.01)

    frame = x.frame(rf.Bins(nbins), rf.Title(""))
    frame.SetTitle("")

    frame.SetYTitle("J/#psi candidates / ({0:.3f}".format(ptbin) +
                    " (GeV/c)^{2})")

    frame.GetXaxis().SetTitleOffset(1.2)
    frame.GetYaxis().SetTitleOffset(1.6)

    print "Int data:", hPt.Integral()

    #plot the data
    if binned == True:
        dataH.plotOn(frame, rf.Name("data"))
    else:
        data.plotOn(frame, rf.Name("data"))

    pdf_logPt2.plotOn(frame, rf.Range("fitran"), rf.LineColor(rt.kRed),
                      rf.Name("pdf_logPt2"))
    pdf_logPt2.plotOn(frame, rf.Range("plotran"), rf.LineColor(rt.kRed),
                      rf.Name("pdf_logPt2_full"), rf.LineStyle(rt.kDashed))

    frame.Draw()

    leg = ut.prepare_leg(0.61, 0.77, 0.16, 0.19, 0.03)
    #ut.add_leg_mass(leg, mmin, mmax)
    hx = ut.prepare_TH1D("hx", 1, 0, 1)
    hx.Draw("same")
    ln = ut.col_lin(rt.kRed, 2)
    leg.AddEntry(hx, "Data", "p")
    leg.AddEntry(hSum, "Sum", "l")
    leg.AddEntry(hPtCoh, "Coherent J/#psi", "l")
    leg.AddEntry(ln, "Incoherent parametrization", "l")
    leg.AddEntry(hPtGG, "#gamma#gamma#rightarrow e^{+}e^{-}", "l")
    #leg.AddEntry(ln, "ln(10)*#it{A}*10^{log_{10}#it{p}_{T}^{2}}exp(-#it{b}10^{log_{10}#it{p}_{T}^{2}})", "l")
    leg.Draw("same")

    l0 = ut.cut_line(fitran[0], 0.9, frame)
    l1 = ut.cut_line(fitran[1], 0.9, frame)
    #l0.Draw()
    #l1.Draw()

    pleg = ut.prepare_leg(0.12, 0.75, 0.14, 0.22, 0.03)
    pleg.AddEntry(None, "#bf{|#kern[0.3]{#it{y}}| < 1}", "")
    ut.add_leg_mass(pleg, mmin, mmax)
    pleg.AddEntry(None, "STAR Preliminary", "")
    pleg.AddEntry(None, "AuAu@200 GeV", "")
    pleg.AddEntry(None, "UPC sample", "")
    pleg.Draw("same")

    desc = pdesc(frame, 0.14, 0.9, 0.057)
    desc.set_text_size(0.03)
    desc.itemD("#chi^{2}/ndf", frame.chiSquare("pdf_logPt2", "data", 2), -1,
               rt.kRed)
    desc.itemD("#it{A}", a, -1, rt.kRed)
    desc.itemR("#it{b}", b, rt.kRed)
    #desc.draw()

    #put the sum
    hSum.Draw("same")

    frame.Draw("same")

    #put gamma-gamma and coherent J/psi
    hPtGG.Draw("same")
    hPtCoh.Draw("same")

    #ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Beispiel #2
0
def plot_pt2_real():

    #pT^2 with realistic normalization for incoherent and gamma-gamma components

    ptbin = 0.002
    ptmin = 0.
    ptmax = 0.2  # 0.3

    mmin = 2.8
    mmax = 3.2

    ngg = 131  # number of gamma-gamma from mass fit

    strsel = "jRecM>{0:.3f} && jRecM<{1:.3f}".format(mmin, mmax)

    can = ut.box_canvas()

    hPt = ut.prepare_TH1D("hPt", ptbin, ptmin, ptmax)
    hPtCoh = ut.prepare_TH1D("hPtCoh", ptbin, ptmin, ptmax)
    hPtIncoh = ut.prepare_TH1D("hPtIncoh", ptbin, ptmin, ptmax)
    hPtGG = ut.prepare_TH1D("hPtGG", ptbin, ptmin, ptmax)

    ut.put_yx_tit(hPt, "Events / ({0:.3f}".format(ptbin) + " GeV^{2})",
                  "#it{p}_{T}^{2} (GeV^{2})")

    ut.set_margin_lbtr(gPad, 0.11, 0.09, 0.01, 0.02)

    draw = "jRecPt*jRecPt"

    tree.Draw(draw + " >> hPt", strsel)
    tree_coh.Draw(draw + " >> hPtCoh", strsel)
    tree_gg.Draw(draw + " >> hPtGG", strsel)

    #incoherent functional shape
    func_incoh_pt2 = TF1("func_incoh", "[0]*exp(-[1]*x)", 0., 10.)
    func_incoh_pt2.SetParameters(873.04, 3.28)

    #fill incoherent histogram from functional shape
    ut.fill_h1_tf(hPtIncoh, func_incoh_pt2, rt.kRed)

    ut.norm_to_data(hPtCoh, hPt, rt.kBlue, 0., 0.015)
    ut.norm_to_num(hPtGG, ngg, rt.kGreen)

    hPt.Draw()
    hPtCoh.Draw("same")
    hPtIncoh.Draw("same")
    hPtGG.Draw("same")

    leg = ut.prepare_leg(0.6, 0.78, 0.14, 0.18, 0.03)
    ut.add_leg_mass(leg, mmin, mmax)
    leg.AddEntry(hPt, "Data")
    leg.AddEntry(hPtCoh, "Coherent MC, Sartre", "l")
    leg.AddEntry(hPtIncoh, "Incoherent parametrization", "l")
    leg.AddEntry(hPtGG, "#gamma#gamma#rightarrow e^{+}e^{-} MC", "l")
    leg.Draw("same")

    uoleg = ut.make_uo_leg(hPt, 0.14, 0.9, 0.01, 0.1)
    #uoleg.Draw("same")

    gPad.SetLogy()

    #ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Beispiel #3
0
def pdf_logPt2_incoh():

    #PDF fit to log_10(pT^2)

    #tree_in = tree_incoh
    tree_in = tree

    #ptbin = 0.04
    ptbin = 0.12
    ptmin = -5.
    ptmax = 1.

    mmin = 2.8
    mmax = 3.2

    #fitran = [-5., 1.]
    fitran = [-0.9, 0.1]

    binned = False

    #gamma-gamma 131 evt for pT<0.18

    #output log file
    out = open("out.txt", "w")
    ut.log_results(
        out, "in " + infile + " in_coh " + infile_coh + " in_gg " + infile_gg)
    loglist = [(x, eval(x)) for x in
               ["ptbin", "ptmin", "ptmax", "mmin", "mmax", "fitran", "binned"]]
    strlog = ut.make_log_string(loglist)
    ut.log_results(out, strlog + "\n")

    #input data
    pT = RooRealVar("jRecPt", "pT", 0, 10)
    m = RooRealVar("jRecM", "mass", 0, 10)
    dataIN = RooDataSet("data", "data", tree_in, RooArgSet(pT, m))
    strsel = "jRecM>{0:.3f} && jRecM<{1:.3f}".format(mmin, mmax)
    data = dataIN.reduce(strsel)
    #x is RooRealVar for log(Pt2)
    draw = "TMath::Log10(jRecPt*jRecPt)"
    draw_func = RooFormulaVar("x", "log_{10}( #it{p}_{T}^{2} ) (GeV^{2})",
                              draw, RooArgList(pT))
    x = data.addColumn(draw_func)
    x.setRange("fitran", fitran[0], fitran[1])

    #binned data
    nbins, ptmax = ut.get_nbins(ptbin, ptmin, ptmax)
    hPt = TH1D("hPt", "hPt", nbins, ptmin, ptmax)
    tree_in.Draw(draw + " >> hPt", strsel)
    dataH = RooDataHist("dataH", "dataH", RooArgList(x), hPt)

    #range for plot
    x.setMin(ptmin)
    x.setMax(ptmax)
    x.setRange("plotran", ptmin, ptmax)

    #create the pdf
    b = RooRealVar("b", "b", 5., 0., 10.)
    pdf_func = "log(10.)*pow(10.,x)*exp(-b*pow(10.,x))"
    pdf_logPt2 = RooGenericPdf("pdf_logPt2", pdf_func, RooArgList(x, b))

    #make the fit
    if binned == True:
        r1 = pdf_logPt2.fitTo(dataH, rf.Range("fitran"), rf.Save())
    else:
        r1 = pdf_logPt2.fitTo(data, rf.Range("fitran"), rf.Save())

    ut.log_results(out, ut.log_fit_result(r1))

    #calculate norm to number of events
    xset = RooArgSet(x)
    ipdf = pdf_logPt2.createIntegral(xset, rf.NormSet(xset),
                                     rf.Range("fitran"))
    print "PDF integral:", ipdf.getVal()
    if binned == True:
        nevt = tree_incoh.Draw(
            "", strsel + " && " + draw + ">{0:.3f}".format(fitran[0]) +
            " && " + draw + "<{1:.3f}".format(fitran[0], fitran[1]))
    else:
        nevt = data.sumEntries("x", "fitran")

    print "nevt:", nevt
    pdf_logPt2.setNormRange("fitran")
    print "PDF norm:", pdf_logPt2.getNorm(RooArgSet(x))

    #a = nevt/ipdf.getVal()
    a = nevt / pdf_logPt2.getNorm(RooArgSet(x))
    ut.log_results(out, "log_10(pT^2) parametrization:")
    ut.log_results(out, "A = {0:.2f}".format(a))
    ut.log_results(out, ut.log_fit_parameters(r1, 0, 2))
    print "a =", a

    #Coherent contribution
    hPtCoh = ut.prepare_TH1D("hPtCoh", ptbin, ptmin, ptmax)
    hPtCoh.Sumw2()
    #tree_coh.Draw(draw + " >> hPtCoh", strsel)
    tree_coh.Draw("TMath::Log10(jGenPt*jGenPt) >> hPtCoh", strsel)
    ut.norm_to_data(hPtCoh, hPt, rt.kBlue, -5., -2.2)  # norm for coh
    #ut.norm_to_data(hPtCoh, hPt, rt.kBlue, -5, -2.1)
    #ut.norm_to_num(hPtCoh, 405, rt.kBlue)
    print "Coherent integral:", hPtCoh.Integral()

    #TMath::Log10(jRecPt*jRecPt)

    #Sartre generated coherent shape
    sartre = TFile.Open(
        "/home/jaroslav/sim/sartre_tx/sartre_AuAu_200GeV_Jpsi_coh_2p7Mevt.root"
    )
    sartre_tree = sartre.Get("sartre_tree")
    hSartre = ut.prepare_TH1D("hSartre", ptbin, ptmin, ptmax)
    sartre_tree.Draw("TMath::Log10(pT*pT) >> hSartre",
                     "rapidity>-1 && rapidity<1")
    ut.norm_to_data(hSartre, hPt, rt.kViolet, -5, -2)  # norm for Sartre

    #gamma-gamma contribution
    hPtGG = ut.prepare_TH1D("hPtGG", ptbin, ptmin, ptmax)
    tree_gg.Draw(draw + " >> hPtGG", strsel)
    #ut.norm_to_data(hPtGG, hPt, rt.kGreen, -5., -2.9)
    ut.norm_to_num(hPtGG, 131., rt.kGreen)

    print "Int GG:", hPtGG.Integral()

    #psi' contribution
    psiP = TFile.Open(basedir_mc + "/ana_slight14e4x1_s6_sel5z.root")
    psiP_tree = psiP.Get("jRecTree")
    hPtPsiP = ut.prepare_TH1D("hPtPsiP", ptbin, ptmin, ptmax)
    psiP_tree.Draw(draw + " >> hPtPsiP", strsel)
    ut.norm_to_num(hPtPsiP, 12, rt.kViolet)

    #sum of all contributions
    hSum = ut.prepare_TH1D("hSum", ptbin, ptmin, ptmax)
    hSum.SetLineWidth(3)
    #add ggel to the sum
    hSum.Add(hPtGG)
    #add incoherent contribution
    func_logPt2 = TF1("pdf_logPt2",
                      "[0]*log(10.)*pow(10.,x)*exp(-[1]*pow(10.,x))", -10.,
                      10.)
    func_logPt2.SetParameters(a, b.getVal())
    hInc = ut.prepare_TH1D("hInc", ptbin, ptmin, ptmax)
    ut.fill_h1_tf(hInc, func_logPt2)
    hSum.Add(hInc)
    #add coherent contribution
    hSum.Add(hPtCoh)
    #add psi(2S) contribution
    #hSum.Add(hPtPsiP)
    #set to draw as a lines
    ut.line_h1(hSum, rt.kBlack)

    #create canvas frame
    can = ut.box_canvas()
    ut.set_margin_lbtr(gPad, 0.11, 0.09, 0.01, 0.01)

    frame = x.frame(rf.Bins(nbins), rf.Title(""))
    frame.SetTitle("")
    frame.SetMaximum(75)

    frame.SetYTitle("Events / ({0:.3f}".format(ptbin) + " GeV^{2})")

    print "Int data:", hPt.Integral()

    #plot the data
    if binned == True:
        dataH.plotOn(frame, rf.Name("data"))
    else:
        data.plotOn(frame, rf.Name("data"))

    pdf_logPt2.plotOn(frame, rf.Range("fitran"), rf.LineColor(rt.kRed),
                      rf.Name("pdf_logPt2"))
    pdf_logPt2.plotOn(frame, rf.Range("plotran"), rf.LineColor(rt.kRed),
                      rf.Name("pdf_logPt2_full"), rf.LineStyle(rt.kDashed))

    frame.Draw()

    amin = TMath.Power(10, ptmin)
    amax = TMath.Power(10, ptmax) - 1
    print amin, amax
    pt2func = TF1("f1", "TMath::Power(10, x)", amin,
                  amax)  #TMath::Power(x, 10)
    aPt2 = TGaxis(-5, 75, 1, 75, "f1", 510, "-")
    ut.set_axis(aPt2)
    aPt2.SetTitle("pt2")
    #aPt2.Draw();

    leg = ut.prepare_leg(0.57, 0.78, 0.14, 0.19, 0.03)
    ut.add_leg_mass(leg, mmin, mmax)
    hx = ut.prepare_TH1D("hx", 1, 0, 1)
    hx.Draw("same")
    ln = ut.col_lin(rt.kRed)
    leg.AddEntry(hx, "Data")
    leg.AddEntry(hPtCoh, "Sartre MC", "l")
    leg.AddEntry(hPtGG, "#gamma#gamma#rightarrow e^{+}e^{-} MC", "l")
    #leg.AddEntry(ln, "ln(10)*#it{A}*10^{log_{10}#it{p}_{T}^{2}}exp(-#it{b}10^{log_{10}#it{p}_{T}^{2}})", "l")
    #leg.AddEntry(ln, "Incoherent fit", "l")
    leg.Draw("same")

    l0 = ut.cut_line(fitran[0], 0.9, frame)
    l1 = ut.cut_line(fitran[1], 0.9, frame)
    #l0.Draw()
    #l1.Draw()

    desc = pdesc(frame, 0.14, 0.8, 0.054)
    desc.set_text_size(0.03)
    desc.itemD("#chi^{2}/ndf", frame.chiSquare("pdf_logPt2", "data", 2), -1,
               rt.kRed)
    desc.itemD("#it{A}", a, -1, rt.kRed)
    desc.itemR("#it{b}", b, rt.kRed)
    desc.draw()

    #put the sum
    #hSum.Draw("same")

    #gPad.SetLogy()

    frame.Draw("same")

    #put gamma-gamma
    hPtGG.Draw("same")
    #put coherent J/psi
    hPtCoh.Draw("same")

    #put Sartre generated coherent shape
    #hSartre.Draw("same")

    #put psi(2S) contribution
    #hPtPsiP.Draw("same")

    leg2 = ut.prepare_leg(0.14, 0.9, 0.14, 0.08, 0.03)
    leg2.AddEntry(
        ln,
        "ln(10)*#it{A}*10^{log_{10}#it{p}_{T}^{2}}exp(-#it{b}10^{log_{10}#it{p}_{T}^{2}})",
        "l")
    #leg2.AddEntry(hPtCoh, "Sartre MC reconstructed", "l")
    #leg2.AddEntry(hSartre, "Sartre MC generated", "l")
    leg2.Draw("same")

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Beispiel #4
0
def plot_pt():

    #pT with coherent incoherent and gamma-gamma components

    ptbin = 0.02
    ptmin = 0.
    ptmax = 1.1

    mmin = 2.8
    mmax = 3.2
    #mmin = 3.4
    #mmax = 5.

    strsel = "jRecM>{0:.3f} && jRecM<{1:.3f}".format(mmin, mmax)

    can = ut.box_canvas()

    hPt = ut.prepare_TH1D("hPt", ptbin, ptmin, ptmax)
    hPtCoh = ut.prepare_TH1D("hPtCoh", ptbin, ptmin, ptmax)
    hPtIncoh = ut.prepare_TH1D("hPtIncoh", ptbin, ptmin, ptmax)
    hPtGG = ut.prepare_TH1D("hPtGG", ptbin, ptmin, ptmax)

    #ut.put_yx_tit(hPt, "Events / ({0:.3f}".format(ptbin)+" GeV)", "#it{p}_{T} (GeV})")
    ut.put_yx_tit(hPt,
                  "J/#psi candidates / ({0:.3f}".format(ptbin) + " GeV/c)",
                  "Dielectron #it{p}_{T} (GeV/c)", 1.5, 1.2)

    ut.set_margin_lbtr(gPad, 0.11, 0.09, 0.01, 0.02)

    draw = "jRecPt"

    tree.Draw(draw + " >> hPt", strsel)
    tree_coh.Draw(draw + " >> hPtCoh", strsel)
    tree_incoh.Draw(draw + " >> hPtIncoh", strsel)
    tree_gg.Draw(draw + " >> hPtGG", strsel)

    ut.norm_to_data(hPtCoh, hPt, rt.kBlue, 0., 0.08)
    ut.norm_to_data(hPtIncoh, hPt, rt.kRed, 0.28, 1.)
    #ut.norm_to_data(hPtGG, hPt, rt.kGreen, 0., 0.03)
    ut.norm_to_num(hPtGG, 131, rt.kGreen + 1)

    #sum of all contributions
    hSum = ut.prepare_TH1D("hSum", ptbin, ptmin, ptmax)
    hSum.SetLineWidth(3)
    #add ggel to the sum
    hSum.Add(hPtGG)
    #add incoherent contribution
    hSum.Add(hPtIncoh)
    #add coherent contribution
    hSum.Add(hPtCoh)
    #set to draw as a lines
    ut.line_h1(hSum, rt.kBlack)

    hPt.Draw()
    hSum.Draw("same")
    hPtCoh.Draw("same")
    hPtIncoh.Draw("same")
    hPtGG.Draw("same")

    leg = ut.prepare_leg(0.64, 0.65, 0.14, 0.3, 0.03)
    leg.AddEntry(None, "#bf{|#kern[0.3]{#it{y}}| < 1}", "")
    ut.add_leg_mass(leg, mmin, mmax)
    leg.AddEntry(hPt, "Data", "p")
    leg.AddEntry(hSum, "Sum", "l")
    leg.AddEntry(hPtCoh, "Coherent J/#psi", "l")
    leg.AddEntry(hPtIncoh, "Incoherent J/#psi", "l")
    leg.AddEntry(hPtGG, "#gamma#gamma#rightarrow e^{+}e^{-}", "l")
    leg.Draw("same")

    uoleg = ut.make_uo_leg(hPt, 0.14, 0.9, 0.01, 0.1)
    #uoleg.Draw("same")

    pleg = ut.prepare_leg(0.33, 0.8, 0.01, 0.14, 0.035)
    pleg.AddEntry(None, "STAR Preliminary", "")
    pleg.AddEntry(None, "AuAu@200 GeV", "")
    pleg.AddEntry(None, "UPC sample", "")
    pleg.Draw("same")

    #ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Beispiel #5
0
def plot():

    #plot of log_10(pT^2) with components

    ptbin = 0.12
    ptmin = -5.
    ptmax = 1.

    mmin = 2.8  #  2.8   2.4 for ls
    mmax = 3.2

    strsel = "jRecM>{0:.3f} && jRecM<{1:.3f}".format(mmin, mmax)
    strsel_ls = "jRecM>{0:.3f} && jRecM<{1:.3f}".format(2.3, mmax)

    can = ut.box_canvas()

    hPt = ut.prepare_TH1D("hPt", ptbin, ptmin, ptmax)
    hPtLS = ut.prepare_TH1D("hPtLS", ptbin, ptmin, ptmax)
    hPtGG = ut.prepare_TH1D("hPtGG", ptbin, ptmin, ptmax)
    hPtInc = ut.prepare_TH1D("hPtInc", ptbin, ptmin, ptmax)

    ut.put_yx_tit(hPt, "Events / ({0:.3f}".format(ptbin) + " GeV^{2})",
                  "log_{10}( #it{p}_{T}^{2} ) (GeV^{2})")
    ut.set_margin_lbtr(gPad, 0.11, 0.09, 0.01, 0.01)

    #data
    draw = "TMath::Log10(jRecPt*jRecPt)"
    tree.Draw(draw + " >> hPt", strsel)

    #like-sign data
    tree_ls.Draw(draw + " >> hPtLS", strsel_ls)
    ut.set_H1D_col(hPtLS, rt.kRed)
    print hPtLS.GetEntries()

    #gamma-gamma
    tree_gg.Draw(draw + " >> hPtGG", strsel)
    ut.norm_to_num(hPtGG, 131., rt.kGreen)

    #incoherent contribution
    tree_inc.Draw(draw + " >> hPtInc", strsel)
    ut.norm_to_num(hPtInc, 270., rt.kRed)  # 270  100

    #psi' contribution
    psiP = TFile.Open(basedir_mc + "/ana_slight14e4x1_s6_sel5z.root")
    psiP_tree = psiP.Get("jRecTree")
    hPtPsiP = ut.prepare_TH1D("hPtPsiP", ptbin, ptmin, ptmax)
    psiP_tree.Draw(draw + " >> hPtPsiP", strsel)
    ut.norm_to_num(hPtPsiP, 30, rt.kViolet)

    #incoherent parametrization
    func_incoh_logPt2 = TF1("func_incoh_logPt2",
                            "[0]*log(10.)*pow(10.,x)*exp(-[1]*pow(10.,x))",
                            -10., 10.)
    func_incoh_logPt2.SetParName(0, "A")
    func_incoh_logPt2.SetParName(1, "b")
    func_incoh_logPt2.SetNpx(1000)
    func_incoh_logPt2.SetLineColor(rt.kRed)
    func_incoh_logPt2.SetParameters(
        80, 3)  # 4.9 from incoherent mc, 3.3 from data fit

    #signal empirical shape
    sig1 = TF1("sig1", "gaus", -10, 10)
    sig1.SetParameters(40, -2.3, 0.4)  # const, mean, sigma
    sig2 = TF1("sig2", "gaus", -10, 10)
    sig2.SetParameters(35, -1.35, 0.2)

    #add like-sign to incoherent MC
    #hPtInc.Add(hPtLS)

    #subtract the individual components
    hPt.Add(hPtGG, -1)
    hPt.Add(sig1, -1)
    hPt.Add(sig2, -1)
    hPt.Add(hPtPsiP, -1)
    hPt.Add(func_incoh_logPt2, -1)

    hPt.Draw()
    #hPtLS.Draw("same")
    #hPtGG.Draw("same")
    #func_incoh_logPt2.Draw("same")
    #hPtPsiP.Draw("same")
    #hPtInc.Draw("same")

    #sig1.Draw("same")
    #sig2.Draw("same")

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Beispiel #6
0
def fit():

    #fit to log_10(pT^2) with components and plot of plain pT^2

    #range in log_10(pT^2)
    ptbin = 0.12
    ptmin = -5.
    ptmax = 0.99  # 1.01

    #range in pT^2
    ptsq_bin = 0.03
    ptsq_min = 1e-5
    ptsq_max = 1

    mmin = 2.8
    mmax = 3.2

    #range for incoherent fit
    fitran = [-0.9, 0.1]

    #number of gamma-gamma events
    ngg = 131

    #number of psi' events
    npsiP = 20

    #input data
    pT = RooRealVar("jRecPt", "pT", 0, 10)
    m = RooRealVar("jRecM", "mass", 0, 10)
    data_all = RooDataSet("data", "data", tree, RooArgSet(pT, m))
    #select for mass range
    strsel = "jRecM>{0:.3f} && jRecM<{1:.3f}".format(mmin, mmax)
    data = data_all.reduce(strsel)

    #create log(pT^2) from pT
    ptsq_draw = "jRecPt*jRecPt"  # will be used for pT^2
    logPtSq_draw = "TMath::Log10(" + ptsq_draw + ")"
    logPtSq_form = RooFormulaVar("logPtSq", "logPtSq", logPtSq_draw,
                                 RooArgList(pT))
    logPtSq = data.addColumn(logPtSq_form)
    logPtSq.setRange("fitran", fitran[0], fitran[1])

    #bins and range for the plot
    nbins, ptmax = ut.get_nbins(ptbin, ptmin, ptmax)
    logPtSq.setMin(ptmin)
    logPtSq.setMax(ptmax)
    logPtSq.setRange("plotran", ptmin, ptmax)

    #range for pT^2
    ptsq_nbins, ptsq_max = ut.get_nbins(ptsq_bin, ptsq_min, ptsq_max)

    #incoherent parametrization
    bval = RooRealVar("bval", "bval", 3.3, 0, 10)
    inc_form = "log(10.)*pow(10.,logPtSq)*exp(-bval*pow(10.,logPtSq))"
    incpdf = RooGenericPdf("incpdf", inc_form, RooArgList(logPtSq, bval))

    #make the incoherent fit
    res = incpdf.fitTo(data, rf.Range("fitran"), rf.Save())

    #get incoherent norm to the number of events
    lset = RooArgSet(logPtSq)
    iinc = incpdf.createIntegral(lset, rf.NormSet(lset), rf.Range("fitran"))
    inc_nevt = data.sumEntries("logPtSq", "fitran")
    incpdf.setNormRange("fitran")
    aval = RooRealVar("aval", "aval", inc_nevt / incpdf.getNorm(lset))
    #print "A =", aval.getVal()
    #print "b =", bval.getVal()

    #incoherent distribution from log_10(pT^2) function for the sum with gamma-gamma
    hIncPdf = ut.prepare_TH1D_n("hGG", nbins, ptmin, ptmax)
    func_incoh_logPt2 = TF1("func_incoh_logPt2",
                            "[0]*log(10.)*pow(10.,x)*exp(-[1]*pow(10.,x))",
                            -10., 10.)
    func_incoh_logPt2.SetNpx(1000)
    func_incoh_logPt2.SetLineColor(rt.kMagenta)
    func_incoh_logPt2.SetParameters(
        aval.getVal(),
        bval.getVal())  # 4.9 from incoherent mc, 3.3 from data fit
    ut.fill_h1_tf(hIncPdf, func_incoh_logPt2, rt.kMagenta)

    #gamma-gamma contribution
    hGG = ut.prepare_TH1D_n("hGG", nbins, ptmin, ptmax)
    tree_gg.Draw(logPtSq_draw + " >> hGG", strsel)
    ut.norm_to_num(hGG, ngg, rt.kGreen + 1)

    #sum of incoherent distribution and gamma-gamma
    hSumIncGG = ut.prepare_TH1D_n("hSumIncGG", nbins, ptmin, ptmax)
    hSumIncGG.Add(hIncPdf)
    hSumIncGG.Add(hGG)
    ut.line_h1(hSumIncGG, rt.kMagenta)

    #gamma-gamma in pT^2
    hGG_ptsq = ut.prepare_TH1D_n("hGG_ptsq", ptsq_nbins, ptsq_min, ptsq_max)
    tree_gg.Draw(ptsq_draw + " >> hGG_ptsq", strsel)
    ut.norm_to_num(hGG_ptsq, ngg, rt.kGreen + 1)

    #psi' contribution
    psiP_file = TFile.Open(basedir_mc + "/ana_slight14e4x1_s6_sel5z.root")
    psiP_tree = psiP_file.Get("jRecTree")
    hPsiP = ut.prepare_TH1D_n("hPsiP", nbins, ptmin, ptmax)
    psiP_tree.Draw(logPtSq_draw + " >> hPsiP", strsel)
    ut.norm_to_num(hPsiP, npsiP, rt.kViolet)

    #psi' in pT^2
    hPsiP_ptsq = ut.prepare_TH1D_n("hPsiP_ptsq", ptsq_nbins, ptsq_min,
                                   ptsq_max)
    psiP_tree.Draw(ptsq_draw + " >> hPsiP_ptsq", strsel)
    ut.norm_to_num(hPsiP_ptsq, npsiP, rt.kViolet)

    #create canvas frame
    gStyle.SetPadTickY(1)
    can = ut.box_canvas(1086, 543)  # square area is still 768^2
    can.SetMargin(0, 0, 0, 0)
    can.Divide(2, 1, 0, 0)
    gStyle.SetLineWidth(1)

    can.cd(1)
    ut.set_margin_lbtr(gPad, 0.11, 0.1, 0.01, 0)

    frame = logPtSq.frame(rf.Bins(nbins))
    frame.SetTitle("")
    frame.SetMaximum(80)

    frame.SetYTitle("Events / ({0:.3f}".format(ptbin) + " GeV^{2})")
    frame.SetXTitle("log_{10}( #it{p}_{T}^{2} ) (GeV^{2})")

    frame.GetXaxis().SetTitleOffset(1.2)
    frame.GetYaxis().SetTitleOffset(1.6)

    #plot the data
    data.plotOn(frame, rf.Name("data"), rf.LineWidth(2))

    #incoherent parametrization
    incpdf.plotOn(frame, rf.Range("fitran"), rf.LineColor(rt.kRed),
                  rf.Name("incpdf"), rf.LineWidth(2))
    incpdf.plotOn(frame, rf.Range("plotran"), rf.LineColor(rt.kRed),
                  rf.Name("incpdf_full"), rf.LineStyle(rt.kDashed),
                  rf.LineWidth(2))

    frame.Draw()

    #add gamma-gamma contribution
    hGG.Draw("same")

    #sum of incoherent distribution and gamma-gamma
    #hSumIncGG.Draw("same")

    #add psi'
    #hPsiP.Draw("same")

    #legend for log_10(pT^2)
    leg = ut.prepare_leg(0.15, 0.77, 0.28, 0.19, 0.035)
    hxl = ut.prepare_TH1D("hxl", 1, 0, 1)
    hxl.Draw("same")
    ilin = ut.col_lin(rt.kRed, 2)
    ilin2 = ut.col_lin(rt.kRed, 2)
    ilin2.SetLineStyle(rt.kDashed)
    leg.AddEntry(ilin, "Incoherent parametrization, fit region", "l")
    leg.AddEntry(ilin2, "Incoherent parametrization, extrapolation region",
                 "l")
    leg.AddEntry(hGG, "#gamma#gamma#rightarrow e^{+}e^{-}", "l")
    #leg.AddEntry(hxl, "Data", "lp")
    leg.AddEntry(hxl, "Data, log_{10}( #it{p}_{T}^{2} )", "lp")
    leg.Draw("same")

    #----- plot pT^2 on the right -----

    #pT^2 variable from pT
    ptsq_form = RooFormulaVar("ptsq", "ptsq", ptsq_draw, RooArgList(pT))
    ptsq = data.addColumn(ptsq_form)

    #range for pT^2 plot
    ptsq.setMin(ptsq_min)
    ptsq.setMax(ptsq_max)

    #make the pT^2 plot
    can.cd(2)
    gPad.SetLogy()
    #gPad.SetLineWidth(3)
    #gPad.SetFrameLineWidth(1)
    ut.set_margin_lbtr(gPad, 0, 0.1, 0.01, 0.15)

    ptsq_frame = ptsq.frame(rf.Bins(ptsq_nbins), rf.Title(""))

    #print type(ptsq_frame), type(ptsq)

    ptsq_frame.SetTitle("")

    ptsq_frame.SetXTitle("#it{p}_{T}^{2} (GeV^{2})")
    ptsq_frame.GetXaxis().SetTitleOffset(1.2)

    data.plotOn(ptsq_frame, rf.Name("data"), rf.LineWidth(2))

    ptsq_frame.SetMaximum(9e2)
    ptsq_frame.SetMinimum(0.8)  # 0.101

    ptsq_frame.Draw()

    #incoherent parametrization in pT^2 over the fit region, scaled to the plot
    inc_ptsq = TF1("inc_ptsq", "[0]*exp(-[1]*x)", 10**fitran[0], 10**fitran[1])
    inc_ptsq.SetParameters(aval.getVal() * ptsq_bin, bval.getVal())

    #incoherent parametrization in the extrapolation region, below and above the fit region
    inc_ptsq_ext1 = TF1("inc_ptsq_ext1", "[0]*exp(-[1]*x)", 0., 10**fitran[0])
    inc_ptsq_ext2 = TF1("inc_ptsq_ext2", "[0]*exp(-[1]*x)", 10**fitran[1], 10)
    inc_ptsq_ext1.SetParameters(aval.getVal() * ptsq_bin, bval.getVal())
    inc_ptsq_ext1.SetLineStyle(rt.kDashed)
    inc_ptsq_ext2.SetParameters(aval.getVal() * ptsq_bin, bval.getVal())
    inc_ptsq_ext2.SetLineStyle(rt.kDashed)

    inc_ptsq.Draw("same")
    inc_ptsq_ext1.Draw("same")
    inc_ptsq_ext2.Draw("same")

    #add gamma-gamma in pT^2
    hGG_ptsq.Draw("same")

    #add psi' in pT^2
    #hPsiP_ptsq.Draw("same")

    #redraw the frame
    #ptsq_frame.Draw("same")

    ptsq_frame.GetXaxis().SetLimits(-9e-3, ptsq_frame.GetXaxis().GetXmax())

    #vertical axis for pT^2 plot
    xpos = ptsq_frame.GetXaxis().GetXmax()
    ypos = ptsq_frame.GetMaximum()
    ymin = ptsq_frame.GetMinimum()

    ptsq_axis = TGaxis(xpos, 0, xpos, ypos, ymin, ypos, 510, "+GL")
    ut.set_axis(ptsq_axis)
    ptsq_axis.SetMoreLogLabels()

    ptsq_axis.SetTitle("Events / ({0:.3f}".format(ptsq_bin) + " GeV^{2})")
    ptsq_axis.SetTitleOffset(2.2)

    ptsq_axis.Draw()

    #legend for input data
    #dleg = ut.prepare_leg(0.4, 0.77, 0.14, 0.18, 0.035)
    dleg = ut.prepare_leg(0.4, 0.71, 0.16, 0.24, 0.035)
    dleg.AddEntry(None, "#bf{|#kern[0.3]{#it{y}}| < 1}", "")
    ut.add_leg_mass(dleg, mmin, mmax)
    dleg.AddEntry(None, "AuAu@200 GeV", "")
    dleg.AddEntry(None, "UPC sample", "")
    dleg.AddEntry(hxl, "Data, #it{p}_{T}^{2}", "lp")
    dleg.Draw("same")

    #ut.invert_col_can(can)
    can.SaveAs("01fig.pdf")
Beispiel #7
0
    strsel = "jRecM>{0:.3f} && jRecM<{1:.3f}".format(mmin, mmax)

    tree.Draw("jRecPt*jRecPt >> hPt", strsel)
    tree_gg.Draw("jRecPt*jRecPt >> hPtGG", strsel)

    #incoherent functional shape
    func_incoh_pt2 = TF1("func_incoh", "[0]*exp(-[1]*x)", 0., 10.)
    func_incoh_pt2.SetParameters(873.04, 3.28)

    #fill incoherent histogram from functional shape
    #hPtIncoh = ut.prepare_TH1D("hPtIncoh", ptbin, ptmin, ptmax)
    hPtIncoh = ut.prepare_TH1D_vec("hPtIncoh", bins)
    ut.fill_h1_tf(hPtIncoh, func_incoh_pt2, rt.kRed)

    #normalize gamma-gamma component
    ut.norm_to_num(hPtGG, ngg, rt.kGreen)

    #subtract gamma-gamma and incoherent components
    hPt.Sumw2()
    hPt.Add(hPtGG, -1)
    hPt.Add(hPtIncoh, -1)

    #scale the luminosity
    lumi_scaled = lumi * ratio_ana * ratio_zdc_vtx
    print "lumi_scaled:", lumi_scaled

    #deconvolution
    #deconv_min = bins[0]
    #deconv_max = bins[bins.size()-1]
    #deconv_nbin = bins.size()-1
    #response = RooUnfoldResponse(deconv_nbin, deconv_min, deconv_max, deconv_nbin/2, deconv_min, deconv_max)
Beispiel #8
0
def main():

    gROOT.SetBatch()

    #range for |t|
    ptmin = 0.
    ptmax = 0.109  #   0.109  0.01 for interference range

    #default binning
    ptbin = 0.004  # 0.004  0.0005 for interference range

    #long bins at high |t|
    ptmid = 0.06  # 0.08, value > ptmax will switch it off   0.06
    ptlon = 0.01  # 0.01

    #short bins at low |t|
    ptlow = 0.01
    ptshort = 0.0005

    #mass interval
    mmin = 2.8
    mmax = 3.2

    #dy = 2. # rapidity interval, for integrated sigma
    dy = 1.

    ngg = 131  # number of gamma-gamma from mass fit

    lumi = 13871.907  # lumi in inv. ub

    #correction to luminosity for ana/triggered events
    ratio_ana = 3420950. / 3694000

    #scale the lumi for |z| around nominal bunch crossing
    ratio_zdc_vtx = 0.502

    Reta = 0.503  # pseudorapidity preselection
    #Reta = 1.

    trg_eff = 0.67  # bemc trigger efficiency

    ratio_tof = 1.433  # tof correction to efficiency

    bbceff = 0.97  # BBC veto inefficiency

    zdc_acc = 0.49  # ZDC acceptance to XnXn 0.7
    #zdc_acc = 1.

    br = 0.05971  # dielectrons branching ratio

    #data
    basedir = "../../../star-upc-data/ana/muDst/muDst_run1/sel5"
    infile = "ana_muDst_run1_all_sel5z.root"

    #MC
    basedir_sl = "../../../star-upc-data/ana/starsim/slight14e/sel5"
    #infile_sl = "ana_slight14e1x2_s6_sel5z.root"
    infile_sl = "ana_slight14e1x3_s6_sel5z.root"
    #
    basedir_sart = "../../../star-upc-data/ana/starsim/sartre14a/sel5"
    infile_sart = "ana_sartre14a1_sel5z_s6_v2.root"
    #
    basedir_bgen = "../../../star-upc-data/ana/starsim/bgen14a/sel5"
    infile_bgen = "ana_bgen14a1_v0_sel5z_s6.root"
    #infile_bgen = "ana_bgen14a2_sel5z_s6.root"
    #
    basedir_gg = "../../../star-upc-data/ana/starsim/slight14e/sel5"
    infile_gg = "ana_slight14e2x1_sel5_nzvtx.root"

    #model predictions
    gSlight = load_starlight(dy)
    gSartre = load_sartre()
    gFlat = loat_flat_pt2()
    gMS = load_ms()
    gCCK = load_cck()

    #open the inputs
    inp = TFile.Open(basedir + "/" + infile)
    tree = inp.Get("jRecTree")
    #
    inp_gg = TFile.Open(basedir_gg + "/" + infile_gg)
    tree_gg = inp_gg.Get("jRecTree")
    #
    inp_sl = TFile.Open(basedir_sl + "/" + infile_sl)
    tree_sl_gen = inp_sl.Get("jGenTree")
    #
    inp_sart = TFile.Open(basedir_sart + "/" + infile_sart)
    tree_sart_gen = inp_sart.Get("jGenTree")
    #
    inp_bgen = TFile.Open(basedir_bgen + "/" + infile_bgen)
    tree_bgen_gen = inp_bgen.Get("jGenTree")

    #evaluate binning
    #print "bins:", ut.get_nbins(ptbin, ptmin, ptmax)

    bins = ut.get_bins_vec_2pt(ptbin, ptlon, ptmin, ptmax, ptmid)
    #bins = ut.get_bins_vec_3pt(ptshort, ptbin, ptlon, ptmin, ptmax, ptlow, ptmid)
    #print "bins2:", bins.size()-1

    #load the data
    strsel = "jRecM>{0:.3f} && jRecM<{1:.3f}".format(mmin, mmax)

    hPt = ut.prepare_TH1D_vec("hPt", bins)
    tree.Draw("jRecPt*jRecPt >> hPt", strsel)

    #distribution for bin centers
    hPtCen = hPt.Clone("hPtCen")

    #gamma-gamma component
    hPtGG = ut.prepare_TH1D_vec("hPtGG", bins)
    tree_gg.Draw("jRecPt*jRecPt >> hPtGG", strsel)

    #normalize the gamma-gamma component
    ut.norm_to_num(hPtGG, ngg, rt.kGreen)

    #incoherent functional shape
    func_incoh_pt2 = TF1("func_incoh", "[0]*exp(-[1]*x)", 0., 10.)
    func_incoh_pt2.SetParameters(873.04, 3.28)

    #fill incoherent histogram from functional shape
    hPtIncoh = ut.prepare_TH1D_vec("hPtIncoh", bins)
    ut.fill_h1_tf(hPtIncoh, func_incoh_pt2, rt.kRed)

    #print "Entries before gamma-gamma and incoherent subtraction:", hPt.GetEntries()

    #subtract gamma-gamma and incoherent components
    hPt.Sumw2()
    hPt.Add(hPtGG, -1)
    #print "Gamma-gamma entries:", hPtGG.Integral()
    #print "Entries after gamma-gamma subtraction:", hPt.Integral()
    #print "Incoherent entries:", hPtIncoh.Integral()
    hPt.Add(hPtIncoh, -1)

    #print "Entries after all subtraction:", hPt.Integral()

    #scale the luminosity
    lumi_scaled = lumi * ratio_ana * ratio_zdc_vtx
    #print "lumi_scaled:", lumi_scaled

    #denominator for deconvoluted distribution, conversion ub to mb
    den = Reta * br * zdc_acc * trg_eff * bbceff * ratio_tof * lumi_scaled * 1000. * dy

    #deconvolution
    deconv_min = bins[0]
    deconv_max = bins[bins.size() - 1]
    deconv_nbin = bins.size() - 1
    gROOT.LoadMacro("fill_response_matrix.C")

    #Starlight response
    #resp_sl = RooUnfoldResponse(deconv_nbin, deconv_min, deconv_max, deconv_nbin, deconv_min, deconv_max)
    resp_sl = RooUnfoldResponse(hPt, hPt)
    rt.fill_response_matrix(tree_sl_gen, resp_sl)
    #
    unfold_sl = RooUnfoldBayes(resp_sl, hPt, 15)
    #unfold_sl = RooUnfoldSvd(resp_sl, hPt, 15)
    hPtSl = unfold_sl.Hreco()
    #ut.set_H1D(hPtSl)
    #apply the denominator and bin width
    ut.norm_to_den_w(hPtSl, den)

    #Sartre response
    #resp_sart = RooUnfoldResponse(deconv_nbin, deconv_min, deconv_max, deconv_nbin, deconv_min, deconv_max)
    #resp_sart = RooUnfoldResponse(hPt, hPt)
    #rt.fill_response_matrix(tree_sart_gen, resp_sart)
    #
    #unfold_sart = RooUnfoldBayes(resp_sart, hPt, 10)
    #hPtSart = unfold_sart.Hreco()
    #ut.set_H1D(hPtSart)
    #hPtSart.SetMarkerStyle(21)

    #Flat pT^2 response
    #resp_bgen = RooUnfoldResponse(deconv_nbin, deconv_min, deconv_max, deconv_nbin, deconv_min, deconv_max)
    resp_bgen = RooUnfoldResponse(hPt, hPt)
    rt.fill_response_matrix(tree_bgen_gen, resp_bgen)
    #
    unfold_bgen = RooUnfoldBayes(resp_bgen, hPt, 14)
    hPtFlat = unfold_bgen.Hreco()
    #ut.set_H1D(hPtFlat)
    #apply the denominator and bin width
    ut.norm_to_den_w(hPtFlat, den)
    #hPtFlat.SetMarkerStyle(22)
    #hPtFlat.SetMarkerSize(1.3)

    #systematical errors
    err_zdc_acc = 0.1
    err_bemc_eff = 0.03
    #sys_err = rt.TMath.Sqrt(err_zdc_acc*err_zdc_acc + err_bemc_eff*err_bemc_eff)
    sys_err = err_zdc_acc * err_zdc_acc + err_bemc_eff * err_bemc_eff
    #print "Total sys err:", sys_err
    hSys = ut.prepare_TH1D_vec("hSys", bins)
    hSys.SetOption("E2")
    hSys.SetFillColor(rt.kOrange + 1)
    hSys.SetLineColor(rt.kOrange)
    for ibin in xrange(1, hPtFlat.GetNbinsX() + 1):
        hSys.SetBinContent(ibin, hPtFlat.GetBinContent(ibin))
        sig_sl = hPtSl.GetBinContent(ibin)
        sig_fl = hPtFlat.GetBinContent(ibin)
        err_deconv = TMath.Abs(sig_fl - sig_sl) / sig_fl
        #print "err_deconv", err_deconv
        #sys_err += err_deconv*err_deconv
        sys_err_sq = sys_err + err_deconv * err_deconv
        sys_err_bin = TMath.Sqrt(sys_err_sq)
        stat_err = hPtFlat.GetBinError(ibin) / hPtFlat.GetBinContent(ibin)
        tot_err = TMath.Sqrt(stat_err * stat_err + sys_err_sq)
        #hSys.SetBinError(ibin, hPtFlat.GetBinContent(ibin)*err_deconv)
        hSys.SetBinError(ibin, hPtFlat.GetBinContent(ibin) * sys_err_bin)
        #hPtFlat.SetBinError(ibin, hPtFlat.GetBinContent(ibin)*tot_err)

    #draw the results
    gStyle.SetPadTickX(1)
    gStyle.SetFrameLineWidth(2)

    #frame for models plot only
    frame = ut.prepare_TH1D("frame", ptbin, ptmin, ptmax)

    can = ut.box_canvas()
    #ut.set_margin_lbtr(gPad, 0.1, 0.09, 0.03, 0.03)
    ut.set_margin_lbtr(gPad, 0.1, 0.09, 0.055, 0.01)

    ytit = "d#it{#sigma}/d#it{t}d#it{y} (mb/(GeV/c)^{2})"
    xtit = "|#kern[0.3]{#it{t}}| ((GeV/c)^{2})"

    ut.put_yx_tit(frame, ytit, xtit, 1.4, 1.2)
    frame.SetMaximum(11)
    #frame.SetMinimum(1.e-6)
    #frame.SetMinimum(2e-4)
    frame.SetMinimum(1e-5)  # 3e-5
    frame.Draw()

    #hSys.Draw("e2same")

    #bin center points from data
    #gSig = apply_centers(hPtFlat, hPtCen)
    gSig = fixed_centers(hPtFlat)
    ut.set_graph(gSig)

    #hPtSl.Draw("e1same")
    #hPtSart.Draw("e1same")
    #hPtFlat.Draw("e1same")

    #put model predictions
    #gSartre.Draw("lsame")
    #gFlat.Draw("lsame")
    gMS.Draw("lsame")
    gCCK.Draw("lsame")
    gSlight.Draw("lsame")

    gSig.Draw("P")

    frame.Draw("same")

    gPad.SetLogy()

    cleg = ut.prepare_leg(0.1, 0.96, 0.14, 0.01, 0.035)
    cleg.AddEntry(
        None,
        "Au+Au #rightarrow J/#psi + Au+Au + XnXn, #sqrt{#it{s}_{#it{NN}}} = 200 GeV",
        "")
    cleg.Draw("same")

    leg = ut.prepare_leg(0.45, 0.82, 0.18, 0.1, 0.035)
    leg.AddEntry(None, "#bf{|#kern[0.3]{#it{y}}| < 1}", "")
    hx = ut.prepare_TH1D("hx", 1, 0, 1)
    leg.AddEntry(hx, "STAR")
    hx.Draw("same")
    leg.Draw("same")

    #legend for models
    mleg = ut.prepare_leg(0.68, 0.76, 0.3, 0.16, 0.035)
    #mleg = ut.prepare_leg(0.68, 0.8, 0.3, 0.12, 0.035)
    mleg.AddEntry(gSlight, "STARLIGHT", "l")
    mleg.AddEntry(gMS, "MS", "l")
    mleg.AddEntry(gCCK, "CCK-hs", "l")
    #mleg.AddEntry(gSartre, "Sartre", "l")
    #mleg.AddEntry(gFlat, "Flat #it{p}_{T}^{2}", "l")
    mleg.Draw("same")

    #legend for deconvolution method
    dleg = ut.prepare_leg(0.3, 0.75, 0.2, 0.18, 0.035)
    #dleg = ut.prepare_leg(0.3, 0.83, 0.2, 0.1, 0.035)
    dleg.AddEntry(None, "Unfolding with:", "")
    dleg.AddEntry(hPtSl, "Starlight", "p")
    #dleg.AddEntry(hPtSart, "Sartre", "p")
    dleg.AddEntry(hPtFlat, "Flat #it{p}_{T}^{2}", "p")
    #dleg.Draw("same")

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")

    #to prevent 'pure virtual method called'
    gPad.Close()

    #save the cross section to output file
    out = TFile("sigma.root", "recreate")
    gSig.Write("sigma")
    out.Close()

    #beep when finished
    gSystem.Exec("mplayer ../computerbeep_1.mp3 > /dev/null 2>&1")