コード例 #1
0
def makeXiAcceptance(pot,log):
    c = Canvas('c')
    c.cd()
    if log: c.SetLogy()
    c.SetTicks(1,1)
    c.SetGrid(1,1)
    h = ROOT.TH1F('h', '', 100, 0, 0.2)
    for year in years:
        for pf in protonFiles:
            if year == pf[0]: pfile = pf[1]
        h.Add( pfile.Get('plots/h_pro_xi_%s' % pot) )
    h.Rebin(2)
    #h.Scale(1.0/100.0)                                                                                                                                                                                                                               
    for pp in proton_pot:
        if pot == pp[0]: v_pot = pp
    h.GetXaxis().SetTitle('#xi '+v_pot[1])
    h.GetYaxis().SetTitle('Events')
    h.SetLineColor(ROOT.kBlack)
    h.SetMarkerStyle(24)
    minx, miny, maxx, maxy = 0.0001, h.GetMinimum(), 0.2, h.GetMaximum()*10 if log else h.GetMaximum()*1.2
    c.DrawFrame(minx, miny, maxx, maxy)
    h.Draw('p e2')
    h.SetMaximum(maxy)
    pLabel, lLabel = prelimLabel('top',log,maxy), lumiLabel(log,years)
    lLabel.SetTextSize(0.034)
    pLabel.Draw(), lLabel.Draw()
    c.SaveAs('plots/%s/h_xi_%s_%s.pdf' % (s_years,side,s_years))
コード例 #2
0
def makeNumPro(method):
    c = Canvas('c')
    c.cd()
    c.SetTicks(1,1)
    c.SetLogy()
    h_16 = getHist(method,['2016'],'h_num_pro')
    h_17 = getHist(method,['2017'],'h_num_pro')
    h_18 = getHist(method,['2018'],'h_num_pro')
    h_18.SetTitle(''), h_18.GetXaxis().SetTitle('Number Of Reconstructed Protons'), h_18.GetYaxis().SetTitle('Events')
    h_18.SetMarkerStyle(20), h_17.SetMarkerStyle(20), h_16.SetMarkerStyle(20)
    h_18.SetMarkerColor(ROOT.darkLime), h_17.SetMarkerColor(ROOT.turquois), h_16.SetMarkerColor(ROOT.orangeSoda)
    h_18.SetMarkerSize(1.5), h_17.SetMarkerSize(1.5), h_16.SetMarkerSize(1.5)
    h_18.SetLineColor(ROOT.darkLime), h_17.SetLineColor(ROOT.turquois), h_16.SetLineColor(ROOT.orangeSoda)
    h_18.SetLineWidth(2), h_17.SetLineWidth(2), h_16.SetLineWidth(2)
    h_18.SetMinimum(10000.0)
    h_18.Draw('p')
    h_17.Draw('p same')
    h_16.Draw('p same')
    c.SetGrid(0,1)
    legend = TLegend(0.6,0.7,0.8,0.78)
    legend.SetTextSize(0.03)
    legend.SetLineColor( 0 )
    legend.SetFillColor( 0 )
    legend.AddEntry(h_18,"2018",'lp')
    legend.AddEntry(h_17,"2017",'lp')
    legend.AddEntry(h_16,"2016",'lp')
    legend.Draw()
    pLabel = prelimLabel('top',True,h_18.GetMaximum())
    pLabel.Draw()
    c.SaveAs('plots/combined/h_num_pro_%s.png' % (selection))
