def kinematic_plots(var1): fileo2 = TFile("../codeHF/AnalysisResults_O2.root") cres = TCanvas("cres", "resolution distribution") cres.SetCanvasSize(1600, 1200) cres.Divide(1, 3) sig = fileo2.Get("hf-task-jpsi-mc/h%sSig" % var1) bkg = fileo2.Get("hf-task-jpsi-mc/h%sBg" % var1) gen = fileo2.Get("hf-task-jpsi-mc/h%sGen" % var1) cres.cd(1) gPad.SetLogz() sig.Draw("coltz") sig.SetTitle("%s Signal distribution(Rec. Level)" % var1) cres.cd(2) gPad.SetLogz() bkg.Draw("coltz") bkg.SetTitle("%s Background distribution(Rec. Level)" % var1) cres.cd(3) gPad.SetLogz() gen.Draw("coltz") gen.SetTitle("%s Gen distribution(Gen. Level)" % var1) saveCanvas(cres, "%s" % var1) ceff = TCanvas("ceff", "2D efficiencies") ceff.SetCanvasSize(1600, 1200) ceff.cd() eff = sig.Clone("eff") den = gen.Clone("den") eff.Divide(den) eff.Draw("COLZ") eff.SetTitle("%s Jpsi reco and sel. efficiency (Reco pt / Gen pt)" % var1) saveCanvas(ceff, "efficiencyYpt")
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 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 DrawMC_DetectorResponse(mc): # Canvas padQA.Clear() padQA.SetWindowSize(1600, 600) padQA.Divide(2) padQA.SetTicks() padQA.Draw() # Histos drmPrompt = mc.FindObject("JpsiPrompt").FindObject("Jet_DetResponse").Clone("hsDrmPrompt") drmBdecay = mc.FindObject("JpsiBdecay").FindObject("Jet_DetResponse").Clone("hsDrmBdecay") # jet pT ptPrompt = GetDetectorResponse_JetPt(drmPrompt, "Prompt") ptBdecay = GetDetectorResponse_JetPt(drmBdecay, "Bdecay") padQA.cd(1) ptPrompt.Draw("COLZ") gPad.SetLogz() padQA.cd(2) ptBdecay.Draw("COLZ") ROOT.gPad.SetLogz() padQA.Print(args.print, "Title:Response_JetPt") # z - Fragmentation Function zPrompt = GetDetectorResponse_FF(drmPrompt, "Prompt") zBdecay = GetDetectorResponse_FF(drmBdecay, "Bdecay") padQA.cd(1) zPrompt.Draw("COLZ") ROOT.gPad.SetLogz() padQA.cd(2) zBdecay.Draw("COLZ") ROOT.gPad.SetLogz() padQA.Print(args.print, "Title:Response_FF") padQA.Clear()
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_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_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 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 plot_page(canvas, histos, histo_title, label, save_name, xtitle=None, ytitle=None, title=None, log=False): canvas.Clear() if isinstance(histos[histo_title], TH1F): histos[histo_title].Draw() elif isinstance(histos[histo_title], TH2F): histos[histo_title].Draw('colz') if log: gPad.SetLogz() else: #raise NotImplementedException('plot_sector_page only supports TH1F, TH2F') pass if title: label.DrawLatex(0.1, 0.925, title) if xtitle: label.DrawLatex(0.5, 0.015, xtitle) if ytitle: label.SetTextAngle(90) label.DrawLatex(0.04, 0.5, ytitle) label.SetTextAngle(0) canvas.Print(save_name)
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 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 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 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 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 setPadStyle(): gPad.SetLeftMargin(0.05) gPad.SetRightMargin(0.08) gPad.SetTopMargin(0.10) gPad.SetBottomMargin(0.10) gPad.SetLogz(plots[plot].zLog) gPad.SetFillColor(kWhite) gPad.SetBorderMode(0)
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 plot_distortion(config, h_dist, h_deltas, h_deltas_vs_dist, prof, suffix, opt_name): cev = TCanvas("canvas_%s_nEv%d_%s" % (suffix, config.train_events, opt_name), "canvas_%s_nEv%d_%s" % (suffix, config.train_events, opt_name), 1600, 1600) cev.Divide(2, 2) c1 = cev.cd(1) c1.SetMargin(0.12, 0.12, 0.12, 0.05) gPad.SetLogz() setup_frame(h_dist, "d#it{%s}_{true} (cm)" % opt_name.lower(), "d#it{%s}_{pred} (cm)" % opt_name.lower(), x_offset=1.2, y_offset=1.2) h_dist.Draw("colz") txt1 = add_desc_to_canvas(config, 0.18, 0.7, 0.3, 0.9, 0.04, {"add_alice": False, "add_gran": True, "add_inputs": False, "add_events": True}) txt1.Draw() c2 = cev.cd(2) c2.SetMargin(0.12, 0.05, 0.12, 0.05) gPad.SetLogy() setup_frame(h_deltas_vs_dist, "d#it{%s}_{true} (cm)" % opt_name.lower(), "Entries", x_offset=1.2, y_offset=1.2) h_deltas_vs_dist.ProjectionX().Draw() txt2 = add_desc_to_canvas(config, 0.18, 0.7, 0.3, 0.9, 0.04, {"add_alice": False, "add_gran": True, "add_inputs": False, "add_events": True}) txt2.Draw() c3 = cev.cd(3) c3.SetMargin(0.12, 0.05, 0.12, 0.05) gPad.SetLogy() setup_frame(h_deltas, "<d#it{%s}_{pred} - d#it{%s}_{true}> (cm)" %\ (opt_name.lower(), opt_name.lower()), "Entries", x_offset=1.2, y_offset=1.5) h_deltas.Draw() txt3 = add_desc_to_canvas(config, 0.18, 0.7, 0.3, 0.9, 0.04, {"add_alice": False, "add_gran": True, "add_inputs": False, "add_events": True}) txt3.Draw() c4 = cev.cd(4) c4.SetMargin(0.15, 0.05, 0.12, 0.05) setup_frame(prof, "d#it{%s}_{true} (cm)" % opt_name.lower(), "<d#it{%s}_{pred} - d#it{%s}_{true}> (cm)" %\ (opt_name.lower(), opt_name.lower()), x_offset=1.2, y_offset=1.8) prof.Draw() txt4 = add_desc_to_canvas(config, 0.45, 0.7, 0.85, 0.9, 0.04, {"add_alice": False, "add_gran": True, "add_inputs": False, "add_events": True}) txt4.Draw() #cev.cd(5) #h_deltas_vs_dist.GetXaxis().SetTitle("Numeric R distortion (cm)") #h_deltas_vs_dist.GetYaxis().SetTitle("(Predicted - Numeric) R distortion (cm)") #h_deltas_vs_dist.Draw("colz") cev.SaveAs("%s/canvas_%s_nEv%d.pdf" % (config.dirplots, suffix, config.train_events))
def plot_sector_page_single(canvas, histos, title_formatter, save_name, xtitle=None, ytitle=None, title=None, x_range=None, log=False, hline=None): """ Plot one histogram for each sector. """ label = TLatex() label.SetNDC() label.SetTextSize(0.045) canvas.Clear() canvas.Divide(3, 2) root_garbage_can = [] for i in range(1, 7): canvas.cd(i) if x_range: histos.get(title_formatter.format(i), default_histo2d).GetXaxis().SetRangeUser( x_range[0], x_range[1]) histos.get(title_formatter.format(i), default_histo2d).Draw('colz') if log: gPad.SetLogz() if title: label.DrawLatex(0.1, 0.925, title) if xtitle: label.DrawLatex(0.45, 0.015, xtitle) if ytitle: label.SetTextAngle(90) label.DrawLatex(0.0325, 0.65, ytitle) label.SetTextAngle(0) if hline: xmin = histos.get(title_formatter.format(i)).GetXaxis().GetXmin() xmax = histos.get(title_formatter.format(i)).GetXaxis().GetXmax() line = TLine(xmin, hline, xmax, hline) line.SetLineColor(1) line.SetLineStyle(1) line.Draw('same') root_garbage_can.append(line) canvas.Print(save_name)
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 CSCFloatSlopeV2(plotter, even): xTitle = "True muon p_{T} * charge [GeV]" yTitle = "CLCT Slope * endcap [Half-strips/layer]" title = "%s;%s;%s" % (topTitle, xTitle, yTitle) for st in range(0, len(cscStations)): h_bins = "(100,-50,50)" nBins = int(h_bins[1:-1].split(',')[0]) minBin = float(h_bins[1:-1].split(',')[1]) maxBin = float(h_bins[1:-1].split(',')[2]) ''' bins with size 1/16-strip / layer 1 bin with size 1/8-strip / layer 1 (overflow) bin with size 1/4-strip / layer ''' h_binsY = [ -2.5, -2.0, -1.75, -1.625, -1.5, -1.375, -1.25, -1.125, -1.0, -0.875, -0.75, -0.625, -0.5, -0.375, -0.25, -0.125, 0.0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1.0, 1.125, 1.25, 1.375, 1.5, 1.625, 1.75, 2.0, 2.5 ] toPlot1 = "%s : (simTrack.pt * simTrack.charge)" % (slope_clct_bend( st, even)) c = newCanvas2D() gPad.SetLogz() base = draw_2Dbis(plotter.tree, title, h_bins, 32, array('d', h_binsY), toPlot1, "", "COLZ") base.GetXaxis().SetLabelSize(0.05) base.GetYaxis().SetLabelSize(0.05) base.GetXaxis().SetTitleSize(0.05) base.GetYaxis().SetTitleSize(0.05) CMS_lumi.CMS_lumi(c, iPeriod, iPos) csc = drawCSCLabel(cscStations[st].label, 0.75, 0.85, 0.05) if even: c.Print("%sOcc_CSCCLCT_floatslope_even_final_%s%s" % (plotter.targetDir + subdirectory, cscStations[st].labelc, plotter.ext)) else: c.Print("%sOcc_CSCCLCT_floatslope_odd_final_%s%s" % (plotter.targetDir + subdirectory, cscStations[st].labelc, plotter.ext)) del c, base, csc
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 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 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 hits_en_z_s1(): #energy along the z position of the hit in s1 #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 zbin = 0.05 # cm zmax = 2 # cm #zmin = -36 # cm zmin = -2 # cm ebin = 0.1 emin = 0 emax = 20 can = ut.box_canvas() hEnZ = ut.prepare_TH2D("hEnZ", zbin, zmin, zmax, ebin, emin, emax) ut.put_yx_tit(hEnZ, "#it{E} (GeV)", "#it{z} (cm)") nevt = tree.GetEntries() #nevt = 100000 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) hEnZ.Fill(hit.z / 10, hit.en) # cm hEnZ.SetMinimum(0.98) hEnZ.SetContour(300) hEnZ.Draw() gPad.SetGrid() gPad.SetLogz() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def el_en_theta(): #electrons energy and theta #bins in theta tbin = 5e-2 tmin = 0 tmax = TMath.Pi() + 1e-2 #bins in energy ebin = 0.6 emin = 0 emax = 50 tree = tree_qr lab_data = "QR" #tree = tree_py #lab_data = "Pythia6" can = ut.box_canvas() hEnThetaAll = ut.prepare_TH2D("hEnThetaAll", tbin, tmin, tmax, ebin, emin, emax) form = "true_el_E:true_el_theta" tree.Draw(form + " >> hEnThetaAll") ytit = "Electron energy #it{E} (GeV)" xtit = "Electron polar angle #theta (rad)" ut.put_yx_tit(hEnThetaAll, ytit, xtit, 1.4, 1.3) ut.set_margin_lbtr(gPad, 0.1, 0.1, 0.015, 0.12) gPad.SetLogz() gPad.SetGrid() hEnThetaAll.SetMinimum(0.98) hEnThetaAll.SetContour(300) hEnThetaAll.Draw("colz") leg = ut.prepare_leg(0.6, 0.82, 0.24, 0.12, 0.04) # x, y, dx, dy, tsiz leg.AddEntry(None, lab_data, "") leg.Draw("same") #ut.invert_col(rt.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")