Logo ROOT  
Reference Guide
df010_trivialDataSource.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_dataframe
3/// \notebook -draw
4/// This tutorial illustrates how use the RDataFrame in combination with a
5/// RDataSource. In this case we use a TTrivialDS, which is nothing more
6/// than a simple generator: it does not interface to any existing dataset.
7/// The TTrivialDS has a single column, col0, which has value n for entry n.
8///
9/// \macro_code
10///
11/// \date September 2017
12/// \author Danilo Piparo
13
15{
16 auto nEvents = 128U;
17 auto d_s = ROOT::RDF::MakeTrivialDataFrame(nEvents);
18
19 /// Now we have a regular RDataFrame: the ingestion of data is delegated to
20 /// the RDataSource. At this point everything works as before.
21 auto h_s = d_s.Define("x", "1./(1. + col0)").Histo1D({"h_s", "h_s", 128, 0, .6}, "x");
22
23 /// Now we redo the same with a RDF from scratch and we draw the two histograms
24 ROOT::RDataFrame d(nEvents);
25
26 /// This lambda redoes what the TTrivialDS provides
27 auto g = []() {
28 static ULong64_t i = 0;
29 return i++;
30 };
31 auto h = d.Define("col0", g).Define("x", "1./(1. + col0)").Histo1D({"h", "h", 128, 0, .6}, "x");
32
33 auto c_s = new TCanvas();
34 c_s->SetLogy();
35 h_s->DrawClone();
36
37 auto c = new TCanvas();
38 c->SetLogy();
39 h->DrawClone();
40
41 return 0;
42}
#define d(i)
Definition: RSha256.hxx:102
#define c(i)
Definition: RSha256.hxx:101
#define g(i)
Definition: RSha256.hxx:105
#define h(i)
Definition: RSha256.hxx:106
unsigned long long ULong64_t
Definition: RtypesCore.h:70
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTrees,...
Definition: RDataFrame.hxx:42
The Canvas class.
Definition: TCanvas.h:31
RInterface< RDFDetail::RLoopManager, RTrivialDS > MakeTrivialDataFrame(ULong64_t size, bool skipEvenEntries=false)
Definition: RTrivialDS.cxx:92