Beispiel #1
0
def qg_fragmentation_comparison():
    simuFile = '/Users/kocolosk/work/2009-03-19-pi-fragmentation/merged.root'

    import operator
    from array import array

    from analysis.plots import graphics
    from analysis.histos2 import HistogramManager

    bin_centers = array('d', [2.59, 3.87, 5.44, 7.56, 10.82])

    dss_g = [2.5988E+06, 1.3668E+05, 1.0331E+04, 7.4421E+02, 3.4858E+01]
    dss_q = [7.9033E+05, 6.0820E+04, 6.3704E+03, 6.3982E+02, 4.3774E+01]

    kretzer_g = [1.6305E+06, 7.3650E+04, 4.8672E+03, 3.0306E+02, 1.1753E+01]
    kretzer_q = [1.4892E+06, 1.1274E+05, 1.1583E+04, 1.1391E+03, 7.5693E+01]

    dss_graph = ROOT.TGraph(
        5, bin_centers,
        array('d', map(operator.div, dss_g, map(operator.add, dss_q, dss_g))))
    kretzer_graph = ROOT.TGraph(
        5, bin_centers,
        array(
            'd',
            map(operator.div, kretzer_g, map(operator.add, kretzer_q,
                                             kretzer_g))))

    dss_graph.SetLineStyle(2)
    [graph.SetLineWidth(2) for graph in (dss_graph, kretzer_graph)]

    mgr = HistogramManager(ROOT.TFile(simuFile))
    gluon = mgr.qg['96011']['plus']['pt_gluon_jet']
    quark = mgr.qg['96011']['plus']['pt_quark_jet']
    ratio = gluon.Clone()
    both = gluon.Clone()
    both.Add(quark)
    ratio.Divide(both)
    ratio.GetXaxis().SetRangeUser(2.00, 12.84)
    ratio.GetYaxis().SetRangeUser(0.0, 1.0)

    ratio.SetMarkerStyle(24)
    ratio.SetTitle('Fraction of qg #pi+ from gluon jet')
    ratio.SetXTitle('#pi p_{T}')

    leg = ROOT.TLegend(0.7, 0.7, 0.88, 0.88)
    leg.AddEntry(dss_graph, 'DSS', 'l')
    leg.AddEntry(kretzer_graph, 'Kretzer', 'l')
    leg.AddEntry(ratio, 'Pythia')

    c = graphics.canvas1()
    ratio.Draw()
    dss_graph.Draw()
    kretzer_graph.Draw()
    leg.Draw()

    graphics.maybe_save()
Beispiel #2
0
def qg_fragmentation_comparison():
    simuFile = "/Users/kocolosk/work/2009-03-19-pi-fragmentation/merged.root"

    import operator
    from array import array

    from analysis.plots import graphics
    from analysis.histos2 import HistogramManager

    bin_centers = array("d", [2.59, 3.87, 5.44, 7.56, 10.82])

    dss_g = [2.5988e06, 1.3668e05, 1.0331e04, 7.4421e02, 3.4858e01]
    dss_q = [7.9033e05, 6.0820e04, 6.3704e03, 6.3982e02, 4.3774e01]

    kretzer_g = [1.6305e06, 7.3650e04, 4.8672e03, 3.0306e02, 1.1753e01]
    kretzer_q = [1.4892e06, 1.1274e05, 1.1583e04, 1.1391e03, 7.5693e01]

    dss_graph = ROOT.TGraph(5, bin_centers, array("d", map(operator.div, dss_g, map(operator.add, dss_q, dss_g))))
    kretzer_graph = ROOT.TGraph(
        5, bin_centers, array("d", map(operator.div, kretzer_g, map(operator.add, kretzer_q, kretzer_g)))
    )

    dss_graph.SetLineStyle(2)
    [graph.SetLineWidth(2) for graph in (dss_graph, kretzer_graph)]

    mgr = HistogramManager(ROOT.TFile(simuFile))
    gluon = mgr.qg["96011"]["plus"]["pt_gluon_jet"]
    quark = mgr.qg["96011"]["plus"]["pt_quark_jet"]
    ratio = gluon.Clone()
    both = gluon.Clone()
    both.Add(quark)
    ratio.Divide(both)
    ratio.GetXaxis().SetRangeUser(2.00, 12.84)
    ratio.GetYaxis().SetRangeUser(0.0, 1.0)

    ratio.SetMarkerStyle(24)
    ratio.SetTitle("Fraction of qg #pi+ from gluon jet")
    ratio.SetXTitle("#pi p_{T}")

    leg = ROOT.TLegend(0.7, 0.7, 0.88, 0.88)
    leg.AddEntry(dss_graph, "DSS", "l")
    leg.AddEntry(kretzer_graph, "Kretzer", "l")
    leg.AddEntry(ratio, "Pythia")

    c = graphics.canvas1()
    ratio.Draw()
    dss_graph.Draw()
    kretzer_graph.Draw()
    leg.Draw()

    graphics.maybe_save()
