예제 #1
0
def tracks_eta():

    #bins in eta
    ebin = 0.2
    emin = -1.2
    emax = 1.2

    hEta = ut.prepare_TH1D("hEta", ebin, emin, emax)
    hEtaMC = ut.prepare_TH1D("hEtaMC", ebin, emin, emax)

    can = ut.box_canvas()

    tree.Draw("jT0eta >> hEta", gsel)
    tree.Draw("jT1eta >>+ hEta", gsel)

    tree_coh.Draw("jT0eta >> hEtaMC", gsel)
    tree_coh.Draw("jT1eta >>+ hEtaMC", gsel)

    ut.norm_to_data(hEtaMC, hEta)

    #gPad.SetLogy()

    hEta.Draw()
    hEtaMC.Draw("same")

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
예제 #2
0
def zdc_east():

    #bins in eta
    xbin = 18
    xmin = 0
    xmax = 1300

    plot = "jZDCUnAttEast"

    hDat = ut.prepare_TH1D("hDat", xbin, xmin, xmax)
    hMC = ut.prepare_TH1D("hMC", xbin, xmin, xmax)

    can = ut.box_canvas()

    tree.Draw(plot + " >> hDat", gsel)
    tree_coh.Draw(plot + " >> hMC", gsel)

    ut.norm_to_data(hMC, hDat)

    #gPad.SetLogy()

    hMC.Draw()
    hDat.Draw("e1same")
    hMC.Draw("same")

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
예제 #3
0
def pT():

    #pT in data and MC

    pbin = 0.015
    pmin = 0.
    pmax = 1.

    hPt = ut.prepare_TH1D("hPt", pbin, pmin, pmax)
    hPtMC = ut.prepare_TH1D("hPtMC", pbin, pmin, pmax)

    can = ut.box_canvas()

    tree.Draw("jRecPt >> hPt", gsel_ym)

    tree_coh.Draw("jRecPt >> hPtMC", gsel_ym)
    #tree_coh.Draw("jGenPt >> hPtMC", gsel_ym)

    ut.norm_to_data(hPtMC, hPt)

    #gPad.SetLogy()

    hPtMC.Draw()
    hPt.Draw("e1same")
    hPtMC.Draw("same")

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
예제 #4
0
def evt_Log10_Q2_ecal_compare():

    #compare log_10(Q^2) from ecal for two separate inputs

    infile1 = "../data/ir6/lmon_pythia_5M_beff2_5Mevt_v2.root"
    #infile2 = "../data/ir6_close/lmon_pythia_5M_beff2_close_5Mevt.root"
    #infile2 = "../data/ir6/lmon_pythia_5M_beff2_1p5T_5Mevt.root"
    infile2 = "../data/ir6/lmon_pythia_5M_beff2_1p5T_5Mevt_v2.root"

    lqbin = 5e-2
    lqmin = -2.5
    lqmax = 2.5

    inp1 = TFile.Open(infile1)
    inp2 = TFile.Open(infile2)
    tree1 = inp1.Get("DetectorTree")
    tree2 = inp2.Get("DetectorTree")

    hQ2ecal = ut.prepare_TH1D("hQ2ecal", lqbin, lqmin, lqmax)
    hQ2ecal_close = ut.prepare_TH1D("hQ2ecal_close", lqbin, lqmin, lqmax)

    tree1.Draw(gL10Q2 + " >> hQ2ecal", "ecal_IsHit==1")
    tree2.Draw(gL10Q2 + " >> hQ2ecal_close", "ecal_IsHit==1")

    print "All events:", hQ2ecal.GetEntries()
    #print "Selected  :", hLog10Q2Tag.GetEntries()

    can = ut.box_canvas()
    frame = gPad.DrawFrame(lqmin, 10, lqmax, 1e5)
    frame.Draw()

    ytit = "Events / {0:.3f}".format(lqbin)
    ut.put_yx_tit(frame, ytit, "log_{10}(#it{Q}^{2})", 1.4, 1.2)

    ut.set_margin_lbtr(gPad, 0.1, 0.1, 0.03, 0.02)

    ut.line_h1(hQ2ecal, rt.kBlue, 3)
    ut.line_h1(hQ2ecal_close, rt.kRed, 3)

    #hQ2ecal.SetMinimum(10)

    gPad.SetLogy()
    gPad.SetGrid()

    hQ2ecal.Draw("e1same")
    hQ2ecal_close.Draw("e1same")

    #hLog10Q2.SetMaximum(2e5) # for qr

    leg = ut.prepare_leg(0.6, 0.83, 0.2, 0.1, 0.035)
    #leg.AddEntry(hLog10Q2, "All electrons from quasi-real photoproduction", "l")
    #leg.AddEntry(hLog10Q2, "All Pythia6 scattered electrons", "l")
    #leg.AddEntry(hLog10Q2Tag, "Electrons hitting the tagger", "l")
    leg.AddEntry(hQ2ecal, "Default geometry", "l")
    #leg.AddEntry(hQ2ecal_close, "Magnets in central det", "l")
    leg.AddEntry(hQ2ecal_close, "1.5T solenoid", "l")
    leg.Draw("same")

    #ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
