25void th2polyEurope(
Int_t npoints=500000)
48 const char *countries[nx] = {
49 "france",
"spain",
"sweden",
"germany",
"finland",
50 "norway",
"poland",
"italy",
"yugoslavia",
"united_kingdom",
51 "romania",
"belarus",
"greece",
"czechoslovakia",
"bulgaria",
52 "iceland",
"hungary",
"portugal",
"austria",
"ireland",
53 "lithuania",
"latvia",
"estonia",
"denmark",
"netherlands",
54 "switzerland",
"moldova",
"belgium",
"albania",
"cyprus",
55 "luxembourg",
"andorra",
"malta",
"liechtenstein",
"san_marino",
"monaco" };
57 547030, 505580, 449964, 357021, 338145,
58 324220, 312685, 301230, 255438, 244820,
59 237500, 207600, 131940, 127711, 110910,
60 103000, 93030, 89242, 83870, 70280,
61 65200, 64589, 45226, 43094, 41526,
62 41290, 33843, 30528, 28748, 9250,
63 2586, 468, 316, 160, 61, 2};
65 TH1F *
h =
new TH1F(
"h",
"Countries surfaces (in km^{2})",3,0,3);
66 for (i=0; i<nx; i++)
h->Fill(countries[i],
surfaces[i]);
71 f =
TFile::Open(
"http://root.cern.ch/files/europe.root",
"cacheread");
74 printf(
"Cannot access europe.root. Is internet working ?\n");
80 "Europe (bin contents are normalized to the surfaces in km^{2})",
82 p->GetXaxis()->SetNdivisions(520);
83 p->GetXaxis()->SetTitle(
"longitude");
84 p->GetYaxis()->SetTitle(
"latitude");
91 while ((key = (
TKey*)nextkey())) {
104 p->ChangePartition(100, 100);
109 for (i=0; i<npoints; i++) {
110 longitude =
r.Uniform(lon1,lon2);
111 latitude =
r.Uniform(lat1,lat2);
118 Int_t nbins =
p->GetNumberOfBins();
125 for (j=0; j<nx; j++) {
126 for (i=0; i<nbins; i++) {
127 if (strstr(countries[j],
p->GetBinName(i+1))) {
128 h2->
Fill(countries[j],
p->GetBinContent(i+1));
136 for (i=0; i<nbins; i++)
p->SetBinContent(i+1, scale*
p->GetBinContent(i+1));
142 c1->SetRightMargin(0.047);
147 h->SetLineColor(
kRed-3);
149 h->SetMarkerStyle(20);
151 h->SetMarkerSize(0.8);
153 h->GetXaxis()->SetLabelFont(42);
154 h->GetXaxis()->SetLabelSize(0.03);
155 h->GetYaxis()->SetLabelFont(42);
165 leg->SetTextFont(42);
166 leg->SetTextSize(0.025);
167 leg->AddEntry(
h,
"Real countries surfaces from Wikipedia (in km^{2})",
"lp");
168 leg->AddEntry(h2,
"Countries surfaces from TH2Poly (with errors)",
"lp");
175 printf(
"THPoly Europe surface estimation error wrt wikipedia = %f per cent when using %d points\n",100*error,npoints);
R__EXTERN TBenchmark * gBenchmark
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
R__EXTERN TStyle * gStyle
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
virtual void Start(const char *name)
Starts Benchmark with the specified name.
virtual void Show(const char *name)
Stops Benchmark name and Prints results.
virtual void ToggleEventStatus()
Toggle event statusbar.
A ROOT file is composed of a header, followed by consecutive data records (TKey instances) with a wel...
static Bool_t SetCacheFileDir(ROOT::Internal::TStringView cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
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.
1-D histogram with a float per channel (see TH1 documentation)}
void Reset(Option_t *option="") override
Reset.
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
virtual Double_t GetMaximum(Double_t maxval=FLT_MAX) const
Return maximum value smaller than maxval of bins in the range, unless the value has been overridden b...
virtual void SetBinError(Int_t bin, Double_t error)
Set the bin Error Note that this resets the bin eror option to be of Normal Type and for the non-empt...
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
void Draw(Option_t *option="") override
Draw this histogram with options.
virtual Double_t Integral(Option_t *option="") const
Return integral of bin contents.
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
TObject * Clone(const char *newname="") const override
Make a complete copy of the underlying object.
2D Histogram with Polygonal Bins
Book space in a file, create I/O buffers, to fill them, (un)compress them.
virtual TObject * ReadObj()
To read a TObject* from the file.
This class displays a legend box (TPaveText) containing several legend entries.
A TMultiGraph is a collection of TGraph (or derived) objects.
Mother of all ROOT objects.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
void SetGridx(Int_t value=1) override
void SetGridy(Int_t value=1) override
This is the base class for the ROOT Random number generators.
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
void SetStatX(Float_t x=0)
void SetStatW(Float_t w=0.19)
void SetStatY(Float_t y=0)
Double_t Log(Double_t x)
Returns the natural logarithm of x.
Double_t Sqrt(Double_t x)
Returns the square root of x.
Double_t Tan(Double_t)
Returns the tangent of an angle of x radians.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.