Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
df029_SQlitePlatformDistribution.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_dataframe
3 /// \notebook -js
4 ///
5 /// In order to display the Platform Distribution of ROOT, we choose to create two TH1F
6 /// histograms: one that includes all types of platforms, other filtering and classifying them.
7 /// This procedure is using a lambda expression taking as parameter the values
8 /// stored in the "Platform" column from the database. At the end, the histograms are filled
9 /// with their specific demand regarding the platform's type.
10 ///
11 /// \macro_code
12 /// \macro_image
13 ///
14 /// \date August 2018
15 /// \author Alexandra-Maria Dobrescu
16 
17 void df029_SQlitePlatformDistribution() {
18 
19  auto rdf = ROOT::RDF::MakeSqliteDataFrame( "http://root.cern/files/root_download_stats.sqlite", "SELECT * FROM accesslog;" );
20 
21  TH1F hRootPlatform("hrootPlatform", "Platform Distribution", 7, 0, -1);
22  TH1F hShortRootPlatform("hShortRootPlatform", "Short Platform Distribution", 7, 0, -1);
23 
24  auto fillRootPlatform = [&hRootPlatform, &hShortRootPlatform] ( const std::string &platform ) {
25  TString Platform = platform;
26  TString Platform_0(Platform(0,5));
27  TString Platform_1(Platform(0,6));
28  TString Platform_2(Platform(0,8));
29 
30  if ( Platform.Contains("win32") ){
31  hShortRootPlatform.Fill(Platform_0,1);
32  } else if ( Platform.Contains("Linux") ){
33  hShortRootPlatform.Fill(Platform_0,1);
34  } else if ( Platform.Contains("source") ){
35  hShortRootPlatform.Fill(Platform_1,1);
36  } else if ( Platform.Contains("macosx64") ){
37  hShortRootPlatform.Fill(Platform_2,1);
38  } else if ( Platform.Contains("IRIX64") ){
39  hShortRootPlatform.Fill(Platform_1,1);
40  }
41 
42  hRootPlatform.Fill(Platform,1);
43  };
44 
45  rdf.Foreach( fillRootPlatform, { "Platform" } );
46 
47  auto PlatformDistributionHistogram = new TCanvas();
48 
49  hRootPlatform.GetXaxis()->LabelsOption("a");
50  hRootPlatform.LabelsDeflate("X");
51  hRootPlatform.DrawClone();
52 
53  auto shortPlatformDistributionHistogram = new TCanvas();
54 
55  hShortRootPlatform.GetXaxis()->LabelsOption("a");
56  hShortRootPlatform.LabelsDeflate("X");
57  hShortRootPlatform.DrawClone();
58 }