Beispiel #3
0
def nlo_pion_fractions(ff='Kretzer'):
    simuFile = '/Users/kocolosk/data/run5-simu/hist/merged.cphist.root'

    import operator
    from array import array

    from analysis.plots import graphics
    from analysis.histos2 import HistogramManager

    bin_centers = array('d', [2.59, 3.87, 5.44, 7.56, 10.82])

    if ff == 'DSS':
        gg_gg = [4.4390E+06, 1.9967E+05, 1.2634E+04, 7.4998E+02, 2.8100E+01]
        qg_qg = [3.3888E+06, 1.9764E+05, 1.6707E+04, 1.3828E+03, 7.8631E+01]
        qq_qq = [2.5272E+05, 2.2866E+04, 2.9083E+03, 3.6410E+02, 3.2692E+01]
        qb_qb = [1.4414E+05, 1.1077E+04, 1.1646E+03, 1.1523E+02, 7.4628E+00]
        total = [8.3013E+06, 4.3322E+05, 3.3477E+04, 2.6092E+03, 1.4636E+02]
    elif ff == 'Kretzer':
        gg_gg = [2.0141E+06, 8.0377E+04, 4.5900E+03, 2.4401E+02, 7.9185E+00]
        qg_qg = [3.0735E+06, 1.8293E+05, 1.6132E+04, 1.4147E+03, 8.5984E+01]
        qq_qq = [4.8958E+05, 4.3564E+04, 5.4494E+03, 6.7049E+02, 5.8678E+01]
        qb_qb = [1.3586E+05, 1.0378E+04, 1.0776E+03, 1.0510E+02, 6.6962E+00]
        total = [5.9360E+06, 3.3000E+05, 2.8449E+04, 2.5438E+03, 1.6599E+02]

    pythia_id = {11: qq_qq, 12: qb_qb, 28: qg_qg, 68: gg_gg}

    graph = {
        11:
        ROOT.TGraph(5, bin_centers,
                    array('d', map(operator.div, pythia_id[11], total))),
        12:
        ROOT.TGraph(5, bin_centers,
                    array('d', map(operator.div, pythia_id[12], total))),
        28:
        ROOT.TGraph(5, bin_centers,
                    array('d', map(operator.div, pythia_id[28], total))),
        68:
        ROOT.TGraph(5, bin_centers,
                    array('d', map(operator.div, pythia_id[68], total)))
    }

    mgr = HistogramManager(ROOT.TFile(simuFile))
    hist = {
        11: mgr.qq['96011']['plus']['pt'],
        28: mgr.qg['96011']['plus']['pt'],
        68: mgr.gg['96011']['plus']['pt']
    }
    htotal = mgr.anyspin['96011']['plus']['pt']
    [h.Divide(htotal) for h in hist.values()]

    graph[68].SetLineColor(ROOT.kRed)
    graph[28].SetLineColor(ROOT.kGreen)
    graph[11].SetLineColor(ROOT.kBlue)
    graph[12].SetLineColor(ROOT.kMagenta)
    [g.SetLineWidth(2) for g in graph.values()]

    hist[68].SetMarkerColor(ROOT.kRed)
    hist[28].SetMarkerColor(ROOT.kGreen)
    hist[11].SetMarkerColor(ROOT.kBlue)
    [h.SetMarkerStyle(24) for h in hist.values()]

    bg = ROOT.TH2D('bg', '', 1, 2.00, 12.84, 1, 0., 0.7)
    bg.SetTitle('Subprocess Fractions (solid=NLO+%s, points=Pythia)' % ff)
    bg.SetXTitle('#pi p_{T}')

    leg = ROOT.TLegend(0.8, 0.2, 0.88, 0.8)
    leg.AddEntry(graph[68], 'gg', 'l')
    leg.AddEntry(graph[28], 'qg', 'l')
    leg.AddEntry(graph[11], 'qq', 'l')
    leg.AddEntry(graph[12], 'q#bar{q}', 'l')

    c = graphics.canvas1()
    bg.Draw()
    [g.Draw() for g in graph.values()]
    [h.Draw('same') for h in hist.values()]
    leg.Draw()

    graphics.maybe_save()
