예제 #1
0
 def plot_distorsion(h_dist, h_deltas, h_deltas_vs_dist, prof, suffix, opt_name, total_events):
     cev = TCanvas("canvas_%s_nEv%d_%s" % (suffix, total_events, opt_name),
                   "canvas_%s_nEv%d_%s" % (suffix, total_events, opt_name),
                   1400, 1000)
     cev.Divide(2, 2)
     cev.cd(1)
     h_dist.GetXaxis().SetTitle("Numeric %s distortion fluctuation (cm)" % opt_name)
     h_dist.GetYaxis().SetTitle("Predicted distortion fluctuation (cm)")
     h_dist.Draw("colz")
     cev.cd(2)
     gPad.SetLogy()
     h_deltas_vs_dist.GetXaxis().SetTitle("Numeric %s distorsion fluctuation (cm)" % opt_name)
     h_deltas_vs_dist.ProjectionX().Draw()
     h_deltas_vs_dist.GetYaxis().SetTitle("Entries")
     cev.cd(3)
     gPad.SetLogy()
     h_deltas.GetXaxis().SetTitle("(Predicted - Numeric) %s distortion fluctuation (cm)"
                                  % opt_name)
     h_deltas.GetYaxis().SetTitle("Entries")
     h_deltas.Draw()
     cev.cd(4)
     prof.GetYaxis().SetTitle("(Predicted - Numeric) %s distortion fluctuation (cm)" % opt_name)
     prof.GetXaxis().SetTitle("Numeric %s distortion fluctuation (cm)" % opt_name)
     prof.Draw()
     #cev.cd(5)
     #h_deltas_vs_dist.GetXaxis().SetTitle("Numeric R distorsion (cm)")
     #h_deltas_vs_dist.GetYaxis().SetTitle("(Predicted - Numeric) R distorsion (cm)")
     #h_deltas_vs_dist.Draw("colz")
     cev.SaveAs("plots/canvas_%s_nEv%d.pdf" % (suffix, total_events))
예제 #2
0
 def plot_distorsion(h_dist, h_deltas, h_deltasvsdist, prof, suffix,
                     namevar):
     cev = TCanvas("canvas" + suffix, "canvas" + suffix, 1400, 1000)
     cev.Divide(2, 2)
     cev.cd(1)
     h_dist.GetXaxis().SetTitle("Numeric %s distortion fluctuation (cm)" %
                                namevar)
     h_dist.GetYaxis().SetTitle("Predicted distortion fluctuation (cm)")
     h_dist.Draw("colz")
     cev.cd(2)
     gPad.SetLogy()
     h_deltasvsdist.GetXaxis().SetTitle(
         "Numeric %s distorsion fluctuation (cm)" % namevar)
     h_deltasvsdist.GetYaxis().SetTitle("Entries")
     h_deltasvsdist.ProjectionX().Draw()
     cev.cd(3)
     gPad.SetLogy()
     h_deltas.GetXaxis().SetTitle(
         "(Predicted - Numeric) %s distortion fluctuation (cm)" % namevar)
     h_deltas.GetYaxis().SetTitle("Entries")
     h_deltas.Draw()
     cev.cd(4)
     prof.GetYaxis().SetTitle(
         "(Predicted - Numeric) %s distortion fluctuation (cm)" % namevar)
     prof.GetXaxis().SetTitle("Numeric %s distortion fluctuation (cm)" %
                              namevar)
     prof.Draw()
     #cev.cd(5)
     #h_deltasvsdist.GetXaxis().SetTitle("Numeric R distorsion (cm)")
     #h_deltasvsdist.GetYaxis().SetTitle("(Predicted - Numeric) R distorsion (cm)")
     #h_deltasvsdist.Draw("colz")
     cev.SaveAs("plots/canvas_%s.pdf" % (suffix))
