Logo ROOT  
Reference Guide
tmva002_RDataFrameAsTensor.C File Reference

Detailed Description

View in nbviewer Open in SWAN This tutorial shows how the content of an RDataFrame can be converted to an RTensor object.

using namespace TMVA::Experimental;
void tmva002_RDataFrameAsTensor()
{
// Creation of an RDataFrame with five entries filled with ascending numbers
auto df2 = df.Define("x", "1.f*rdfentry_").Define("y", "-1.f*rdfentry_");
// Convert content of columns to an RTensor object
auto x = AsTensor<float>(df2);
std::cout << "RTensor from an RDataFrame:\n" << x << "\n\n";
// The utility also supports reading only a part of the RDataFrame and different
// memory layouts.
auto x2 = AsTensor<float>(df2, {"x"}, MemoryLayout::ColumnMajor);
std::cout << "RTensor from a single column of the RDataFrame:\n" << x2 << "\n\n";
}
RTensor from an RDataFrame:
{ { 0, -0 } { 1, -1 } { 2, -2 } { 3, -3 } { 4, -4 } }
RTensor from a single column of the RDataFrame:
{ { 0 } { 1 } { 2 } { 3 } { 4 } }
Date
December 2018
Author
Stefan Wunsch

Definition in file tmva002_RDataFrameAsTensor.C.

TMVA::Experimental::MemoryLayout::ColumnMajor
@ ColumnMajor
x
Double_t x[n]
Definition: legend1.C:17
ROOT::RDataFrame
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTrees,...
Definition: RDataFrame.hxx:42
TMVA::Experimental
Definition: Classification.h:127
x2
static const double x2[5]
Definition: RooGaussKronrodIntegrator1D.cxx:364