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))
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))
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)
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')
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))
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))
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))
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))
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))
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))
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))
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))