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