Ejemplo n.º 1
0
def pressure_func():

    gen = make_gen()

    #pressure function
    pf = gen.pressure_func

    ut.set_F1(pf, rt.kBlue)

    can = ut.box_canvas()
    frame = gPad.DrawFrame(-5.5e3, 0, 15.5e3, 7e-9)

    pf.Draw("same")

    gPad.SetGrid()

    ut.invert_col(gPad)
    can.SaveAs("01fig.pdf")
Ejemplo n.º 2
0
def vtx_yz():

    #vertex position in yz plane
    zmin = -5.5
    zmax = 15.5
    zbin = 1e-1

    ymax = 15
    ybin = 0.1

    #gdir = "/home/jaroslav/sim/GETaLM_data/beam_gas/"
    #inp = "beam_gas_ep_10GeV_emin0p1_10Mevt.root"
    gdir = "/home/jaroslav/sim/GETaLM/cards/"
    inp = "bg.root"

    infile = TFile.Open(gdir + inp)
    tree = infile.Get("ltree")

    can = ut.box_canvas()

    hyz = ut.prepare_TH2D("hyz", zbin, zmin, zmax, ybin, -ymax, ymax)

    tree.Draw("vtx_y:(vtx_z/1e3) >> hyz")

    hyz.SetXTitle("#it{z} (m)")
    hyz.SetYTitle("#it{y} (mm)")

    hyz.SetTitleOffset(1.3, "Y")
    hyz.SetTitleOffset(1.3, "X")

    hyz.GetXaxis().CenterTitle()
    hyz.GetYaxis().CenterTitle()

    ut.set_margin_lbtr(gPad, 0.09, 0.1, 0.02, 0.11)

    hyz.SetMinimum(0.98)
    hyz.SetContour(300)

    gPad.SetLogz()

    gPad.SetGrid()

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Ejemplo n.º 3
0
def lQ2_rec_gen_p10():

    #reconstructed and generated Q^2 with labels in powers of 10

    lqbin = 0.1
    gen_min = -8
    rec_min = -6
    lqmax = -1

    can = ut.box_canvas()
    hLQ2 = ut.prepare_TH2D("hLQ2", lqbin, gen_min, lqmax, lqbin, rec_min,
                           lqmax)

    tree.Draw("rec_lq:true_lq >> hLQ2")

    ytit = "Reconstructed electron log_{10}(Q^{2})"
    xtit = "Generated true log_{10}(Q^{2})"
    ut.put_yx_tit(hLQ2, ytit, xtit, 1.9, 1.3)

    ut.set_margin_lbtr(gPad, 0.14, 0.1, 0.03, 0.11)

    #labels in power of 10 along y
    ay = hLQ2.GetYaxis()
    laby = range(rec_min, lqmax + 1, 1)
    #for i in range(len(laby)):
    #ay.ChangeLabel(i+1, -1, -1, -1, -1, -1, "10^{"+str(laby[i])+"}")
    #ay.SetLabelOffset(0.012)

    hLQ2.Draw()

    hLQ2.SetMinimum(0.98)
    hLQ2.SetContour(300)

    gPad.SetGrid()

    gPad.SetLogz()

    leg = ut.prepare_leg(0.15, 0.85, 0.24, 0.1, 0.035)  # x, y, dx, dy, tsiz
    leg.AddEntry("", "Tagger 1", "")
    #leg.AddEntry("", "Tagger 2", "")
    leg.Draw("same")

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Ejemplo n.º 4
0
def evt_Q2_el_Q2():

    #comparison between true Q^2 and electron Q^2

    lqbin = 0.02
    lqmin = -10
    lqmax = 3
    #lqmin = -2.5 # ecal
    #lqmax = 3

    #Q2sel = "lowQ2s1_IsHit==1"
    #Q2sel = "lowQ2s2_IsHit==1"
    #Q2sel = "ecal_IsHit==1"
    #Q2sel = "lowQ2s1_IsHit==1 || lowQ2s2_IsHit==1"
    #Q2sel = "lowQ2s1_IsHit==1 || lowQ2s2_IsHit==1 || ecal_IsHit==1"
    Q2sel = ""

    hQ2 = ut.prepare_TH2D("hQ2", lqbin, lqmin, lqmax, lqbin, lqmin, lqmax)

    can = ut.box_canvas()

    Q2form = "(2*18*el_gen*(1-TMath::Cos(TMath::Pi()-el_theta)))"
    #Q2form = "gen_el_Q2" # from generator

    tree.Draw("TMath::Log10(" + Q2form + "):TMath::Log10(true_Q2) >> hQ2",
              Q2sel)

    ytit = "Electron  log_{10}(#it{Q}^{2}_{e})"  #+" / {0:.3f}".format(xbin)
    xtit = "Generator true  log_{10}(#it{Q}^{2})"  #+" / {0:.3f}".format(xbin)
    ut.put_yx_tit(hQ2, ytit, xtit, 1.6, 1.4)

    ut.set_margin_lbtr(gPad, 0.12, 0.11, 0.03, 0.12)

    hQ2.Draw()

    hQ2.SetMinimum(0.98)
    hQ2.SetContour(300)

    gPad.SetGrid()

    gPad.SetLogz()

    #ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Ejemplo n.º 5