Beispiel #4
0
def run6_result_theory_curves():
    """
    result plot showing asymmetries versus z
    """    
    asym_p = AsymmetryGenerator('asym_p', bins=zbins, key='z_away2')
    asym_m = AsymmetryGenerator('asym_m', bins=zbins, key='z_away2')
    
    scalars = ScalarCounts(os.environ['STAR'] + 
        '/StRoot/StSpinPool/StTamuRelLum/inputs/run6.txt')
    
    polarizations = Polarizations.Final
    
    allFiles = glob(histDir + '/chargedPions_*.hist.root')
    for fname in allFiles[:]:
        run = getRun(fname)
        if run in runlist:
            print fname, run
            mgr = HistogramManager(ROOT.TFile(fname), ['z_away2'])
            
            try:
                bin6 = scalars[str(run) + '-5-6']
                bin7 = scalars[str(run) + '-5-7']
                bin8 = scalars[str(run) + '-5-8']
                bin9 = scalars[str(run) + '-5-9']
            except KeyError:
                bin6 = scalars[str(run) + '-6-6']
                bin7 = scalars[str(run) + '-6-7']
                bin8 = scalars[str(run) + '-6-8']
                bin9 = scalars[str(run) + '-6-9']
            uu = bin6.uu + bin7.uu + bin8.uu + bin9.uu
            ud = bin6.ud + bin7.ud + bin8.ud + bin9.ud
            du = bin6.du + bin7.du + bin8.du + bin9.du
            dd = bin6.dd + bin7.dd + bin8.dd + bin9.dd
            
            pol = polarizations[bin7.fill]
            
            asym_p.FillFromHistogramManager(mgr, 'jetpatch', 1, uu,ud,du,dd, \
                pol.py,pol.pb)
            asym_m.FillFromHistogramManager(mgr, 'jetpatch', -1, uu,ud,du,dd, \
                pol.py,pol.pb)
    
    ## fun with graphics
    ROOT.gStyle.SetErrorX(0.0)
    ROOT.gStyle.SetOptDate(0)
    
    c = graphics.canvas2()
    c.SetLogy(0)
    
    for i in (1, 2):
        pad = c.cd(i)
        pad.SetTopMargin(0.03)
        pad.SetBottomMargin(0.1)
        pad.SetLeftMargin(0.12)
        pad.SetRightMargin(0.02)
    
    line = ROOT.TLine(zbins[0], 0.0, zbins[-1], 0.0)
    line.SetLineStyle(2)
    
    prelim = ROOT.TText()
    prelim.SetTextColor(44)
    prelim.SetTextAlign(21)
    
    latex = ROOT.TLatex()
    latex.SetTextSize(0.25)
    
    syst = systematic_uncertainties()
    syst_m = ROOT.TGraphErrors(len(zbins))
    syst_p = ROOT.TGraphErrors(len(zbins))
    
    for g in (syst_m,syst_p):
        g.SetMarkerColor(15)
        g.SetFillColor(15)
        g.SetPoint(len(zbins), 1.0, 0)
        g.SetPointError(len(zbins), 0., 0.)
        g.GetXaxis().SetRangeUser(zbins[0], zbins[-1])
    
    hm = asym_m.GetAsymmetry('ll')
    hp = asym_p.GetAsymmetry('ll')
    for i in range(len(zbins)-1):
        z = (zbins[i] + zbins[i+1])/2
        syst_m.SetPoint(i, z, hm.GetBinContent(i+1))
        syst_m.SetPointError(i, 0.01, syst['minus'][i])
        syst_p.SetPoint(i, z, hp.GetBinContent(i+1))
        syst_p.SetPointError(i, 0.01, syst['plus'][i])
    
    [ g.GetXaxis().SetRangeUser(zbins[0], zbins[-1]) for g in (syst_m,syst_p) ]
    
    for h in (hm,hp, syst_m, syst_p):
        h.SetTitle('')
        h.GetXaxis().SetTitle('z')
        h.GetYaxis().SetRangeUser(-0.05, 0.08)
        h.GetYaxis().SetTitle('A_{LL}  ')
        h.GetYaxis().SetTitleSize(0.06)
        h.GetYaxis().SetTitleOffset(1.0)
        h.GetXaxis().SetTitle('z  ')
        h.GetXaxis().SetTitleSize(0.065)
        h.GetXaxis().SetTitleOffset(0.7)
    
    title = {
        'STD': 'GRSV-STD',
        'GSC': 'GS Set C',
        'DSSV': 'DSSV'
    }
    
    def make_graph(num, denom):
        g = ROOT.TGraphErrors(len(num))
        for i,n in enumerate(num):
            d = denom[i]
            val = n.y / d.y
            err = val*math.sqrt((n.sys/n.y)**2 + (d.sys/d.y)**2)
            g.SetPoint(i, n.x, val)
            g.SetPointError(i, 0, err)
        return g
    
    nlo_m = {
        'STD': make_graph(analysis.deflorian.minus.std, 
            analysis.deflorian.minus.mrst),
        'DSSV': make_graph(analysis.deflorian.minus.dssv, 
            analysis.deflorian.minus.mrst),
        'GSC': make_graph(analysis.deflorian.minus.gsc, 
            analysis.deflorian.minus.mrst),
    }
    nlo_p = {
        'STD': make_graph(analysis.deflorian.plus.std, 
            analysis.deflorian.plus.mrst),
        'DSSV': make_graph(analysis.deflorian.plus.dssv, 
            analysis.deflorian.plus.mrst),
        'GSC': make_graph(analysis.deflorian.plus.gsc, 
            analysis.deflorian.plus.mrst),
    }
    
    for nlo in (nlo_m, nlo_p):
        nlo['DSSV'].SetLineStyle(2)
        nlo['GSC'].SetLineColor(ROOT.kMagenta)
        nlo['DSSV'].SetLineColor(ROOT.kGreen+2)
        [gr.SetLineWidth(3) for gr in nlo.values()]
        [gr.SetFillColor(ROOT.kOrange) for gr in nlo.values()]
    
    leg = ROOT.TLegend(0.69, 0.15, 0.97, 0.36)
    leg.SetBorderSize(0)
    leg.SetNColumns(1)
    leg.AddEntry(nlo_m['STD'], 'GRSV-STD', 'l')
    leg.AddEntry(nlo_m['DSSV'], 'DSSV', 'l')
    leg.AddEntry(nlo_m['GSC'], 'GS-C', 'l')
    
    latex2 = ROOT.TLatex()
    
    c.cd(1)
    hm.SetMarkerStyle(20)
    syst_m.Draw('a2p')
    prelim.DrawText(0.42,-0.041,"STAR Preliminary")
    latex.DrawLatex(0.05 + zbins[0], 0.044, '#pi^{-}')
    latex2.DrawLatex(0.45, 0.06, '10 < jet p_{T} < 30')
    latex2.DrawLatex(0.5, 0.045, '#pi p_{T} > 2')
    [ g.Draw('3') for g in nlo_m.values() ]
    [ g.Draw('lx') for g in nlo_m.values() ]
    line.Draw()
    syst_m.Draw('2p')
    hm.Draw('e1 same')
    
    c.cd(2)
    hp.SetMarkerStyle(21)
    syst_p.Draw('a2p')
    prelim.DrawText(0.42,-0.041,"STAR Preliminary")
    latex.DrawLatex(0.05 + zbins[0], 0.044, '#pi^{+}')
    [ g.Draw('3') for g in nlo_p.values() ]
    [ g.Draw('lx') for g in nlo_p.values() ]
    line.Draw()
    leg.Draw()
    syst_p.Draw('2p')
    hp.Draw('e1 same')
    
    graphics.maybe_save(c)
