Esempio n. 1
0
def hit_z():

    #hit z position

    #detector = "up"
    #detector = "down"
    detector = "phot"

    #plot range
    zbin = 1e-3
    zmin = -0.1
    zmax = 0.1

    inp_lmon = TFile.Open("lmon.root")
    tree = inp_lmon.Get(detector)

    can = ut.box_canvas()
    hZ = ut.prepare_TH1D("hZ", zbin, zmin, zmax)

    tree.Draw("z >> hZ")
    print("Entries:", hZ.GetEntries())

    ut.set_H1D_col(hZ, rt.kBlue)

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

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

    gPad.SetGrid()

    gPad.SetLogy()

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Esempio n. 2
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")
Esempio n. 3
0
def proton_pt():

    ptmin = 0
    ptmax = 800
    ptbin = 5

    can = ut.box_canvas()

    #inp = TFile.Open("/home/jaroslav/sim/bhgen/bhgen-eic/runs/g18x275/evt.root")
    #tree = inp.Get("prim_tree")
    inp = TFile.Open(
        "/home/jaroslav/sim/bhgen/data/g18x275_emin0p5_100Mevt/evt.root")
    tree = inp.Get("bhgen_tree")
    hPt18 = ut.prepare_TH1D("hPt18", ptbin, ptmin, ptmax)
    tree.Draw("p_pt*1e3 >> hPt18")

    #inp2 = TFile.Open("/home/jaroslav/sim/bhgen/bhgen-eic/runs/g10x100/evt.root")
    #tree2 = inp2.Get("prim_tree")
    inp2 = TFile.Open(
        "/home/jaroslav/sim/bhgen/data/g10x100_emin0p5_100Mevt/evt.root")
    tree2 = inp2.Get("bhgen_tree")
    hPt10 = ut.prepare_TH1D("hPt10", ptbin, ptmin, ptmax)
    tree2.Draw("p_pt*1e3 >> hPt10")

    ut.set_H1D_col(hPt18, rt.kRed)
    ut.set_H1D_col(hPt10, rt.kGreen + 1)

    ut.put_yx_tit(hPt18, "Counts", "Proton #it{p}_{T} (MeV)", 1.5, 1.4)

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

    hPt18.Draw()
    hPt10.Draw("e1same")
    hPt18.Draw("e1same")

    leg = ut.prepare_leg(0.7, 0.82, 0.24, 0.12, 0.035)  # x, y, dx, dy, tsiz
    leg.AddEntry(hPt18, "18x275 GeV", "lp")
    leg.AddEntry(hPt10, "10x100 GeV", "lp")
    leg.Draw("same")

    gPad.SetGrid()

    gPad.SetLogy()

    #ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Esempio n. 4