0
def el_en_theta_tag():

    #electron generated energy and polar angle for electrons hitting the tagger

    #bins in log_10(theta)
    tbin = 0.001
    tmin = 0.0001
    tmax = 1

    #bins in energy
    ebin = 0.1
    emin = 3
    emax = 20

    #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", tbin, tmin, tmax, ebin, emin,
                                  emax)

    tree.Draw("el_gen:(TMath::Pi()-el_theta) >> hEnThetaTag", sel)

    ytit = "#it{E}_{e} / " + "{0:.1f} GeV".format(ebin)
    xtit = "#theta_{e} / " + "{0:.1f} rad".format(tbin)
    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")
Ejemplo n.º 6
0
def evt_true_lQ2_lx():

    #generator true log_10(Q^2) and x

    lqbin = 5e-2
    #lqmin = -5
    lqmin = -10
    lqmax = 3

    #xbin = 0.01
    xbin = 0.1
    xmin = -12
    xmax = 0

    #Q2sel = "lowQ2s1_IsHit==1"
    #Q2sel = "lowQ2s2_IsHit==1"
    #Q2sel = "ecal_IsHit==1"
    #Q2sel = "lowQ2s1_IsHit==1 || lowQ2s2_IsHit==1"
    #Q2sel = "lowQ2s1_IsHit==1 || lowQ2s2_IsHit==1 || ecal_IsHit==1"
    Q2sel = ""

    lQ2form = "TMath::Log10(true_Q2)"
    lxform = "TMath::Log10(true_x)"

    hLog10Q2xTag = ut.prepare_TH2D("hLog10Q2xTag", xbin, xmin, xmax, lqbin,
                                   lqmin, lqmax)

    can = ut.box_canvas()

    tree.Draw(lQ2form + ":" + lxform + " >> hLog10Q2xTag", Q2sel)
    #tree.Draw(lQ2form+":"+lxform+" >> hLog10Q2xTag")

    ytit = "log_{10}(#it{Q}^{2})" + " / {0:.3f}".format(lqbin) + " GeV^{2}"
    xtit = "log_{10}(#it{x})" + " / {0:.1f}".format(xbin)
    ut.put_yx_tit(hLog10Q2xTag, ytit, xtit, 1.6, 1.3)

    ut.set_margin_lbtr(gPad, 0.12, 0.1, 0.03, 0.14)

    gPad.SetGrid()

    hLog10Q2xTag.Draw()

    #ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Ejemplo n.º 7
0
def evt_true_lx_ly():

    #generator true log_10(y) and log_10(x)

    xbin = 0.05  # 2e-2
    xmin = -12
    xmax = 0

    ybin = 0.02
    ymin = -4.5
    ymax = 0

    #Q2sel = "lowQ2s1_IsHit==1"
    #Q2sel = "lowQ2s2_IsHit==1"
    #Q2sel = "ecal_IsHit==1"
    #Q2sel = "lowQ2s1_IsHit==1 || lowQ2s2_IsHit==1"
    #Q2sel = "lowQ2s1_IsHit==1 || lowQ2s2_IsHit==1 || ecal_IsHit==1"
    Q2sel = ""

    hXY = ut.prepare_TH2D("hXY", xbin, xmin, xmax, ybin, ymin, ymax)

    can = ut.box_canvas()

    #tree.Draw("TMath::Log10(true_y):TMath::Log10(true_x) >> hXY")
    tree.Draw("TMath::Log10(true_y):TMath::Log10(true_x) >> hXY", Q2sel)

    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.set_margin_lbtr(gPad, 0.1, 0.11, 0.03, 0.12)

    hXY.Draw()

    hXY.SetMinimum(0.98)
    hXY.SetContour(300)

    gPad.SetGrid()

    #gPad.SetLogy()
    gPad.SetLogz()

    #ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Ejemplo n.º 8