예제 #3
0
파일: lat3.py 프로젝트: gothman5/LAT
def MakeCutPlot(c,cal,var,eb,elo,ehi,vb,vlo,vhi,d2Cut,d1Cut,outPlot,fastMode):
    """ Creates a channel-specific energy calibration plot. """

    # Calculate cut vals (assumes plot range is correct)
    h1 = wl.H1D(cal,vb,vlo,vhi,var,d1Cut)
    h1Sum = h1.Integral()
    if h1Sum == 0:
        print "Error: Failed %s, histogram sum is 0 so cannot normalize, setting to [0,0,0,0,0]"%(var)
        return 0,0,0,0,0
    h1.Scale(1/h1Sum)
    try:
        cut99,cut95,cut01,cut05,cut90 = wl.GetIntegralPoints(h1)
    except:
        print "Error: Failed %s using cut %s, setting to [0,0,0,0,0]"%(var,d1Cut)
        return 0,0,0,0,0
    if fastMode:
        print "Returning fastMode output: ", cut99,cut95,cut01,cut05,cut90
        return cut99,cut95,cut01,cut05,cut90

    # Generate the plot for inspection.
    c.cd(2)
    gPad.SetLogy(0)
    h1.GetXaxis().SetRangeUser(cut01-abs(0.25*cut01), cut99 + abs(0.25*cut99) )
    h1.SetTitle("")
    h1.GetXaxis().SetTitle(var)
    h1.Draw("hist")

    c.cd(1)
    gPad.SetLogy(0)
    cal.Draw("%s:trapENFCal>>b(%d,%d,%d,%d,%.3E,%.3E)"%(var,eb+10,elo-5,ehi+5,vb,cut01-abs(0.25*cut01),cut99+abs(0.25*cut99)) ,d2Cut)

    l1, l2, l3 = TLine(), TLine(), TLine()
    l1.SetLineColor(ROOT.kGreen)
    l2.SetLineColor(ROOT.kRed)
    l3.SetLineColor(ROOT.kMagenta)

    l1.DrawLine(elo-5, cut99, ehi+5, cut99)
    l2.DrawLine(elo-5, cut95, ehi+5, cut95)
    l2.DrawLine(elo-5, cut05, ehi+5, cut05)
    l1.DrawLine(elo-5, cut01, ehi+5, cut01)

    c.cd(3)
    x_h1, y_h1 = wl.npTH1D(h1)
    int_h1 = wl.integFunc(y_h1)
    g2 = TGraph(len(x_h1), x_h1, int_h1)
    g2.GetXaxis().SetRangeUser(cut01-abs(0.3*cut01), cut99 + abs(0.3*cut99) )
    g2.SetTitle("")
    g2.GetXaxis().SetTitle(var)
    g2.GetYaxis().SetTitle("Percentile")
    g2.Draw("ACP")
    l1.DrawLine(cut99, 0, cut99, 1)
    l2.DrawLine(cut95, 0, cut95, 1)
    l1.DrawLine(cut01, 0, cut01, 1)
    l2.DrawLine(cut05, 0, cut05, 1)

    c.Print(outPlot)
    return cut99,cut95,cut01,cut05,cut90
예제 #4
0
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))
예제 #5
0
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")
예제 #6
0
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")
예제 #7
0
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")
예제 #8
0
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")
예제 #9
0
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")
예제 #10
0
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")
예제 #11
0
def efficiencytracking():

    hadron_list = ["pion", "proton", "electron", "muon"]
    color_list = [1, 2, 4, 6]
    fileo2 = TFile("../codeHF/AnalysisResults_O2.root")

    c1 = TCanvas("c1", "A Simple Graph Example")
    c1.SetCanvasSize(1500, 1500)
    c1.cd()
    gPad.SetLogx()
    gPad.SetLogy()
    eff_list = []
    hempty = TH1F("hempty", ";p_{T};efficiency", 100, 0.001, 5.0)
    hempty.Draw()
    leg = TLegend(0.1, 0.7, 0.3, 0.9, "")
    leg.SetFillColor(0)

    for i, had in enumerate(hadron_list):
        hnum = fileo2.Get("qa-tracking-efficiency-%s/num" % had)
        hden = fileo2.Get("qa-tracking-efficiency-%s/den" % had)
        hnum.Rebin(4)
        hden.Rebin(4)
        eff = TEfficiency(hnum, hden)
        eff.SetLineColor(color_list[i])
        eff_list.append(eff)
        eff.Draw("same")
        leg.AddEntry(eff_list[i], had)
    leg.Draw()
    c1.SaveAs("efficiency_tracking.pdf")
예제 #12
0
def makeROC(fpr, tpr, thresholds, AUC, outfile, signal_label,
            background_label):

    c = TCanvas("c", "c", 700, 600)
    gPad.SetMargin(0.15, 0.07, 0.15, 0.05)
    gPad.SetLogy(0)
    gPad.SetGrid(1, 1)
    gStyle.SetGridColor(15)

    roc = TGraph(len(fpr), tpr, fpr)

    roc.SetLineColor(2)
    roc.SetLineWidth(2)
    roc.SetTitle(";Signal efficiency (%s); Background efficiency (%s)" %
                 (signal_label, background_label))
    roc.GetXaxis().SetTitleOffset(1.4)
    roc.GetXaxis().SetTitleSize(0.045)
    roc.GetYaxis().SetTitleOffset(1.4)
    roc.GetYaxis().SetTitleSize(0.045)
    roc.GetXaxis().SetRangeUser(0, 1)
    roc.GetYaxis().SetRangeUser(0.000, 1)
    roc.Draw("AL")

    latex = TLatex()
    latex.SetTextFont(42)
    latex.SetTextSize(0.05)
    latex.DrawLatexNDC(0.2, 0.88, 'AUC = %.3f' % AUC)

    c.SaveAs(outfile)
