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")
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")
def evt_Q2_theta(): #Q^2 and theta qbin = 5e-6 qmin = 1e-10 qmax = 1e-1 tbin = 1e-4 tmin = 0 tmax = 0.011 qform = "2.*18.*el_gen*(1.-TMath::Cos(TMath::Pi()-el_theta))" hQ2thetaTag = ut.prepare_TH2D("hQ2thetaTag", tbin, tmin, tmax, qbin, qmin, qmax) tree.Draw(qform + ":TMath::Pi()-el_theta >> hQ2thetaTag", gQ2sel) ytit = "Q^{2} / 5x10^{-6} GeV^{2}" xtit = "Polar angle #theta (rad) / {0:.2f} mrad".format(tbin * 1e3) ut.put_yx_tit(hQ2thetaTag, ytit, xtit, 1.6, 1.4) can = ut.box_canvas() ut.set_margin_lbtr(gPad, 0.11, 0.1, 0.03, 0.11) gPad.SetLogy() gPad.SetLogz() hQ2thetaTag.Draw() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def make_both(): lqmin = -11 lqmax = 5 ymax = 8.5 gQr = make_qr() gPy = make_py() gQr10x100 = make_qr_10x100() gQr5x41 = make_qr_5x41() can = ut.box_canvas() frame = gPad.DrawFrame(lqmin, 0, lqmax, ymax) frame.Draw() xtit = "log_{10}(#it{Q}^{2})" ytit = "#frac{d#it{#sigma}}{d(" + xtit + ")} (#mub/GeV^{2})" ut.put_yx_tit(frame, ytit, xtit, 1.6, 1.3) ut.set_margin_lbtr(gPad, 0.14, 0.1, 0.03, 0.02) gQr.Draw("lsame") gPy.Draw("lsame") gQr10x100.Draw("lsame") gQr5x41.Draw("lsame") leg = ut.prepare_leg(0.53, 0.83, 0.2, 0.1, 0.035) leg.AddEntry(gPy, "Pythia6", "l") leg.AddEntry(gQr, "Quasi-real photoproduction", "l") leg.AddEntry(gQr10x100, "Quasi-real 10x100", "l") leg.Draw("same") ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
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")
def phot_en_conv(): #photon energy with conversions or clean conversions #plot range emin = 0 emax = 19 ebin = 0.1 inp = TFile.Open("ew.root") tree = inp.Get("conv_tree") can = ut.box_canvas() hE = ut.prepare_TH1D("hE", ebin, emin, emax) nev = tree.Draw("gen_en >> hE") #nev = tree.Draw("gen_en >> hE", "conv==1") #nev = tree.Draw("gen_en >> hE", "clean==1") print(nev) ut.line_h1(hE) ut.put_yx_tit(hE, "Counts", "#it{E} (GeV)") ut.set_margin_lbtr(gPad, 0.11, 0.09, 0.02, 0.01) gPad.SetGrid() gPad.SetLogy() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
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")
def gen_mlt(): #electron mlt = -log_10(pi-true_el_theta) #mlt range tbin = 0.1 tmin = -2 tmax = 8 hT = ut.prepare_TH1D("hT", tbin, tmin, tmax) can = ut.box_canvas() form = "-TMath::Log10(TMath::Pi()-true_el_theta)" tree.Draw(form + " >> hT") ut.put_yx_tit(hT, "Events", "mlt", 1.4, 1.2) hT.Draw() gPad.SetLogy() gPad.SetGrid() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def gen_Log10_Q2(): #plot the log_10(Q^2) lqbin = 0.02 lqmin = -11 lqmax = 6 hLog10Q2 = ut.prepare_TH1D("hLog10Q2", lqbin, lqmin, lqmax) tree.Draw("TMath::Log10(true_Q2) >> hLog10Q2") #tree.Draw("TMath::Log10(gen_el_Q2) >> hLog10Q2") can = ut.box_canvas() gPad.SetGrid() ut.put_yx_tit(hLog10Q2, "Events", "log_{10}(#it{Q}^{2})", 1.4, 1.2) gPad.SetLogy() hLog10Q2.Draw() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def time_delta_nphot(): #time difference between last and first photoelectron and number of photoelectrons nbin = 2e3 nmin = 0 nmax = 8e4 tbin = 4 # time ns tmin = 30 tmax = 200 cell = "03x03" can = ut.box_canvas() hNT = ut.prepare_TH2D("hNT", nbin, nmin, nmax, tbin, tmin, tmax) tform = "(phot_"+cell+"_OpDet_tmax-phot_"+cell+"_OpDet_tmin)" nform = "phot_"+cell+"_OpDet_nphot" tree.Draw(tform+":"+nform+" >> hNT")#, "phot_en>1000") hNT.SetMinimum(0.98) hNT.SetContour(100) gPad.SetGrid() hNT.Draw() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def draw_pulse(): #draw a single pulse of photoelectrons using the hits for a given event ievt = 7 cell = "03x03" #tree.Print() #get the hits from the tree hitTime = std.vector(float)() hitNphot = std.vector(int)() tree.SetBranchAddress("phot_"+cell+"_OpDet_hits_time", hitTime) tree.SetBranchAddress("phot_"+cell+"_OpDet_hits_nphot", hitNphot) tree.GetEntry(ievt) nhits = hitTime.size() can = ut.box_canvas() gHits = TGraph(nhits) for i in xrange(nhits): gHits.SetPoint(i, hitTime.at(i), hitNphot.at(i)) gHits.Draw("A*l") ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def make_E_theta(): #energy and angle tmin = 0 tmax = 4 # 5 tbin = 0.03 ebin = 0.15 emin = 0.5 emax = 10.5 #gdir = "/home/jaroslav/sim/GETaLM_data/lumi/" #inp = "lumi_18x275_Lif_emin0p5_d200_beff3_5Mevt.root" #gdir = "/home/jaroslav/sim/lattice/gen/" #inp = "lgen_Lif_10g.root" gdir = "/home/jaroslav/sim/GETaLM/cards/" inp = "bg.root" infile = TFile.Open(gdir + inp) tree = infile.Get("ltree") #tree.Print() #return can = ut.box_canvas() hEnT = ut.prepare_TH2D("hEnT", ebin, emin, emax, tbin, tmin, tmax) plot = "((TMath::Pi()-true_phot_theta)*1000)" + ":" + "(true_phot_E)" #plot = "((TMath::Pi()-phot_theta)*1000)" + ":" + "(phot_en)" tree.Draw(plot + " >> hEnT") hEnT.SetXTitle("#it{E}_{#gamma} (GeV)") hEnT.SetYTitle("#it{#theta}_{#gamma} (mrad)") hEnT.SetTitleOffset(1.6, "Y") hEnT.SetTitleOffset(1.3, "X") ut.set_margin_lbtr(gPad, 0.11, 0.1, 0.02, 0.13) hEnT.SetMinimum(0.98) hEnT.SetContour(300) leg = ut.prepare_leg(0.43, 0.84, 0.24, 0.12, 0.05) # x, y, dx, dy, tsiz #leg.AddEntry(None, "No divergence", "") #leg.AddEntry("", "#it{ep}, 18 #times 275 GeV", "") leg.AddEntry("", "#it{E}_{e} = 10 GeV", "") #leg.SetTextColor(rt.kRed) leg.Draw("same") gPad.SetGrid() gPad.SetLogz() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
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")
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")
def gen_eta(): #electron pseudorapidity #eta range etabin = 0.3 etamin = -20 etamax = 10 hEta = ut.prepare_TH1D("hEta", etabin, etamin, etamax) can = ut.box_canvas() form = "-TMath::Log(TMath::Tan(true_el_theta/2.))" #form = "-TMath::Log(TMath::Tan(el_theta/2.))" tree.Draw(form + " >> hEta") ut.put_yx_tit(hEta, "Events", "#eta", 1.4, 1.2) hEta.Draw() gPad.SetLogy() gPad.SetGrid() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def gen_E(): #electron energy ebin = 0.01 emin = 0 emax = 20 hE = ut.prepare_TH1D("hE", ebin, emin, emax) #tree.Draw("gen_E >> hE") tree.Draw("true_el_E >> hE") can = ut.box_canvas() ut.put_yx_tit(hE, "Events", "#it{E'}", 1.4, 1.2) hE.Draw() gPad.SetLogy() gPad.SetGrid() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def plot_logPt2(): #ptbin = 0.12 ptbin = 0.1 ptmin = -5 ptmax = 1 mmin = 2.8 mmax = 3.2 east_1n = 120.3335 west_1n = 138.9685 strsel = "(jRecM>{0:.3f} && jRecM<{1:.3f})".format(mmin, mmax) #strsel += " && (jZDCUnAttEast<{0:.3f} && jZDCUnAttWest<{1:.3f})".format(east_1n, west_1n) strsel += " && (jZDCUnAttEast>{0:.3f} && jZDCUnAttWest>{1:.3f})".format(east_1n, west_1n) can = ut.box_canvas() hPt = ut.prepare_TH1D("hPt", ptbin, ptmin, ptmax) tree.Draw("TMath::Log10(jRecPt*jRecPt) >> hPt", strsel) print("Entries: ", hPt.GetEntries()) hPt.Draw() gPad.SetGrid() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def gen_theta(): #electron polar angle theta #theta range, rad tbin = 1e-3 #tmin = 0 #tmax = 0.2 tmin = 2.9 tmax = 3.15 hTheta = ut.prepare_TH1D("hTheta", tbin, tmin, tmax) #tree.Draw("TMath::Pi()-true_el_theta >> hTheta") tree.Draw("true_el_theta >> hTheta") can = ut.box_canvas() ut.put_yx_tit(hTheta, "Events", "#theta (rad)", 1.4, 1.2) hTheta.Draw() gPad.SetLogy() gPad.SetGrid() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
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")
def gen_Q2_theta(): #Q^2 relative to theta qbin = 1e-3 #qmin = 1e-5 qmin = 0 qmax = 0.45 tbin = 5e-4 tmin = 0 tmax = 0.04 hQ2theta = ut.prepare_TH2D("hQ2theta", tbin, tmin, tmax, qbin, qmin, qmax) tree.Draw("true_Q2:gen_theta >> hQ2theta") can = ut.box_canvas() ut.put_yx_tit(hQ2theta, "#it{Q}^{2}", "#theta (rad)", 1.4, 1.2) hQ2theta.Draw() #gPad.SetLogx() gPad.SetLogz() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
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")
def gen_Log10x_y(): #distribution of log_10(x) and y xbin = 0.01 xmin = -13.5 xmax = -3.5 ybin = 5e-5 #ymin = 0.06 ymin = 0 ymax = 1.1 hXY = ut.prepare_TH2D("hXY", xbin, xmin, xmax, ybin, ymin, ymax) can = ut.box_canvas() tree.Draw("gen_y:TMath::Log10(gen_x) >> hXY") #tree.Draw("gen_y:gen_u >> hXY") ytit = "#it{y}" + " / {0:.3f}".format(ybin) xtit = "log_{10}(x)" + " / {0:.3f}".format(xbin) ut.put_yx_tit(hXY, ytit, xtit, 1.4, 1.4) ut.set_margin_lbtr(gPad, 0.1, 0.11, 0.03, 0.12) hXY.Draw() gPad.SetLogy() gPad.SetLogz() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
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")
def gen_xy(): #distribution of x and y xbin = 2e-9 xmin = 8e-14 xmax = 2e-4 ybin = 1e-2 ymin = 0.06 ymax = 1.1 hXY = ut.prepare_TH2D("hXY", xbin, xmin, xmax, ybin, ymin, ymax) tree.Draw("gen_y:gen_x >> hXY") can = ut.box_canvas() ut.put_yx_tit(hXY, "#it{y}", "#it{x}", 1.4, 1.2) hXY.Draw() gPad.SetLogx() gPad.SetLogz() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
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")
def gen_ys(): #CM energy s * generated y as input to gamma-p total cross section sqrt_s = 28.6 # GeV #ys range ysbin = 0.1 ysmin = 0 ysmax = 30 hYS = ut.prepare_TH1D("hYS", ysbin, ysmin, ysmax) tree.Draw("true_y*" + str(sqrt_s) + " >> hYS") can = ut.box_canvas() ut.put_yx_tit(hYS, "Events", "#ys (GeV^{2})", 1.4, 1.2) hYS.Draw() gPad.SetLogy() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def evt_Log10_Q2_y(): #log_10(Q^2) and y lqbin = 5e-2 #lqmin = -5 lqmin = -10 lqmax = -1.5 ybin = 1e-2 #ymin = 0.06 ymin = 0 ymax = 0.8 yform = "(18.-el_gen)/18." hLog10Q2yTag = ut.prepare_TH2D("hLog10Q2yTag", ybin, ymin, ymax, lqbin, lqmin, lqmax) can = ut.box_canvas() tree.Draw(gL10Q2 + ":" + yform + " >> hLog10Q2yTag", gQ2sel) ut.put_yx_tit(hLog10Q2yTag, "log_{10}(#it{Q}^{2})", "y", 1.6, 1.4) gPad.SetLogx() hLog10Q2yTag.Draw() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def gamma_p_ys(): #distribution of total gamma-proton cross section over a given CM energy s and generated y sqrt_s = 28.6 # GeV #gamma-p range gpbin = 0.01 gpmin = 0 gpmax = 1 hGP = ut.prepare_TH1D("hGP", gpbin, gpmin, gpmax) scm = sqrt_s**2 form = "0.0677*TMath::Power((true_y*" + str(scm) + "), 0.0808)" form += "+0.129*TMath::Power((true_y*" + str(scm) + "), -0.4525)" #print form tree.Draw(form + " >> hGP") can = ut.box_canvas() ut.put_yx_tit(hGP, "Events", "#sigma(#gamma p) (mb)", 1.4, 1.2) hGP.Draw() gPad.SetLogy() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
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")
def hits_xy_up(): #hits on up spectrometer detector in xy ypos = 14.2 # cm xybin = 0.1 # cm xysiz = 22 # cm can = ut.box_canvas() hXY = ut.prepare_TH2D("hXY", xybin, -xysiz/2., xysiz/2., xybin, ypos-(xysiz/2.), ypos+(xysiz/2.)) nevt = tree.GetEntries() #nevt = 10000 hits = BoxCalV2Hits("up", tree) for ievt in xrange(nevt): tree.GetEntry(ievt) for ihit in xrange(hits.GetN()): hXY.Fill(hits.GetX(ihit)/10, hits.GetY(ihit)/10) #print hits.GetX(ihit)/10, hits.GetY(ihit)/10 hXY.SetMinimum(0.98) hXY.SetContour(300) hXY.Draw() gPad.SetGrid() gPad.SetLogz() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")