Loading [MathJax]/extensions/tex2jax.js
Logo ROOT   6.12/07
Reference Guide
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
tdf010_trivialDataSource.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_tdataframe
3 /// \notebook
4 /// This tutorial illustrates how use the TDataFrame in combination with a
5 /// TDataSource. 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;
18 
19  /// Now we have a regular TDataFrame: the ingestion of data is delegated to
20  /// the TDataSource. 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 TDF from scratch and we draw the two histograms
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 }
virtual TObject * DrawClone(Option_t *option="") const
Draw a clone of this object in the current selected pad for instance with: gROOT->SetSelectedPad(gPad...
Definition: TObject.cxx:219
TH1 * h
Definition: legend2.C:5
The Canvas class.
Definition: TCanvas.h:31
TDataFrame MakeTrivialDataFrame(ULong64_t size)
Definition: TTrivialDS.cxx:82
unsigned long long ULong64_t
Definition: RtypesCore.h:70
ROOT's TDataFrame offers a high level interface for analyses of data stored in TTrees.
Definition: TDataFrame.hxx:39
static constexpr double g