23 void th2polyEurope(
Int_t npoints=500000)
30 Double_t R = (lat2-lat1)/(lon2-lon1);
47 const char *countries[
nx] = {
"france",
"spain",
"sweden",
"germany",
"finland",
48 "norway",
"poland",
"italy",
"yugoslavia",
"united_kingdom",
49 "romania",
"belarus",
"greece",
"czechoslovakia",
"bulgaria",
50 "iceland",
"hungary",
"portugal",
"austria",
"ireland",
51 "lithuania",
"latvia",
"estonia",
"denmark",
"netherlands",
52 "switzerland",
"moldova",
"belgium",
"albania",
"cyprus",
53 "luxembourg",
"andorra",
"malta",
"liechtenstein",
"san_marino",
55 Float_t surfaces[
nx] = { 547030, 505580, 449964, 357021, 338145,
56 324220, 312685, 301230, 255438, 244820,
57 237500, 207600, 131940, 127711, 110910,
58 103000, 93030, 89242, 83870, 70280,
59 65200, 64589, 45226, 43094, 41526,
60 41290, 33843, 30528, 28748, 9250,
61 2586, 468, 316, 160, 61,
64 TH1F *h =
new TH1F(
"h",
"Countries surfaces (in km^{2})",3,0,3);
65 for (i=0; i<
nx; i++) h->
Fill(countries[i], surfaces[i]);
70 f =
TFile::Open(
"http://root.cern.ch/files/europe.root",
"cacheread");
73 printf(
"Cannot access europe.root. Is internet working ?\n");
79 "Europe (bin contents are normalized to the surfaces in km^{2})",
90 while ((key = (
TKey*)nextkey())) {
108 for (i=0; i<npoints; i++) {
109 longitude = r.
Uniform(lon1,lon2);
110 latitude = r.
Uniform(lat1,lat2);
124 for (j=0; j<
nx; j++) {
125 for (i=0; i<
nbins; i++) {
126 if (strstr(countries[j],p->
GetBinName(i+1))) {
134 Double_t scale = surfaces[0]/maximum;
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);
virtual void SetGridx(Int_t value=1)
virtual void SetLineWidth(Width_t lwidth)
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
Double_t GetBinContent(Int_t bin) const
Returns the content of the input bin For the overflow/underflow/sea bins: -1 | -2 | -3 ---+----+---- ...
This class displays a legend box (TPaveText) containing several legend entries.
virtual void ToggleEventStatus()
Toggle event statusbar.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Double_t GetBinError(Int_t bin) const
Returns the value of error associated to bin number bin.
void ChangePartition(Int_t n, Int_t m)
Changes the number of partition cells in the histogram.
virtual void SetContour(Int_t nlevels, const Double_t *levels=0)
Set the number and values of contour levels.
R__EXTERN TStyle * gStyle
virtual void Draw(Option_t *option="")
Draw this legend with its current attributes.
Int_t GetNumberOfBins() const
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
virtual void SetNdivisions(Int_t n=510, Bool_t optim=kTRUE)
Set the number of divisions for this axis.
A TMultiGraph is a collection of TGraph (or derived) objects.
virtual void Show(const char *name)
Stops Benchmark name and Prints results.
void SetStatX(Float_t x=0)
1-D histogram with a float per channel (see TH1 documentation)}
const char * GetBinName(Int_t bin) const
Returns the bin name.
void SetStatY(Float_t y=0)
virtual void Reset(Option_t *option="")
Reset.
TObject * Clone(const char *newname=0) const
Make a complete copy of the underlying object.
virtual void SetLabelFont(Style_t font=62)
Set labels' font.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
virtual void SetTextFont(Font_t tfont=62)
Double_t GetMaximum() const
Returns the maximum value of the histogram.
virtual void Start(const char *name)
Starts Benchmark with the specified name.
This is the base class for the ROOT Random number generators.
void SetTitleX(Float_t x=0)
Int_t AddBin(TObject *poly)
Adds a new bin to the histogram.
virtual void SetMarkerColor(Color_t mcolor=1)
Book space in a file, create I/O buffers, to fill them, (un)compress them.
virtual void SetBinError(Int_t bin, Double_t error)
see convention for numbering bins in TH1::GetBin
virtual void SetLineColor(Color_t lcolor)
virtual Double_t Integral(Option_t *option="") const
Return integral of bin contents.
virtual void Draw(Option_t *option="")
Draw this histogram with options.
void SetBinContent(Int_t bin, Double_t content)
Sets the contents of the input bin to the input content Negative values between -1 and -9 are for the...
R__EXTERN TBenchmark * gBenchmark
virtual void LabelsDeflate(Option_t *axis="X")
Reduce the number of bins for the axis passed in the option to the number of bins having a label...
void SetStatW(Float_t w=0.19)
virtual void SetMarkerStyle(Style_t mstyle=1)
virtual void SetLabelSize(Float_t size=0.04)
Set size of axis labels The size is expressed in per cent of the pad width.
virtual void SetMarkerSize(Size_t msize=1)
TLegendEntry * AddEntry(const TObject *obj, const char *label="", Option_t *option="lpf")
Add a new entry to this legend.
virtual void SetGridy(Int_t value=1)
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
virtual void SetRightMargin(Float_t rightmargin)
Set Pad right margin in fraction of the pad width.
Mother of all ROOT objects.
virtual TObject * ReadObj()
To read a TObject* from the file.
static Bool_t SetCacheFileDir(const char *cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
Sets the directory where to locally stage/cache remote files.
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
Double_t Sqrt(Double_t x)
virtual void SetTextSize(Float_t tsize=1)
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 SetTitle(const char *title="")
Change (i.e. set) the title of the TNamed.
void SetPalette(Int_t ncolors=kBird, Int_t *colors=0, Float_t alpha=1.)
See TColor::SetPalette.
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
Int_t Fill(Double_t x, Double_t y)
Increment the bin containing (x,y) by 1.
2D Histogram with Polygonal Bins