21filename = ROOT.gROOT.GetTutorialDir().Data() +
"/dataframe/df017_vecOpsHEP.root"
24def WithPyROOT(filename):
26 f = ROOT.TFile(filename)
27 h = ROOT.TH1F(
"pt",
"With PyROOT", 16, 0, 4)
28 for event
in f.myDataset:
29 for E, px, py
in zip(event.E, event.px, event.py):
31 h.Fill(sqrt(px*px + py*py))
34def WithRDataFrameVecOpsJit(treename, filename):
36 h = f.Define(
"good_pt",
"sqrt(px*px + py*py)[E>100]")\
37 .Histo1D((
"pt",
"With RDataFrame and RVec", 16, 0, 4),
"good_pt")
47WithRDataFrameVecOpsJit(treename, filename)
48c.SaveAs(
"df017_vecOpsHEP.png")
50print(
"Saved figure to df017_vecOpsHEP.png")
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...