{
"cells": [
{
"cell_type": "markdown",
"id": "72b95d4b",
"metadata": {},
"source": [
"# df029_SQlitePlatformDistribution\n",
"Use RDataFrame to display data about ROOT downloads.\n",
"\n",
"In order to display the Platform Distribution of ROOT, we choose to create two TH1F\n",
"histograms: one that includes all types of platforms, other filtering and classifying them.\n",
"This procedure is using a lambda expression taking as parameter the values\n",
"stored in the \"Platform\" column from the database. At the end, the histograms are filled\n",
"with their specific demand regarding the platform's type.\n",
"\n",
"\n",
"\n",
"\n",
"**Author:** Alexandra-Maria Dobrescu \n",
"This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Tuesday, March 19, 2024 at 07:07 PM."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "f472d756",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2024-03-19T19:07:20.256537Z",
"iopub.status.busy": "2024-03-19T19:07:20.256147Z",
"iopub.status.idle": "2024-03-19T19:07:31.884446Z",
"shell.execute_reply": "2024-03-19T19:07:31.861898Z"
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Warning in : axis xaxis of Histogram hrootPlatform has extra following bins without labels. Sorting will work only for first label bins\n",
"Warning in : axis xaxis of Histogram hShortRootPlatform has extra following bins without labels. Sorting will work only for first label bins\n"
]
}
],
"source": [
"auto rdf = ROOT::RDF::FromSqlite(\"http://root.cern/files/root_download_stats.sqlite\", \"SELECT * FROM accesslog;\");\n",
"\n",
"TH1F hRootPlatform(\"hrootPlatform\", \"Platform Distribution\", 7, 0, -1);\n",
"TH1F hShortRootPlatform(\"hShortRootPlatform\", \"Short Platform Distribution\", 7, 0, -1);\n",
"\n",
"auto fillRootPlatform = [&hRootPlatform, &hShortRootPlatform] ( const std::string &platform ) {\n",
" TString Platform = platform;\n",
" TString Platform_0(Platform(0,5));\n",
" TString Platform_1(Platform(0,6));\n",
" TString Platform_2(Platform(0,8));\n",
"\n",
" if ( Platform.Contains(\"win32\") ){\n",
" hShortRootPlatform.Fill(Platform_0,1);\n",
" } else if ( Platform.Contains(\"Linux\") ){\n",
" hShortRootPlatform.Fill(Platform_0,1);\n",
" } else if ( Platform.Contains(\"source\") ){\n",
" hShortRootPlatform.Fill(Platform_1,1);\n",
" } else if ( Platform.Contains(\"macosx64\") ){\n",
" hShortRootPlatform.Fill(Platform_2,1);\n",
" } else if ( Platform.Contains(\"IRIX64\") ){\n",
" hShortRootPlatform.Fill(Platform_1,1);\n",
" }\n",
"\n",
" hRootPlatform.Fill(Platform,1);\n",
"};\n",
"\n",
"rdf.Foreach( fillRootPlatform, { \"Platform\" } );\n",
"\n",
"auto PlatformDistributionHistogram = new TCanvas();\n",
"\n",
"hRootPlatform.GetXaxis()->LabelsOption(\"a\");\n",
"hRootPlatform.LabelsDeflate(\"X\");\n",
"hRootPlatform.DrawClone();\n",
"\n",
"auto shortPlatformDistributionHistogram = new TCanvas();\n",
"\n",
"hShortRootPlatform.GetXaxis()->LabelsOption(\"a\");\n",
"hShortRootPlatform.LabelsDeflate(\"X\");\n",
"hShortRootPlatform.DrawClone();"
]
},
{
"cell_type": "markdown",
"id": "b8a70093",
"metadata": {},
"source": [
"Draw all canvases "
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "41e34a9f",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2024-03-19T19:07:31.977843Z",
"iopub.status.busy": "2024-03-19T19:07:31.977477Z",
"iopub.status.idle": "2024-03-19T19:07:32.715830Z",
"shell.execute_reply": "2024-03-19T19:07:32.707730Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
"
\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
"
\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%jsroot on\n",
"gROOT->GetListOfCanvases()->Draw()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "ROOT C++",
"language": "c++",
"name": "root"
},
"language_info": {
"codemirror_mode": "text/x-c++src",
"file_extension": ".C",
"mimetype": " text/x-c++src",
"name": "c++"
}
},
"nbformat": 4,
"nbformat_minor": 5
}