0
def phot_gen_en():

    #energy deposited in photon detector relative to generated photon energy

    ebin = 5e-5
    emin = 0
    emax = 5e-3

    can = ut.box_canvas()

    hE = ut.prepare_TH2D("hE", ebin, emin, emax, ebin, emin, emax)

    tree.Draw("phot_en:phot_gen >> hE", "phot_gen<0.003")
    #tree.Draw("phot_en >> hE", "lowQ2s1_IsHit == 1")
    #tree.Draw("phot_gen >> hE", "lowQ2s1_IsHit == 1")
    #tree.Draw("phot_gen >> hE", "lowQ2s2_IsHit == 1")
    #tree.Draw("phot_gen >> hE", "lowQ2s1_en > 1")
    #tree.Draw("phot_gen >> hE", "lowQ2s2_en > 1")

    #hE.SetYTitle("Events / ({0:.3f}".format(ebin)+" GeV)")
    #hE.SetXTitle("#it{E}_{#gamma} (GeV)")

    #hE.SetTitleOffset(1.5, "Y")
    #hE.SetTitleOffset(1.3, "X")

    #gPad.SetTopMargin(0.01)
    #gPad.SetRightMargin(0.02)
    #gPad.SetBottomMargin(0.1)
    #gPad.SetLeftMargin(0.11)

    #hE.GetYaxis().SetMoreLogLabels()

    hE.SetMinimum(0.98)
    hE.SetContour(300)

    hE.Draw()

    gPad.SetLogz()

    gPad.SetGrid()

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Ejemplo n.º 9
0
def main():

    #field = 0.37 # T, 18 GeV
    #field = 0.2 # T, 10 GeV
    field = 0.1  # T, 5 GeV

    emin = 0
    emax = 19

    amax = 1

    can = ut.box_canvas()
    frame = gPad.DrawFrame(emin, 0, emax, amax)

    ut.put_yx_tit(frame, "Spectrometer acceptance",
                  "Photon energy #it{E} (GeV)", 1.6, 1.3)

    frame.Draw()

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

    #geometry
    geo = rt.GeoParser("../../config/geom_all.in")

    #distance from magnet center to the front of spectrometer detectors
    length = geo.GetD("lumi_dipole", "zpos") - geo.GetD(
        "vac_lumi_spec_mid", "z0")

    #print(geo.GetD("lumi_dipole", "zpos"))
    #print(geo.GetD("vac_lumi_spec_mid", "z0"))
    #print(geo.GetD("vac_lumi_spec_mid", "dY0"))
    #print(geo.GetD("vac_lumi_mag_spec", "dY1"))

    #acc = spec_acc(9700, 0.26, 42, 242)
    acc = spec_acc(length, field, geo.GetD("vac_lumi_spec_mid", "dY0"),
                   geo.GetD("vac_lumi_mag_spec", "dY1"))
    acc.scale = 1
    acc.acc_func.Draw("same")

    gPad.SetGrid()

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Ejemplo n.º 10
0
    def draw(self, elements):

        gROOT.SetBatch()

        gStyle.SetPadTickY(1)
        gStyle.SetPadTickX(1)

        c1 = TCanvas("c1", "c1", 1000, 700)
        frame = gPad.DrawFrame(self.zmin, self.xmin, self.zmax,
                               self.xmax)  # xmin, ymin, xmax, ymax in ROOT
        frame.SetTitle(";Length #it{z} (m);Horizontal #it{x} (cm)")
        siz = 0.035
        frame.SetTitleSize(siz)
        frame.SetLabelSize(siz)
        frame.SetTitleSize(siz, "Y")
        frame.SetLabelSize(siz, "Y")

        frame.GetYaxis().SetTitleOffset(1)
        frame.GetXaxis().SetTitleOffset(1.2)
        frame.GetYaxis().CenterTitle()
        frame.GetXaxis().CenterTitle()
        gPad.SetLeftMargin(0.07)
        gPad.SetRightMargin(0.01)
        gPad.SetTopMargin(0.02)
        gPad.SetBottomMargin(0.09)

        #loop over elements
        for el in elements.itervalues():
            if not hasattr(el, "draw_2d"): continue
            el.draw_2d()

        #redraw these elements on the top
        #draw_top = ["Q0EF", "beam_electron", "beam_hadron"]
        draw_top = ["ew"]
        for i in draw_top:
            el = elements.get(i)
            if el is not None: el.draw_2d()

        gPad.SetGrid()

        #self.invert_col(gPad)

        c1.SaveAs("01fig.pdf")
