using FourVector = ROOT::Math::XYZTVector; using FourVectorVec = std::vector; using FourVectorRVec = ROOT::VecOps::RVec; using CylFourVector = ROOT::Math::RhoEtaPhiVector; // A simple helper function to fill a test tree: this makes the example // stand-alone. void fill_tree(const char *filename, const char *treeName) { const double M = 0.13957; // set pi+ mass TRandom3 R(1); auto genTracks = [&](){ FourVectorVec tracks; const auto nPart = R.Poisson(15); tracks.reserve(nPart); for (int j = 0; j < nPart; ++j) { const auto px = R.Gaus(0, 10); const auto py = R.Gaus(0, 10); const auto pt = sqrt(px * px + py * py); const auto eta = R.Uniform(-3, 3); const auto phi = R.Uniform(0.0, 2 * TMath::Pi()); CylFourVector vcyl(pt, eta, phi); // set energy auto E = sqrt(vcyl.R() * vcyl.R() + M * M); // fill track vector tracks.emplace_back(vcyl.X(), vcyl.Y(), vcyl.Z(), E); } return tracks; }; ROOT::RDataFrame d(64); d.Define("tracks", genTracks).Snapshot(treeName, filename, {"tracks"}); } void test(){ auto fileName = "df002_dataModel.root"; auto treeName = "myTree"; fill_tree(fileName, treeName); ROOT::RDataFrame df(treeName, fileName, {"tracks"}); auto d = df.Filter([](ULong64_t e){if (0ULL == e) std::cout << "Running evtloop" << std::endl; return true;},{"rdfentry_"}); //d.Snapshot("myNewTree", "newfile.root"); // now start to work on 'd'. At every loop, at he first event, you'll have a message. auto h1 = df.Histo1D("tracks_pts"); h1->Draw(); }