Exemplo n.º 1
0
def plot_vtx_z():

    #primary vertex position along z from data and MC
    vbin = 4.
    vmax = 120.

    mmin = 1.5
    mmax = 5

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

    can = ut.box_canvas()

    hVtx = ut.prepare_TH1D("hVtx", vbin, -vmax, vmax)
    hVtxMC = ut.prepare_TH1D("hVtxMC", vbin/2., -vmax, vmax)

    tree.Draw("jVtxZ >> hVtx", strsel)
    mctree.Draw("jVtxZ >> hVtxMC", strsel)
    ut.norm_to_data(hVtxMC, hVtx, rt.kBlue, -40, 40)

    hVtx.SetYTitle("Counts / {0:.0f} cm".format(vbin));
    hVtx.SetXTitle("#it{z} of primary vertex (cm)");

    hVtx.SetTitleOffset(1.5, "Y")
    hVtx.SetTitleOffset(1.3, "X")

    gPad.SetTopMargin(0.02)
    gPad.SetRightMargin(0.02)
    gPad.SetBottomMargin(0.1)
    gPad.SetLeftMargin(0.11)

    cut_lo = ut.cut_line(-30, 0.8, hVtx)
    cut_hi = ut.cut_line(30, 0.8, hVtx)

    leg = ut.prepare_leg(0.16, 0.82, 0.26, 0.12, 0.025)
    #leg.SetMargin(0.15)
    #leg.SetBorderSize(1)
    ut.add_leg_mass(leg, mmin, mmax)
    leg.AddEntry(hVtx, "Data")
    #leg.AddEntry(hVtxMC, "MC, coherent J/#it{#psi}", "l")
    leg.AddEntry(hVtxMC, "MC, #it{#gamma}#it{#gamma} #rightarrow e^{+}e^{-}", "l")
    leg.AddEntry(cut_lo, "Cut at #pm30 cm", "l")

    hVtx.Draw()
    hVtxMC.Draw("same")
    leg.Draw("same")
    cut_lo.Draw("same")
    cut_hi.Draw("same")

    #ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Exemplo n.º 2
0
def plot_east():

    zmin = 0
    zbin = 10
    zmax = 400

    can = ut.box_canvas()

    hZdc = ut.prepare_TH1D("hZdc", zbin, zmin, zmax)

    tree.Draw("jZDCUnAttEast >> hZdc")

    ut.set_margin_lbtr(gPad, 0.1, 0.08, 0.01, 0.04)
    ut.put_yx_tit(hZdc, "ZDC East", "ADC")

    #middle point from 1n and 2n positions, dl-202011.03
    mid_1n2n = (164.996 + 75.671) / 2
    print("mid_1n2n:", mid_1n2n)

    lin = ut.cut_line(mid_1n2n, 0.7, hZdc)

    gF = make_FastZDC("jZDCUnAttEast", hZdc)

    hZdc.Draw()
    gF.Draw("same")
    hZdc.Draw("e1same")
    lin.Draw("same")

    gPad.SetGrid()
    #gPad.SetLogy()

    ut.invert_col(gPad)
    can.SaveAs("01fig.pdf")