コード例 #3
0
def plotEA(h_selected,h_total,label_selected,label_total,fileOut):
    c = Canvas('c')
    pad1 = TPad('pad1', 'pad1', 0., 0.3, 1., 1.)
    pad1.SetBottomMargin(0.005)
    pad1.SetTicks(1,1)
    pad1.SetGrid(1,1)
    pad1.Draw()
    c.cd()
    pad2 = TPad('pad2', 'pad2', 0., 0.05, 1., 0.29)
    pad2.SetTopMargin(0.005)
    pad2.SetBottomMargin(0.3)
    pad2.SetTicks(1,1)
    pad2.Draw()
    pad1.cd()
    h_total.SetTitle('')
    h_total.GetYaxis().SetTitle('Events')
    h_total.SetLineColor(r.kBlue)
    h_total.SetFillColorAlpha(r.kBlue,0.2)
    h_total.Draw('HIST')
    h_selected.SetTitle('')
    h_selected.SetLineColor(r.kRed)
    h_selected.SetFillColorAlpha(r.kRed,0.2)
    h_selected.Draw('HIST same')
    legend = TLegend(0.12, 0.61, 0.28, 0.8)
    legend.SetBorderSize(0)
    legend.SetFillColor(0)
    legend.SetFillStyle(0)
    legend.SetTextFont(42)
    legend.SetTextSize(0.031)
    legend.AddEntry(h_selected,label_selected, 'f')
    legend.AddEntry(h_total,label_total, 'f')
    legend.Draw()
    cLabel, pLabel, dLabel = condLabel(), simLabel(), descriptionLabel()
    cLabel.SetTextSize(0.049), pLabel.SetTextSize(0.049)
    cLabel.Draw(), pLabel.Draw(), dLabel.Draw()
    pad2.cd()
    pad2.SetGrid(0,1)
    h_new = h_selected.Clone('h_new')
    h_new.Sumw2()
    h_new.Divide(h_total)
    h_new.SetMarkerStyle(20)
    h_new.SetMarkerSize(0.9)
    h_new.SetLineColor(r.kBlack)
    h_new.GetXaxis().SetTitle('#xi' if 'xi' in fileOut else 'missing mass')
    h_new.SetMinimum(-0.01), h_new.SetMaximum(1.05)
    h_new.Draw('p same')
    Prettify(h_new)
    h_new.GetYaxis().SetTitle('Red/Blue')
    c.SaveAs('plots/%s' % fileOut)
コード例 #4
0
def plotXiReco():
    c0 = Canvas('c0')
    c1 = Canvas('c1')
    h0 = f_eff.Get('h_xi_reco_vs_xi_simu')
    h0.GetXaxis().SetRange(0,67), h0.GetYaxis().SetRange(0,67)
    cLabel, pLabel = condLabel(), simLabel()
    c0.cd()
    c0.SetTicks(1,1)
    h0.Draw('colz')
    cLabel.Draw(), pLabel.Draw()
    c0.SaveAs('plots/h2_xi_recoVsim_arm0_%s.png' % era)
コード例 #5
0
def makeProtonSide(log):
    c = Canvas('c')
    c.cd()
    c.SetLeftMargin(0.15)
    if log: c.SetLogy()
    c.SetTicks(1,1)
    h_single = ROOT.TH1F('h_single', '', 4, 0, 4)
    h_multi = ROOT.TH1F('h_multi', '', 4, 0, 4)
    for year in years:
        for pf in protonFiles:
            if year == pf[0]: pf_single, pf_multi = pf[1], pf[2]
        h_single.Add( pf_single.Get('plots/h_proton_side') )
        h_multi.Add( pf_multi.Get('plots/h_proton_side') )
    
    denom = h_single.GetEntries()
    h_multi.Scale(1.0/denom)
    h_multi.GetYaxis().SetTitle('Fraction Of Events')
    h_multi.GetXaxis().SetBinLabel(1,'No protons'), h_multi.GetXaxis().SetBinLabel(2,'sector45 only'), h_multi.GetXaxis().SetBinLabel(3,'sector56 only'), h_multi.GetXaxis().SetBinLabel(4,'Both')
    h_multi.Draw('p')
    h_single.Scale(1.0/denom)
    h_single.Draw('p same')
    h_single.SetMarkerColor(62), h_multi.SetMarkerColor(207)
    h_single.SetLineColor(62), h_multi.SetLineColor(207)
    h_single.SetLineWidth(2), h_multi.SetLineWidth(2)
    h_single.SetMarkerStyle(20), h_multi.SetMarkerStyle(20)
    h_multi.SetMinimum(0.0), h_multi.SetMaximum( h_multi.GetMaximum()*1.5 )
    h_single.SetMarkerSize(0.9), h_multi.SetMarkerSize(0.9)
    c.SetGrid(0,1)
    legend = TLegend(0.6,0.7,0.8,0.78)
    legend.SetTextSize(0.03)
    legend.SetLineColor( 0 )
    legend.SetFillColor( 0 )
    legend.AddEntry(h_single,"singleRP",'lp')
    legend.AddEntry(h_multi,"multiRP",'lp')
    legend.Draw()
    pLabel, lLabel = prelimLabel('top',log,h_single.GetMaximum()), lumiLabel(False,years)
    pLabel.SetMargin(0.49)
    pLabel.Draw(), lLabel.Draw()
    c.SaveAs('plots/%s/h_proton_side_%s_%s.pdf' % (s_years,selection,s_years))
