38ROOT.ROOT.EnableImplicitMT()
41path =
"root://eospublic.cern.ch//eos/opendata/atlas/OutreachDatasets/2020-01-22"
44 "mini", (os.path.join(path,
"GamGam/Data/data_{}.GamGam.root".format(x))
for x
in (
"A",
"B",
"C",
"D"))
46df[
"ggH"] =
ROOT.RDataFrame(
"mini", os.path.join(path,
"GamGam/MC/mc_343981.ggH125_gamgam.GamGam.root"))
47df[
"VBF"] =
ROOT.RDataFrame(
"mini", os.path.join(path,
"GamGam/MC/mc_345041.VBFH125_gamgam.GamGam.root"))
48processes = list(df.keys())
51for p
in [
"ggH",
"VBF"]:
52 df[p] = df[p].Define(
"weight",
"scaleFactor_PHOTON * scaleFactor_PhotonTRIGGER * scaleFactor_PILEUP * mcWeight")
53df[
"data"] = df[
"data"].Define(
"weight",
"1.0")
58 df[p] = df[p].Filter(
"trigP")
65 "photon_isTightID && (photon_pt > 25000) && (abs(photon_eta) < 2.37) && ((abs(photon_eta) < 1.37) || (abs(photon_eta) > 1.52))",
67 .Filter(
"Sum(goodphotons) == 2")
73 .Filter(
"Sum(photon_ptcone30[goodphotons] / photon_pt[goodphotons] < 0.065) == 2")
74 .Filter(
"Sum(photon_etcone20[goodphotons] / photon_pt[goodphotons] < 0.065) == 2")
78ROOT.gInterpreter.Declare(
80using Vec_t = const ROOT::VecOps::RVec<float>;
81float ComputeInvariantMass(Vec_t& pt, Vec_t& eta, Vec_t& phi, Vec_t& e) {
82 ROOT::Math::PtEtaPhiEVector p1(pt[0], eta[0], phi[0], e[0]);
83 ROOT::Math::PtEtaPhiEVector p2(pt[1], eta[1], phi[1], e[1]);
84 return (p1 + p2).mass() / 1000.0;
95 "ComputeInvariantMass(photon_pt[goodphotons], photon_eta[goodphotons], photon_phi[goodphotons], photon_E[goodphotons])",
101 .Filter(
"photon_pt[goodphotons][0] / 1000.0 / m_yy > 0.35")
102 .Filter(
"photon_pt[goodphotons][1] / 1000.0 / m_yy > 0.25")
103 .Filter(
"m_yy > 105 && m_yy < 160")
107 hists[p] = df[p].Histo1D(
108 ROOT.RDF.TH1DModel(p,
"Diphoton invariant mass; m_{#gamma#gamma} [GeV];Events", 30, 105, 160),
"m_yy",
"weight"
119ggh = hists[
"ggH"].GetValue()
120vbf = hists[
"VBF"].GetValue()
121data = hists[
"data"].GetValue()
129c = RCanvas.Create(
"df104_HiggsToTwoPhotons")
131lower_pad = c.AddPad(RPadPos(0, 0.65), RPadExtent(1, 0.35))
132upper_pad = c.AddPad(RPadPos(0, 0), RPadExtent(1, 0.65))
134upper_frame = upper_pad.AddFrame()
135upper_frame.margins.bottom = 0
136upper_frame.margins.left = 0.14
137upper_frame.margins.right = 0.05
138upper_frame.x.labels.hide =
True
140lower_frame = lower_pad.AddFrame()
141lower_frame.margins.top = 0
142lower_frame.margins.left = 0.14
143lower_frame.margins.right = 0.05
144lower_frame.margins.bottom = 0.3
147fit = ROOT.TF1(
"fit",
"([0]+[1]*x+[2]*x^2+[3]*x^3)+[4]*exp(-0.5*((x-[5])/[6])^2)", 105, 160)
148fit.FixParameter(5, 125.0)
149fit.FixParameter(4, 119.1)
150fit.FixParameter(6, 2.39)
152fit.SetLineStyle(ROOT.kSolid)
155data.Fit(
"fit",
"0",
"", 105, 160)
158data.SetMarkerStyle(20)
159data.SetMarkerSize(1.2)
161data.SetLineColor(
"black")
164data.GetYaxis().SetLabelSize(0.045)
165data.GetYaxis().SetTitleSize(0.05)
166data.GetYaxis().SetTitleOffset(1.4)
170data_drawable = upper_pad.Add[TObjectDrawable]()
171data_drawable.Set(data,
"E")
174fit_drawable = upper_pad.Add[TObjectDrawable]()
175fit_drawable.Set(fit,
"SAME")
178bkg = ROOT.TF1(
"bkg",
"([0]+[1]*x+[2]*x^2+[3]*x^3)", 105, 160)
180 bkg.SetParameter(i, fit.GetParameter(i))
182bkg.SetLineStyle(ROOT.kDashed)
184bkg_drawable = upper_pad.Add[TObjectDrawable]()
185bkg_drawable.Set(bkg,
"SAME")
190ggh.Scale(lumi * 0.102 / 55922617.6297)
191vbf.Scale(lumi * 0.008518764 / 3441426.13711)
194higgs_drawable = upper_pad.Add[TObjectDrawable]()
195higgs_drawable.Set(higgs,
"HIST SAME")
199ratiobkg = ROOT.TH1I(
"zero",
"", 10, 105, 160)
200ratiobkg.SetLineColor(4)
201ratiobkg.SetLineStyle(ROOT.kDashed)
202ratiobkg.SetLineWidth(2)
203ratiobkg.SetMinimum(-125)
204ratiobkg.SetMaximum(250)
205ratiobkg.SetStats(
False)
206ratiobkg.GetXaxis().SetLabelSize(0.08)
207ratiobkg.GetXaxis().SetTitleSize(0.12)
208ratiobkg.GetXaxis().SetTitleOffset(1.0)
209ratiobkg.GetYaxis().SetLabelSize(0.08)
210ratiobkg.GetYaxis().SetTitleSize(0.09)
211ratiobkg.GetYaxis().SetTitle(
"Data - Bkg.")
212ratiobkg.GetYaxis().SetTitleOffset(0.7)
213ratiobkg.GetYaxis().CenterTitle()
214ratiobkg.GetYaxis().SetNdivisions(503,
False)
215ratiobkg.GetYaxis().ChangeLabel(-1, -1, 0)
216ratiobkg.GetXaxis().SetTitle(
"m_{#gamma#gamma} [GeV]")
217lower_pad.Add[TObjectDrawable]().Set(ratiobkg,
"AXIS")
219ratiosig = ROOT.TH1F(
"ratiosig",
"ratiosig", 5500, 105, 160)
221ratiosig.SetLineColor(2)
222ratiosig.SetLineStyle(ROOT.kSolid)
223ratiosig.SetLineWidth(2)
225lower_pad.Add[TObjectDrawable]().Set(ratiosig,
"SAME")
227ratiodata = data.Clone()
228ratiodata.Add(bkg, -1)
229for i
in range(1, data.GetNbinsX()):
230 ratiodata.SetBinError(i, data.GetBinError(i))
232lower_pad.Add[TObjectDrawable]().Set(ratiodata,
"E SAME")
235legend = upper_pad.Draw[RLegend](RPadPos(0.01, 0.01), RPadExtent(0.3, 0.4))
236legend.text.size = 0.05
237legend.text.align = RAttrText.kRightCenter
238legend.text.font = RAttrFont.kArial
239legend.border.style = RAttrLine.kNone
240legend.border.width = 0
241legend.fill.style = RAttrFill.kHollow
243legend.AddEntry(data_drawable,
"Data",
"lme")
244legend.AddEntry(bkg_drawable,
"Background",
"l")
245legend.AddEntry(fit_drawable,
"Signal + Bkg.",
"l")
246legend.AddEntry(higgs_drawable,
"Signal",
"l")
249lbl1 = upper_pad.Draw[RText](RPadPos(0.05, 0.88),
"ATLAS")
251lbl1.text.font = RAttrFont.kArialBoldOblique
253lbl1.text.align = RAttrText.kLeftBottom
254lbl2 = upper_pad.Draw[RText](RPadPos(0.05 + 0.16, 0.88),
"Open Data")
256lbl2.text.font = RAttrFont.kArial
258lbl2.text.align = RAttrText.kLeftBottom
259lbl3 = upper_pad.Draw[RText](RPadPos(0.05, 0.82),
"#sqrt{s} = 13 TeV, 10 fb^{-1}")
261lbl3.text.font = RAttrFont.kArial
263lbl3.text.align = RAttrText.kLeftBottom
270if c.SaveAs(
"df104.png"):
271 print(
"Saved figure to df104.png")
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...
Namespace for ROOT features in testing.
unsigned int RunGraphs(std::vector< RResultHandle > handles)
Run the event loops of multiple RDataFrames concurrently.
A struct which stores some basic parameters of a TH1D.