19auto filename =
gROOT->GetTutorialDir() +
"/dataframe/df017_vecOpsHEP.root";
20auto treename =
"myDataset";
32 TH1F h(
"pt",
"pt", 16, 0, 4);
35 for (
auto i=0U;i < px.GetSize(); ++i) {
36 if (
E[i] > 100)
h.Fill(
sqrt(px[i]*px[i] + py[i]*py[i]));
44 RDF
f(treename, filename.Data());
45 auto CalcPt = [](doubles &px, doubles &py, doubles &
E) {
47 for (
auto i=0U;i < px.size(); ++i) {
49 v.emplace_back(
sqrt(px[i]*px[i] + py[i]*py[i]));
54 f.Define(
"pt", CalcPt, {
"px",
"py",
"E"})
55 .Histo1D<doubles>({
"pt",
"pt", 16, 0, 4},
"pt")->DrawCopy();
58void WithRDataFrameVecOps()
60 RDF
f(treename, filename.Data());
61 auto CalcPt = [](doubles &px, doubles &py, doubles &
E) {
62 auto pt =
sqrt(px*px + py*py);
65 f.Define(
"good_pt", CalcPt, {
"px",
"py",
"E"})
66 .Histo1D<doubles>({
"pt",
"pt", 16, 0, 4},
"good_pt")->DrawCopy();
69void WithRDataFrameVecOpsJit()
71 RDF
f(treename, filename.Data());
72 f.Define(
"good_pt",
"sqrt(px*px + py*py)[E>100]")
73 .Histo1D({
"pt",
"pt", 16, 0, 4},
"good_pt")->DrawCopy();
87 WithRDataFrameVecOps();
89 WithRDataFrameVecOpsJit();
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTrees,...
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
1-D histogram with a float per channel (see TH1 documentation)}
An interface for reading collections stored in ROOT columnar datasets.
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
constexpr Double_t E()
Base of natural log: