16void fill_tree(
const char *treeName,
const char *fileName)
20 d.Define(
"b1", [&i]() {
return i; })
27 .Snapshot(treeName, fileName);
33 auto fileName =
"df007_snapshot.root";
34 auto outFileName =
"df007_snapshot_output.root";
35 auto outFileNameAllColumns =
"df007_snapshot_output_allColumns.root";
36 auto treeName =
"myTree";
37 fill_tree(treeName, fileName);
44 auto d_cut =
d.Filter(
"b1 % 2 == 0");
47 auto d2 = d_cut.Define(
"b1_square",
"b1 * b1")
51 for (
int i = 0; i < 3; i++)
63 d2.Snapshot(treeName, outFileName, {
"b1",
"b1_square",
"b2_vector"});
67 auto t =
f1.Get<
TTree>(treeName);
68 std::cout <<
"These are the columns b1, b1_square and b2_vector:" << std::endl;
69 for (
auto branch : *t->GetListOfBranches()) {
70 std::cout <<
"Branch: " << branch->
GetName() << std::endl;
77 d2.Snapshot(treeName, outFileNameAllColumns);
80 TFile f2(outFileNameAllColumns);
81 t = f2.Get<
TTree>(treeName);
82 std::cout <<
"These are all the columns available to this dataframe:" << std::endl;
83 for (
auto branch : *t->GetListOfBranches()) {
84 std::cout <<
"Branch: " << branch->
GetName() << std::endl;
92 auto snapshot_df = d2.Snapshot<
int>(treeName, outFileName, {
"b1_square"});
93 auto h = snapshot_df->Histo1D();
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...
A ROOT file is composed of a header, followed by consecutive data records (TKey instances) with a wel...
const char * GetName() const override
Returns name of object.
A TTree represents a columnar dataset.