Skip to content

Instantly share code, notes, and snippets.

@mattleblanc
Created September 7, 2020 21:48
Show Gist options
  • Save mattleblanc/80dcdc1af13376b5a795b2a6b896911d to your computer and use it in GitHub Desktop.
Save mattleblanc/80dcdc1af13376b5a795b2a6b896911d to your computer and use it in GitHub Desktop.
import ROOT
from ROOT import gROOT,gPad,gStyle,TCanvas,TFile,TLine,TLatex,TAxis,TLegend,TPostScript
import os
global canvas, canvas
ROOT.gROOT.SetBatch(True)
ROOT.gStyle.SetOptStat(False)
ROOT.gStyle.SetOptTitle(False)
ROOT.gStyle.SetLegendBorderSize(0);
canvas = ROOT.TCanvas('draw1', 'draw1', 0, 0, 800, 600)
c = ROOT.TCanvas('draw', 'draw', 0, 0, 800, 600)
# canvas.SetLeftMargin(0.25)
# canvas.SetRightMargin(0.20)
pad = ROOT.TPad()
canvas.cd()
legend=TLegend(0.65,0.65,0.88,0.80)
l=TLatex()
l.SetNDC()
l.SetTextFont(72)
p=TLatex()
p.SetNDC();
p.SetTextFont(42)
q=TLatex()
q.SetNDC();
q.SetTextFont(42)
q.SetTextSize(0.03)
r=TLatex()
r.SetNDC();
r.SetTextFont(42)
r.SetTextSize(0.03)
single_tag_file = ROOT.TFile.Open("R22/data-ANALYSIS/valid1:valid1.364701.Pythia8EvtGen_A14NNPDF23LO_jetjet_JZ1WithSW.deriv.DAOD_PHYS.e7142_e5984_s3227_r11825_p4166.root")
triple_tag_file = ROOT.TFile.Open("R22/data-ANALYSIS/valid1:valid1.364701.Pythia8EvtGen_A14NNPDF23LO_jetjet_JZ1WithSW.deriv.DAOD_PHYS.e7142_e5984_s3227_r12007_r12045_r12032_p4166.root")
single_tag_tree = single_tag_file.Get("TinyJetTrees_R32")
triple_tag_tree = triple_tag_file.Get("TinyJetTrees_R32")
print("Single tag events:\t"+str(single_tag_tree.GetEntries()))
print("Triple tag events:\t"+str(triple_tag_tree.GetEntries()))
histos = [
# title cutstr nbins min max
["jet_pt", "jet_pt", 25, 0, 250*1.e3 ],
["njet", "Length$(jet_pt)", 5, 2, 7 ],
["jet_eta", "jet_eta", 25, -2.5, 2.5 ],
["jetChargedFrac", "jetChargedFrac", 30, 0, 3.0 ],
["jetTile0", "jetTile0", 50, 0., 1.0 ],
["jetEM3", "jetEM3", 50, 0., 1.0 ],
["jetNtrk", "jetNtrk", 25, 0., 25.0 ],
["jetWtrk", "jetWtrk", 20, 0., 1.0 ],
#["Rpt", "jet_pt[0]/truthJet_pt[0]", 20, 0., 5.0 ],
]
for h in histos:
canvas.SetLogy()
h1_rjet_single = ROOT.TH1F("h1_"+h[0]+"_single","h1_"+h[0]+"_single",h[2],h[3],h[4])
h1_rjet_triple = ROOT.TH1F("h1_"+h[0]+"_triple","h1_"+h[0]+"_triple",h[2],h[3],h[4])
single_tag_tree.Draw(h[1]+" >> h1_"+h[0]+"_single","(jet_pt>25.*1.e3)*(abs(jet_eta)<2.1)*mcWeight*(eventClean_LooseBad>0)")
triple_tag_tree.Draw(h[1]+" >> h1_"+h[0]+"_triple","(jet_pt>25.*1.e3)*(abs(jet_eta)<2.1)*mcWeight*(eventClean_LooseBad>0)")
h1_rjet_single.Scale(1./h1_rjet_single.Integral())
h1_rjet_triple.Scale(1./h1_rjet_triple.Integral())
h1_rjet_single.SetLineColor(ROOT.TColor.GetColor('#FF0000'))
h1_rjet_triple.SetLineColor(ROOT.TColor.GetColor('#0000FF'))
h1_rjet_single.SetLineWidth(2)
h1_rjet_triple.SetLineWidth(2)
h1_rjet_triple.SetLineStyle(2)
h1_rjet_single.SetMaximum(h1_rjet_single.GetMaximum()*1000.)
h1_rjet_single.SetMinimum(1.e-7)
h1_rjet_single.GetXaxis().SetTitle(h[0])
h1_rjet_single.Draw("hist ")
h1_rjet_triple.Draw("hist same")
legend.Clear()
legend.AddEntry(h1_rjet_single,"r11825","l")
legend.AddEntry(h1_rjet_triple,"r12007_r12045_r12032","l")
legend.Draw()
l.DrawLatex(0.15,0.83,"ATLAS")
p.DrawLatex(0.285,0.83,"Simulation Internal")
q.DrawLatex(0.15,0.78,"#it{p}_{T}^{reco} > 25 GeV, |#it{#eta}^{reco}| < 2.1")
q.DrawLatex(0.15,0.68,"Anti-#it{k_{t}} #it{R} = 0.4 jets, PFlow+JES+GSC")
q.DrawLatex(0.15,0.73,"#sqrt{#it{s}} = 13 TeV")
canvas.SaveAs("validation/h1_"+h[0]+".pdf")
print("All done!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment