28path =
"root://eospublic.cern.ch//eos/opendata/atlas/OutreachDatasets/2020-01-22"
29files = json.load(open(os.path.join(os.path.dirname(os.path.abspath(__file__)),
"df106_HiggsToFourLeptons.json")))
30processes = files.keys()
42 samples.append(sample)
43 df[sample] =
ROOT.RDataFrame(
"mini",
"{}/4lep/{}/{}.4lep.root".format(path, folder, sample))
46ROOT.gInterpreter.Declare(
"""
47using cRVecF = const ROOT::RVecF &;
48bool GoodElectronsAndMuons(const ROOT::RVecI & type, cRVecF pt, cRVecF eta, cRVecF phi, cRVecF e, cRVecF trackd0pv, cRVecF tracksigd0pv, cRVecF z0)
50 for (size_t i = 0; i < type.size(); i++) {
51 ROOT::Math::PtEtaPhiEVector p(pt[i] / 1000.0, eta[i], phi[i], e[i] / 1000.0);
53 if (pt[i] < 7000 || abs(eta[i]) > 2.47 || abs(trackd0pv[i] / tracksigd0pv[i]) > 5 || abs(z0[i] * sin(p.Theta())) > 0.5) return false;
55 if (abs(trackd0pv[i] / tracksigd0pv[i]) > 5 || abs(z0[i] * sin(p.Theta())) > 0.5) return false;
64 df[s] = df[s].Filter(
"trigE || trigM")
70 df[s] = df[s].Define(
"good_lep",
"abs(lep_eta) < 2.5 && lep_pt > 5000 && lep_ptcone30 / lep_pt < 0.3 && lep_etcone20 / lep_pt < 0.3")\
71 .Filter(
"Sum(good_lep) == 4")\
72 .Filter(
"Sum(lep_charge[good_lep]) == 0")\
73 .Define(
"goodlep_sumtypes",
"Sum(lep_type[good_lep])")\
74 .Filter(
"goodlep_sumtypes == 44 || goodlep_sumtypes == 52 || goodlep_sumtypes == 48")
77 df[s] = df[s].Filter(
"GoodElectronsAndMuons(lep_type[good_lep], lep_pt[good_lep], lep_eta[good_lep], lep_phi[good_lep], lep_E[good_lep], lep_trackd0pvunbiased[good_lep], lep_tracksigd0pvunbiased[good_lep], lep_z0[good_lep])")
80 df[s] = df[s].Define(
"goodlep_pt",
"lep_pt[good_lep]")\
81 .Define(
"goodlep_eta",
"lep_eta[good_lep]")\
82 .Define(
"goodlep_phi",
"lep_phi[good_lep]")\
83 .Define(
"goodlep_E",
"lep_E[good_lep]")
86 df[s] = df[s].Filter(
"goodlep_pt[0] > 25000 && goodlep_pt[1] > 15000 && goodlep_pt[2] > 10000")
92 df[s] = df[s].Define(
"weight",
"1.0")
94 df[s] = df[s].Define(
"weight",
"scaleFactor_ELE * scaleFactor_MUON * scaleFactor_LepTRIGGER * scaleFactor_PILEUP * mcWeight * {} / {} * {}".format(xsecs[s], sumws[s], lumi))
97ROOT.gInterpreter.Declare(
"""
98float ComputeInvariantMass(cRVecF pt, cRVecF eta, cRVecF phi, cRVecF e)
100 ROOT::Math::PtEtaPhiEVector p1(pt[0], eta[0], phi[0], e[0]);
101 ROOT::Math::PtEtaPhiEVector p2(pt[1], eta[1], phi[1], e[1]);
102 ROOT::Math::PtEtaPhiEVector p3(pt[2], eta[2], phi[2], e[2]);
103 ROOT::Math::PtEtaPhiEVector p4(pt[3], eta[3], phi[3], e[3]);
104 return (p1 + p2 + p3 + p4).M() / 1000;
110 df[s] = df[s].Define(
"m4l",
"ComputeInvariantMass(goodlep_pt, goodlep_eta, goodlep_phi, goodlep_E)")
121def merge_histos(label):
123 for i, d
in enumerate(files[label]):
124 t = histos[d[1]].GetValue()
125 if i == 0: h = t.Clone()
127 h.SetNameTitle(label, label)
130data = merge_histos(
"data")
131higgs = merge_histos(
"higgs")
132zz = merge_histos(
"zz")
133other = merge_histos(
"other")
141ROOT.gROOT.SetStyle(
"ATLAS")
144c = ROOT.TCanvas(
"c",
"", 600, 600)
145pad = ROOT.TPad(
"upper_pad",
"", 0, 0, 1, 1)
152stack = ROOT.THStack()
153for h, color
in zip([other, zz, higgs], [(155, 152, 204), (100, 192, 232), (191, 34, 41)]):
156 h.SetFillColor(ROOT.TColor.GetColor(*color))
159stack.GetXaxis().SetLabelSize(0.04)
160stack.GetXaxis().SetTitleSize(0.045)
161stack.GetXaxis().SetTitleOffset(1.3)
162stack.GetXaxis().SetTitle(
"m_{4l}^{H#rightarrow ZZ} [GeV]")
163stack.GetYaxis().SetTitle(
"Events")
164stack.GetYaxis().SetLabelSize(0.04)
165stack.GetYaxis().SetTitleSize(0.045)
167stack.GetYaxis().ChangeLabel(1, -1, 0)
170data.SetMarkerStyle(20)
171data.SetMarkerSize(1.2)
173data.SetLineColor(ROOT.kBlack)
177legend = ROOT.TLegend(0.60, 0.65, 0.92, 0.92)
178legend.SetTextFont(42)
179legend.SetFillStyle(0)
180legend.SetBorderSize(0)
181legend.SetTextSize(0.04)
182legend.SetTextAlign(32)
183legend.AddEntry(data,
"Data" ,
"lep")
184legend.AddEntry(higgs,
"Higgs",
"f")
185legend.AddEntry(zz,
"ZZ",
"f")
186legend.AddEntry(other,
"Other",
"f")
193text.SetTextSize(0.045)
194text.DrawLatex(0.21, 0.86,
"ATLAS")
196text.DrawLatex(0.21 + 0.16, 0.86,
"Open Data")
197text.SetTextSize(0.04)
198text.DrawLatex(0.21, 0.80,
"#sqrt{s} = 13 TeV, 10 fb^{-1}")
201c.SaveAs(
"df106_HiggsToFourLeptons.png")
202print(
"Saved figure to df106_HiggsToFourLeptons.png")
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTree,...
void RunGraphs(std::vector< RResultHandle > handles)
Trigger the event loop of multiple RDataFrames concurrently.
A struct which stores the parameters of a TH1D.