ROOT
Version v6.34
master
v6.32
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
/// This tutorial demonstrates how TSQLServer can be used to create a connection with a SQlite3 database.
5
/// It accesses the Sqlite data base.
6
/// Download from https://root.cern/files/root_download_stats.sqlite
7
/// In order to display the Platform Distribution of ROOT, we choose to create two TH1F
8
/// histograms: one that includes all types of platforms, other filtering and classifying them.
9
/// This procedure is taking as parameter the values stored in the "Platform" column from the
10
/// database. At the end, the histograms are filled
11
/// with their specific demand regarding the platform's type.
12
/// This product includes GeoLite2 data created by MaxMind, available from
13
/// <a href="http://www.maxmind.com">http://www.maxmind.com</a>.
14
///
15
/// \macro_code
16
///
17
/// \author Alexandra-Maria Dobrescu 08/2018
18
19
#include <
TSQLiteServer.h
>
20
#include <
TSQLiteResult.h
>
21
#include <
TSQLRow.h
>
22
#include <
TString.h
>
23
24
void
SQLitePlatformDistribution
(){
25
26
TSQLServer
*
db
=
TSQLServer::Connect
(
"sqlite://root_download_stats.sqlite"
,
""
,
""
);
27
28
const
char
*
rootPlatform
=
"SELECT Platform FROM accesslog;"
;
29
30
TSQLResult
*
rootPlatformRes
=
db
->Query(
rootPlatform
);
31
32
TH1F
*
hrootPlatform
=
new
TH1F
(
"hrootPlatform"
,
"Platform Distribution"
, 7, 0, -1);
33
TH1F
*
shorthrootPlatform
=
new
TH1F
(
"shorthrootPlatform"
,
"Short Platform Distribution"
, 7, 0, -1);
34
35
while
(
TSQLRow
*row =
rootPlatformRes
->Next()) {
36
TString
rowPlatform
(row->GetField(0));
37
TString
Platform
(
rowPlatform
);
38
TString
Platform_0
(
rowPlatform
(0,5));
39
TString
Platform_1
(
rowPlatform
(0,6));
40
TString
Platform_2
(
rowPlatform
(0,8));
41
if
(
rowPlatform
.Contains(
"win32"
) ){
42
shorthrootPlatform
->Fill(
Platform_0
,1);
43
}
else
if
(
rowPlatform
.Contains(
"Linux"
) ){
44
shorthrootPlatform
->Fill(
Platform_0
,1);
45
}
else
if
(
rowPlatform
.Contains(
"source"
) ){
46
shorthrootPlatform
->Fill(
Platform_1
,1);
47
}
else
if
(
rowPlatform
.Contains(
"macosx64"
) ){
48
shorthrootPlatform
->Fill(
Platform_2
,1);
49
}
else
if
(
rowPlatform
.Contains(
"IRIX64"
) ){
50
shorthrootPlatform
->Fill(
Platform_1
,1);
51
}
52
53
hrootPlatform
->Fill(
Platform
,1);
54
55
delete
row;
56
}
57
58
TCanvas
*
PlatformDistributionHistogram
=
new
TCanvas
();
59
60
hrootPlatform
->GetXaxis()->LabelsOption(
"a"
);
61
hrootPlatform
->LabelsDeflate(
"X"
);
62
hrootPlatform
->Draw();
63
64
TCanvas
*
shortPlatformDistributionHistogram
=
new
TCanvas
();
65
66
shorthrootPlatform
->GetXaxis()->LabelsOption(
"a"
);
67
shorthrootPlatform
->LabelsDeflate(
"X"
);
68
shorthrootPlatform
->Draw();
69
}
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:622
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 tags/6-34-04 - Reference Guide Generated on Fri Mar 21 2025 04:40:18 (GVA Time) using Doxygen 1.10.0