コード例 #1
0
ファイル: spin2008.py プロジェクト: gdwebb/UnderlyingEvent
def minbias_pt_reweight():
    """plots ratio of JP and MB jet spectrum and fits it"""
    f = ROOT.TFile(datamcFile)
    mgr = HistogramManager(f, keys=['true_jet_pt'])
    mb = mgr.anyspin['117001']['true_jet_pt']
    jp = mgr.anyspin['jetpatch']['true_jet_pt']
    jp.Divide(mb)
    
    jp.SetStats(True)
    jp.GetXaxis().SetRangeUser(5,30)
    jp.GetYaxis().SetRangeUser(0.,1.)
    jp.SetXTitle('corrected jet pT')
    jp.SetYTitle('nJets (JP) / nJets (MB)')
    
    fit = ROOT.TF1('fit', 'pol1', 9.8, 25.3)
    
    # sigmoid = ROOT.TF1('sigmoid', '[0]*log([1]*x+[2])', 9.8 , 25.3)
    # sigmoid.SetParameter(0, 1.)
    # sigmoid.SetParameter(1, 0.08)
    # sigmoid.SetParameter(2, 0.)
    c1 = graphics.canvas1()
    jp.Fit(fit, 'r')
    ROOT.gStyle.SetOptFit(111)
    raw_input('wait here:')
    c1.Print('minbias_pt_reweight.png')
    
    jp.GetYaxis().SetRangeUser(1.E-5,1.)
    ROOT.gPad.SetLogy()
    raw_input('wait here:')
    c1.Print('minbias_pt_reweight_log.png')
コード例 #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.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()
コード例 #3
0
ファイル: simu.py プロジェクト: kocolosk/analysis
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()
コード例 #4
0
ファイル: spin2008.py プロジェクト: gdwebb/UnderlyingEvent
def dphi():
    data = hadd_interactive(histDir, runlist, 'jetpatch', 'anyspin', 'sum', \
        'dphi')
    mgr = HistogramManager(ROOT.TFile(datamcFile), keys=['dphi'])
    simu = mgr.anyspin['jetpatch'].tracks_sum['dphi']
    c = graphics.canvas1()
    simu.SetLineColor(ROOT.kRed)
    simu.GetXaxis().SetTitle('#Delta#phi')
    simu.GetYaxis().SetTitle('normalized yield')
    simu.DrawNormalized('hist')
    
    data.SetMarkerStyle(20)
    data.DrawNormalized('same')
    raw_input('wait here:')
コード例 #5
0
ファイル: spin2008.py プロジェクト: gdwebb/UnderlyingEvent
def pt_shift_uncertainty():
    ## this is my guess based on inverting Dave's fit
    measured_pt = [10.31, 12.91, 15.58, 19.06, 23.20, 28.45]
    
    ## http://cyclotron.tamu.edu/star/2005n06Jets/PRDweb/
    ## "numbers are from the preliminary analysis"
    total_uncertainty = [ 0.72, 0.90, 0.99, 1.09, 1.27, 1.52 ]
    
    c = graphics.canvas1()
    
    low = ROOT.TGraph(len(measured_pt))
    for i,(pt,error) in enumerate(zip(measured_pt, total_uncertainty)):
        low.SetPoint(i, pt, shifted(pt)-error)
    lowfit = ROOT.TF1('lowfit', 'pol2', 10, 30)
    lowfit.SetLineStyle(2)
    low.Fit(lowfit)
    low.GetXaxis().SetTitle('measured jet p_{T}')
    low.GetXaxis().SetRangeUser(10,30)
    low.GetYaxis().SetTitle('corrected jet p_{T}')
    low.GetYaxis().SetRangeUser(9,26)
    low.SetTitle('Uncertainty on p_{T} shift')
    low.SetLineStyle(2)
    low.Draw('ap2')
    
    high = ROOT.TGraph(len(measured_pt))
    for i,(pt,error) in enumerate(zip(measured_pt, total_uncertainty)):
        high.SetPoint(i, pt, shifted(pt)+error)
    highfit = ROOT.TF1('lowfit', 'pol2', measured_pt[0], measured_pt[-1])
    highfit.SetLineStyle(2)
    high.Fit(highfit)
    high.SetLineStyle(2)
    high.Draw('same')
    
    mid = ROOT.TF1('mid', lambda x: shifted(x[0]), 10.31, 28.45)
    mid.Draw('same')
    
    raw_input('wait here:')
