Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
df000_simple.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_dataframe
3/// \notebook -draw
4/// Simple RDataFrame example in C++.
5///
6/// This tutorial shows a minimal example of RDataFrame. It starts without input
7/// data, generates a new column `x` with random numbers, and finally draws
8/// a histogram for `x`.
9///
10/// \macro_code
11/// \macro_output
12///
13/// \date September 2021
14/// \author Enric Tejedor (CERN)
15
16void df000_simple()
17{
18 // Create a data frame with 100 rows
19 ROOT::RDataFrame rdf(100);
20
21 // Define a new column `x` that contains random numbers
22 auto rdf_x = rdf.Define("x", [](){ return gRandom->Rndm(); });
23
24 // Create a histogram from `x`
25 auto h = rdf_x.Histo1D("x");
26
27 // At the end of this function, the histogram pointed to by `h` will be deleted.
28 // Draw a copy of the histogram object instead:
29 h->DrawClone();
30}
#define h(i)
Definition RSha256.hxx:106
R__EXTERN TRandom * gRandom
Definition TRandom.h:62
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTree,...
virtual Double_t Rndm()
Machine independent random number generator.
Definition TRandom.cxx:552