This tutorial illustrates how 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 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.
A TTree represents a columnar dataset.
- Date
- August 2017
- Author
- Danilo Piparo
Definition in file df009_FromScratchVSTTree.C.