コード例 #6
0
def makeXiComp(era, sector, log):
    pf = TFile("output_reconstructionPlotter_2017" + era + ".root")

    c = Canvas('c')
    c.cd()
    c.SetTicks(1, 1)
    if log: c.SetLogy()
    #c.SetGrid(1,1)

    h_near = ROOT.TH1F('h_near', '', 100, 0.0, 0.3)
    h_far = ROOT.TH1F('h_far', '', 100, 0.0, 0.3)
    h_multi = ROOT.TH1F('h_multi', '', 100, 0.0, 0.3)

    # Add hists
    if sector == '45':
        h_near.Add(pf.Get('singleRPPlots/rp3/h_xi'))
        h_far.Add(pf.Get('singleRPPlots/rp23/h_xi'))
        h_multi.Add(pf.Get('multiRPPlots/arm0/h_xi'))
    elif sector == '56':
        h_near.Add(pf.Get('singleRPPlots/rp103/h_xi'))
        h_far.Add(pf.Get('singleRPPlots/rp123/h_xi'))
        h_multi.Add(pf.Get('multiRPPlots/arm1/h_xi'))

    h_far.SetLineColor(210)
    h_near.SetLineColor(62)
    h_multi.SetLineColor(207)
    h_far.GetYaxis().SetTitle('Events')
    h_far.GetYaxis().SetTitleOffset(1.5)
    h_far.GetXaxis().SetTitle('#xi - sector' + sector)
    if log: h_far.SetMaximum(h_far.GetMaximum() * 10)
    else: h_far.SetMaximum(h_far.GetMaximum() * 1.2)
    h_far.Draw('HIST')
    h_near.Draw('HIST same')

    h_multi.Draw('HIST same')
    legend = TLegend(0.6, 0.7, 0.8, 0.8)
    legend.SetTextSize(0.03)
    legend.SetLineColor(0)
    legend.SetFillColor(0)
    legend.AddEntry(h_near, "singleRP near", 'l')
    legend.AddEntry(h_far, "singleRP far", 'l')
    legend.AddEntry(h_multi, "multiRP", 'l')
    legend.Draw()

    pLabel, lLabel = prelimLabel('top', log, h_far.GetMaximum()), lumiLabel(
        False, ['2017'])
    pLabel.Draw(), lLabel.Draw()

    c.SaveAs('h_xi_comp_' + sector + '_Run2017' + era + '.pdf')
コード例 #7
0
def makeXiAcceptanceSide(side,log):
    c = Canvas('c')
    c.cd()
    if log: c.SetLogy()
    c.SetTicks(1,1)
    c.SetGrid(1,1)
    h = ROOT.TH1F('h', '', 100, 0, 0.3)
    for year in years:
        for pf in protonFiles:
            if year == pf[0]: pfile = pf[2]
        h.Add( pfile.Get('plots/h_pro_xi%s' % side) )
    #h.Rebin(2)
    h.GetXaxis().SetTitle('#xi ^{%s}' % ('+' if side == 'p' else '-'))
    h.GetYaxis().SetTitle('Events')
    h.SetLineColor(ROOT.kBlack)
    h.SetMarkerStyle(24)
    minx, miny, maxx, maxy = 0.0001, h.GetMinimum(), 0.2, h.GetMaximum()*10 if log else h.GetMaximum()*1.2
    c.DrawFrame(minx, miny, maxx, maxy)
    h.Draw('p e2')
    h.SetMaximum(maxy)
    pLabel, lLabel = prelimLabel('top',log,maxy), lumiLabel(log,years)
    lLabel.SetTextSize(0.034)
    pLabel.Draw(), lLabel.Draw()
    c.SaveAs('plots/%s/h_xi%s_%s.pdf' % (s_years,side,s_years))