Exemplo n.º 3
0
def plot_dphi_bemc():

    #tracks opening angle at BEMC
    phibin = 0.01
    phimin = 2.4
    phimax = 3.1

    mmin = 1.5
    mmax = 5
    #mmin = 2.8
    #mmax = 3.2

    ptmax = 0.17

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

    can = ut.box_canvas()

    hDphi = ut.prepare_TH1D("hDphi", phibin, phimin, phimax)
    hDphiMC = ut.prepare_TH1D("hDphiMC", phibin, phimin, phimax)

    ut.put_yx_tit(hDphi, "Events / {0:.2f}".format(phibin),
                  "Tracks #Delta#phi at BEMC")
    ut.put_yx_tit(hDphiMC, "Events / {0:.2f}".format(phibin),
                  "Tracks #Delta#phi at BEMC")

    ut.set_margin_lbtr(gPad, 0.1, 0.08, 0.014, 0.01)

    tree.Draw("jDeltaPhiBemc >> hDphi", strsel)
    mctree.Draw("jDeltaPhiBemc >> hDphiMC", strsel)
    ut.norm_to_data(hDphiMC, hDphi, rt.kBlue)

    hDphiMC.Draw()
    hDphi.Draw("e1same")
    #hDphi.Draw()
    hDphiMC.Draw("same")

    lin = ut.cut_line(2.618, 0.5, hDphi)
    lin.Draw("same")

    leg = ut.prepare_leg(0.14, 0.71, 0.14, 0.21, 0.03)
    ut.add_leg_pt_mass(leg, ptmax, mmin, mmax)
    leg.AddEntry(hDphi, "Data")
    leg.AddEntry(hDphiMC, "MC", "l")
    leg.AddEntry(lin, "Cut at 2.618", "l")
    leg.Draw("same")

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

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Exemplo n.º 4
0
def fit_pt_incoh():

    #fit to incoherent MC pT

    ptbin = 0.015
    #ptbin = math.sqrt(0.005)
    ptmin = 0.
    ptmax = 1.4

    mmin = 2.8
    mmax = 3.2

    fitran = [0.4, 1.]

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

    can = ut.box_canvas()

    hPtIncoh = ut.prepare_TH1D("hPtIncoh", ptbin, ptmin, ptmax)
    ut.put_yx_tit(hPtIncoh, "Events / ({0:.3f}".format(ptbin) + " GeV)",
                  "#it{p}_{T} (GeV)")

    tree_incoh.Draw("jRecPt >> hPtIncoh", strsel)

    print "Input events:", hPtIncoh.GetEntries()
    print "Histogram integral:", hPtIncoh.Integral()
    print "Histogram integral (w):", hPtIncoh.Integral("width")

    #hPtIncoh.Sumw2()
    #hPtIncoh.Scale(1./hPtIncoh.Integral("width"))

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

    func_incoh = TF1("func_incoh", "2*[0]*x*exp(-[1]*x*x)", 0., 10.)
    func_incoh.SetParName(0, "A")
    func_incoh.SetParName(1, "b")
    func_incoh.SetNpx(1000)
    func_incoh.SetLineColor(rt.kRed)

    func_incoh.SetParameters(3000., 5.)

    r1 = (hPtIncoh.Fit(func_incoh, "RS", "", fitran[0], fitran[1])).Get()

    print "Fit integral:", func_incoh.Integral(0., 10.)

    hPtIncoh.Draw()
    func_incoh.Draw("same")

    #normalize fit function to number of events
    pdf_incoh = TF1("pdf_incoh", "2*[0]*x*exp(-[1]*x*x)", 0., 10.)
    pdf_incoh.SetParName(0, "A")
    pdf_incoh.SetParName(1, "b")
    #    tree_incoh.Draw("jRecPt >> hPtIncoh", strsel)
    #strsel = "jRecM>{0:.3f} && jRecM<{1:.3f}".format(mmin, mmax)
    nevt = tree_incoh.Draw(
        "", strsel +
        " && jRecPt>{0:.3f} && jRecPt<{1:.3f}".format(fitran[0], fitran[1]))
    k_norm = nevt / func_incoh.Integral(fitran[0], fitran[1])
    pdf_incoh.SetParameter(0, k_norm * func_incoh.GetParameter(0))
    pdf_incoh.SetParameter(1, func_incoh.GetParameter(1))
    #verify the normalization:
    print "Function integral after norm:", pdf_incoh.Integral(0., 10.)

    #create pdf for pT^2 and verify normalization
    pdf_pt2 = TF1("pdf_pt2", "[0]*exp(-[1]*x)", 0., 10.)
    pdf_pt2.SetParameter(0, pdf_incoh.GetParameter(0))
    pdf_pt2.SetParameter(1, pdf_incoh.GetParameter(1))
    print "PDF for pT^2 integral:", pdf_pt2.Integral(0., 10.)

    leg = ut.prepare_leg(0.67, 0.84, 0.14, 0.12, 0.03)
    ut.add_leg_mass(leg, mmin, mmax)
    leg.AddEntry(hPtIncoh, "Incoherent MC")
    leg.AddEntry(func_incoh, "2#it{A}*#it{p}_{T}exp(-#it{b}*#it{p}_{T}^{2})",
                 "l")
    leg.Draw("same")

    desc = pdesc(hPtIncoh, 0.72, 0.84, 0.057)
    desc.set_text_size(0.03)
    desc.itemD("#chi^{2}/ndf", r1.Chi2() / r1.Ndf(), -1, rt.kRed)
    desc.prec = 2
    desc.itemRes("#it{A}", r1, 0, rt.kRed)
    desc.itemD("#it{A}", pdf_incoh.GetParameter(0), -1, rt.kRed)
    desc.prec = 3
    desc.itemRes("#it{b}", r1, 1, rt.kRed)
    desc.draw()

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

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

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Exemplo n.º 5
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")
Exemplo n.º 6
0
def fit_logPt2_incoh():

    #fit to incoherent log_10(pT^2)

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

    mmin = 2.8
    mmax = 3.2

    fitran = [-1., -0.1]

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

    can = ut.box_canvas()

    hPtIncoh = ut.prepare_TH1D("hPtIncoh", ptbin / 3., ptmin, ptmax)

    ut.put_yx_tit(hPtIncoh, "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)

    draw = "TMath::Log10(jRecPt*jRecPt)"
    tree_incoh.Draw(draw + " >> hPtIncoh", strsel)

    #hPtIncoh.Sumw2()
    #hPtIncoh.Scale(1./hPtIncoh.Integral("width"))

    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(3000., 5.)

    r1 = (hPtIncoh.Fit(func_incoh_logPt2, "RS", "", fitran[0],
                       fitran[1])).Get()

    #create pdf normalized to number of events
    pdf_logPt2 = TF1("pdf_logPt2",
                     "[0]*log(10.)*pow(10.,x)*exp(-[1]*pow(10.,x))", -10., 10.)
    nevt = tree_incoh.Draw(
        "", strsel + " && " + draw + ">{0:.3f}".format(fitran[0]) + " && " +
        draw + "<{1:.3f}".format(fitran[0], fitran[1]))
    k_norm = nevt / func_incoh_logPt2.Integral(fitran[0], fitran[1])
    pdf_logPt2.SetParameter(0, k_norm * func_incoh_logPt2.GetParameter(0))
    pdf_logPt2.SetParameter(1, func_incoh_logPt2.GetParameter(1))
    #verify the normalization:
    print "PDF integral", pdf_logPt2.Integral(-10., 10.)

    hPtIncoh.Draw()
    func_incoh_logPt2.Draw("same")

    leg = ut.prepare_leg(0.18, 0.78, 0.14, 0.15, 0.03)
    ut.add_leg_mass(leg, mmin, mmax)
    leg.AddEntry(hPtIncoh, "Incoherent MC")
    leg.AddEntry(
        func_incoh_logPt2,
        "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")

    desc = pdesc(hPtIncoh, 0.18, 0.78, 0.057)
    desc.set_text_size(0.03)
    desc.itemD("#chi^{2}/ndf", r1.Chi2() / r1.Ndf(), -1, rt.kRed)
    desc.itemRes("#it{A}", r1, 0, rt.kRed)
    desc.itemD("#it{A}", pdf_logPt2.GetParameter(0), -1, rt.kRed)
    desc.itemRes("#it{b}", r1, 1, rt.kRed)
    desc.draw()

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

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

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Exemplo n.º 7
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")
Exemplo n.º 8
0
    desc.itemR("#sigma", sig, ccb)
    if alphafix > 0.:
        desc.itemD("#alpha", alpha.getVal(), -1, ccb)
    else:
        desc.itemR("#alpha", alpha, ccb)
    if nfix > 0.:
        desc.itemD("#it{n}", n.getVal(), -1, ccb)
    else:
        desc.itemR("#it{n}", n, ccb)
    desc.itemR("#lambda", lam, cbkg)
    desc.itemR("#it{c}_{1}", c1, cbkg)
    desc.itemR("#it{c}_{2}", c2, cbkg)
    desc.draw()

    #integration range
    lin_lo = ut.cut_line(intran[0], 0.33, frame)
    lin_hi = ut.cut_line(intran[1], 0.33, frame)
    lin_lo.Draw("same")
    lin_hi.Draw("same")

    #integration result
    desc2 = pdesc(frame, 0.8, 0.6, 0.045)
    desc2.prec = 0
    #igg_desc = "#int_{#it{m} = %.1f}^{#it{m} = %.1f}#it{f}_{#gamma#gamma}" % (intran[0], intran[1])
    #igg_desc = "#it{n}_{#gamma#gamma,#it{J}/#psi} = #int_{%.1f}^{%.1f}#color[2]{#it{f}_{#gamma#gamma}}" % (intran[0], intran[1])
    #igg_desc = "#it{n}_{#gamma#gamma,lo} = #int_{%.1f}^{%.1f}#color[2]{#it{f}_{#gamma#gamma}}" % (intran[0], intran[1])
    igg_desc = "#it{n}_{#gamma#gamma,hi} = #int_{%.1f}^{%.1f}#color[2]{#it{f}_{#gamma#gamma}}" % (intran[0], intran[1])
    #desc2.itemD(igg_desc, intBkg.getVal(), intBkg.getError(), cbkg)
    desc2.itemD(igg_desc, intBkg.getVal(), intBkg.getError())
    desc2.draw()
Exemplo n.º 9
0
def z_proj():

    #z projection for primary photons

    #plot range, upper and lower, mm
    zmax = 300
    zbin = 0.5

    inp = TFile.Open("ew.root")
    tree = inp.Get("prim_tree")

    can = ut.box_canvas()

    hZ = ut.prepare_TH1D("hZ", zbin, -zmax, zmax)

    tree.Draw("z >> hZ")
    ut.line_h1(hZ)

    #lines at 250 mrad projected in z for a given aperture tmax in mrad, example: z (mm) = 18644*tan(0.002)/tan(0.25) = 144.9
    z0 = 18644.  # mm, exit window position in z

    #lines for 2 mrad aperture
    tmax = 2.  # mrad, apperture by maximal theta for photons
    zlim = z0 * tan(tmax * 1e-3) / tan(0.25)
    zline = [
        ut.cut_line(zlim, 0.75, hZ, True),
        ut.cut_line(-zlim, 0.75, hZ, True)
    ]
    zline[0].SetLineColor(rt.kRed)
    zline[1].SetLineColor(rt.kRed)
    zline[0].Draw("same")
    zline[1].Draw("same")

    #fraction of events at 2 mrad aperture in z, cross check to the xy projection
    nz = float(tree.Draw("", "TMath::Abs(z)<" + str(zlim)))
    nev = tree.GetEntries()
    print(nz, "{0:.2f}".format(100. * nz / nev))

    #lines at 1 mrad aperture
    tmax = 1.  # mrad, apperture by maximal theta for photons
    zlim = z0 * tan(tmax * 1e-3) / tan(0.25)
    zline2 = [
        ut.cut_line(zlim, 0.75, hZ, True),
        ut.cut_line(-zlim, 0.75, hZ, True)
    ]
    zline2[0].SetLineColor(rt.kOrange)
    zline2[1].SetLineColor(rt.kOrange)
    zline2[0].Draw("same")
    zline2[1].Draw("same")

    #fraction of events at 1 mrad aperture in z, cross check to the xy projection
    nz = float(tree.Draw("", "TMath::Abs(z)<" + str(zlim)))
    print(nz, "{0:.2f}".format(100. * nz / nev))

    ut.put_yx_tit(hZ, "Counts", "#it{z} (mm)")

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

    gPad.SetGrid()

    gPad.SetLogy()

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