0
def neut_abs_eta():

    #neutron absolute pseudorapidity

    etabin = 0.05
    etamin = 5
    etamax = 20

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

    can = ut.box_canvas()

    particles = TClonesArray("TParticle", 200)
    tree.SetBranchAddress("particles", particles)

    nev = tree.GetEntriesFast()
    #nev = 24
    for iev in xrange(nev):
        tree.GetEntry(iev)
        for imc in xrange(particles.GetEntriesFast()):
            part = particles.At(imc)
            if part.GetPdgCode() != 2112: continue
            #hEta.Fill( TMath.Abs(part.Eta()) )
            hEta.Fill(abs(part.Eta()))

    ytit = "Events / {0:.2f}".format(etabin)
    ut.put_yx_tit(hEta, ytit, "Neutron |#kern[0.3]{#eta}|", 1.4, 1.2)

    ut.set_H1D_col(hEta, rt.kRed)

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

    hEta.Draw()

    gPad.SetGrid()

    gPad.SetLogy()

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Esempio n. 5
0
def en_bun():

    #energy in bunch crossing

    infile = "/home/jaroslav/sim/lmon/data/luminosity/lm1a/hits.root"

    #detector = "bun_up_en"
    #detector = "bun_down_en"
    #detector = "bun_phot_en"
    detector = "bun_up_en+bun_down_en"

    cond = "(bun_up_en>1)&&(bun_down_en>1)"

    #plot range
    ebin = 0.5
    emax = 35.
    #emax = 150.

    inp_lmon = TFile.Open(infile)
    tree = inp_lmon.Get("bunch")

    can = ut.box_canvas()
    hE = ut.prepare_TH1D("hE", ebin, 0, emax)

    tree.Draw(detector + " >> hE", cond, "", 100000)

    ut.set_H1D_col(hE, rt.kBlue)

    ut.put_yx_tit(hE, "Counts", "Incident energy in bunch crossing (GeV)", 1.5,
                  1.4)

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

    gPad.SetGrid()

    gPad.SetLogy()

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Esempio n. 6
0
def plot_proj_both(frame2, frame_east, frame_west, adc_bin, adc_min, adc_max,
                   ptmax, mmin, mmax):

    can = ut.box_canvas(800, 700)  #900, 700

    xp = Double(0)
    yp = Double(0)

    #east data on the left
    hEast = frame_east.getHist("data")
    plot_east = frame2.Clone("plot_east")
    plot_east.SetMarkerStyle(22)
    plot_east.SetMarkerSize(1.4)
    ut.set_H1D_col(plot_east, rt.kBlue)
    for ibin in xrange(hEast.GetN()):
        hEast.GetPoint(ibin, xp, yp)
        plot_east.SetBinContent(ibin + 1, yp)
        plot_east.SetBinError(ibin + 1, hEast.GetErrorY(ibin))

    frame2.SetMaximum(1.2 * plot_east.GetMaximum())  # 1.15

    #west data on the right
    hWest = frame_west.getHist("data")
    plot_west = frame2.Clone("plot_west")
    plot_west.SetMarkerStyle(21)
    ut.set_H1D_col(plot_west, rt.kRed)
    for i in xrange(hWest.GetN()):
        hWest.GetPoint(i, xp, yp)
        ibin = frame2.GetNbinsX() - i
        plot_west.SetBinContent(ibin, yp)
        plot_west.SetBinError(ibin, hWest.GetErrorY(i))

    #east fit
    cEast = frame_east.getCurve("model")
    gEast = TGraph(cEast.GetN() - 1)
    for i in xrange(cEast.GetN() - 1):
        cEast.GetPoint(i, xp, yp)
        gEast.SetPoint(i, xp, yp)

    gEast.SetLineColor(rt.kBlue)
    gEast.SetLineWidth(3)
    gEast.SetLineStyle(rt.kDashed)
    #gEast.SetLineStyle(rt.kDashDotted)

    #west fit on the left
    cWest = frame_west.getCurve("model")
    gWest = TGraph(cWest.GetN() - 1)
    xmax = frame2.GetBinCenter(
        frame2.GetNbinsX()) + frame2.GetBinWidth(frame2.GetNbinsX()) / 2.
    for i in xrange(cWest.GetN() - 1):
        cWest.GetPoint(i, xp, yp)
        xplot = xmax - xp
        gWest.SetPoint(i, xplot, yp)

    gWest.SetLineColor(rt.kRed)
    gWest.SetLineWidth(3)
    #gWest.SetLineStyle(rt.kDashDotted)
    #gWest.SetLineStyle(rt.kDashed)

    #horizontal axis
    frame2.SetMinimum(0)
    #frame2.SetMinimum(0.98)
    frame2.GetXaxis().SetNdivisions(0, rt.kFALSE)
    #east axis
    ypos = frame2.GetYaxis().GetXmin()
    axisE = TGaxis(adc_min, ypos, adc_max, ypos, adc_min, adc_max)
    ut.set_axis(axisE)
    axisE.SetWmin(axisE.GetWmin() * 0.01)
    axisE.SetWmax(axisE.GetWmax() * 0.01)
    axisE.SetTitle("ZDC East #times100")
    axisE.SetTitleOffset(1.1)
    #west axis
    xpos = frame2.GetXaxis().GetXmax()
    axisW = TGaxis(xpos, ypos, xpos - adc_max, ypos, adc_min, adc_max, 510,
                   "-")
    ut.set_axis(axisW)
    axisW.SetWmin(axisW.GetWmin() * 0.01)
    axisW.SetWmax(axisW.GetWmax() * 0.01)
    axisW.SetLabelOffset(-0.024)
    axisW.SetTitle("ZDC West #times100")
    axisW.SetTitleOffset(1.1)

    #vertical axis
    yvpos = 1. * frame2.GetMaximum()
    axisV = TGaxis(xpos, 0, xpos, yvpos, 0, yvpos, 510, "+L")
    #axisV = TGaxis(xpos, 0, xpos, yvpos, 0.98, yvpos, 510, "+G")
    ut.set_axis(axisV)

    frame2.SetYTitle("ZDC East / ({0:.0f} ADC units)".format(adc_bin))
    axisV.SetTitle("ZDC West / ({0:.0f} ADC units)".format(adc_bin))

    frame2.GetYaxis().SetTitleOffset(1.5)
    axisV.SetTitleOffset(1.5)

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

    frame2.Draw()
    plot_east.Draw("e1same")
    plot_west.Draw("e1same")
    gEast.Draw("lsame")
    gWest.Draw("lsame")

    axisE.Draw()
    axisW.Draw()
    axisV.Draw()

    #kinematics legend
    #kleg = ut.prepare_leg(0.16, 0.78, 0.32, 0.2, 0.035)
    kleg = ut.prepare_leg(0.16, 0.73, 0.32, 0.2, 0.035)
    kleg.AddEntry(None, "AuAu@200 GeV", "")
    kleg.AddEntry(None, "UPC sample", "")
    ut.add_leg_pt_mass(kleg, ptmax, mmin, mmax)
    kleg.Draw("same")

    #data legend
    dleg = ut.prepare_leg(0.6, 0.8, 0.15, 0.08, 0.03)
    dleg.AddEntry(plot_east, "ZDC East", "p")
    dleg.AddEntry(plot_west, "ZDC West", "p")
    #dleg.Draw("same")

    #projections legend
    #pleg = ut.prepare_leg(0.24, 0.56, 0.25, 0.2, 0.035)
    pleg = ut.prepare_leg(0.24, 0.51, 0.25, 0.2, 0.035)
    pleg.AddEntry(plot_east, "ZDC East", "p")
    pleg.AddEntry(plot_west, "ZDC West", "p")
    pleg.AddEntry(gEast, "Fit projection to east", "l")
    pleg.AddEntry(gWest, "Fit projection to west", "l")
    pleg.Draw("same")

    #gPad.SetLogy()
    #gPad.SetGrid()

    #ut.invert_col(gPad)
    can.SaveAs("01fig.pdf")
