%%cpp -d void fill_tree(const char *treeName, const char *fileName) { ROOT::RDataFrame d(100); auto i = 0.; d.Define("b1", [&i]() { return i; }) .Define("b2", [&i]() { float j = i * i; ++i; return j; }) .Snapshot(treeName, fileName); } auto fileName = "df005_fillAnyObject.root"; auto treeName = "myTree"; fill_tree(treeName, fileName); ROOT::RDataFrame d(treeName, fileName); auto th1d = d.Fill(TH1D("th1d", "th1d", 64, 0, 128), {"b1"}); auto th1i = d.Fill(TH1I("th1i", "th1i", 64, 0, 128), {"b2"}); auto th2d = d.Fill(TH2D("th2d", "th2d", 64, 0, 128, 64, 0, 1024), {"b1", "b2"}); auto c1 = new TCanvas(); th1d->DrawClone(); auto c2 = new TCanvas(); th1i->DrawClone(); auto c3 = new TCanvas(); th2d->DrawClone("COLZ"); return 0; gROOT->GetListOfCanvases()->Draw()