Logo ROOT   6.21/01
Reference Guide
df030_SQliteVersionsOfROOT.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_dataframe
3 /// \notebook -js
4 /// Plot the downloads of different ROOT versions reading a remote sqlite3 file with RSqliteDS.
5 /// Then a TH1F histogram is created and filled
6 /// using a lambda expression which receives the recorded
7 /// values in the "version" column of the sqlite3 database.
8 /// The histogram shows the usage of the ROOT development version.
9 ///
10 /// \macro_code
11 /// \macro_image
12 ///
13 /// \date August 2018
14 /// \author Alexandra-Maria Dobrescu
15 
16 void df030_SQliteVersionsOfROOT() {
17 
18  auto rdf = ROOT::RDF::MakeSqliteDataFrame("http://root.cern/files/root_download_stats.sqlite", "SELECT Version FROM accesslog;");
19 
20  TH1F hVersionOfRoot("hVersionOfRoot", "Development Versions of ROOT", 8, 0, -1);
21 
22  auto fillVersionHisto = [&hVersionOfRoot] (const std::string &version) {
23  TString copyVersion = version;
24  TString shortVersion(copyVersion(0,4));
25  hVersionOfRoot.Fill(shortVersion, 1);
26  };
27 
28  rdf.Foreach( fillVersionHisto, { "Version" } );
29 
30  auto VersionOfRootHistogram = new TCanvas();
31 
32  gStyle->SetOptStat(0);
33  hVersionOfRoot.GetXaxis()->LabelsOption("a");
34  hVersionOfRoot.LabelsDeflate("X");
35  hVersionOfRoot.DrawClone("");
36 }
R__EXTERN TStyle * gStyle
Definition: TStyle.h:410
Basic string class.
Definition: TString.h:131
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:571
The Canvas class.
Definition: TCanvas.h:31
RDataFrame MakeSqliteDataFrame(std::string_view fileName, std::string_view query)
Factory method to create a SQlite RDataFrame.
Definition: RSqliteDS.cxx:541
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
Definition: TStyle.cxx:1452