17filename = ROOT.gROOT.GetTutorialDir().Data() +
"/dataframe/df017_vecOpsHEP.root"
20def WithPyROOT(filename):
22 f = ROOT.TFile(filename)
23 h = ROOT.TH1F(
"pt",
"With PyROOT", 16, 0, 4)
24 for event
in f.myDataset:
25 for E, px, py
in zip(event.E, event.px, event.py):
27 h.Fill(sqrt(px*px + py*py))
30def WithRDataFrameVecOpsJit(treename, filename):
32 h = f.Define(
"good_pt",
"sqrt(px*px + py*py)[E>100]")\
33 .Histo1D((
"pt",
"With RDataFrame and RVec", 16, 0, 4),
"good_pt")
43WithRDataFrameVecOpsJit(treename, filename)
44c.SaveAs(
"df017_vecOpsHEP.png")
46print(
"Saved figure to df017_vecOpsHEP.png")
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTree,...