Ejemplo n.º 11
0
def evt_W():

    #event photon-proton CM energy W

    xbin = 0.1
    xmin = 0
    xmax = 155

    can = ut.box_canvas()

    hPy = ut.prepare_TH1D("hPy", xbin, xmin, xmax)
    hQr = ut.prepare_TH1D("hQr", xbin, xmin, xmax)

    tree_py.Draw("TMath::Sqrt(true_W2) >> hPy")
    tree_qr.Draw("TMath::Sqrt(true_W2) >> hQr")

    ut.line_h1(hPy, rt.kBlue)
    ut.line_h1(hQr, rt.kRed)

    vmax = hQr.GetMaximum()
    vmax += 0.4 * vmax
    frame = gPad.DrawFrame(xmin, 100, xmax, vmax)

    ut.put_yx_tit(frame, "Counts", "Photon-proton CM energy #it{W} (GeV)", 1.6,
                  1.3)

    frame.Draw()

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

    gPad.SetGrid()
    gPad.SetLogy()

    hQr.Draw("same")
    hPy.Draw("same")

    leg = ut.prepare_leg(0.72, 0.8, 0.24, 0.12, 0.035)  # x, y, dx, dy, tsiz
    leg.AddEntry(hPy, "Pythia6", "l")
    leg.AddEntry(hQr, "QR", "l")
    leg.Draw("same")

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Ejemplo n.º 12
0
def gen_el_en_log10_theta():

    #electron energy and scattering angle

    #bins in log_10(theta)
    ltbin = 0.2
    ltmin = -8
    #ltmax = -1.2
    ltmax = 1

    #bins in energy
    ebin = 0.4
    emin = 0
    emax = 21

    can = ut.box_canvas()

    hEnTheta = ut.prepare_TH2D("hEnTheta", ltbin, ltmin, ltmax, ebin, emin,
                               emax)

    form = "el_en:TMath::Log10(TMath::Pi()-el_theta)"
    tree.Draw(form + " >> hEnTheta")

    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(hEnTheta, ytit, xtit, 1.4, 1.3)

    hEnTheta.SetTitleOffset(1.5, "Z")
    hEnTheta.SetZTitle("Event counts")

    ut.set_margin_lbtr(gPad, 0.1, 0.1, 0.01, 0.15)

    gPad.SetLogz()
    gPad.SetGrid()

    hEnTheta.SetMinimum(0.98)
    hEnTheta.SetContour(300)

    hEnTheta.Draw("colz")

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Ejemplo n.º 13
0
def CSCCLCTPos1(plotter):

    for st in range(0, len(cscStations)):

        h_bins = "(100,-1,1)"
        nBins = int(h_bins[1:-1].split(',')[0])
        minBin = float(h_bins[1:-1].split(',')[1])
        maxBin = float(h_bins[1:-1].split(',')[2])

        c = newCanvas()
        gPad.SetGrid(1, 1)
        base = TH1F("base", title, nBins, minBin, maxBin)
        base.SetMinimum(0)
        base.SetMaximum(0.08)
        base.GetXaxis().SetLabelSize(0.05)
        base.GetYaxis().SetLabelSize(0.05)
        base.GetXaxis().SetTitleSize(0.05)
        base.GetYaxis().SetTitleSize(0.05)
        base.Draw("")
        CMS_lumi.CMS_lumi(c, iPeriod, iPos)

        toPlot1 = delta_fhs_clct(st)
        h1 = draw_1D(plotter.tree, title, h_bins, toPlot1, "", "same", kBlue)

        h1.Scale(1. / h1.GetEntries())
        base.SetMaximum(h1.GetBinContent(h1.GetMaximumBin()) * 1.5)
        h1.Draw("histsame")

        leg = TLegend(0.15, 0.6, .45, 0.9, "", "brNDC")
        leg.SetBorderSize(0)
        leg.SetFillStyle(0)
        leg.SetTextSize(0.05)
        leg.AddEntry(h1, "1/2 strip", "pl")
        leg.Draw("same")

        csc = drawCSCLabel(cscStations[st].label, 0.85, 0.85, 0.05)

        c.Print("%sRes_CSCCLCT_pos1_%s%s" %
                (plotter.targetDir + subdirectory, cscStations[st].labelc,
                 plotter.ext))

        del base, leg, csc, h1, c