コード例 #8
0
def makeHitMap(sector):
    c = Canvas('c')
    c.cd()
    c.SetTicks(1,1)
    h_map = ROOT.TH2F('h_map', '', 100, 0, 12, 100, -8, 8)
    for year in years:
        for pf in protonFiles:
            if year == pf[0]: pfile = pf[1]
        h_map.Add( pfile.Get('plots/h_hitmap'+sector) )
    h_map.GetXaxis().SetTitle('x (mm)')
    h_map.GetYaxis().SetTitle('y (mm)')
    h_map.Draw('colz')
    pLabel, lLabel = prelimLabel('top',False,h_map.GetMaximum()), lumiLabel(False,years)
    pLabel.Draw(), lLabel.Draw()
    c.SaveAs('plots/%s/hitmap_%s_%s_%s.pdf' % (s_years,sector,s_years,selection))
コード例 #9
0
def makeXiComp(sector,log):
    sec = 'p' if sector == '45' else 'm'
    c = Canvas('c')
    c.cd()
    c.SetTicks(1,1)
    if log: c.SetLogy()
    #c.SetGrid(1,1)
    h_near = ROOT.TH1F('h_near', '', 100, 0.0, 0.2) 
    h_far = ROOT.TH1F('h_far', '', 100, 0.0, 0.2) 
    h_multi = ROOT.TH1F('h_multi', '', 100, 0.0, 0.2) 
    # Add hists
    for year in years:
        for pf in protonFiles:
            if year == pf[0]: pf_single, pf_multi = pf[1], pf[2]
        h_near.Add( pf_single.Get('plots/h_pro_xi_'+sector+'n') )
        h_far.Add( pf_single.Get('plots/h_pro_xi_'+sector+'f') )
        h_multi.Add( pf_multi.Get('plots/h_pro_xi'+sec) )

    h_far.SetLineColor(210)
    #h_far.Rebin(2)
    h_near.SetLineColor(62)
    #h_near.Rebin(2)
    h_multi.SetLineColor(207)
    #h_multi.Rebin(2)
    h_far.GetYaxis().SetTitle('Events')
    h_far.GetYaxis().SetTitleOffset(1.5)
    h_far.GetXaxis().SetTitle('#xi - sector'+sector)
    if log: h_far.SetMaximum( h_far.GetMaximum()*10 )
    else: h_far.SetMaximum( h_far.GetMaximum()*1.2 )
    h_far.Draw('HIST')
    h_near.Draw('HIST same')
    h_multi.Draw('HIST same')
    legend = TLegend(0.6,0.7,0.8,0.8)
    legend.SetTextSize(0.03)
    legend.SetLineColor( 0 )
    legend.SetFillColor( 0 )
    legend.AddEntry(h_near,"singleRP near",'l')
    legend.AddEntry(h_far,"singleRP far",'l')
    legend.AddEntry(h_multi,"multiRP",'l')
    legend.Draw()
    pLabel, lLabel = prelimLabel('top',log,h_far.GetMaximum()), lumiLabel(False,years)
    pLabel.Draw(), lLabel.Draw()
    c.SaveAs('plots/%s/h_xi_comp_%s_%s.pdf' % (s_years,s_years,sector)) 
コード例 #10
0
ファイル: plotReMiniaod.py プロジェクト: jwill24/PPSAnalyzer
def makeComp(hist, label, log):
    var = hist.split('_')[-1]

    new_file = TFile("tmp/histOut_data2017D_new_HLT_multiRP.root")
    old_file = TFile("tmp/histOut_data2017D_old_HLT_multiRP.root")

    h_new = new_file.Get('plots/%s' % hist)
    h_old = old_file.Get('plots/%s' % hist)

    c1 = Canvas('c1')
    c1.SetLeftMargin(0.15)
    c1.cd()
    c1.SetTicks(1, 1)
    if log: c1.SetLogy()
    h_new.SetTitle('')
    h_new.GetYaxis().SetTitleOffset(2.1)
    h_new.GetYaxis().SetTitle('Events')
    h_new.GetXaxis().SetTitleOffset(1.2)
    h_new.GetXaxis().SetTitle(label)
    h_new.SetMarkerStyle(20)
    h_new.SetMarkerColor(r.kRed)
    h_new.GetXaxis().SetNdivisions(507)
    h_old.SetLineColor(r.kBlue)
    h_new.Rebin(4), h_old.Rebin(4)
    h_new.Draw('p')
    h_old.Draw('HIST same')
    legend = TLegend(0.69, 0.75, 0.82, 0.85)
    legend.SetBorderSize(0)
    legend.SetFillColor(0)
    legend.SetFillStyle(0)
    legend.SetTextFont(42)
    legend.SetTextSize(0.023)
    legend.AddEntry(h_old, 'Legacy data', 'l')
    legend.AddEntry(h_new, 'Reminiaod data', 'p')
    legend.Draw()
    pLabel = prelimLabel('top', False)
    pLabel.Draw()
    c1.SaveAs('plots/reMiniAOD_validation_%s.%s' % (var, extension))
