{ "cells": [ { "cell_type": "markdown", "id": "6da51216", "metadata": {}, "source": [ "# df027_SQliteDependencyOverVersion\n", "Plot the ROOT downloads based on the version reading a remote sqlite3 file.\n", "\n", "This tutorial uses the Reduce method which allows to extract the minimum time\n", "stored in the SQlite3 database.\n", "The next step is to create a TH1F Histogram, which will be filled with the values stored in\n", "two different columns from the database. This procedure is simplified with a lambda\n", "expression that takes as parameters the values stored in the \"Time\" and \"Version\" columns.\n", "\n", "\n", "\n", "\n", "**Author:** Alexandra-Maria Dobrescu, Sergey Linev \n", "This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Tuesday, May 19, 2026 at 08:09 PM." ] }, { "cell_type": "code", "execution_count": 1, "id": "4d6291c2", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:10:02.683251Z", "iopub.status.busy": "2026-05-19T20:10:02.683117Z", "iopub.status.idle": "2026-05-19T20:10:12.066961Z", "shell.execute_reply": "2026-05-19T20:10:12.053732Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Minimum time is '2018-07-06 07:54:32'\n" ] } ], "source": [ "auto rdfb = ROOT::RDF::FromSqlite(\"http://root.cern/files/root_download_stats.sqlite\", \"SELECT * FROM accesslog;\");\n", "\n", "auto minTimeStr = *rdfb.Reduce([](std::string a, std::string b) {return std::min(a, b);}, \"Time\", std::string(\"Z\"));\n", "\n", "std::cout << \"Minimum time is '\" << minTimeStr << \"'\" << std::endl;\n", "\n", "double minTime = TDatime(minTimeStr.c_str()).Convert();\n", "double maxTime = minTime + 3600.*24*365.25*4; // cover approx 4 years from minimal time\n", "\n", "auto rdf = rdfb.Define(\"datime\", [](const std::string &time){return TDatime(time.c_str()).Convert();}, {\"Time\"});\n", "\n", "auto h614 = rdf.Filter([](const std::string &v){ return 0 == v.find(\"6.14\");}, {\"Version\"})\n", " .Histo1D({\"h614\", \"Download time for version 6.14\", 64, minTime, maxTime}, {\"datime\"});\n", "\n", "auto h616 = rdf.Filter([](const std::string &v){ return 0 == v.find(\"6.16\");}, {\"Version\"})\n", " .Histo1D({\"h616\", \"Download time for version 6.16\", 64, minTime, maxTime}, {\"datime\"});\n", "\n", "auto h618 = rdf.Filter([](const std::string &v){ return 0 == v.find(\"6.18\");}, {\"Version\"})\n", " .Histo1D({\"h618\", \"Download time for version 6.18\", 64, minTime, maxTime}, {\"datime\"});\n", "\n", "auto customize_histo = [](TH1D &histo) {\n", " auto *xaxis = histo.GetXaxis();\n", " xaxis->SetTimeDisplay(1);\n", " xaxis->SetLabelSize(0.02);\n", " xaxis->SetNdivisions(512, kFALSE);\n", " xaxis->SetTimeFormat(\"%Y-%m-%d%F1970-00-00 00:00:00\");\n", " histo.SetStats(kFALSE);\n", "};\n", "\n", "customize_histo(*h614);\n", "customize_histo(*h616);\n", "customize_histo(*h618);\n", "\n", "std::vector drawables{h614->Clone(), h616->Clone(), h618->Clone()};\n", "\n", "auto c1 = new TCanvas(\"c1\",\"Download time\", 800, 1500);\n", "c1->Divide(1, drawables.size());\n", "for (unsigned n = 0; n < drawables.size(); ++n)\n", " c1->GetPad(n + 1)->Add(drawables[n]);" ] }, { "cell_type": "markdown", "id": "20051c20", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 2, "id": "cd16c245", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:10:12.092434Z", "iopub.status.busy": "2026-05-19T20:10:12.092271Z", "iopub.status.idle": "2026-05-19T20:10:12.318348Z", "shell.execute_reply": "2026-05-19T20:10:12.317744Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\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 }