Beispiel #5
0
def nlo_pion_fractions(ff="Kretzer"):
    simuFile = "/Users/kocolosk/data/run5-simu/hist/merged.cphist.root"

    import operator
    from array import array

    from analysis.plots import graphics
    from analysis.histos2 import HistogramManager

    bin_centers = array("d", [2.59, 3.87, 5.44, 7.56, 10.82])

    if ff == "DSS":
        gg_gg = [4.4390e06, 1.9967e05, 1.2634e04, 7.4998e02, 2.8100e01]
        qg_qg = [3.3888e06, 1.9764e05, 1.6707e04, 1.3828e03, 7.8631e01]
        qq_qq = [2.5272e05, 2.2866e04, 2.9083e03, 3.6410e02, 3.2692e01]
        qb_qb = [1.4414e05, 1.1077e04, 1.1646e03, 1.1523e02, 7.4628e00]
        total = [8.3013e06, 4.3322e05, 3.3477e04, 2.6092e03, 1.4636e02]
    elif ff == "Kretzer":
        gg_gg = [2.0141e06, 8.0377e04, 4.5900e03, 2.4401e02, 7.9185e00]
        qg_qg = [3.0735e06, 1.8293e05, 1.6132e04, 1.4147e03, 8.5984e01]
        qq_qq = [4.8958e05, 4.3564e04, 5.4494e03, 6.7049e02, 5.8678e01]
        qb_qb = [1.3586e05, 1.0378e04, 1.0776e03, 1.0510e02, 6.6962e00]
        total = [5.9360e06, 3.3000e05, 2.8449e04, 2.5438e03, 1.6599e02]

    pythia_id = {11: qq_qq, 12: qb_qb, 28: qg_qg, 68: gg_gg}

    graph = {
        11: ROOT.TGraph(5, bin_centers, array("d", map(operator.div, pythia_id[11], total))),
        12: ROOT.TGraph(5, bin_centers, array("d", map(operator.div, pythia_id[12], total))),
        28: ROOT.TGraph(5, bin_centers, array("d", map(operator.div, pythia_id[28], total))),
        68: ROOT.TGraph(5, bin_centers, array("d", map(operator.div, pythia_id[68], total))),
    }

    mgr = HistogramManager(ROOT.TFile(simuFile))
    hist = {11: mgr.qq["96011"]["plus"]["pt"], 28: mgr.qg["96011"]["plus"]["pt"], 68: mgr.gg["96011"]["plus"]["pt"]}
    htotal = mgr.anyspin["96011"]["plus"]["pt"]
    [h.Divide(htotal) for h in hist.values()]

    graph[68].SetLineColor(ROOT.kRed)
    graph[28].SetLineColor(ROOT.kGreen)
    graph[11].SetLineColor(ROOT.kBlue)
    graph[12].SetLineColor(ROOT.kMagenta)
    [g.SetLineWidth(2) for g in graph.values()]

    hist[68].SetMarkerColor(ROOT.kRed)
    hist[28].SetMarkerColor(ROOT.kGreen)
    hist[11].SetMarkerColor(ROOT.kBlue)
    [h.SetMarkerStyle(24) for h in hist.values()]

    bg = ROOT.TH2D("bg", "", 1, 2.00, 12.84, 1, 0.0, 0.7)
    bg.SetTitle("Subprocess Fractions (solid=NLO+%s, points=Pythia)" % ff)
    bg.SetXTitle("#pi p_{T}")

    leg = ROOT.TLegend(0.8, 0.2, 0.88, 0.8)
    leg.AddEntry(graph[68], "gg", "l")
    leg.AddEntry(graph[28], "qg", "l")
    leg.AddEntry(graph[11], "qq", "l")
    leg.AddEntry(graph[12], "q#bar{q}", "l")

    c = graphics.canvas1()
    bg.Draw()
    [g.Draw() for g in graph.values()]
    [h.Draw("same") for h in hist.values()]
    leg.Draw()

    graphics.maybe_save()