예제 #13
0
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")
예제 #14
0
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")
예제 #15
0
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")
예제 #16
0
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")
예제 #17
0
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")
예제 #18
0
def aXe():
    can = TCanvas("can", "can", 1000, 900)
    gPad.SetLogy(1)
    gStyle.SetOptStat(0)
    VariablesNum = {}
    VariablesDen = {}
    treeG = {}
    for tre in darkFactors:
        #                treeG[tre] = darkFiles[tre].Get("darkGens")
        VariablesNum[tre] = TH1F(
            tre + "-num", ";Dark Photon Pt [GeV];Acceptance x Efficiency", 26,
            150, 800)
        VariablesDen[tre] = TH1F(
            tre + "-den", ";Dark Photon Pt [GeV];Acceptance x Efficiency", 26,
            150, 800)
        VariablesNum[tre].SetLineColor(colors[tre])
        VariablesNum[tre].SetLineWidth(2)
        treepj[tre].Draw("GenDarkPho_pt>>" + tre + "-num")
        treeTrig[tre].Draw("GenDarkPho_pt>>" + tre + "-den")
        VariablesNum[tre].Sumw2()
        VariablesDen[tre].Sumw2()
        VariablesNum[tre].Divide(VariablesDen[tre])
        VariablesNum[tre].SetMaximum(10.0)
    VariablesNum['df1en0'].Draw('e1')
    VariablesNum['df1en1'].Draw('e1same')
    VariablesNum['df1en2'].Draw('e1same')
    VariablesNum['df1en3'].Draw('e1same')
    led = TLegend(0.6, 0.6, 0.9, 0.9)
    led.AddEntry(VariablesNum['df1en0'], "f_{D} = 1E0")
    led.AddEntry(VariablesNum['df1en1'], "f_{D} = 1E-1")
    led.AddEntry(VariablesNum['df1en2'], "f_{D} = 1E-2")
    led.AddEntry(VariablesNum['df1en3'], "f_{D} = 1E-3")
    led.SetFillColor(0)
    led.Draw("same")
    can.SaveAs("plots/aXe.pdf")
예제 #19
0
def plot_pt():

    #ptbin = 0.03
    #ptmax = 1.1
    #ptbin = 1e-2
    ptbin = 0.5e-2
    ptmax = 0.11

    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, 0, ptmax)

    #tree.Draw("jRecPt >> hPt", strsel)
    tree.Draw("jRecPt*jRecPt >> hPt", strsel)

    print("Entries: ", hPt.GetEntries())

    hPt.Draw()

    gPad.SetGrid()
    gPad.SetLogy()

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
예제 #20
0
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")
예제 #21
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")
예제 #22
0
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")
예제 #23
0
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")
예제 #24
0
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")
예제 #25
0
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")
예제 #26
0
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")
예제 #27
0
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")
예제 #28
0
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")
예제 #29
0
def evt_Log10_Q2_ecal_compare():

    #compare log_10(Q^2) from ecal for two separate inputs

    infile1 = "../data/ir6/lmon_pythia_5M_beff2_5Mevt_v2.root"
    #infile2 = "../data/ir6_close/lmon_pythia_5M_beff2_close_5Mevt.root"
    #infile2 = "../data/ir6/lmon_pythia_5M_beff2_1p5T_5Mevt.root"
    infile2 = "../data/ir6/lmon_pythia_5M_beff2_1p5T_5Mevt_v2.root"

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

    inp1 = TFile.Open(infile1)
    inp2 = TFile.Open(infile2)
    tree1 = inp1.Get("DetectorTree")
    tree2 = inp2.Get("DetectorTree")

    hQ2ecal = ut.prepare_TH1D("hQ2ecal", lqbin, lqmin, lqmax)
    hQ2ecal_close = ut.prepare_TH1D("hQ2ecal_close", lqbin, lqmin, lqmax)

    tree1.Draw(gL10Q2 + " >> hQ2ecal", "ecal_IsHit==1")
    tree2.Draw(gL10Q2 + " >> hQ2ecal_close", "ecal_IsHit==1")

    print "All events:", hQ2ecal.GetEntries()
    #print "Selected  :", hLog10Q2Tag.GetEntries()

    can = ut.box_canvas()
    frame = gPad.DrawFrame(lqmin, 10, lqmax, 1e5)
    frame.Draw()

    ytit = "Events / {0:.3f}".format(lqbin)
    ut.put_yx_tit(frame, ytit, "log_{10}(#it{Q}^{2})", 1.4, 1.2)

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

    ut.line_h1(hQ2ecal, rt.kBlue, 3)
    ut.line_h1(hQ2ecal_close, rt.kRed, 3)

    #hQ2ecal.SetMinimum(10)

    gPad.SetLogy()
    gPad.SetGrid()

    hQ2ecal.Draw("e1same")
    hQ2ecal_close.Draw("e1same")

    #hLog10Q2.SetMaximum(2e5) # for qr

    leg = ut.prepare_leg(0.6, 0.83, 0.2, 0.1, 0.035)
    #leg.AddEntry(hLog10Q2, "All electrons from quasi-real photoproduction", "l")
    #leg.AddEntry(hLog10Q2, "All Pythia6 scattered electrons", "l")
    #leg.AddEntry(hLog10Q2Tag, "Electrons hitting the tagger", "l")
    leg.AddEntry(hQ2ecal, "Default geometry", "l")
    #leg.AddEntry(hQ2ecal_close, "Magnets in central det", "l")
    leg.AddEntry(hQ2ecal_close, "1.5T solenoid", "l")
    leg.Draw("same")

    #ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
예제 #30
0
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")