Ejemplo n.º 14
0
def gen_true_W():

    #generator true W = sqrt( ys(1-x) ) with true x and y

    # GeV^2
    #scm = 19800.8 # 18x275
    #scm = 820.8 # 5x41

    #W range
    wbin = 0.1
    wmin = 0
    wmax = 200

    hW = ut.prepare_TH1D("hW", wbin, wmin, wmax)
    hW2 = ut.prepare_TH1D("hW2", wbin, wmin, wmax)

    #form = "TMath::Sqrt(true_y*"+str(scm)+"*(1.-true_x))"
    #form2 = "TMath::Sqrt(true_y*"+str(scm)+")"
    form3 = "TMath::Sqrt(true_W2)"

    #tree.Draw(form+" >> hW")
    tree.Draw(form3 + " >> hW")
    #tree.Draw(form2+" >> hW2")
    #tree.Draw(form3+" >> hW2")

    can = ut.box_canvas()

    ut.put_yx_tit(hW, "Events", "W (GeV)", 1.4, 1.2)

    #ut.set_H1D_col(hW2, rt.kRed)
    ut.line_h1(hW)
    #ut.line_h1(hW2, rt.kRed)

    hW.Draw()
    #hW2.Draw("e1same")

    gPad.SetGrid()
    gPad.SetLogy()
    gPad.SetLogx()

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Ejemplo n.º 15
0
def el_Q3eR_xy():

    #electron hit at Q3eR position in x and y

    xysiz = 2  # cm
    xybin = 0.01  # cm

    #Q3eR geometry position
    xpos = 472.033  # mm

    can = ut.box_canvas()

    hXY = ut.prepare_TH2D("hXY", xybin, -xysiz / 2., xysiz / 2., xybin,
                          -xysiz / 2., xysiz / 2.)

    #tree.Draw("Q3eR_hy:Q3eR_hx >> hXY")
    tree.Draw("Q3eR_hy/10:(Q3eR_hx-" + str(xpos) + ")/10 >> hXY")

    print "Entries:", hXY.GetEntries()

    ut.put_yx_tit(hXY, "Vertical #it{y} (mm)", "Horizontal #it{x} (mm)", 1.4,
                  1.2)

    ut.set_margin_lbtr(gPad, 0.1, 0.09, 0.08, 0.12)

    hXY.SetMinimum(0.98)
    hXY.SetContour(300)

    hXY.Draw()

    #Q3eR entering radius, cm
    r1 = TCrown(0, 0, 4, 0)
    r1.SetLineColor(rt.kOrange)
    r1.SetLineStyle(rt.kDashed)
    r1.SetLineWidth(3)
    #r1.Draw("same")

    gPad.SetGrid()
    gPad.SetLogz()

    #ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Ejemplo n.º 16
0
def neut_mult():

    #neutron multiplicity, both positive and negative rapidity

    nbin = 1
    nmin = 0
    nmax = 55

    can = ut.box_canvas()

    hN = ut.prepare_TH1I("hN", nbin, nmin, nmax)
    hS = ut.prepare_TH1I("hS", nbin, nmin, nmax)

    hN.SetLineWidth(3)
    hS.SetLineWidth(3)
    hS.SetLineColor(rt.kRed)

    tree.Draw("npos >> hN")
    tree.Draw("nneg >>+ hN")

    tree.Draw("npos >> hS", "jZDCUnAttEast<1200 && jZDCUnAttWest<1200")
    tree.Draw("nneg >>+ hS", "jZDCUnAttEast<1200 && jZDCUnAttWest<1200")

    gPad.SetGrid()
    gPad.SetLogy()

    hN.SetTitle("")

    ut.put_yx_tit(hN, "Counts", "Neutrons in event", 1.4, 1.2)

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

    hN.Draw()
    hS.Draw("same")

    leg = ut.prepare_leg(0.5, 0.78, 0.2, 0.1, 0.035)
    leg.AddEntry(hN, "All central XnXn events", "l")
    leg.AddEntry(hS, "ADC < 1200", "l")
    leg.Draw("same")

    #ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Ejemplo n.º 17
0
def el_eta():

    #electron pseudorapidity eta

    xbin = 0.1
    xmin = -20
    xmax = 10

    can = ut.box_canvas()

    hPy = ut.prepare_TH1D("hPy", xbin, xmin, xmax)
    hQr = ut.prepare_TH1D("hQr", xbin, xmin, xmax)

    form = "-TMath::Log(TMath::Tan(true_el_theta/2.))"
    tree_py.Draw(form + " >> hPy")
    tree_qr.Draw(form + " >> hQr")

    ut.line_h1(hPy, rt.kBlue)
    ut.line_h1(hQr, rt.kRed)

    vmax = hPy.GetMaximum() + 0.1 * hPy.GetMaximum()
    frame = gPad.DrawFrame(xmin, 0.5, xmax, vmax)

    ut.put_yx_tit(frame, "Counts", "Electron #eta", 1.6, 1.3)

    frame.Draw()

    ut.set_margin_lbtr(gPad, 0.11, 0.1, 0.05, 0.02)

    gPad.SetGrid()
    #gPad.SetLogy()

    hQr.Draw("same")
    hPy.Draw("same")

    leg = ut.prepare_leg(0.72, 0.8, 0.24, 0.12, 0.035)  # x, y, dx, dy, tsiz
    leg.AddEntry(hPy, "Pythia6", "l")
    leg.AddEntry(hQr, "QR", "l")
    leg.Draw("same")

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Ejemplo n.º 18
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)
    
    mg = TMultiGraph()
    
    roc = TGraph(len(fpr),tpr,fpr)

    roc.SetLineColor(2)
    roc.SetLineWidth(3)
    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)
    mg.Add(roc)
    #roc.Draw("AL")
    
    tpr_diag = np.arange(0,1.09,0.1)
    fpr_diag = np.arange(0,1.09,0.1)
    roc_diag = TGraph(len(fpr_diag),tpr_diag,fpr_diag)
    roc_diag.SetLineStyle(2)
    roc_diag.SetLineWidth(3)
    roc_diag.SetLineColor(13)
    mg.Add(roc_diag)
    #roc_diag.Draw("AL same")
    
    mg.Draw("AL")
    mg.SetTitle(";Signal efficiency (%s); Background efficiency (%s)"%(signal_label, background_label))

    latex = TLatex()
    latex.SetTextFont(42)
    latex.SetTextSize(0.05)
    latex.DrawLatexNDC(0.2,0.88,'AUC = %.3f'%AUC)
	
    c.SaveAs(outfile)
