%%cpp -d void classicWay() { TFile f("df009_FromScratchVSTTree_classic.root", "RECREATE"); TTree t("treeName", "treeName"); double b1; int b2; t.Branch("b1", &b1); t.Branch("b2", &b2); for (int i = 0; i < 10; ++i) { b1 = i; b2 = i * i; t.Fill(); } t.Write(); f.Close(); } %%cpp -d void RDFWay() { ROOT::RDataFrame df(10); auto b = 0.; df.Define("b1", [&b]() { return b++; }) .Define("b2", "(int) b1 * b1") This can even be a string .Snapshot("treeName", "df009_FromScratchVSTTree_df.root"); } classicWay(); RDFWay();