예제 #5
0
def plot_pt2():

    #pT^2 with coherent incoherent and gamma-gamma components

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

    mmin = 2.8
    mmax = 3.2
    #mmin = 1.5
    #mmax = 2.6

    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 / 3., 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_incoh.Draw(draw + " >> hPtIncoh", strsel)
    tree_gg.Draw(draw + " >> hPtGG", strsel)

    ut.norm_to_data(hPtCoh, hPt, rt.kBlue, 0., 0.015)
    ut.norm_to_data(hPtIncoh, hPt, rt.kRed, 0.05, 0.16)  # 0.3
    ut.norm_to_data(hPtGG, hPt, rt.kGreen, 0., 0.001)

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

    leg = ut.prepare_leg(0.67, 0.78, 0.14, 0.18, 0.03)
    ut.add_leg_mass(leg, mmin, mmax)
    leg.AddEntry(hPt, "Data")
    leg.AddEntry(hPtCoh, "Coherent MC", "l")
    leg.AddEntry(hPtIncoh, "Incoherent MC", "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")
예제 #6
0
def up_down_corrected():

    #energy in spectrometer corrected for the acceptance
    ebin = 0.5
    emin = 1
    emax = 20

    edet = 1

    sel = "up_en>" + str(edet * 1e3) + " && down_en>" + str(edet * 1e3)

    can = ut.box_canvas()

    #sum energy from up and down detectors
    hSum = ut.prepare_TH1D("hSum", ebin, emin, emax)
    tree.Draw("(up_en+down_en)/1000. >> hSum", sel)

    #calculate the acceptance
    hRec = ut.prepare_TH1D("hRec", ebin, emin, emax)
    hGen = ut.prepare_TH1D("hGen", ebin, emin, emax)

    tree.Draw("phot_gen/1000 >> hRec", sel)
    tree.Draw("phot_gen/1000 >> hGen")

    hAcc = hRec.Clone()
    hAcc.Sumw2()
    hAcc.Divide(hGen)

    #apply the acceptance
    hSum.Sumw2()
    for i in xrange(hAcc.GetNbinsX() + 1):
        acc = hAcc.GetBinContent(i)
        if acc > 0.:
            hSum.SetBinContent(i, hSum.GetBinContent(i) / acc)
        else:
            hSum.SetBinContent(i, 0)

    hSum.Draw()

    #cross section parametrization
    sys.path.append('/home/jaroslav/sim/lgen/')
    from gen_zeus import gen_zeus
    gen = gen_zeus(18, 275, emin)
    sig = gen.dSigDe
    sig.SetNpx(300)
    sig.SetLineWidth(3)

    #scale the cross section to the plot
    norm = ebin * hSum.Integral() / sig.Integral(emin, gen.Ee)
    gen.ar2 = norm * gen.ar2

    sig.Draw("same")

    gPad.SetLogy()

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
예제 #7
0
def plot_jpsi_logPt2():

    # log_10(pT^2)

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

    mmin = 2.8
    mmax = 3.2

    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 / 3., ptmin, ptmax)
    hPtIncoh = ut.prepare_TH1D("hPtIncoh", ptbin / 3., ptmin, ptmax)
    hPtGG = ut.prepare_TH1D("hPtGG", 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)

    draw = "TMath::Log10(jRecPt*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, -5., -1.8)  # norm for coh
    ut.norm_to_data(hPtIncoh, hPt, rt.kRed, -1.1, 1.)  # for incoh
    ut.norm_to_data(hPtGG, hPt, rt.kGreen, -5., -2.9)  # for ggel

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

    leg = ut.prepare_leg(0.67, 0.79, 0.14, 0.17, 0.03)
    ut.add_leg_mass(leg, mmin, mmax)
    leg.AddEntry(hPt, "Data")
    leg.AddEntry(hPtCoh, "Coherent MC", "l")
    leg.AddEntry(hPtIncoh, "Incoherent MC", "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")
