Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
SQLitePlatformDistribution.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_sql
3/// \notebook -js
4///
5/// This tutorial demonstrates how TSQLServer can be used to create a
6/// connection with a SQlite3 database. It accesses the Sqlite data base.
7/// Download from https://root.cern/files/root_download_stats.sqlite
8/// In order to display the Platform Distribution of ROOT, we choose to create two TH1F
9/// histograms: one that includes all types of platforms, other filtering and classifying them.
10/// This procedure is taking as parameter the values stored in the "Platform" column from the
11/// database. At the end, the histograms are filled
12/// with their specific demand regarding the platform's type.
13/// This product includes GeoLite2 data created by MaxMind, available from
14/// <a href="http://www.maxmind.com">http://www.maxmind.com</a>.
15///
16/// \macro_code
17///
18/// \author Alexandra-Maria Dobrescu 08/2018
19
20#include <TSQLiteServer.h>
21#include <TSQLiteResult.h>
22#include <TSQLRow.h>
23#include <TString.h>
24
26
27 TSQLServer *db = TSQLServer::Connect("sqlite://root_download_stats.sqlite", "", "");
28
29 const char *rootPlatform = "SELECT Platform FROM accesslog;";
30
32
33 TH1F *hrootPlatform = new TH1F("hrootPlatform", "Platform Distribution", 7, 0, -1);
34 TH1F *shorthrootPlatform = new TH1F("shorthrootPlatform", "Short Platform Distribution", 7, 0, -1);
35
36 while (TSQLRow *row = rootPlatformRes->Next()) {
37 TString rowPlatform(row->GetField(0));
42 if ( rowPlatform.Contains("win32") ){
44 } else if ( rowPlatform.Contains("Linux") ){
46 } else if ( rowPlatform.Contains("source") ){
48 } else if ( rowPlatform.Contains("macosx64") ){
50 } else if ( rowPlatform.Contains("IRIX64") ){
52 }
53
54 hrootPlatform->Fill(Platform,1);
55
56 delete row;
57 }
58
60
61 hrootPlatform->GetXaxis()->LabelsOption("a");
62 hrootPlatform->LabelsDeflate("X");
63 hrootPlatform->Draw();
64
66
67 shorthrootPlatform->GetXaxis()->LabelsOption("a");
68 shorthrootPlatform->LabelsDeflate("X");
69 shorthrootPlatform->Draw();
70}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
The Canvas class.
Definition TCanvas.h:23
1-D histogram with a float per channel (see TH1 documentation)
Definition TH1.h:621
static TSQLServer * Connect(const char *db, const char *uid, const char *pw)
The db should be of the form: <dbms>://<host>[:<port>][/<database>], e.g.: mysql://pcroot....
Basic string class.
Definition TString.h:139