Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
df028_SQliteIPLocation.C File Reference

Detailed Description

View in nbviewer Open in SWAN Plot the location of ROOT downloads reading a remote sqlite3 file.

The world map is held by a TH2Poly histogram which, after filling, will show the world wide dispersion of ROOT's users. To histogram filling, is done thanks to a lambda expression having as input parameters the two columns of the database: "IPLongitude' - for the longitude, and the "IPLatitude" - for the latitude. The data related to the latitude and the longitude has been provided from the log files storing the users IP. This product includes GeoLite2 data created by MaxMind, available from <a href="http://www.maxmind.com">http://www.maxmind.com.

void df028_SQliteIPLocation() {
auto rdf = ROOT::RDF::MakeSqliteDataFrame( "http://root.cern/files/root_download_stats.sqlite", "SELECT * FROM accesslog;" );
auto f = TFile::Open("http://root.cern.ch/files/WM.root");
auto worldMap = f->Get<TH2Poly>("WMUSA");
auto fillIPLocation = [&worldMap] ( const std::string &sLongitude, const std::string &sLatitude ) {
if (!( sLongitude == "" ) && !( sLatitude == "" )) {
auto latitude = std::stof(sLatitude);
auto longitude = std::stof(sLongitude);
worldMap->Fill(longitude, latitude);
}
};
rdf.Foreach( fillIPLocation, { "IPLongitude", "IPLatitude" } );
auto worldMapCanvas = new TCanvas();
worldMapCanvas->SetLogz();
worldMap->SetTitle("ROOT Downloads per Location (GitHub excluded);Longitude;Latitude");
worldMap->DrawClone("colz");
}
#define f(i)
Definition RSha256.hxx:104
The Canvas class.
Definition TCanvas.h:23
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
Definition TFile.cxx:4025
2D Histogram with Polygonal Bins
Definition TH2Poly.h:66
RDataFrame MakeSqliteDataFrame(std::string_view fileName, std::string_view query)
Factory method to create a SQlite RDataFrame.
Date
August 2018
Author
Alexandra-Maria Dobrescu

Definition in file df028_SQliteIPLocation.C.