예제 #8
0
def el_eta_beff():

    #electron pseudorapidity eta and angular divergence

    xbin = 0.1
    xmin = -20
    xmax = 10

    qrpy = 0
    if qrpy == 0:
        tree = tree_qr
        lab_data = "QR"
        col = rt.kBlue
    else:
        tree = tree_py
        lab_data = "Pythia6"
        col = rt.kRed

    can = ut.box_canvas()

    hE = ut.prepare_TH1D("hE", xbin, xmin, xmax)
    hB = ut.prepare_TH1D("hB", xbin, xmin, xmax)

    form = "-TMath::Log(TMath::Tan(true_el_theta/2.))"
    form2 = "-TMath::Log(TMath::Tan(el_theta/2.))"
    tree.Draw(form + " >> hE")
    tree.Draw(form2 + " >> hB")

    ut.line_h1(hE, col)
    ut.line_h1(hB, rt.kViolet)

    vmax = hB.GetMaximum() + 0.1 * hB.GetMaximum()
    frame = gPad.DrawFrame(xmin, 0.5, xmax, vmax)

    ut.put_yx_tit(frame, "Counts", "Electron #eta", 1.6, 1.3)

    frame.Draw()

    ut.set_margin_lbtr(gPad, 0.11, 0.1, 0.05, 0.02)

    gPad.SetGrid()
    #gPad.SetLogy()

    hB.Draw("same")
    hE.Draw("same")

    leg = ut.prepare_leg(0.56, 0.8, 0.24, 0.12, 0.035)  # x, y, dx, dy, tsiz
    leg.AddEntry(hE, lab_data + ", no divergence", "l")
    leg.AddEntry(hB, "Divergence included", "l")
    leg.Draw("same")

    #ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