コード例 #11
0
def makeProtonPlot(name, xTitle, rbin, method, log):
    c = Canvas('c')
    c.cd()
    c.SetTicks(1,1)
    if log: c.SetLogy()
    h = getHist(method,years,name)
    h.SetTitle('')
    h.SetXTitle(xTitle)
    h.SetYTitle('Events')
    h.Rebin(rbin)
    #h.SetFillColor(208)
    #h.SetLineColor(208)
    h.SetFillColor(ROOT.azure)
    h.SetLineColor(ROOT.darkAzure)
    if log: h.SetMaximum( h.GetMaximum()*30 )
    else: h.SetMaximum( h.GetMaximum()*1.2 )
    if 'detType' in name: h.GetXaxis().SetBinLabel(1,'Strip'), h.GetXaxis().SetBinLabel(2,'Pixel')
    h.Draw('HIST')
    pLabel, sLabel, lLabel = prelimLabel('left',log,h.GetMaximum()), selectionLabel(lab,False,log,h.GetMaximum()), lumiLabel(False,years)
    pLabel.Draw(), sLabel.Draw(), lLabel.Draw()
    c.SaveAs('plots/%s/%s_%s_%s.pdf' % (s_years,name,s_years,selection))
コード例 #12
0
def makeDetType():
    c = Canvas('c')
    c.cd()
    c.SetTicks(1,1)
    h_type = ROOT.TH1F('h_type', '', 2, 3, 5)
    for year in years:
        for pf in protonFiles:
            if year == pf[0]: pfile = pf[1]
        h_type.Add( pfile.Get('plots/h_detType') )
    h_type.Scale(1.0/1000.0)
    h_type.GetXaxis().SetBinLabel(1,'Si Strip'), h_type.GetXaxis().SetBinLabel(2,'Pixel')
    h_type.GetYaxis().SetTitle('Events/0.001')
    h_type.Draw('p')
    h_type.SetLineColor(ROOT.kBlack)
    h_type.SetLineWidth(2)
    h_type.SetMarkerStyle(20)
    h_type.SetMinimum(0.0), h_type.SetMaximum( h_type.GetMaximum() * 1.5 )
    h_type.SetMarkerSize(0.9)
    c.SetGrid(0,1)
    pLabel, sLabel, lLabel = prelimLabel('left',False,h_type.GetMaximum()), selectionLabel('singleRP',False,False,h_type.GetMaximum()), lumiLabel(False,years)
    pLabel.Draw(), sLabel.Draw(), lLabel.Draw()
    c.SaveAs('plots/%s/h_detType_%s_%s.png' % (s_years,selection,s_years))
