ROOT
Version v6.32
master
v6.36
v6.34
v6.30
v6.28
v6.26
v6.24
v6.22
v6.20
v6.18
v6.16
v6.14
v6.12
v6.10
v6.08
v6.06
Reference Guide
►
ROOT
•
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
25
void
SQLitePlatformDistribution
(){
26
27
TSQLServer
*
db
=
TSQLServer::Connect
(
"sqlite://root_download_stats.sqlite"
,
""
,
""
);
28
29
const
char
*
rootPlatform
=
"SELECT Platform FROM accesslog;"
;
30
31
TSQLResult
*
rootPlatformRes
=
db
->Query(
rootPlatform
);
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));
38
TString
Platform
(
rowPlatform
);
39
TString
Platform_0
(
rowPlatform
(0,5));
40
TString
Platform_1
(
rowPlatform
(0,6));
41
TString
Platform_2
(
rowPlatform
(0,8));
42
if
(
rowPlatform
.Contains(
"win32"
) ){
43
shorthrootPlatform
->Fill(
Platform_0
,1);
44
}
else
if
(
rowPlatform
.Contains(
"Linux"
) ){
45
shorthrootPlatform
->Fill(
Platform_0
,1);
46
}
else
if
(
rowPlatform
.Contains(
"source"
) ){
47
shorthrootPlatform
->Fill(
Platform_1
,1);
48
}
else
if
(
rowPlatform
.Contains(
"macosx64"
) ){
49
shorthrootPlatform
->Fill(
Platform_2
,1);
50
}
else
if
(
rowPlatform
.Contains(
"IRIX64"
) ){
51
shorthrootPlatform
->Fill(
Platform_1
,1);
52
}
53
54
hrootPlatform
->Fill(
Platform
,1);
55
56
delete
row;
57
}
58
59
TCanvas
*
PlatformDistributionHistogram
=
new
TCanvas
();
60
61
hrootPlatform
->GetXaxis()->LabelsOption(
"a"
);
62
hrootPlatform
->LabelsDeflate(
"X"
);
63
hrootPlatform
->Draw();
64
65
TCanvas
*
shortPlatformDistributionHistogram
=
new
TCanvas
();
66
67
shorthrootPlatform
->GetXaxis()->LabelsOption(
"a"
);
68
shorthrootPlatform
->LabelsDeflate(
"X"
);
69
shorthrootPlatform
->Draw();
70
}
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
TSQLRow.h
TSQLiteResult.h
TSQLiteServer.h
TString.h
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TCanvas
The Canvas class.
Definition
TCanvas.h:23
TH1F
1-D histogram with a float per channel (see TH1 documentation)
Definition
TH1.h:621
TSQLResult
Definition
TSQLResult.h:31
TSQLRow
Definition
TSQLRow.h:30
TSQLServer
Definition
TSQLServer.h:41
TSQLServer::Connect
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....
Definition
TSQLServer.cxx:61
TString
Basic string class.
Definition
TString.h:139
tutorials
sql
SQLitePlatformDistribution.C
ROOT v6-32 - Reference Guide Generated on Sun Apr 27 2025 05:42:52 (GVA Time) using Doxygen 1.10.0