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_el_en_log10_theta_tag(): #Tagger acceptance in energy and theta #bins in log_10(theta) ltbin = 0.2 ltmin = -8 ltmax = 1 #bins in energy ebin = 0.4 emin = 0 emax = 21 #sel = "lowQ2s1_IsHit==1" #sel = "lowQ2s2_IsHit==1" sel = "lowQ2s1_IsHit==1 || lowQ2s2_IsHit==1" can = ut.box_canvas() hEnThetaTag = ut.prepare_TH2D("hEnThetaTag", ltbin, ltmin, ltmax, ebin, emin, emax) hEnThetaAll = ut.prepare_TH2D("hEnThetaAll", ltbin, ltmin, ltmax, ebin, emin, emax) form = "el_gen:TMath::Log10(TMath::Pi()-el_theta)" #form = "true_el_E:TMath::Log10(TMath::Pi()-true_el_theta)" tree.Draw(form + " >> hEnThetaTag", sel) tree.Draw(form + " >> hEnThetaAll") hEnThetaTag.Divide(hEnThetaAll) ytit = "Electron energy #it{E}_{e} / " + "{0:.1f} GeV".format(ebin) xtit = "Scattering angle log_{10}(#theta_{e}) / " + "{0:.2f} rad".format( ltbin) ut.put_yx_tit(hEnThetaTag, ytit, xtit, 1.4, 1.3) hEnThetaTag.SetTitleOffset(1.5, "Z") hEnThetaTag.SetZTitle("Acceptance") ut.set_margin_lbtr(gPad, 0.1, 0.1, 0.015, 0.15) #gPad.SetLogz() gPad.SetGrid() hEnThetaTag.SetMinimum(0) hEnThetaTag.SetMaximum(1) hEnThetaTag.SetContour(300) hEnThetaTag.Draw("colz") ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def acc_el_en_theta_tag(): #Tagger acceptance in energy and theta #bins in theta tbin = 4e-4 tmin = TMath.Pi() - 2.1e-2 tmax = TMath.Pi() + 0.5e-2 #bins in energy ebin = 0.3 emin = 0 emax = 21 sel = "lowQ2s1_IsHit==1" #sel = "lowQ2s2_IsHit==1" #sel = "lowQ2s1_IsHit==1 || lowQ2s2_IsHit==1" can = ut.box_canvas() hEnThetaTag = ut.prepare_TH2D("hEnThetaTag", tbin, tmin, tmax, ebin, emin, emax) hEnThetaAll = ut.prepare_TH2D("hEnThetaAll", tbin, tmin, tmax, ebin, emin, emax) form = "true_el_E:true_el_theta" tree.Draw(form + " >> hEnThetaTag", sel) tree.Draw(form + " >> hEnThetaAll") hEnThetaTag.Divide(hEnThetaAll) ytit = "Electron energy #it{E} (GeV)" xtit = "Electron polar angle #theta (rad)" ut.put_yx_tit(hEnThetaTag, ytit, xtit, 1.4, 1.3) hEnThetaTag.SetTitleOffset(1.5, "Z") hEnThetaTag.SetZTitle("Acceptance") ut.set_margin_lbtr(gPad, 0.1, 0.1, 0.015, 0.15) #gPad.SetLogz() gPad.SetGrid() hEnThetaTag.SetMinimum(0) hEnThetaTag.SetMaximum(1) hEnThetaTag.SetContour(300) hEnThetaTag.Draw("colz") 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")
def hits_xy_phot(): #hits on photon detector in xy xybin = 0.1 xysiz = 22 can = ut.box_canvas() hXY = ut.prepare_TH2D("hXY", xybin, -xysiz/2., xysiz/2., xybin, -xysiz/2., xysiz/2.) nevt = tree.GetEntries() #nevt = 10000 hits = BoxCalV2Hits("phot", 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) hXY.SetMinimum(0.98) hXY.SetContour(300) hXY.Draw() gPad.SetGrid() gPad.SetLogz() 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 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 evt_log10_Q2_theta(): #log_10(Q^2) and theta lqbin = 0.01 lqmin = -8 lqmax = -1 tbin = 1e-4 tmin = 0 tmax = 0.011 hlQ2thetaTag = ut.prepare_TH2D("hlQ2thetaTag", tbin, tmin, tmax, lqbin, lqmin, lqmax) tree.Draw(gL10Q2 + ":TMath::Pi()-el_theta >> hlQ2thetaTag", gQ2sel) ytit = "log_{10}(Q^{2}) / " + "{0:.3f}".format(lqbin) xtit = "Polar angle #theta (rad) / {0:.2f} mrad".format(tbin * 1e3) ut.put_yx_tit(hlQ2thetaTag, ytit, xtit, 1.6, 1.4) can = ut.box_canvas() ut.set_margin_lbtr(gPad, 0.12, 0.1, 0.03, 0.12) #gPad.SetLogx() gPad.SetLogz() hlQ2thetaTag.Draw() #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 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 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_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 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 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 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 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 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 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 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_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 evt_lx_ly(): #log_10(x) and log_10(y) xbin = 0.01 #xbin = 0.1 xmin = -14 xmax = 0 ybin = 0.01 #ybin = 0.1 ymin = -5 ymax = 0 hXY = ut.prepare_TH2D("hXY", xbin, xmin, xmax, ybin, ymin, ymax) hXYtag = ut.prepare_TH2D("hXYtag", xbin, xmin, xmax, ybin, ymin, ymax) can = ut.box_canvas() #yform = "(18.-el_gen)/18." yform = "1.-(1.-TMath::Cos(el_theta))*el_gen/(2.*18.)" #yform = Q2form = "2.*18.*el_gen*(1.-TMath::Cos(TMath::Pi()-el_theta))" xform = Q2form + "/((" + yform + ")*19800.82)" lyform = "TMath::Log10(" + yform + ")" lxform = "TMath::Log10(" + xform + ")" tree.Draw(lyform + ":" + lxform + " >> hXY") tree.Draw(lyform + ":" + lxform + " >> hXYtag", gQ2sel) ytit = "log_{10}(#it{y})" + " / {0:.3f}".format(ybin) xtit = "log_{10}(#it{x})" + " / {0:.3f}".format(xbin) ut.put_yx_tit(hXY, ytit, xtit, 1.4, 1.4) ut.put_yx_tit(hXYtag, ytit, xtit, 1.4, 1.4) ut.set_margin_lbtr(gPad, 0.1, 0.11, 0.03, 0.12) hXY.Draw() #hXYtag.Draw() gPad.SetGrid() gPad.SetLogz() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def hits_xy_s1(): #hits on s1 tagger in xy #bin in mm xybin = 3 #tagger location in x and z xpos = 528.56 # mm zpos = -24000 # mm rot_y = -0.018332 # rad, rotation in x-z plane by rotation along y #rot_y = 0 #front area, mm xysiz = 430 #minimal z to select the front face zmin = -5 # mm #minimal energy for the hit emin = 1 # GeV can = ut.box_canvas() hXY = ut.prepare_TH2D("hXY", xybin, -xysiz / 2., xysiz / 2., xybin, -xysiz / 2., xysiz / 2.) #nevt = tree.GetEntries() nevt = 1000000 hits = BoxCalV2Hits("lowQ2s1", tree) for ievt in xrange(nevt): tree.GetEntry(ievt) for ihit in xrange(hits.GetN()): hit = hits.GetHit(ihit) hit.GlobalToLocal(xpos, 0, zpos, rot_y) if hit.z < zmin: continue #if hit.en < emin: continue hXY.Fill(hit.x, hit.y) ut.put_yx_tit(hXY, "#it{x} (mm)", "#it{y} (mm)") ut.set_margin_lbtr(gPad, 0.11, 0.08, 0.01, 0.12) hXY.SetMinimum(0.98) hXY.SetContour(300) hXY.Draw() gPad.SetGrid() gPad.SetLogz() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def el_hit_xy(): #electron hit on the tagger in x and y #xybin = 0.3 # s1 #xpos = 51 #xysiz = 42 xybin = 0.1 # s2 xpos = 63 xysiz = 28 #xybin = 0.5 # ecal #xpos = 0 #xysiz = 200 #xpos = 47.2 # Q3eR #xysiz = 2 #xybin = 0.01 #ybin = 1 #nam = "lowQ2s1" nam = "lowQ2s2" #nam = "ecal" #nam = "Q3eR" can = ut.box_canvas() #x and y of the electrons hXY = ut.prepare_TH2D("hXY", xybin, xpos - (xysiz / 2.), xpos + (xysiz / 2.), xybin, -xysiz / 2., xysiz / 2.) #hXY = ut.prepare_TH2D_n("hXY", 50, xmin, xmax, 50, ymin, ymax) #tree.Draw(nam+"_hy/10:"+nam+"_hx/10 >> hXY", nam+"_IsHit==1") tree.Draw(nam + "_hy/10:" + nam + "_hx/10 >> hXY", "phot_gen<1.8") print "Entries:", hXY.GetEntries() ut.put_yx_tit(hXY, "Vertical #it{y} (cm)", "Horizontal #it{x} (cm)", 1.4, 1.2) ut.set_margin_lbtr(gPad, 0.1, 0.09, 0.09, 0.12) hXY.SetMinimum(0.98) hXY.SetContour(300) hXY.GetXaxis().SetMoreLogLabels() hXY.Draw() gPad.SetGrid() gPad.SetLogz() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def el_theta_phi_tag(): #electron generated polar and azimuthal angle for electrons hitting the tagger #bins in theta tbin = 1e-4 tmin = 3e-4 tmax = 1.1e-2 #bins in phi pbin = 1e-1 pmin = -TMath.Pi() pmax = TMath.Pi() can = ut.box_canvas() hThetaPhi = ut.prepare_TH2D("hThetaPhi", tbin, tmin, tmax, pbin, pmin, pmax) hThetaPhiTag = ut.prepare_TH2D("hThetaPhiTag", tbin, tmin, tmax, pbin, pmin, pmax) tree.Draw("el_phi:TMath::Pi()-el_theta >> hThetaPhi") tree.Draw("el_phi:TMath::Pi()-el_theta >> hThetaPhiTag", gQ2sel) ytit = "Azimuthal angle #varphi (rad) / {0:.3f}".format(pbin) xtit = "Polar angle #theta (rad) / {0:.2f} mrad".format(tbin * 1e3) ut.put_yx_tit(hThetaPhiTag, ytit, xtit, 1.2, 1.4) ut.set_margin_lbtr(gPad, 0.09, 0.1, 0.03, 0.12) gPad.SetLogx() #gPad.SetLogz() hThetaPhiTag.GetXaxis().SetMoreLogLabels() #hThetaPhi.Draw() hThetaPhiTag.Draw() #ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def el_en_log10_theta_tag(): #electron generated energy and log_10 of polar angle for electrons hitting the tagger #bins in log_10(theta) ltbin = 0.1 ltmin = -7 ltmax = -1.2 #ltbin = 0.01 #ltmin = -2 #ltmax = 0 #bins in energy ebin = 0.1 emin = 1 #emax = 14 emax = 20 #ebin = 0.1 #emin = 0 #emax = 20 sel = "" #sel = "lowQ2s1_IsHit==1" #sel = "lowQ2s2_IsHit==1" #sel = "ecal_IsHit==1" #gQ2sel = "lowQ2s1_IsHit==1 || lowQ2s2_IsHit==1 || ecal_IsHit==1" can = ut.box_canvas() hEnThetaTag = ut.prepare_TH2D("hEnThetaTag", ltbin, ltmin, ltmax, ebin, emin, emax) tree.Draw("el_gen:TMath::Log10(TMath::Pi()-el_theta) >> hEnThetaTag", sel) ytit = "#it{E}_{e} / " + "{0:.1f} GeV".format(ebin) xtit = "log_{10}(#theta_{e}) / " + "{0:.2f} rad".format(ltbin) ut.put_yx_tit(hEnThetaTag, ytit, xtit, 1.6, 1.3) ut.set_margin_lbtr(gPad, 0.12, 0.1, 0.03, 0.11) gPad.SetLogz() gPad.SetGrid() hEnThetaTag.SetMinimum(0.98) hEnThetaTag.SetContour(300) #hEnThetaTag.SetContour(10) hEnThetaTag.Draw("colz") ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def xypos(): xybin = 1 xymax = 120 #inp = "hits_spect.root" #inp = "/home/jaroslav/sim/lmon/data/luminosity/lm2a/hits_spect.root" #inp = "/home/jaroslav/sim/lmon/data/luminosity/lm2ax1/hits_spect.root" #inp = "/home/jaroslav/sim/lmon/data/luminosity/lm1bx1/hits_spect.root" inp = "/home/jaroslav/sim/lmon/data/luminosity/lm1cx1/hits_spect.root" #det = "phot" #det = "up" det = "down" #det = "ew_front" #det = "ew_rear" #det = "mag_front" #det = "mag_rear" sel = "" #sel += "(pdg!=22)" infile = TFile.Open(inp) tree = infile.Get(det) can = ut.box_canvas() hxy = ut.prepare_TH2D("hxy", xybin, -xymax, xymax, xybin, -xymax, xymax) tree.Draw("y:x >> hxy", sel) hxy.SetXTitle("#it{x} (mm)") hxy.SetYTitle("#it{y} (mm)") hxy.SetTitleOffset(1.3, "Y") hxy.SetTitleOffset(1.3, "X") hxy.GetXaxis().CenterTitle() hxy.GetYaxis().CenterTitle() ut.set_margin_lbtr(gPad, 0.09, 0.1, 0.02, 0.11) hxy.SetMinimum(0.98) hxy.SetContour(300) gPad.SetLogz() gPad.SetGrid() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def theta_both(): #inp = "/home/jaroslav/sim/bhgen/data/g18x275_emin0p5/evt.root" inp = "/home/jaroslav/sim/bhgen/data/g18x275_emin0p5_100Mevt/evt.root" #inp = "/home/jaroslav/sim/bhgen/data/g10x100_emin0p5_100Mevt/evt.root" #photon scattering angle as pi - theta, mrad xbin = 0.2 xmin = 0 xmax = 12 #electron scattering angle as pi - theta_e, mrad ybin = 0.6 ymin = 0 ymax = 30 infile = TFile.Open(inp) tree = infile.Get("bhgen_tree") can = ut.box_canvas() hXY = ut.prepare_TH2D("hXY", xbin, xmin, xmax, ybin, ymin, ymax) sel = "(p_pt*1e3>50)&&(el_en>8)&&(el_en<16)&&(phot_en>5)" tree.Draw("((TMath::Pi()-el_theta)*1000):((TMath::Pi()-phot_theta)*1000) >> hXY", sel) ytit = "Electron scattering angle #it{#pi}-#it{#theta}_{e} (mrad)" xtit = "Photon scattering angle #it{#pi}-#it{#theta}_{#gamma} (mrad)" ut.put_yx_tit(hXY, ytit, xtit, 1.3, 1.3) ut.set_margin_lbtr(gPad, 0.1, 0.1, 0.015, 0.11) gPad.SetGrid() gPad.SetLogz() hXY.SetMinimum(0.98) hXY.SetContour(300) hXY.Draw("colz") leg = ut.prepare_leg(0.45, 0.75, 0.24, 0.2, 0.035) # x, y, dx, dy, tsiz leg.AddEntry("", "18x275 GeV", "") #leg.AddEntry("", "10x100 GeV", "") leg.AddEntry("", "Proton #it{p}_{T} > 50 MeV", "") leg.AddEntry("", "Electron 8 < #it{E}_{e} < 16 GeV", "") leg.AddEntry("", "Photon #it{E}_{#gamma} > 5 GeV", "") leg.Draw("same") #ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def hits_xy_s2(): #hits on s2 tagger in xy #Tagger 2 position xpos = 661.88 # mm zpos = -37000 # mm rot_y = -0.018332 # rad #front area, mm xysiz = 330 #minimal z to select the front face zmin = -5 # mm #bin in mm xybin = 3 can = ut.box_canvas() hXY = ut.prepare_TH2D("hXY", xybin, -xysiz / 2., xysiz / 2., xybin, -xysiz / 2., xysiz / 2.) #nevt = tree.GetEntries() nevt = 100000 hits = BoxCalV2Hits("lowQ2s2", tree) for ievt in xrange(nevt): tree.GetEntry(ievt) for ihit in xrange(hits.GetN()): hit = hits.GetHit(ihit) hit.GlobalToLocal(xpos, 0, zpos, rot_y) if hit.z < zmin: continue #if hit.en < emin: continue hXY.Fill(hit.x, hit.y) hXY.SetMinimum(0.98) hXY.SetContour(300) hXY.Draw() gPad.SetGrid() gPad.SetLogz() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def plot_2d(): zmin = 0 zbin = 10 #zmax = 400 zmax = 1300 ptmax = 0.18 #mmin = 1.5 #mmax = 5. mmin = 2.8 mmax = 3.2 east_1n = 120.3335 west_1n = 138.9685 znam = ["jZDCUnAttEast", "jZDCUnAttWest"] xtit = ["ZDC East ADC", "ZDC West ADC"] can = ut.box_canvas() strsel = "1" strsel += " && jRecPt<{0:.3f}".format(ptmax) 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) print(strsel) hZdc = ut.prepare_TH2D("hZdc", zbin, zmin, zmax, zbin, zmin, zmax) tree.Draw(znam[1] + ":" + znam[0] + " >> hZdc", strsel) # y:x print("Entries: ", hZdc.GetEntries()) 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 pitheta_en(): #inp = "/home/jaroslav/sim/bhgen/data/g18x275_emin0p5/evt.root" #inp = "/home/jaroslav/sim/bhgen/data/g18x275_emin0p5_100Mevt/evt.root" inp = "/home/jaroslav/sim/bhgen/data/g10x100_emin0p5_100Mevt/evt.root" #photon energy, GeV xbin = 0.3 xmin = 0.1 #xmax = 19 xmax = 11 #photon scattering angle as pi - theta, mrad ybin = 0.2 ymin = 0 ymax = 12 infile = TFile.Open(inp) tree = infile.Get("bhgen_tree") can = ut.box_canvas() hXY = ut.prepare_TH2D("hXY", xbin, xmin, xmax, ybin, ymin, ymax) tree.Draw("((TMath::Pi()-phot_theta)*1000):phot_en >> hXY", "p_pt*1e3 > 50")#, "", int(5e6)) ytit = "Photon scattering angle #it{#pi}-#it{#theta}_{#gamma} (mrad)" xtit = "Photon energy #it{E}_{#gamma} (GeV)" ut.put_yx_tit(hXY, ytit, xtit, 1.3, 1.3) ut.set_margin_lbtr(gPad, 0.1, 0.1, 0.015, 0.11) gPad.SetGrid() gPad.SetLogz() hXY.SetMinimum(0.98) hXY.SetContour(300) hXY.Draw("colz") leg = ut.prepare_leg(0.5, 0.85, 0.24, 0.1, 0.035) # x, y, dx, dy, tsiz #leg.AddEntry("", "18x275 GeV", "") leg.AddEntry("", "10x100 GeV", "") leg.AddEntry("", "Proton #it{p}_{T} > 50 MeV", "") leg.Draw("same") #ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")