コード例 #13
0
ファイル: plotReMiniaod.py プロジェクト: jwill24/PPSAnalyzer
def makeProComp(var, label, log):
    new_file = TFile("tmp/histOut_data2017D_new_HLT_multiRP.root")
    old_file = TFile("tmp/histOut_data2017D_old_HLT_multiRP.root")

    str_45 = 'xip' if var == 'xi' else 'thetaY_45'
    str_56 = 'xim' if var == 'xi' else 'thetaY_56'

    h_new_45 = new_file.Get('plots/h_pro_%s' % str_45)
    h_new_56 = new_file.Get('plots/h_pro_%s' % str_56)
    h_old_45 = old_file.Get('plots/h_pro_%s' % str_45)
    h_old_56 = old_file.Get('plots/h_pro_%s' % str_56)

    c1 = Canvas('c1')
    c1.SetLeftMargin(0.15)
    c1.cd()
    c1.SetTicks(1, 1)
    if log: c1.SetLogy()
    h_new_45.SetTitle('')
    h_new_45.GetYaxis().SetTitleOffset(2.1)
    h_new_45.GetYaxis().SetTitle('Events')
    h_new_45.GetXaxis().SetTitleOffset(1.2)
    h_new_45.GetXaxis().SetTitle(label)
    h_new_45.SetLineColor(r.kRed)
    h_new_45.GetXaxis().SetNdivisions(507)
    h_old_45.SetLineColor(r.kBlue)
    h_new_45.Draw('HIST')
    h_old_45.Draw('HIST same')
    text45 = TPaveText(0.72, 0.81, 0.9, 0.9, 'NB NDC')
    text45.AddText('sector 45')
    text45.SetTextSize(0.032)
    text45.SetTextFont(42)
    text45.SetFillStyle(0)
    text45.Draw()
    legend = TLegend(0.6, 0.6, 0.75, 0.7)
    legend.SetBorderSize(0)
    legend.SetFillColor(0)
    legend.SetFillStyle(0)
    legend.SetTextFont(42)
    legend.SetTextSize(0.028)
    legend.AddEntry(h_old_45, 'Legacy data', 'l')
    legend.AddEntry(h_new_45, 'Reminiaod data', 'l')
    legend.Draw()
    pLabel = prelimLabel('top', False)
    pLabel.Draw()
    c1.SaveAs('plots/reMiniAOD_validation_%s_45.%s' % (var, extension))

    c2 = Canvas('c2')
    c2.SetLeftMargin(0.15)
    c2.cd()
    c2.SetTicks(1, 1)
    if log: c2.SetLogy()
    h_new_56.SetTitle('')
    h_new_56.GetYaxis().SetTitleOffset(2.1)
    h_new_56.GetYaxis().SetTitle('Events')
    h_new_56.GetXaxis().SetTitleOffset(1.2)
    h_new_56.GetXaxis().SetTitle(label)
    h_new_56.SetLineColor(r.kRed)
    h_new_56.GetXaxis().SetNdivisions(507)
    h_old_56.SetLineColor(r.kBlue)
    h_new_56.Draw('HIST')
    h_old_56.Draw('HIST same')
    text56 = TPaveText(0.72, 0.81, 0.9, 0.9, 'NB NDC')
    text56.AddText('sector 56')
    text56.SetTextSize(0.032)
    text56.SetTextFont(42)
    text56.SetFillStyle(0)
    text56.Draw()
    pLabel.Draw()
    legend.Draw()
    c2.SaveAs('plots/reMiniAOD_validation_%s_56.%s' % (var, extension))
