Compare creation of a ROOT dataset with RDataFrame and TTree.
This tutorial illustrates how much simpler it can be to use a RDataFrame to create a dataset with respect to the usage of the TTree interfaces.
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();
}
void RDFWay()
{
df.Define(
"b1", [&
b]() {
return b++; })
.Define("b2", "(int) b1 * b1")
.Snapshot("treeName", "df009_FromScratchVSTTree_df.root");
}
void df009_FromScratchVSTTree()
{
classicWay();
RDFWay();
}
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...
A TTree represents a columnar dataset.
- Date
- August 2017
- Author
- Danilo Piparo (CERN)
Definition in file df009_FromScratchVSTTree.C.