Ejemplo n.º 19
0
def el_phi_tag():

    #electron generated azimuthal angle for electrons hitting the tagger

    #bins in phi
    pbin = 1e-1
    pmin = -TMath.Pi() - 0.3
    pmax = TMath.Pi() + 0.3

    #sel = ""
    sel = "lowQ2s1_IsHit==1"
    #sel = "lowQ2s2_IsHit==1"
    #sel = "lowQ2s1_IsHit==1 || lowQ2s2_IsHit==1"

    #interval in log_10(Q^2)
    #lqmin = -1.5
    #lqmax = -0.9
    #lqsel = gL10Q2+" > "+str(lqmin)+" && "+gL10Q2+" < "+str(lqmax)

    #bins for selected log_10(Q^2)
    #pbins = 2e-2

    can = ut.box_canvas()

    hPhiTag = ut.prepare_TH1D("hPhiTag", pbin, pmin, pmax)
    #hPhiTagQ2sel = ut.prepare_TH1D("hPhiTagQ2sel", pbins, pmin, pmax)

    #tree.Draw("el_phi >> hPhiTag", sel)
    tree.Draw("true_el_phi >> hPhiTag", sel)
    #tree.Draw("el_phi >> hPhiTagQ2sel", "lowQ2_IsHit==1"+" && "+lqsel)

    gPad.SetGrid()
    gPad.SetLogy()

    hPhiTag.Draw()
    #hPhiTagQ2sel.Draw("e1same")
    #hPhiTagQ2sel.Draw()

    #hPhiTag.SetMinimum(0.3)

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Ejemplo n.º 20
0
def evt_Log10_Q2_x():

    #log_10(Q^2) and x

    lqbin = 5e-2
    #lqmin = -5
    lqmin = -10
    lqmax = -1

    #xbin = 0.01
    xbin = 0.1
    xmin = -14
    xmax = -0.3

    yform = "1.-(1.-TMath::Cos(el_theta))*el_gen/(2.*18.)"
    Q2form = "2.*18.*el_gen*(1.-TMath::Cos(TMath::Pi()-el_theta))"
    xform = Q2form + "/((" + yform + ")*19800.82)"

    lQ2form = "TMath::Log10(" + Q2form + ")"
    lxform = "TMath::Log10(" + xform + ")"

    hLog10Q2xTag = ut.prepare_TH2D("hLog10Q2xTag", xbin, xmin, xmax, lqbin,
                                   lqmin, lqmax)

    can = ut.box_canvas()

    tree.Draw(lQ2form + ":" + lxform + " >> hLog10Q2xTag", gQ2sel)
    #tree.Draw(lQ2form+":"+lxform+" >> hLog10Q2xTag")

    ytit = "log_{10}(#it{Q}^{2})" + " / {0:.3f}".format(lqbin) + " GeV^{2}"
    xtit = "log_{10}(#it{x})" + " / {0:.1f}".format(xbin)
    ut.put_yx_tit(hLog10Q2xTag, ytit, xtit, 1.6, 1.3)

    ut.set_margin_lbtr(gPad, 0.12, 0.1, 0.03, 0.11)

    gPad.SetGrid()

    hLog10Q2xTag.Draw()

    #ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Ejemplo n.º 21