예제 #9
0
def plot_pt_gg():

    #pT of gamma-gamma below and above J/psi

    ptbin = 0.02
    #ptbin = 0.03
    ptmin = 0.
    ptmax = 1.1

    mmin = 2.1
    mmax = 2.6
    #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)
    hPtGG = ut.prepare_TH1D("hPtGG", ptbin, ptmin, ptmax)

    #ut.put_yx_tit(hPt, "Events / ({0:.3f}".format(ptbin)+" GeV)", "#it{p}_{T} (GeV})")
    ytit = "#gamma#gamma#rightarrow e^{+}e^{-} candidates / " + "({0:.3f}".format(
        ptbin) + " GeV)"
    ut.put_yx_tit(hPt, ytit, "Dielectron #it{p}_{T} (GeV)", 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_gg.Draw(draw + " >> hPtGG", strsel)
    ut.norm_to_data(hPtGG, hPt, rt.kGreen, 0., 0.3)
    #ut.norm_to_data(hPtGG, hPt, rt.kGreen, 0., 0.18)

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

    leg = ut.prepare_leg(0.67, 0.78, 0.14, 0.18, 0.03)
    leg.AddEntry(None, "#bf{|#kern[0.3]{#it{y}}| < 1}", "")
    ut.add_leg_mass(leg, mmin, mmax)
    leg.AddEntry(hPt, "Data")
    leg.AddEntry(hPtGG, "#gamma#gamma#rightarrow e^{+}e^{-}", "l")
    leg.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")
예제 #10
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")
예제 #11
0
def hit_en():

    #hit energy

    infile = "/home/jaroslav/sim/lmon/data/beam-gas/bg3d/rc.root"

    emin = -9
    emax = 9
    ebin = 0.1

    inp = TFile.Open(infile)
    htree = inp.Get("htree")

    #can = ut.box_canvas()

    hE = ut.prepare_TH1D("hE", ebin, emin, emax)
    htree.Draw("TMath::Log10(en*1e6) >> hE", "zpos<150.")
    xp, yp = ut.h1_to_arrays(hE)

    infile2 = "/home/jaroslav/sim/lmon/data/beam-gas/bg3e/rc.root"
    inp2 = TFile.Open(infile2)
    htree2 = inp2.Get("htree")
    hE2 = ut.prepare_TH1D("hE2", ebin, emin, emax)
    htree2.Draw("TMath::Log10(en*1e6) >> hE2", "zpos<150.")
    xp2, yp2 = ut.h1_to_arrays(hE2)

    #plot
    #plt.style.use("dark_background")
    #col = "lime"
    col = "black"

    fig = plt.figure()
    ax = fig.add_subplot(1, 1, 1)
    set_axes_color(ax, col)
    set_grid(plt, col)

    plt.plot(xp, yp, "-", color="blue", lw=1)
    plt.plot(xp2, yp2, "-", color="red", lw=1)

    ax.set_xlabel("Incident hit energy (keV)")
    ax.set_ylabel("Counts")

    leg = legend()
    leg.add_entry(leg_lin("red"), "$E_\gamma$ > 10 keV")
    leg.add_entry(leg_lin("blue"), "$E_\gamma$ > 100 keV")
    leg.draw(plt, col)

    ax.set_yscale("log")

    plt.xticks(ax.get_xticks()[1:-1], ["$10^{"+"{0:.0f}".format(i)+"}$" for i in ax.get_xticks()[1:-1]])

    fig.savefig("01fig.pdf", bbox_inches = "tight")
    plt.close()
예제 #12
0
def el_theta_beff():

    #electron polar angle theta and effect of angular divergence

    xbin = 5e-5
    #xmin = TMath.Pi() - 2.2e-2
    xmin = 3.13
    xmax = TMath.Pi() + 0.2e-2

    qrpy = 0
    if qrpy == 0:
        tree = tree_qr
        lab_data = "QR"
        col = rt.kBlue
    else:
        tree = tree_py
        lab_data = "Pythia6"
        col = rt.kRed

    can = ut.box_canvas()

    hT = ut.prepare_TH1D("hT", xbin, xmin, xmax)
    hB = ut.prepare_TH1D("hB", xbin, xmin, xmax)

    tree.Draw("true_el_theta >> hT")
    tree.Draw("el_theta >> hB")

    ut.line_h1(hT, col)
    ut.line_h1(hB, rt.kViolet)

    vmax = hT.GetMaximum() + 0.4 * hT.GetMaximum()
    frame = gPad.DrawFrame(xmin, 1e3, xmax, vmax)

    ut.put_yx_tit(frame, "Counts", "Electron #theta (rad)", 1.6, 1.3)

    frame.Draw()

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

    gPad.SetGrid()
    gPad.SetLogy()

    hB.Draw("same")
    hT.Draw("same")

    leg = ut.prepare_leg(0.14, 0.8, 0.24, 0.12, 0.035)  # x, y, dx, dy, tsiz
    leg.AddEntry(hT, lab_data + ", no divergence", "l")
    leg.AddEntry(hB, "Divergence included", "l")
    leg.Draw("same")

    #ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
예제 #13
0
def plot_zdc_vtx():

    #ZDC vertex from selected events and from all triggered events

    vbin = 0.1
    vmin = -5.
    vmax = 7.

    mmin = 1.5
    mmax = 5.

    can = ut.box_canvas()

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

    #make the histograms
    hZdcVtx = ut.prepare_TH1D("hZdcVtx", vbin, vmin, vmax)
    hZdcVtxAll = ut.prepare_TH1D("hZdcVtxAll", vbin / 10., vmin, vmax)

    #convert to meters for plot
    tree.Draw("jZDCVtxZ/100. >> hZdcVtx", strsel)
    treeAll = inp.Get("jAllTree")
    treeAll.Draw("jZDCVtxZ/100. >> hZdcVtxAll")
    ut.norm_to_data(hZdcVtxAll, hZdcVtx, rt.kRed)

    hZdcVtx.SetYTitle("Events / {0:.0f} cm".format(vbin * 100.))
    hZdcVtx.SetXTitle("ZDC vertex along #it{z} (meters)")

    hZdcVtx.SetTitleOffset(1.5, "Y")
    hZdcVtx.SetTitleOffset(1.1, "X")

    gPad.SetTopMargin(0.01)
    gPad.SetRightMargin(0.04)
    gPad.SetBottomMargin(0.08)
    gPad.SetLeftMargin(0.1)

    leg = ut.prepare_leg(0.67, 0.8, 0.28, 0.14, 0.025)
    leg.SetMargin(0.17)
    ut.add_leg_mass(leg, mmin, mmax)
    leg.AddEntry(hZdcVtx, "Selected events")
    leg.AddEntry(hZdcVtxAll, "All UPC-JpsiB triggers", "l")

    #gPad.SetLogy()

    hZdcVtx.Draw()
    hZdcVtxAll.Draw("same")
    leg.Draw("same")

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
예제 #14
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")
예제 #15
0
def phot_theta():

    #polar angle of generated photons

    tbin = 0.01
    tmax = 4

    gdir = "/home/jaroslav/sim/GETaLM/cards/"
    inp = "bg.root"

    infile = TFile.Open(gdir + inp)
    tree = infile.Get("ltree")

    can = ut.box_canvas()

    ht1 = ut.prepare_TH1D("ht1", tbin, 0, tmax)
    ht2 = ut.prepare_TH1D("ht2", tbin, 0, tmax)
    ht2.SetMarkerColor(rt.kRed)
    ht2.SetLineColor(rt.kRed)

    #tree.Draw("(TMath::Pi()-true_phot_theta)*1000 >> ht")
    tree.Draw("(TMath::Pi()-phot_theta)*1000 >> ht1",
              "vtx_z>5000 && vtx_z<12000")
    tree.Draw("(TMath::Pi()-phot_theta)*1000 >> ht2",
              "vtx_z>-5000 && vtx_z<5000")

    #ht.SetYTitle("Events / ({0:.3f}".format(tbin)+" mrad)")
    #ht.SetYTitle("Counts")
    #ht.SetXTitle("Photon #it{#theta} (mrad)")

    #ht.SetTitleOffset(1.5, "Y")
    #ht.SetTitleOffset(1.3, "X")

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

    gPad.SetGrid()

    ht1.Draw()
    ht2.Draw("e1same")

    #leg = ut.prepare_leg(0.2, 0.87, 0.18, 0.08, 0.035)
    #leg.AddEntry(None, "Angular distribution of Bethe-Heitler photons", "")
    #leg.Draw("same")

    gPad.SetLogy()

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
예제 #16
0
def subtract_pt2_incoh():

    #subtract functional shape from pT^2 incoherent MC

    ptbin = 0.008
    ptmin = 0.
    ptmax = 1.

    mmin = 2.8
    mmax = 3.2

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

    can = ut.box_canvas()

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

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

    tree_incoh.Draw("jRecPt*jRecPt >> hPt", strsel)

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

    #values from pdf fit to log(Pt2)
    #func_incoh_pt2.SetParameters(266.3, 3.28)
    func_incoh_pt2.SetParameters(101953.970, 4.810)

    #histogram created from functional values
    hPtFunc = ut.prepare_TH1D("hPtFunc", ptbin, ptmin, ptmax)
    for ibin in xrange(1, hPtFunc.GetNbinsX() + 1):
        edge = hPtFunc.GetBinLowEdge(ibin)
        w = hPtFunc.GetBinWidth(ibin)
        hPtFunc.SetBinContent(ibin, func_incoh_pt2.Integral(edge, edge + w))
        hPtFunc.SetBinError(ibin, 0.)

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

    hPt.Draw()
    hPtFunc.Draw("same")

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

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
예제 #17
0
def el_phi_beff():

    #electron azimuthal angle phi

    xbin = 3e-2
    xmin = -TMath.Pi() - 0.3
    xmax = TMath.Pi() + 0.3

    qrpy = 0
    if qrpy == 0:
        tree = tree_qr
        lab_data = "QR"
        col = rt.kBlue
    else:
        tree = tree_py
        lab_data = "Pythia6"
        col = rt.kRed

    can = ut.box_canvas()

    hP = ut.prepare_TH1D("hP", xbin, xmin, xmax)
    hB = ut.prepare_TH1D("hB", xbin, xmin, xmax)

    tree.Draw("true_el_phi >> hP")
    tree.Draw("el_phi >> hB")

    ut.line_h1(hP, col)
    ut.line_h1(hB, rt.kViolet)

    vmax = hP.GetMaximum() + 0.5 * hP.GetMaximum()
    frame = gPad.DrawFrame(xmin, 0.5, xmax, vmax)

    ut.put_yx_tit(frame, "Counts", "Electron #phi (rad)", 1.6, 1.3)

    frame.Draw()

    ut.set_margin_lbtr(gPad, 0.11, 0.1, 0.05, 0.02)

    gPad.SetGrid()
    #gPad.SetLogy()

    hB.Draw("same")
    hP.Draw("same")

    leg = ut.prepare_leg(0.55, 0.8, 0.24, 0.12, 0.035)  # x, y, dx, dy, tsiz
    leg.AddEntry(hP, lab_data + ", no divergence", "l")
    leg.AddEntry(hB, "Divergence included", "l")
    leg.Draw("same")

    #ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
예제 #18
0
def plot_zdc():

    #ZDC ADC counts east or west 1D

    ew = 0

    zbin = 10.
    zmin = 0.
    zmax = 1300.

    znam = ["jZDCUnAttEast", "jZDCUnAttWest"]
    xtit = ["ZDC East ADC", "ZDC West ADC"]
    lhead = ["East ZDC", "West ZDC"]

    #global gPad
    can = ut.box_canvas()

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

    tree.Draw(znam[ew] + " >> hZdc")
    treeAll = inp.Get("jAllTree")
    treeAll.Draw(znam[ew] + " >> hZdcAll")
    ut.norm_to_data(hZdcAll, hZdc, rt.kRed)

    hZdc.SetYTitle("Events / {0:.1f}".format(zbin))
    hZdc.SetXTitle(xtit[ew])

    hZdc.SetTitleOffset(1.5, "Y")
    hZdc.SetTitleOffset(1.1, "X")

    gPad.SetTopMargin(0.01)
    gPad.SetRightMargin(0.08)
    gPad.SetBottomMargin(0.08)
    gPad.SetLeftMargin(0.1)

    leg = ut.prepare_leg(0.5, 0.76, 0.39, 0.16, 0.035)
    leg.SetMargin(0.17)
    leg.AddEntry(None, lhead[ew], "")
    leg.AddEntry(hZdc, "Selected events")
    leg.AddEntry(hZdcAll, "All UPC-JpsiB triggers", "l")

    hZdc.Draw()
    hZdcAll.Draw("same")
    leg.Draw("same")

    #ut.print_pad(rt.gPad)
    ut.invert_col(rt.gPad)

    can.SaveAs("01fig.pdf")
예제 #19
0
def el_en():

    #electron energy for all events and for electrons hitting the tagger

    ebin = 0.1
    emin = 0
    emax = 20

    can = ut.box_canvas()

    #all generated electrons
    hEnAll = ut.prepare_TH1D("hEnAll", ebin, emin, emax)

    #electrons hitting the tagger
    hEnTag = ut.prepare_TH1D("hEnTag", ebin, emin, emax)

    tree.Draw("el_gen >> hEnAll")
    tree.Draw("el_gen >> hEnTag", "lowQ2s1_IsHit == 1")
    #tree.Draw("el_gen >> hEnTag", "lowQ2s2_IsHit == 1")
    #tree.Draw("lowQ2s2_en >> hEnTag", "lowQ2s2_IsHit == 1")
    #tree.Draw("lowQ2s1_en >> hEnTag", "lowQ2s1_IsHit == 1")
    #tree.Draw("lowQ2_en/1e3 >> hEnTag", "lowQ2_IsHit == 1")
    #tree.Draw("lowQ2_EnPrim/1e3 >> hEnTag", "lowQ2_IsHit == 1")

    ut.line_h1(hEnAll)  # , rt.kBlack
    ut.set_H1D_col(hEnTag, rt.kRed)

    hEnAll.SetYTitle("Events / ({0:.3f}".format(ebin) + " GeV)")
    hEnAll.SetXTitle("#it{E}_{e^{-}} (GeV)")

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

    ut.set_margin_lbtr(gPad, 0.11, 0.1, 0.05, 0.02)

    hEnAll.Draw()
    hEnTag.Draw("same")
    #hEnTag.Draw()

    gPad.SetLogy()

    leg = ut.prepare_leg(0.2, 0.8, 0.2, 0.1, 0.035)
    #leg.AddEntry(hEnAll, "All electrons", "l")
    #leg.AddEntry(hEnAll, "All quasi-real electrons", "l")
    leg.AddEntry(hEnAll, "All bremsstrahlung electrons", "l")
    #leg.AddEntry(hEnTag, "Electrons hitting the tagger", "l")
    #leg.Draw("same")

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
예제 #20
0
def get_eff(tree, draw, match, xbin, xmin, xmax):

    #efficiency calculation, fixed bins

    hAll = ut.prepare_TH1D("hAll", xbin, xmin, xmax)
    hSel = ut.prepare_TH1D("hSel", xbin, xmin, xmax)

    tree.Draw(draw + " >> hAll")
    tree.Draw(draw + " >> hSel", match + " == 1")

    #output efficiency distribution
    hEff = TGraphAsymmErrors(hSel, hAll)

    return hEff
예제 #21
0
def evt_Log10_Q2():

    #plot the log_10(Q^2) using the kinematics formula

    lqbin = 5e-2
    #lqmin = -6
    lqmin = -11
    lqmax = 5
    #lqbin = 5e-3
    #lqmin = -2.2
    #lqmax = -1.8

    hLog10Q2 = ut.prepare_TH1D("hLog10Q2", lqbin, lqmin, lqmax)
    hLog10Q2Tag = ut.prepare_TH1D("hLog10Q2Tag", lqbin, lqmin, lqmax)

    tree.Draw(gL10Q2 + " >> hLog10Q2")
    tree.Draw(gL10Q2 + " >> hLog10Q2Tag", gQ2sel)

    print "All events:", hLog10Q2.GetEntries()
    print "Selected  :", hLog10Q2Tag.GetEntries()

    can = ut.box_canvas()

    ytit = "Events / {0:.3f}".format(lqbin)
    ut.put_yx_tit(hLog10Q2, ytit, "log_{10}(#it{Q}^{2})", 1.4, 1.2)

    ut.set_margin_lbtr(gPad, 0.1, 0.1, 0.03, 0.02)

    ut.line_h1(hLog10Q2, rt.kBlue, 3)
    ut.line_h1(hLog10Q2Tag, rt.kRed, 3)

    gPad.SetLogy()
    gPad.SetGrid()

    hLog10Q2.Draw()
    hLog10Q2Tag.Draw("e1same")

    hLog10Q2.SetMaximum(2e5)  # for qr

    leg = ut.prepare_leg(0.2, 0.83, 0.2, 0.1, 0.035)
    leg.AddEntry(hLog10Q2, "All electrons from quasi-real photoproduction",
                 "l")
    #leg.AddEntry(hLog10Q2, "All Pythia6 scattered electrons", "l")
    leg.AddEntry(hLog10Q2Tag, "Electrons hitting the tagger", "l")
    leg.Draw("same")

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
예제 #22
0
def el_en_tag():

    #energy for electrons hitting the tagger

    #bins in energy
    ebin = 0.1
    emin = 0
    emax = 30

    #sel = ""
    #sel = "lowQ2s1_IsHit==1"
    sel = "lowQ2s2_IsHit==1"
    #sel = "lowQ2s1_IsHit==1 || lowQ2s2_IsHit==1"

    can = ut.box_canvas()

    hEnTag = ut.prepare_TH1D("hEnTag", ebin, emin, emax)
    #hEnTag = ut.prepare_TH1D_n("hEnTag", 10, emin, emax)

    #tree.Draw("el_gen >> hEnTag", sel)
    tree.Draw("true_el_E >> hEnTag", sel)

    hEnTag.Draw()

    gPad.SetGrid()
    gPad.SetLogy()

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
예제 #23
0
def el_theta_tag():

    #electron generated polar angle for electrons hitting the tagger

    #tbin = 5e-2
    #tmin = 0
    #tmax = TMath.Pi() + 1e-2
    tbin = 2e-4
    tmin = TMath.Pi() - 2.1e-2
    tmax = TMath.Pi() + 0.5e-2

    #sel = ""
    sel = "lowQ2s1_IsHit==1"
    #sel = "lowQ2s2_IsHit==1"
    #sel = "lowQ2s1_IsHit==1 || lowQ2s2_IsHit==1"

    can = ut.box_canvas()

    hThetaTag = ut.prepare_TH1D("hThetaTag", tbin, tmin, tmax)

    #tree.Draw("el_theta >> hThetaTag", sel)
    tree.Draw("true_el_theta >> hThetaTag", sel)

    gPad.SetGrid()
    gPad.SetLogy()

    hThetaTag.Draw()

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
예제 #24
0
def el_eta_tag():

    #electron pseudorapidity

    etabin = 0.3
    etamin = -20
    etamax = 10

    #sel = ""
    #sel = "lowQ2s1_IsHit==1"
    #sel = "lowQ2s2_IsHit==1"
    sel = "lowQ2s1_IsHit==1 || lowQ2s2_IsHit==1"

    can = ut.box_canvas()

    hEta = ut.prepare_TH1D("hEta", etabin, etamin, etamax)

    form = "-TMath::Log(TMath::Tan(true_el_theta/2.))"
    #form = "-TMath::Log(TMath::Tan(el_theta/2.))"
    tree.Draw(form + " >> hEta", sel)

    gPad.SetGrid()
    gPad.SetLogy()

    hEta.Draw()

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
예제 #25
0
def el_pT_tag():

    #electron pT

    #ptbin = 0.1
    #ptmin = 0
    #ptmax = 80
    ptbin = 3e-3
    ptmin = 0
    ptmax = 0.3

    #sel = ""
    #sel = "lowQ2s1_IsHit==1"
    sel = "lowQ2s2_IsHit==1"
    #sel = "lowQ2s1_IsHit==1 || lowQ2s2_IsHit==1"

    can = ut.box_canvas()

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

    tree.Draw("true_el_pT >> hPt", sel)

    gPad.SetGrid()
    gPad.SetLogy()

    hPt.Draw()

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
예제 #26
0
def hit_en():

    #energy in tagger

    #infile = "lmon.root"
    infile = "dd.root"

    emin = 0
    emax = 19
    ebin = 0.1
    #emax = 1.1
    #ebin = 0.01

    inp = TFile.Open(infile)
    tree = inp.Get("event")

    can = ut.box_canvas()

    hE = ut.prepare_TH1D("hE", ebin, emin, emax)

    #nev = tree.Draw("hit_s1_en >> hE", "s1_IsHit==1")
    nev = tree.Draw("hit_s2_en >> hE", "s2_IsHit==1")
    #nev = tree.Draw("hit_s1_en/gen_en >> hE", "s1_IsHit==1")
    #nev = tree.Draw("hit_s2_en/gen_en >> hE", "s2_IsHit==1")
    #nev = tree.Draw("hit_s1_en >> hE", "(s1_IsHit==1)&&((hit_s1_en/gen_en)>0.9)")
    #nev = tree.Draw("hit_s2_en >> hE", "(s2_IsHit==1)&&((hit_s2_en/gen_en)>0.9)")
    print(nev)

    gPad.SetGrid()

    gPad.SetLogy()

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
예제 #27
0
def make_py():

    #Pythia6 total cross section
    sigma_py = 54.700142803416348  # micro barn
    infile = "../data/lmon_py_18x275_Q2all_beff2_5Mevt.root"

    lqbin = 0.2
    lqmin = -11
    lqmax = 5

    inp = TFile.Open(infile)
    tree = inp.Get("DetectorTree")

    #can = ut.box_canvas()

    hQ2 = ut.prepare_TH1D("hQ2", lqbin, lqmin, lqmax)

    tree.Draw("TMath::Log10(true_Q2) >> hQ2")

    ut.norm_to_integral(hQ2, sigma_py)

    gPy = ut.h1_to_graph(hQ2)
    gPy.SetLineColor(rt.kRed)
    gPy.SetLineWidth(3)
    gPy.SetLineStyle(rt.kDashed)

    return gPy

    #print hQ2.Integral("width")

    hQ2.Draw()

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
예제 #28
0
def make_qr():

    #quasi-real total cross section
    #sigma_qr = 53.839868617 # micro barn
    #infile = "../data/lmon_18x275_qr_Qd_beff2_5Mevt.root"
    sigma_qr = 55.1027755249  # micro barn
    infile = "../../lgen/data/lgen_18x275_qr_Qe_beff2_5Mevt.root"

    lqbin = 0.2
    lqmin = -11
    lqmax = 5

    inp = TFile.Open(infile)
    #tree = inp.Get("DetectorTree")
    tree = inp.Get("ltree")

    #can = ut.box_canvas()

    hQ2 = ut.prepare_TH1D("hQ2", lqbin, lqmin, lqmax)

    tree.Draw("TMath::Log10(true_Q2) >> hQ2")

    ut.norm_to_integral(hQ2, sigma_qr)

    gQr = ut.h1_to_graph(hQ2)
    gQr.SetLineColor(rt.kRed)
    gQr.SetLineWidth(3)

    return gQr

    hQ2.Draw()

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
예제 #29
0
def make_qr_5x41():

    #quasi-real total cross section for 5x41 beams

    sigma_qr = 65.0648514567  # micro barn
    infile = "../../lgen/data/lgen_5x41_qr_Qe_5Mevt.root"

    lqbin = 0.2
    lqmin = -11
    lqmax = 5

    inp = TFile.Open(infile)
    tree = inp.Get("ltree")

    hQ2 = ut.prepare_TH1D("hQ2", lqbin, lqmin, lqmax)

    tree.Draw("TMath::Log10(true_Q2) >> hQ2")

    ut.norm_to_integral(hQ2, sigma_qr)

    gQr = ut.h1_to_graph(hQ2)
    gQr.SetLineColor(rt.kBlue)
    gQr.SetLineWidth(3)

    return gQr
예제 #30
0
def make_qr_10x100():

    #quasi-real total cross section for 10x100 beams

    sigma_qr = 56.3121075698  # micro barn
    infile = "../../lgen/data/lgen_10x100_qr_Qe_5Mevt.root"

    lqbin = 0.2
    lqmin = -11
    lqmax = 5

    inp = TFile.Open(infile)
    tree = inp.Get("ltree")

    hQ2 = ut.prepare_TH1D("hQ2", lqbin, lqmin, lqmax)

    tree.Draw("TMath::Log10(true_Q2) >> hQ2")

    ut.norm_to_integral(hQ2, sigma_qr)

    gQr = ut.h1_to_graph(hQ2)
    gQr.SetLineColor(rt.kYellow + 1)
    gQr.SetLineWidth(3)

    return gQr