The initial data are stored in TMultiGraphs. They represent the european countries. The histogram filling is done according to a Mercator projection, therefore the bin contains should be proportional to the real surface of the countries.
The script is shooting npoints (script argument) randomly over the Europe area. The number of points inside the countries should be proportional to the country surface The estimated surface is compared to the surfaces taken from wikipedia.
void th2polyEurope(
Int_t npoints=500000)
{
const char *countries[nx] = {
"france", "spain", "sweden", "germany", "finland",
"norway", "poland", "italy", "yugoslavia", "united_kingdom",
"romania", "belarus","greece", "czechoslovakia","bulgaria",
"iceland", "hungary","portugal","austria", "ireland",
"lithuania", "latvia", "estonia", "denmark", "netherlands",
"switzerland","moldova","belgium", "albania", "cyprus",
"luxembourg", "andorra","malta", "liechtenstein", "san_marino", "monaco" };
547030, 505580, 449964, 357021, 338145,
324220, 312685, 301230, 255438, 244820,
237500, 207600, 131940, 127711, 110910,
103000, 93030, 89242, 83870, 70280,
65200, 64589, 45226, 43094, 41526,
41290, 33843, 30528, 28748, 9250,
2586, 468, 316, 160, 61, 2};
TH1F *h =
new TH1F(
"h",
"Countries surfaces (in km^{2})",3,0,3);
for (i=0; i<nx; i++) h->
Fill(countries[i], surfaces[i]);
f =
TFile::Open(
"http://root.cern.ch/files/europe.root",
"cacheread");
if (!f) {
printf("Cannot access europe.root. Is internet working ?\n");
return;
}
"Europe",
"Europe (bin contents are normalized to the surfaces in km^{2})",
lon1,lon2,lat1,lat2);
while ((key = (
TKey*)nextkey())) {
}
}
for (i=0; i<npoints; i++) {
x = longitude;
}
for (j=0; j<nx; j++) {
for (i=0; i<nbins; i++) {
}
}
}
leg->
AddEntry(h,
"Real countries surfaces from Wikipedia (in km^{2})",
"lp");
leg->
AddEntry(h2,
"Countries surfaces from TH2Poly (with errors)",
"lp");
printf("THPoly Europe surface estimation error wrt wikipedia = %f per cent when using %d points\n",100*error,npoints);
}