Esempio n. 7
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")
Esempio n. 8
0
def plot_rec_gen_track_pt():

    #track pT resolution as ( pT_track_rec - pT_track_gen )/pT_track_gen

    ptbin = 0.001
    ptmin = -0.3
    ptmax = 0.1

    #generated dielectron pT selection to input data
    ptlo = 0.2
    pthi = 1

    fitran = [-0.15, 0.018]

    mmin = 2.8
    mmax = 3.2

    ccb = rt.kBlue

    #output log file
    out = open("out.txt", "w")
    #log fit parameters
    loglist1 = [(x, eval(x)) for x in ["infile_mc", "ptbin", "ptmin", "ptmax"]]
    loglist2 = [(x, eval(x))
                for x in ["ptlo", "pthi", "fitran", "mmin", "mmax"]]
    strlog = ut.make_log_string(loglist1, loglist2)
    ut.log_results(out, strlog + "\n")

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

    nbins, ptmax = ut.get_nbins(ptbin, ptmin, ptmax)
    hPtTrackRel = ut.prepare_TH1D_n("hPtTrackRel", nbins, ptmin, ptmax)

    ytit = "Events / ({0:.3f})".format(ptbin)
    xtit = "(#it{p}_{T, rec}^{track} - #it{p}_{T, gen}^{track})/#it{p}_{T, gen}^{track}"

    mctree.Draw("(jT0pT-jGenP0pT)/jGenP0pT >> hPtTrackRel",
                strsel)  # positive charge
    mctree.Draw("(jT1pT-jGenP1pT)/jGenP1pT >>+hPtTrackRel",
                strsel)  # add negative charge

    x = RooRealVar("x", "x", ptmin, ptmax)
    x.setRange("fitran", fitran[0], fitran[1])
    rfPtTrackRel = RooDataHist("rfPtTrackRel", "rfPtTrackRel", RooArgList(x),
                               hPtTrackRel)

    #standard Crystal Ball
    mean = RooRealVar("mean", "mean", -0.003, -0.1, 0.1)
    sigma = RooRealVar("sigma", "sigma", 0.01, 0., 0.9)
    alpha = RooRealVar("alpha", "alpha", 1.2, 0., 10.)
    n = RooRealVar("n", "n", 1.3, 0., 20.)
    cbpdf = RooCBShape("cbpdf", "cbpdf", x, mean, sigma, alpha, n)

    res = cbpdf.fitTo(rfPtTrackRel, rf.Range("fitran"), rf.Save())

    #log fit results
    ut.log_results(out, ut.log_fit_result(res))

    #generate new distribution according to the fit
    gROOT.LoadMacro("cb_gen.h")
    #Crystal Ball generator, min, max, mean, sigma, alpha, n
    #cbgen = rt.cb_gen(-0.18, 0.05, -0.00226, 0.00908, 1.40165, 1.114)  #  -0.18, 0.05  ptmin, ptmax
    cbgen = rt.cb_gen(-0.5, 0.05, -0.00226, 0.00908, 0.2,
                      2.)  #  -0.18, 0.05  ptmin, ptmax
    hRelGen = ut.prepare_TH1D_n("hRelGen", nbins, ptmin, ptmax)
    ut.set_H1D_col(hRelGen, rt.kBlue)
    #rt.cb_generate_n(cbgen, hRelGen, int(hPtTrackRel.GetEntries()))
    rfRelGen = RooDataHist("rfRelGen", "rfRelGen", RooArgList(x), hRelGen)

    #generate distribution with additional smearing applied
    hRelSmear = ut.prepare_TH1D_n("hRelSmear", nbins, ptmin, ptmax)
    ut.set_H1D_col(hRelSmear, rt.kOrange)
    #tcopy = mctree.CopyTree(strsel)
    #rt.cb_apply_smear(cbgen, mctree, hRelSmear)

    can = ut.box_canvas()
    ut.set_margin_lbtr(gPad, 0.12, 0.1, 0.05, 0.03)

    frame = x.frame(rf.Bins(nbins), rf.Title(""))
    ut.put_frame_yx_tit(frame, ytit, xtit)

    rfPtTrackRel.plotOn(frame, rf.Name("data"))

    #rfRelGen.plotOn(frame, rf.Name("data"))

    cbpdf.plotOn(frame, rf.Precision(1e-6), rf.Name("cbpdf"),
                 rf.LineColor(ccb))

    frame.Draw()

    #hRelGen.Draw("e1same")
    #hRelSmear.Draw("e1same")

    desc = pdesc(frame, 0.2, 0.8, 0.057)
    #x, y, sep
    desc.set_text_size(0.03)

    desc.itemD("#chi^{2}/ndf", frame.chiSquare("cbpdf", "data", 4), -1, ccb)
    desc.prec = 5
    desc.itemR("mean", mean, ccb)
    desc.itemR("#sigma", sigma, ccb)
    desc.itemR("#alpha", alpha, ccb)
    desc.prec = 3
    desc.itemR("#it{n}", n, ccb)
    desc.draw()

    leg = ut.prepare_leg(0.2, 0.82, 0.21, 0.12, 0.03)  # x, y, dx, dy, tsiz
    leg.SetMargin(0.05)
    leg.AddEntry(0, "#bf{%.1f < #it{p}_{T}^{pair} < %.1f GeV}" % (ptlo, pthi),
                 "")
    leg.Draw("same")

    #ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Esempio n. 9