コード例 #6
0
ファイル: spin2008.py プロジェクト: gdwebb/UnderlyingEvent
def subprocess_fraction_z(charge = 1):
    import histos
    histos.simu = True
    ROOT.gStyle.SetErrorX()
    f = ROOT.TFile(datamcFile)
    mgr = HistogramManager(f, ['z_away2'])
    mb = {
        'all': mgr.anyspin['117001'].trackHistograms(charge)['z_away2'],
        'gg': mgr.gg['117001'].trackHistograms(charge)['z_away2'],
        'qg': mgr.qg['117001'].trackHistograms(charge)['z_away2'],
        'qq': mgr.qq['117001'].trackHistograms(charge)['z_away2']
    }
    jp = {
        'all': mgr.anyspin['jetpatch'].trackHistograms(charge)['z_away2'],
        'gg': mgr.gg['jetpatch'].trackHistograms(charge)['z_away2'],
        'qg': mgr.qg['jetpatch'].trackHistograms(charge)['z_away2'],
        'qq': mgr.qq['jetpatch'].trackHistograms(charge)['z_away2']
    }
    
    for key in ('gg','qg','qq'):
        mb[key].Divide(mb['all'])
        jp[key].Divide(jp['all'])
    
    for h in (mb,jp):
        h['gg'].SetLineColor(ROOT.kRed)
        h['qg'].SetLineColor(ROOT.kBlue)
        h['qq'].SetLineColor(ROOT.kGreen)
        [h[k].SetMarkerStyle(24) for k in ('gg','qg','qq')]
    
    leg = ROOT.TLegend(0.65, 0.7, 0.85, 0.88)
    leg.AddEntry(mb['gg'], 'gg')
    leg.AddEntry(mb['qg'], 'qg')
    leg.AddEntry(mb['qq'], 'qq')
    
    c = graphics.canvas2()
    c.cd(1)
    mb['gg'].Draw('e1')
    mb['gg'].SetTitle('MB for charge=%d' % charge)
    mb['gg'].GetYaxis().SetRangeUser(0., 0.8)
    mb['gg'].GetXaxis().SetRangeUser(zbins[0], zbins[-1])
    mb['qg'].Draw('e1 same')
    mb['qq'].Draw('e1 same')
    leg.Draw()
    
    c.cd(2)
    jp['gg'].Draw('e1')
    jp['gg'].SetTitle('JP for charge=%d' % charge)
    jp['gg'].GetYaxis().SetRangeUser(0., 0.8)
    jp['gg'].GetXaxis().SetRangeUser(zbins[0], zbins[-1])
    jp['qg'].Draw('e1 same')
    jp['qq'].Draw('e1 same')
    
    c2 = graphics.canvas1()
    delta = {
        'gg': jp['gg'].Clone(),
        'qg': jp['qg'].Clone(),
        'qq': jp['qq'].Clone()
    }
    for k in delta.keys():
        delta[k].Add(mb[k], -1)
        delta[k].SetMarkerStyle(24)
    
    delta['gg'].SetTitle('Subprocess fraction difference (JP - MB) : charge=%d'\
        % charge)
    delta['gg'].GetYaxis().SetRangeUser(-0.4, 0.4)
    delta['gg'].Draw('e1')
    delta['qg'].Draw('e1 same')
    delta['qq'].Draw('e1 same')
    
    leg2 = ROOT.TLegend(0.15, 0.7, 0.25, 0.88)
    leg2.AddEntry(mb['gg'], 'gg')
    leg2.AddEntry(mb['qg'], 'qg')
    leg2.AddEntry(mb['qq'], 'qq')
    leg2.Draw()
    
    line = ROOT.TLine(zbins[0], 0.0, zbins[-1], 0.0)
    line.SetLineStyle(2)
    line.Draw()
    
    raw_input('wait here:')
    
    if charge == 1:
        c.Print('subprocess_fraction_trigger_plus.png')
        c2.Print('subprocess_fraction_difference_plus.png')
    else:
        c.Print('subprocess_fraction_trigger_minus.png')
        c2.Print('subprocess_fraction_difference_minus.png')
コード例 #7
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()
コード例 #8
0
ファイル: simu.py プロジェクト: kocolosk/analysis
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()