def main(): #input inp = TFile.Open("events.root") tree = inp.Get("event") #layer to plot plot = "lay11_edep" #MeV ebin = 0.1 ekmax = 20. edmax = 6 hE = ut.prepare_TH2D("hE", ebin, 0, ekmax, ebin, 0, edmax) can = ut.box_canvas() tree.Draw(plot + ":ekin >> hE", plot + ">0.") hE.SetXTitle("#it{E}_{kin} (MeV)") hE.SetYTitle("#it{E}_{dep} (MeV)") hE.SetTitleOffset(1.3, "Y") hE.SetTitleOffset(1.3, "X") ut.set_margin_lbtr(gPad, 0.09, 0.1, 0.02, 0.11) hE.SetMinimum(0.98) hE.SetContour(300) gPad.SetLogz() gPad.SetGrid() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def plot_w_delta(): #photon w and delta wbin = 0.02 wmin = 1 wmax = 4 dbin = 0.02 dmax = 2.5 can = ut.box_canvas() hWD = ut.prepare_TH2D("hWD", dbin, 0, dmax, wbin, wmin, wmax) #tree.Draw("phot_w:phot_delta >> hWD") # y:x tree.Draw("TMath::Log10(phot_w):TMath::Log10(phot_delta) >> hWD") # y:x hWD.SetXTitle("log(#delta)") hWD.SetYTitle("log(w)") hWD.SetTitleOffset(1.6, "Y") hWD.SetTitleOffset(1.3, "X") ut.set_margin_lbtr(gPad, 0.11, 0.1, 0.02, 0.13) hWD.SetMinimum(0.98) hWD.SetContour(300) #gPad.SetLogz() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def rpos(): #radial hit position and vertex position in z #meters #zmin = 2 zmin = -6 zmax = 16 zbin = 1 #cm #rmin = 3.2 #rmax = 17 #rbin = 1 rmin = 3 rmax = 4.5 rbin = 1e-2 #infile = "/home/jaroslav/sim/lmon/data/beam-gas/rc_1a.root" infile = "/home/jaroslav/sim/lmon/data/beam-gas/rc_2f.root" infile = TFile.Open(infile) tree = infile.Get("ptree") can = ut.box_canvas() hz = ut.prepare_TH2D("hz", zbin, zmin, zmax, rbin, rmin, rmax) tree.Draw("(rpos/1e1):(vtx_z/1e3) >> hz") print("Entries:", hz.GetEntries()) hz.SetXTitle("Vertex #it{z} (m)") hz.SetYTitle("Hit #it{r} (cm)") hz.SetTitleOffset(1.3, "Y") hz.SetTitleOffset(1.3, "X") hz.GetXaxis().CenterTitle() hz.GetYaxis().CenterTitle() ut.set_margin_lbtr(gPad, 0.09, 0.1, 0.02, 0.11) hz.SetMinimum(0.98) hz.SetContour(300) for ix in range(1, hz.GetNbinsX() + 1): for iy in range(1, hz.GetNbinsY() + 1): pass #print(ix, iy, hz.GetBinContent(ix, iy)) #hz.Draw("colztext") gPad.SetLogz() gPad.SetGrid() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def plot_theta(): #polar angle of generated photons tbin = 0.01 tmax = 3 can = ut.box_canvas() ht = ut.prepare_TH1D("ht", tbin, 0, tmax) tree.Draw("(TMath::Pi()-phot_theta)*1000 >> ht") ht.SetYTitle("Events / ({0:.3f}".format(tbin) + " mrad)") ht.SetXTitle("#vartheta (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) ht.Draw() 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")
def plot_en(): #energy distribution of generated photons ebin = 0.1 emin = 4 emax = 28 can = ut.box_canvas() hE = ut.prepare_TH1D("hE", ebin, emin, emax) tree.Draw("phot_en >> hE") hE.SetYTitle("Events / ({0:.3f}".format(ebin) + " GeV)") hE.SetXTitle("#it{E}_{#gamma} (GeV)") hE.SetTitleOffset(1.9, "Y") hE.SetTitleOffset(1.3, "X") gPad.SetTopMargin(0.02) gPad.SetRightMargin(0.01) gPad.SetBottomMargin(0.1) gPad.SetLeftMargin(0.14) hE.GetYaxis().SetMoreLogLabels() hE.Draw() gPad.SetLogy() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def plot_vx(): #vertex position of generated photon along x or y vbin = 0.1 vmin = -10 vmax = 10 can = ut.box_canvas() hV = ut.prepare_TH1D("hV", vbin, vmin, vmax) tree.Draw("beff_vx >> hV") #tree.Draw("beff_vy >> hV") hV.SetYTitle("Events / ({0:.3f}".format(vbin) + " mm)") hV.SetXTitle("x vertex (mm)") #hV.SetXTitle("y vertex (mm)") hV.SetTitleOffset(1.9, "Y") hV.SetTitleOffset(1.3, "X") ut.set_margin_lbtr(gPad, 0.14, 0.1, 0.02, 0.02) ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def plot_dSigDtheta(): # dSigma / dTheta according to ZEUS parametrization Ee = 18 gen = gen_zeus(Ee, 275) # Ee, Ep, GeV sig = gen.dSigDtheta can = ut.box_canvas() sig.SetLineWidth(3) sig.SetNpx(1000) sig.SetTitle("") sig.Draw() sig.GetXaxis().SetTitle("#theta_{#gamma} (rad)") sig.GetYaxis().SetTitle("a. u.") sig.GetYaxis().SetTitleOffset(1.5) sig.GetXaxis().SetTitleOffset(1.3) gPad.SetTopMargin(0.01) gPad.SetRightMargin(0.08) leg = ut.prepare_leg(0.58, 0.78, 0.24, 0.15, 0.035) # x, y, dx, dy, tsiz leg.AddEntry(sig, "#frac{d#sigma}{d#theta_{#gamma}}", "l") leg.AddEntry(None, "E_{e} = 18 GeV", "") leg.Draw("same") gPad.SetLogy() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def plot_vxy(): #vertex position of generated photon along x and y xbin = 0.01 ybin = 0.001 xmin = -1.5 xmax = 1.5 ymin = -0.2 ymax = 0.2 can = ut.box_canvas() hV = ut.prepare_TH2D("hV", xbin, xmin, xmax, ybin, ymin, ymax) tree.Draw("beff_vy:beff_vx >> hV") hV.SetXTitle("#it{x} of primary vertex (mm)") hV.SetYTitle("#it{y} of primary vertex (mm)") hV.SetTitleOffset(1.6, "Y") hV.SetTitleOffset(1.3, "X") ut.set_margin_lbtr(gPad, 0.11, 0.1, 0.02, 0.13) #gPad.SetLogz() #ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def plot_el_en(): #scattered electron energy ebin = 0.1 emin = 0 emax = 20 can = ut.box_canvas() hE = ut.prepare_TH1D("hE", ebin, emin, emax) tree.Draw("el_en >> hE") hE.SetYTitle("Events / ({0:.3f}".format(ebin) + " GeV)") hE.SetXTitle("#it{E}_{e} (GeV)") hE.SetTitleOffset(1.9, "Y") hE.SetTitleOffset(1.3, "X") ut.set_margin_lbtr(gPad, 0.14, 0.1, 0.02, 0.01) #hE.GetYaxis().SetMoreLogLabels() hE.Draw() #gPad.SetLogy() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def plot_zdc_2d(): #ZDC ADC counts east vs. west 2D zbin = 18 zmin = 10 zmax = 700 znam = ["jZDCUnAttEast", "jZDCUnAttWest"] xtit = ["FastZDC East ADC", "FastZDC West ADC"] can = ut.box_canvas() hZdc = ut.prepare_TH2D("hZdc", zbin, zmin, zmax, zbin, zmin, zmax) tree.Draw(znam[1] + ":" + znam[0] + " >> hZdc") ut.put_yx_tit(hZdc, xtit[1], xtit[0], 1.7, 1.2) ut.set_margin_lbtr(gPad, 0.12, 0.09, 0.02, 0.11) hZdc.SetMinimum(0.98) hZdc.SetContour(300) hZdc.Draw() gPad.SetGrid() gPad.SetLogz() ut.invert_col(gPad) can.SaveAs("01fig.pdf")
def acc_from_tmp(): #spectrometer acceptance from temporary file tmp = TFile.Open("tmp/hacc.root") hAcc = tmp.Get("divide_hSel_by_hAll") can = ut.box_canvas() hAcc.Draw("AP") ut.set_margin_lbtr(gPad, 0.14, 0.1, 0.01, 0.02) en = rt.Double(0) av = rt.Double(0) iacc = 0. for i in xrange(hAcc.GetN()): hAcc.GetPoint(i, en, av) iacc += av * (hAcc.GetErrorXhigh(i) + hAcc.GetErrorXlow(i)) print "iacc:", iacc #acceptance parametrization from spec_acc import spec_acc acc = spec_acc() acc.scale = iacc / acc.acc_func.Integral(2, 21) print "int_func:", acc.acc_func.Integral(2, 21) acc.acc_func.Draw("same") ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
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")
def en_2n(): #energy for two neutrons in both + and - eta for mean of 2n energy ebin = 2 emin = 0 emax = 500 can = ut.box_canvas() hE = ut.prepare_TH1D("hE", ebin, emin, emax) tree.Draw("epos >> hE", "npos == 2") tree.Draw("eneg >>+ hE", "nneg == 2") print "UO:", hE.GetBinContent(0), hE.GetBinContent(hE.GetNbinsX() + 1) print "Mean:", hE.GetMean(), "+/-", hE.GetMeanError() gPad.SetGrid() gPad.SetLogy() hE.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 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 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("el_en >> 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 phot_xy(): #photon detector first point in xy xbin = 0.1 xmin = -12 xmax = 12 can = ut.box_canvas() hX = ut.prepare_TH2D("hX", xbin, xmin, xmax, xbin, xmin, xmax) #tree.Draw("phot_y/10:phot_x/10 >> hX")#, "phot_en<1000") tree.Draw("phot_hy/10:phot_hx/10 >> hX") #, "phot_en<1000") hX.SetXTitle("Horizontal #it{x} (cm)") hX.SetYTitle("Vertical #it{y} (cm)") hX.GetXaxis().CenterTitle() hX.GetYaxis().CenterTitle() hX.SetTitleOffset(1.2, "Y") hX.SetTitleOffset(1.2, "X") gPad.SetTopMargin(0.01) gPad.SetRightMargin(0.11) gPad.SetBottomMargin(0.09) gPad.SetLeftMargin(0.09) hX.Draw() gPad.SetLogz() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def gen_y(): #rapidity from Starlight #rapidity range nbin = 200 ymin = -6 ymax = 6 hY = ut.prepare_TH1D_n("hY", nbin, ymin, ymax) hYsl = ut.prepare_TH1D_n("hYsl", nbin, ymin, ymax) can = ut.box_canvas() tree.Draw("rapidity >> hY", "", "", 100000) tree_sl.Draw("VMrapidity >> hYsl", "", "", 100000) ut.line_h1(hYsl) ut.put_yx_tit(hY, "Events", "y", 1.4, 1.2) hY.Draw() hYsl.Draw("same") 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 neut_eta(): #neutron pseudorapidity etabin = 0.05 etamin = -20 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(part.Eta()) ut.put_yx_tit(hEta, "Events", "#eta", 1.4, 1.2) hEta.Draw() gPad.SetGrid() gPad.SetLogy() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def gen_ay(): #abs(y) nbin = 100 ymax = 6 hAY = ut.prepare_TH1D_n("hAY", nbin, 0, ymax) can = ut.box_canvas() tree.Draw("TMath::Abs(rapidity) >> hAY", "", "", 100000) ut.put_yx_tit(hAY, "Events", "|y|", 1.4, 1.2) hAY.Draw() #absolute rapidity directly from Starlight sl = TFile.Open("/home/jaroslav/sim/noon-master/SLoutput.root") hSLy = sl.Get("hAY") hSLy.Draw("same") gPad.SetGrid() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def neut_en_pn(): #neutron energy and positive and negative rapidity #plot range ebin = 18 emin = 10 emax = 700 sel = "" #sel = "npos==1 && nneg == 1" #sel = "npos==2 && nneg == 2" #sel = "npos>1 || nneg>1" hE = ut.prepare_TH2D("hE", ebin, emin, emax, ebin, emin, emax) can = ut.box_canvas() tree.Draw("epos:eneg >> hE", sel) #y:x ut.put_yx_tit(hE, "#it{E}_{#it{n}} (GeV), #it{#eta} > 0", "#it{E}_{#it{n}} (GeV), #it{#eta} < 0", 1.7, 1.2) ut.set_margin_lbtr(gPad, 0.12, 0.09, 0.02, 0.11) hE.SetMinimum(0.98) hE.SetContour(300) hE.Draw() gPad.SetGrid() gPad.SetLogz() 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 eta(): #acceptance in electron polar angle as pi - theta in mrad i1 = "/home/jaroslav/sim/lmon/data/taggers/tag1a/hits_tag.root" i2 = "/home/jaroslav/sim/lmon/data/taggers/tag1ax1/hits_tag.root" #tag = ["s1_IsHit", "Tagger 1", 0.15] tag = ["s2_IsHit", "Tagger 2", 0.3] in1 = TFile.Open(i1) t1 = in1.Get("event") in2 = TFile.Open(i2) t2 = in2.Get("event") #eta xmin = -17 xmax = -3 a1 = rt.acc_Q2_kine(t1, "true_el_theta", tag[0]) a1.modif = 0 # eta from theta a1.prec = 0.01 a1.bmin = 0.1 #a1.nev = int(1e5) g1 = a1.get() a2 = rt.acc_Q2_kine(t2, "true_el_theta", tag[0]) a2.modif = 0 # eta from theta a2.prec = 0.01 a2.bmin = 0.1 #a2.nev = int(1e5) g2 = a2.get() can = ut.box_canvas() frame = gPad.DrawFrame(xmin, 0, xmax, tag[2]) ut.put_yx_tit(frame, "Tagger acceptance", "Electron pseudorapidity #it{#eta}", 1.6, 1.3) frame.Draw() ut.set_margin_lbtr(gPad, 0.11, 0.1, 0.03, 0.02) ut.set_graph(g1, rt.kRed) g1.Draw("psame") ut.set_graph(g2, rt.kBlue) g2.Draw("psame") gPad.SetGrid() leg = ut.prepare_leg(0.15, 0.8, 0.24, 0.14, 0.035) # x, y, dx, dy, tsiz leg.AddEntry("", tag[1], "") leg.AddEntry(g1, "Quasi-real photoproduction", "lp") leg.AddEntry(g2, "Pythia 6", "lp") leg.Draw("same") #ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def energy(): #acceptance in electron energy i1 = "/home/jaroslav/sim/lmon/data/taggers/tag1a/hits_tag.root" i2 = "/home/jaroslav/sim/lmon/data/taggers/tag1ax1/hits_tag.root" #tag = ["s1_IsHit", "Tagger 1", 2] tag = ["s2_IsHit", "Tagger 2", 11] in1 = TFile.Open(i1) t1 = in1.Get("event") in2 = TFile.Open(i2) t2 = in2.Get("event") #mrad xmin = tag[2] xmax = 19 amax = 0.9 a1 = rt.acc_Q2_kine(t1, "true_el_E", tag[0]) a1.prec = 0.05 a1.bmin = 0.1 #a1.nev = int(1e5) g1 = a1.get() a2 = rt.acc_Q2_kine(t2, "true_el_E", tag[0]) a2.prec = 0.05 a2.bmin = 0.1 #a2.nev = int(1e5) g2 = a2.get() can = ut.box_canvas() frame = gPad.DrawFrame(xmin, 0, xmax, amax) ut.put_yx_tit(frame, "Tagger acceptance", "Electron energy #it{E} (GeV)", 1.6, 1.3) frame.Draw() ut.set_margin_lbtr(gPad, 0.11, 0.1, 0.03, 0.02) ut.set_graph(g1, rt.kRed) g1.Draw("psame") ut.set_graph(g2, rt.kBlue) g2.Draw("psame") gPad.SetGrid() leg = ut.prepare_leg(0.15, 0.8, 0.24, 0.14, 0.035) # x, y, dx, dy, tsiz leg.AddEntry("", tag[1], "") leg.AddEntry(g1, "Quasi-real photoproduction", "lp") leg.AddEntry(g2, "Pythia 6", "lp") leg.Draw("same") #ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
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")
def evt_true_lQ2_ly_separate(): #generator true log_10(Q^2) and y, separate for each detector lqbin = 0.2 lqmin = -10 lqmax = 3 ybin = 0.1 ymin = -5 ymax = 0 lQ2form = "TMath::Log10(true_Q2)" lyform = "TMath::Log10(true_y)" hLQ2yAll = ut.prepare_TH2D("hLQ2yAll", ybin * 0.2, ymin, ymax, lqbin * 0.2, lqmin, lqmax) #hLQ2yAll = ut.prepare_TH2D("hLQ2yAll", ybin, ymin, ymax, lqbin, lqmin, lqmax) hLQ2yS1 = ut.prepare_TH2D("hLQ2yS1", ybin, ymin, ymax, lqbin, lqmin, lqmax) hLQ2yS2 = ut.prepare_TH2D("hLQ2yS2", ybin, ymin, ymax, lqbin, lqmin, lqmax) hLQ2yEcal = ut.prepare_TH2D("hLQ2yEcal", ybin, ymin, ymax, lqbin, lqmin, lqmax) can = ut.box_canvas() tree.Draw(lQ2form + ":" + lyform + " >> hLQ2yAll") tree.Draw(lQ2form + ":" + lyform + " >> hLQ2yS1", "lowQ2s1_IsHit==1") tree.Draw(lQ2form + ":" + lyform + " >> hLQ2yS2", "lowQ2s2_IsHit==1") tree.Draw(lQ2form + ":" + lyform + " >> hLQ2yEcal", "ecal_IsHit==1") ytit = "log_{10}(#it{Q}^{2})" #+" / {0:.3f}".format(lqbin)+" GeV^{2}" xtit = "log_{10}(#it{y})" #+" / {0:.1f}".format(xbin) ut.put_yx_tit(hLQ2yAll, ytit, xtit, 1.3, 1.3) ut.set_margin_lbtr(gPad, 0.1, 0.1, 0.01, 0.01) gPad.SetGrid() hLQ2yAll.SetFillColor(rt.kRed - 3) hLQ2yS1.SetFillColor(rt.kYellow) hLQ2yS2.SetFillColor(rt.kGreen) hLQ2yEcal.SetFillColor(rt.kBlue) hLQ2yAll.Draw("box") hLQ2yEcal.Draw("box same") hLQ2yS2.Draw("box same") hLQ2yS1.Draw("box same") leg = ut.prepare_leg(0.12, 0.78, 0.2, 0.18, 0.035) leg.AddEntry(hLQ2yAll, "All quasi-real electrons", "f") leg.AddEntry(hLQ2yS1, "Tagger 1", "f") leg.AddEntry(hLQ2yS2, "Tagger 2", "f") leg.AddEntry(hLQ2yEcal, "ECAL", "f") leg.Draw("same") #ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def acc_mlt_theta_s12(): #acceptance in electron polar angle as -log10(pi - theta) in mrad for tagger 1 and tagger 2 #inp = "/home/jaroslav/sim/lmon/data/taggers/tag1a/hits_tag.root" #inp = "/home/jaroslav/sim/lmon/data/taggers/tag1ax1/hits_tag.root" inp = "/home/jaroslav/sim/lmon/data/taggers/tag2a/hits_tag_10files.root" infile = TFile.Open(inp) tree = infile.Get("event") #mrad tmin = 1.5 tmax = 7.5 #amax = 0.3 amax = 1 as1 = rt.acc_Q2_kine(tree, "true_el_theta", "s1_IsHit") as1.modif = 3 # -log10(pi - theta) as1.prec = 0.05 as1.bmin = 0.1 #as1.nev = int(1e5) gs1 = as1.get() as2 = rt.acc_Q2_kine(tree, "true_el_theta", "s2_IsHit") as2.modif = 3 # -log10(pi - theta) as2.prec = 0.05 as2.bmin = 0.1 #as2.nev = int(1e5) gs2 = as2.get() can = ut.box_canvas() frame = gPad.DrawFrame(tmin, 0, tmax, amax) ut.put_yx_tit(frame, "Acceptance", "Electron -log_{10}(#pi - #it{#theta}_{e})", 1.6, 1.3) frame.Draw() ut.set_margin_lbtr(gPad, 0.11, 0.1, 0.03, 0.02) ut.set_graph(gs1, rt.kBlue) gs1.Draw("psame") ut.set_graph(gs2, rt.kRed) gs2.Draw("psame") gPad.SetGrid() #leg = ut.prepare_leg(0.15, 0.78, 0.24, 0.16, 0.035) # x, y, dx, dy, tsiz #leg.AddEntry(None, "Tagger 1", "") #leg.AddEntry(glQ2Py, "Pythia6", "l") #leg.AddEntry(glQ2Qr, "QR", "l") #leg.Draw("same") ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
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")
def fit_pt2_incoh(): #fit to incoherent MC pT^2 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() hPtIncoh = ut.prepare_TH1D("hPtIncoh", ptbin, ptmin, ptmax) ut.put_yx_tit(hPtIncoh, "Events / ({0:.3f}".format(ptbin) + " GeV^{2})", "#it{p}_{T}^{2} (GeV^{2})") tree_incoh.Draw("jRecPt*jRecPt >> hPtIncoh", strsel) #hPtIncoh.Sumw2() #hPtIncoh.Scale(1./hPtIncoh.Integral("width")) ut.set_margin_lbtr(gPad, 0.11, 0.09, 0.01, 0.01) 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) func_incoh_pt2.SetParameters(3000., 5.) r1 = (hPtIncoh.Fit(func_incoh_pt2, "RS")).Get() hPtIncoh.Draw() func_incoh_pt2.Draw("same") 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_pt2, "#it{A}*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.itemRes("#it{A}", r1, 0, rt.kRed) desc.itemRes("#it{b}", r1, 1, rt.kRed) desc.draw() #gPad.SetLogy() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")