0
def el_E():

    #electron energy E

    xbin = 0.2
    xmin = 0
    xmax = 50

    can = ut.box_canvas()

    hPy = ut.prepare_TH1D("hPy", xbin, xmin, xmax)
    hQr = ut.prepare_TH1D("hQr", xbin, xmin, xmax)

    tree_py.Draw("true_el_E >> hPy")
    tree_qr.Draw("true_el_E >> hQr")

    ut.line_h1(hPy, rt.kBlue)
    ut.line_h1(hQr, rt.kRed)

    vmax = hPy.GetMaximum() + 0.5 * hPy.GetMaximum()
    frame = gPad.DrawFrame(xmin, 0.5, xmax, vmax)

    ut.put_yx_tit(frame, "Counts", "Electron energy #it{E} (GeV)", 1.6, 1.3)

    frame.Draw()

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

    gPad.SetGrid()
    gPad.SetLogy()

    hQr.Draw("same")
    hPy.Draw("same")

    leg = ut.prepare_leg(0.72, 0.8, 0.24, 0.12, 0.035)  # x, y, dx, dy, tsiz
    leg.AddEntry(hPy, "Pythia6", "l")
    leg.AddEntry(hQr, "QR", "l")
    leg.Draw("same")

    #ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Ejemplo n.º 22
0
def el_phi():

    #electron azimuthal angle phi

    xbin = 3e-2
    xmin = -TMath.Pi() - 0.3
    xmax = TMath.Pi() + 0.3

    can = ut.box_canvas()

    hPy = ut.prepare_TH1D("hPy", xbin, xmin, xmax)
    hQr = ut.prepare_TH1D("hQr", xbin, xmin, xmax)

    tree_py.Draw("true_el_phi >> hPy")
    tree_qr.Draw("true_el_phi >> hQr")

    ut.line_h1(hPy, rt.kBlue)
    ut.line_h1(hQr, rt.kRed)

    vmax = hPy.GetMaximum() + 0.4 * hPy.GetMaximum()
    frame = gPad.DrawFrame(xmin, 0.5, xmax, vmax)

    ut.put_yx_tit(frame, "Counts", "Electron #phi (rad)", 1.6, 1.3)

    frame.Draw()

    ut.set_margin_lbtr(gPad, 0.11, 0.1, 0.05, 0.02)

    gPad.SetGrid()
    #gPad.SetLogy()

    hQr.Draw("same")
    hPy.Draw("same")

    leg = ut.prepare_leg(0.72, 0.8, 0.24, 0.12, 0.035)  # x, y, dx, dy, tsiz
    leg.AddEntry(hPy, "Pythia6", "l")
    leg.AddEntry(hQr, "QR", "l")
    leg.Draw("same")

    #ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Ejemplo n.º 23