0
def q2_calc():

    #calculate the generated Q^2 from definition and from kinematics

    qbin = 1e-6
    qmin = 1e-7
    qmax = 3e-2

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

    can = ut.box_canvas()

    hQ2def = ut.prepare_TH1D("hQ2def", qbin, qmin, qmax)
    hQ2defTag = ut.prepare_TH1D("hQ2defTag", qbin, qmin, qmax)

    hQ2kine = ut.prepare_TH1D("hQ2kine", qbin, qmin, qmax)
    hQ2kineTag = ut.prepare_TH1D("hQ2kineTag", qbin, qmin, qmax)

    hLog10q2Def = ut.prepare_TH1D("hLog10q2Def", lqbin, lqmin, lqmax)
    hLog10q2DefTag = ut.prepare_TH1D("hLog10q2DefTag", lqbin, lqmin, lqmax)

    hLog10q2kine = ut.prepare_TH1D("hLog10q2kine", lqbin, lqmin, lqmax)
    hLog10q2kineTag = ut.prepare_TH1D("hLog10q2kineTag", lqbin, lqmin, lqmax)

    #set the tree
    tree.SetBranchStatus("*", 0)
    tree.SetBranchStatus("el_gen", 1)
    tree.SetBranchStatus("el_theta", 1)
    tree.SetBranchStatus("el_phi", 1)
    tree.SetBranchStatus("lowQ2_IsHit", 1)

    #connect the generated electron variables
    gROOT.ProcessLine("struct Entry {Double_t val;};")
    gROOT.ProcessLine("struct EntryBool {Bool_t val;};")
    en = rt.Entry()
    theta = rt.Entry()
    phi = rt.Entry()
    is_hit = rt.EntryBool()
    tree.SetBranchAddress("el_gen", AddressOf(en, "val"))
    tree.SetBranchAddress("el_theta", AddressOf(theta, "val"))
    tree.SetBranchAddress("el_phi", AddressOf(phi, "val"))
    tree.SetBranchAddress("lowQ2_IsHit", AddressOf(is_hit, "val"))

    nevt = tree.GetEntries()
    #nevt = 30000

    #counters for skipped entries
    nskip_def = 0
    nskip_kine = 0

    #tree loop
    for i in xrange(nevt):
        tree.GetEntry(i)

        #if en.val > 10: continue

        #vector of beam electron
        el_beam = TLorentzVector()
        el_beam.SetPxPyPzE(0, 0, -18, 18)

        #scattered electron Lorentz vector
        el_vec = q2_calc_vec_from_kine(en.val, theta.val, phi.val)

        q2_def = -(el_beam - el_vec).Mag2()

        hQ2def.Fill(q2_def)
        if is_hit.val == 1: hQ2defTag.Fill(q2_def)

        #if q2_def < 1e-4: continue

        q2kine = 2. * 18 * en.val * (1 - cos(pi - theta.val))

        hQ2kine.Fill(q2kine)
        if is_hit.val == 1: hQ2kineTag.Fill(q2kine)

        if q2_def > 0.:
            hLog10q2Def.Fill(log10(q2_def))
            if is_hit.val == 1: hLog10q2DefTag.Fill(log10(q2_def))
            #print log10(q2_def)
        else:
            nskip_def += 1

        if q2kine > 0.:
            hLog10q2kine.Fill(log10(q2kine))
            if is_hit.val == 1: hLog10q2kineTag.Fill(log10(q2kine))
        else:
            nskip_kine += 1

        #print q2_def, q2, q2_def-q2

        #print el_vec.Px(), el_vec.Py(), el_vec.Pz()

    #tree loop

    #release the tree at the end
    tree.ResetBranchAddresses()
    tree.SetBranchStatus("*", 1)

    print "Events skipped for Q^2 from definition:", nskip_def
    print "Events skipped for Q^2 from kinematics:", nskip_kine

    #draw the plot

    ut.set_H1D_col(hQ2defTag, rt.kRed)
    ut.set_H1D_col(hQ2kine, rt.kBlue)
    ut.set_H1D_col(hQ2kineTag, rt.kMagenta)

    #gPad.SetLogy()
    #gPad.SetLogx()

    #hQ2def.Draw()
    #hQ2defTag.Draw("e1same")
    #hQ2kine.Draw("e1same")
    #hQ2kineTag.Draw("e1same")

    ut.set_H1D_col(hLog10q2DefTag, rt.kRed)
    ut.set_H1D_col(hLog10q2kine, rt.kBlue)
    ut.set_H1D_col(hLog10q2kineTag, rt.kMagenta)

    hLog10q2Def.Draw()
    hLog10q2DefTag.Draw("e1same")
    #hLog10q2kine.Draw("e1same")
    #hLog10q2kineTag.Draw("e1same")

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Esempio n. 10
0
def main():

    #range for |t|
    tmin = 0.
    tmax = 0.11  #   0.109  0.01 for interference range
    #tmax = 0.015

    #dy = 2. # rapidity interval
    dy = 1.

    gSlight = load_starlight(dy)

    can = ut.box_canvas()
    #frame = gPad.DrawFrame(tmin, 1e-5, tmax, 11)
    frame = gPad.DrawFrame(0, -0.2, tmax, 0.3)

    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.Draw()

    #gPad.SetLogy()

    #run 14
    inp14 = TFile.Open("sigma.root", "read")
    gSig = inp14.Get("sigma")
    ut.set_H1D_col(gSig, rt.kBlack)
    inp14.Close()

    #run 16
    #inp16 = TFile.Open("/home/jaroslav/sim/data_run16/postlim_04.21/subt_corr/root/JPsiPt_corr_14nn.root", "read")
    inp16 = TFile.Open(
        "/home/jaroslav/sim/data_run16/postlim_04.21/subt_corr/root/JPsiPt_corr_XnXn.root",
        "read")
    h16 = inp16.Get("hpt2corsub_JPsicoh")
    #inp16.ls()
    ut.set_H1D(h16)
    ut.set_H1D_col(h16, rt.kRed)

    #for i in range(h16.GetNbinsX()):
    #    print i, h16.GetBinContent(i), h16.GetBinError(i)

    #scale to mb
    h16.Sumw2()
    h16.Scale(1e-3)

    #Starlight
    gSlight.Draw("lsame")

    #data
    gSig.Draw("psame")
    h16.Draw("e1same")

    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.68, 0.76, 0.3, 0.16, 0.035)
    leg.AddEntry(gSig, "Run 14", "lp")
    leg.AddEntry(h16, "Run 16", "lp")
    leg.AddEntry(gSlight, "STARLIGHT", "l")
    leg.Draw("same")

    #gPad.SetGrid()

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