Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
tmva002_RDataFrameAsTensor.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_tmva
3/// \notebook -nodraw
4/// This tutorial shows how the content of an RDataFrame can be converted to an
5/// RTensor object.
6///
7/// \macro_code
8/// \macro_output
9///
10/// \date December 2018
11/// \author Stefan Wunsch
12
13using namespace TMVA::Experimental;
14
15void tmva002_RDataFrameAsTensor()
16{
17 // Creation of an RDataFrame with five entries filled with ascending numbers
18 ROOT::RDataFrame df(5);
19 auto df2 = df.Define("x", "1.f*rdfentry_").Define("y", "-1.f*rdfentry_");
20
21 // Convert content of columns to an RTensor object
22 auto x = AsTensor<float>(df2);
23
24 std::cout << "RTensor from an RDataFrame:\n" << x << "\n\n";
25
26 // The utility also supports reading only a part of the RDataFrame and different
27 // memory layouts.
28 auto x2 = AsTensor<float>(df2, {"x"}, MemoryLayout::ColumnMajor);
29
30 std::cout << "RTensor from a single column of the RDataFrame:\n" << x2 << "\n\n";
31}
static const double x2[5]
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTree,...
Double_t x[n]
Definition legend1.C:17