0
def evt_en():

    #energy in the tagger in event

    ebin = 0.1
    emin = 0
    emax = 20

    #name = "lowQ2s1"
    name = "lowQ2s2"

    elow = 0.5
    #elow = -1

    lumi = 1.45e6  # mb^-1 s^-1

    #sigma = 0.053839868617 # mb, quasireal Qd
    #sigma = 0.054700142803416348 # mb, pythia
    sigma = 276.346654276  # mb, zeus 0.1 GeV

    can = ut.box_canvas()
    hE = ut.prepare_TH1D("hE", ebin, emin, emax)

    nall = float(tree.GetEntries())

    #tree.Draw(name+"_en >> hE")
    nsel = float(tree.Draw(name + "_en >> hE", name + "_en>" + str(elow)))

    print nall, nsel

    #event rate:
    print sigma * lumi * nsel / nall

    hE.Draw()

    gPad.SetGrid()

    gPad.SetLogy()

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Ejemplo n.º 24
0
def diff_hitE_trueE():

    #energy in hit and true generated energy

    #tagger configuration
    config = "recchar_s1.ini"
    #config = "recchar_s2.ini"

    cf = read_con(config)

    #event in tagger
    evt = TagV2Evt(tree, cf)

    nevt = tree.GetEntries()
    #nevt = 320

    #difference plot
    ebin = 0.01
    emin = -10
    emax = 10

    hEdiff = ut.prepare_TH1D("hEdiff", ebin, emin, emax)

    can = ut.box_canvas()

    for iev in xrange(nevt):

        if not evt.read(iev): continue

        hEdiff.Fill((evt.hit_E - evt.true_el_E) * 1000.)

    ut.put_yx_tit(hEdiff, "Events",
                  "(#it{E}_{hit} - #it{E}_{true}) #times 1000", 1.4, 1.2)

    hEdiff.Draw()

    gPad.SetLogy()
    gPad.SetGrid()

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Ejemplo n.º 25
0
def neut_abs_eta():

    #neutron absolute pseudorapidity

    etabin = 0.05
    etamin = 5
    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( TMath.Abs(part.Eta()) )
            hEta.Fill(abs(part.Eta()))

    ytit = "Events / {0:.2f}".format(etabin)
    ut.put_yx_tit(hEta, ytit, "Neutron |#kern[0.3]{#eta}|", 1.4, 1.2)

    ut.set_H1D_col(hEta, rt.kRed)

    ut.set_margin_lbtr(gPad, 0.1, 0.09, 0.01, 0.02)

    hEta.Draw()

    gPad.SetGrid()

    gPad.SetLogy()

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Ejemplo n.º 26
0
def rel_gen_Q2_beff_el_Q2():

    #relative difference in Q^2 between plain generator and electron after beam effects

    dbin = 0.05
    dmin = -10
    dmax = 2

    lqbin = 0.05
    lqmin = -11
    lqmax = 3

    hRQ2 = ut.prepare_TH2D("hRQ2", lqbin, lqmin, lqmax, dbin, dmin, dmax)

    can = ut.box_canvas()

    Q2form = "(2*18*el_en*(1-TMath::Cos(TMath::Pi()-el_theta)))"

    #tree.Draw("(gen_el_Q2-"+Q2form+")/gen_el_Q2:TMath::Log10(gen_el_Q2) >> hRQ2")

    tree.Draw("(gen_Q2-" + Q2form + ")/gen_Q2:TMath::Log10(gen_Q2) >> hRQ2")

    #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.set_margin_lbtr(gPad, 0.1, 0.11, 0.03, 0.12)

    hRQ2.Draw()

    hRQ2.SetMinimum(0.98)
    hRQ2.SetContour(300)

    gPad.SetGrid()

    #gPad.SetLogy()
    gPad.SetLogz()

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Ejemplo n.º 27
0
def zpos():

    #hit position in z and vertex position in z

    zmin = -5.5
    zmax = 15.5
    zbin = 0.2

    infile = TFile.Open("rc_ecal.root")
    tree = infile.Get("rtree")

    can = ut.box_canvas()

    hz = ut.prepare_TH2D("hz", zbin, zmin, zmax, zbin, -zmax, zmax)

    tree.Draw("(zpos/1e3):(vtx_z/1e3) >> hz")

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

    hz.SetXTitle("Vertex #it{z} (m)")
    hz.SetYTitle("Hit #it{z} (m)")

    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)

    gPad.SetLogz()

    gPad.SetGrid()

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Ejemplo n.º 28
0
def plot_spec_acc():

    #acceptance parametrization
    from spec_acc import spec_acc
    acc0 = spec_acc()
    acc = spec_acc(8200, 0.26, 42, 242)

    #acc.length = 8200

    can = ut.box_canvas()

    frame = gPad.DrawFrame(1, 0, 22, 1)
    frame.Draw()

    acc0.acc_func.Draw("same")
    acc0.acc_func.SetLineStyle(rt.kDashed)
    acc.acc_func.Draw("same")

    gPad.SetGrid()

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
Ejemplo n.º 29
0
def en_bun():

    #energy in bunch crossing

    infile = "/home/jaroslav/sim/lmon/data/luminosity/lm1a/hits.root"

    #detector = "bun_up_en"
    #detector = "bun_down_en"
    #detector = "bun_phot_en"
    detector = "bun_up_en+bun_down_en"

    cond = "(bun_up_en>1)&&(bun_down_en>1)"

    #plot range
    ebin = 0.5
    emax = 35.
    #emax = 150.

    inp_lmon = TFile.Open(infile)
    tree = inp_lmon.Get("bunch")

    can = ut.box_canvas()
    hE = ut.prepare_TH1D("hE", ebin, 0, emax)

    tree.Draw(detector + " >> hE", cond, "", 100000)

    ut.set_H1D_col(hE, rt.kBlue)

    ut.put_yx_tit(hE, "Counts", "Incident energy in bunch crossing (GeV)", 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")
Ejemplo n.º 30
0
def clean_conv_en():

    #fraction of clean conversions as a function of photon energy

    #plot range
    emin = 0
    emax = 19
    pmin = 0.2
    pmax = 0.3

    inp = TFile.Open("ew.root")
    tree = inp.Get("conv_tree")

    prec = 0.01
    calc = rt.conv_calc(prec, 1e-6)
    calc.set_tree(tree)
    #calc.nev = 600000
    calc.conv_in_all = True
    calc.clean_in_sel = True

    conv = calc.get_conv()
    calc.release_tree()

    can = ut.box_canvas()
    frame = gPad.DrawFrame(emin, pmin, emax, pmax)

    ut.put_yx_tit(frame, "Fraction of clean conversions",
                  "#it{E}_{#gamma} (GeV)")

    ut.set_margin_lbtr(gPad, 0.11, 0.09, 0.02, 0.01)

    frame.Draw()
    gPad.SetGrid()

    ut.set_graph(conv, rt.kBlue)
    conv.Draw("psame")

    #ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")