17auto filename =
gROOT->GetTutorialDir() +
"/dataframe/df017_vecOpsHEP.root";
18auto treename =
"myDataset";
30 TH1F h(
"pt",
"pt", 16, 0, 4);
33 for (
auto i=0U;i < px.GetSize(); ++i) {
34 if (
E[i] > 100)
h.Fill(
sqrt(px[i]*px[i] + py[i]*py[i]));
42 RDF
f(treename, filename.Data());
43 auto CalcPt = [](doubles &px, doubles &py, doubles &
E) {
45 for (
auto i=0U;i < px.size(); ++i) {
47 v.emplace_back(
sqrt(px[i]*px[i] + py[i]*py[i]));
52 f.Define(
"pt", CalcPt, {
"px",
"py",
"E"})
53 .Histo1D<doubles>({
"pt",
"pt", 16, 0, 4},
"pt")->DrawCopy();
56void WithRDataFrameVecOps()
58 RDF
f(treename, filename.Data());
59 auto CalcPt = [](doubles &px, doubles &py, doubles &
E) {
60 auto pt =
sqrt(px*px + py*py);
63 f.Define(
"good_pt", CalcPt, {
"px",
"py",
"E"})
64 .Histo1D<doubles>({
"pt",
"pt", 16, 0, 4},
"good_pt")->DrawCopy();
67void WithRDataFrameVecOpsJit()
69 RDF
f(treename, filename.Data());
70 f.Define(
"good_pt",
"sqrt(px*px + py*py)[E>100]")
71 .Histo1D({
"pt",
"pt", 16, 0, 4},
"good_pt")->DrawCopy();
85 WithRDataFrameVecOps();
87 WithRDataFrameVecOpsJit();
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTrees,...
A "std::vector"-like collection of values implementing handy operation to analyse them.
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 colmnar datasets such as TTree,...
constexpr Double_t E()
Base of natural log: