12void 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"});
63 auto t =
f1.Get<
TTree>(treeName);
64 std::cout <<
"These are the columns b1, b1_square and b2_vector:" << std::endl;
65 for (
auto branch : *t->GetListOfBranches()) {
66 std::cout <<
"Branch: " << branch->
GetName() << std::endl;
73 d2.Snapshot(treeName, outFileNameAllColumns);
76 TFile f2(outFileNameAllColumns);
77 t = f2.Get<
TTree>(treeName);
78 std::cout <<
"These are all the columns available to this dataframe:" << std::endl;
79 for (
auto branch : *t->GetListOfBranches()) {
80 std::cout <<
"Branch: " << branch->
GetName() << std::endl;
88 auto snapshot_df = d2.Snapshot<
int>(treeName, outFileName, {
"b1_square"});
89 auto h = snapshot_df->Histo1D();
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTrees,...
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
virtual const char * GetName() const
Returns name of object.
A TTree represents a columnar dataset.