コード例 #14
0
def plotRatio(name, h1, v_hist, hs, log):
    c = Canvas('c')

    h_sum = TH1F('h_sum','sum',h1.GetNbinsX(), h1.GetXaxis().GetXmin(), h1.GetXaxis().GetXmax())
    for h in v_hist: h_sum.Add(h)
 
    pad1 = TPad('pad1', 'pad1', 0.0, 0.3, 1., 1.)
    pad1.SetBottomMargin(0.005)
    pad1.SetTicks(1,1)
    pad1.Draw()

    c.cd()
    pad2 = TPad('pad2', 'pad2', 0., 0.05, 1., 0.28)
    pad2.SetTopMargin(0.005)
    pad2.SetBottomMargin(0.3)
    pad2.SetTicks(1,1)
    pad2.Draw()

    pad1.cd()
    if log: pad1.SetLogy()
    stack = THStack('norm_stack','')
    h_mc_err = 0
    for h in v_hist: 
        stack.Add(h)
        if h_mc_err == 0: h_mc_err = h.Clone()
        else: h_mc_err.Add(h)
    stack.Draw('HIST')
    h_mc_err.Draw("e2 same")
    h_mc_err.SetMarkerSize(0)
    h_mc_err.SetFillColor(1)
    h_mc_err.SetFillStyle(3004)
    h_data = asym_error_bars(h1)
    h_data.SetLineColor(ROOT.kBlack)
    h_data.SetFillColor(ROOT.kBlack)
    h_data.SetLineWidth(2)
    h_data.Draw('p e2 same')
    hs.Draw('HIST same')
    ymax = h1.GetMaximum()*pow(10,1.0) if log else h1.GetMaximum()*1.5 
    stack.SetMaximum(ymax)
    if log: stack.SetMinimum(1)
    #stack.GetHistogram().GetYaxis().SetTitleFont(43)
    stack.GetHistogram().GetYaxis().SetTitleOffset(1.0)
    stack.GetHistogram().GetYaxis().SetTitleSize(0.05)
    stack.GetHistogram().GetYaxis().SetTitle('Events')
    pLabel, sLabel, lLabel = prelimLabel('left',log,h1.GetMaximum()), selectionLabel(lab,True,log,h1.GetMaximum()), lumiLabel(True,years)
    pLabel.Draw(), sLabel.Draw(), lLabel.Draw()
    legend = makeLegend(h1,v_hist,hs)
    legend.Draw()

    pad2.cd()
    h_ratio = h1.Clone('h_ratio')

    h_ratio.Sumw2()
    h_ratio.Divide(h_sum)
    h_ratio.SetMinimum(-0.499)
    h_ratio.SetMaximum(2.499)
    h_ratio.SetLineColor(ROOT.kBlack)
    h_ratio.SetMarkerStyle(20)
    h_ratio.SetMarkerColor(ROOT.kBlack)
    h_ratio.SetMarkerSize(0.7)
    h_ratio.Draw('p same')
    denom_err, denom_err2 = h_mc_err.Clone(), h_mc_err.Clone()
    denom_err2.Sumw2(False)
    denom_err.Divide(denom_err2)
    denom_err.Draw("e2same")
    denom_err.SetFillColor(1)
    denom_err.SetFillStyle(3004)

    l1 = TLine(h_ratio.GetXaxis().GetXmin(), 1, h_ratio.GetXaxis().GetXmax(), 1)
    l2 = TLine(h_ratio.GetXaxis().GetXmin(), 1.5, h_ratio.GetXaxis().GetXmax(), 1.5)
    l3 = TLine(h_ratio.GetXaxis().GetXmin(), 0.5, h_ratio.GetXaxis().GetXmax(), 0.5)
    l4 = TLine(h_ratio.GetXaxis().GetXmin(), 0., h_ratio.GetXaxis().GetXmax(), 0.)
    l5 = TLine(h_ratio.GetXaxis().GetXmin(), 2, h_ratio.GetXaxis().GetXmax(), 2.)
    l2.SetLineStyle(3), l3.SetLineStyle(3), l4.SetLineStyle(3), l5.SetLineStyle(3)
    l1.Draw(), l2.Draw(), l3.Draw(), l4.Draw(), l5.Draw()

    Prettify( h_ratio )

    #ax  = h_ratio.GetXaxis();
    #ax.SetNdivisions(506);

    if len(years) == 1: c.SaveAs('plots/%s/%s_%s.%s' % (years[0],name,selection,extension))
    else: c.SaveAs('plots/combined/%s_%s_%s.%s' % (name,selection,s_years,extension)) 
コード例 #15
0
for bg in bgs:
    setPlot(bg[1], bg[2], bg[3])
    h_stack.Add(bg[1])
    v_hist.append(bg[1])
    if h_mc_err == 0: h_mc_err = bg[1].Clone()
    else: h_mc_err.Add(bg[1])

# print totals
for s in selections:
    print 'Selection:', s[0], 'Data:', h_data.GetBinContent(
        selections.index(s) +
        1), 'Total MC:', h_stack.GetStack().Last().GetBinContent(
            selections.index(s) +
            1), 'Error:', h_errors.GetBinContent(selections.index(s) + 1)

c = Canvas('c')

h_sum = TH1F('h_sum', 'sum', h_data.GetNbinsX(),
             h_data.GetXaxis().GetXmin(),
             h_data.GetXaxis().GetXmax())
for h in v_hist:
    h_sum.Add(h)

pad1 = TPad('pad1', 'pad1', 0., 0.3, 1., 1.)
pad1.SetBottomMargin(0.005)
pad1.SetTicks(1, 1)
pad1.Draw()

c.cd()
pad2 = TPad('pad2', 'pad2', 0., 0.05, 1., 0.28)
pad2.SetTopMargin(0.005)