12 void fill_tree(
const char *treeName,
const char *fileName)
16 d.Define(
"b1", [&i]() {
return i; })
23 .Snapshot(treeName, fileName);
29 auto fileName =
"df007_snapshot.root";
30 auto outFileName =
"df007_snapshot_output.root";
31 auto outFileNameAllColumns =
"df007_snapshot_output_allColumns.root";
32 auto treeName =
"myTree";
33 fill_tree(treeName, fileName);
40 auto d_cut =
d.Filter(
"b1 % 2 == 0");
43 auto d2 = d_cut.Define(
"b1_square",
"b1 * b1")
47 for (
int i = 0; i < 3; i++)
59 d2.Snapshot(treeName, outFileName, {
"b1",
"b1_square",
"b2_vector"});
64 f1.GetObject(treeName, t);
65 std::cout <<
"These are the columns b1, b1_square and b2_vector:" << std::endl;
67 std::cout <<
"Branch: " << branch->
GetName() << std::endl;
74 d2.Snapshot(treeName, outFileNameAllColumns);
77 TFile f2(outFileNameAllColumns);
78 f2.GetObject(treeName, t);
79 std::cout <<
"These are all the columns available to this tdf:" << std::endl;
81 std::cout <<
"Branch: " << branch->GetName() << std::endl;
89 auto snapshot_tdf = d2.Snapshot<
int>(treeName, outFileName, {
"b1_square"});
90 auto h = snapshot_tdf->Histo1D();
virtual const char * GetName() const
Returns name of object.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
virtual TObjArray * GetListOfBranches()
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTrees, CSV's and other data formats.
A TTree object has a header with a name and a title.