%%cpp -d void fill_tree(const char *treeName, const char *fileName) { ROOT::RDataFrame d(10000); int i(0); d.Define("b1", [&i]() { return i; }) .Define("b2", [&i]() { float j = i * i; ++i; return j; }) .Snapshot(treeName, fileName); } auto fileName = "df007_snapshot.root"; auto outFileName = "df007_snapshot_output.root"; auto outFileNameAllColumns = "df007_snapshot_output_allColumns.root"; auto treeName = "myTree"; fill_tree(treeName, fileName); ROOT::RDataFrame d(treeName, fileName); auto d_cut = d.Filter("b1 % 2 == 0"); auto d2 = d_cut.Define("b1_square", "b1 * b1") .Define("b2_vector", [](float b2) { std::vector v; for (int i = 0; i < 3; i++) v.push_back(b2 * i); return v; }, {"b2"}); d2.Snapshot(treeName, outFileName, {"b1", "b1_square", "b2_vector"}); TFile f1(outFileName); auto t = f1.Get(treeName); std::cout << "These are the columns b1, b1_square and b2_vector:" << std::endl; for (auto branch : *t->GetListOfBranches()) { std::cout << "Branch: " << branch->GetName() << std::endl; } f1.Close(); d2.Snapshot(treeName, outFileNameAllColumns); TFile f2(outFileNameAllColumns); t = f2.Get(treeName); std::cout << "These are all the columns available to this dataframe:" << std::endl; for (auto branch : *t->GetListOfBranches()) { std::cout << "Branch: " << branch->GetName() << std::endl; } f2.Close(); auto snapshot_df = d2.Snapshot(treeName, outFileName, {"b1_square"}); auto h = snapshot_df->Histo1D(); auto c = new TCanvas(); h->DrawClone(); return 0; gROOT->GetListOfCanvases()->Draw()