# TH2Poly excludes low edge of the bins?

Hi,

It seems that TH2Poly does not include the low edge of the bins while TH1 does (from http://root.cern.ch/root/html/TH1.html):

bin = 1; first bin with low-edge xlow INCLUDED
bin = nbins; last bin with upper-edge xup EXCLUDED

while http://root.cern.ch/root/html/src/TH2Poly.cxx.html#540 and http://root.cern.ch/root/html/src/TH2Poly.cxx.html#543 exclude the low edge. Is this intentional? If yes can a flag be included so that one can have the same behavior?

Thank you,
Bruno

With TH2Poly there is no concept of “low edge” of a bin as the bins can be any polygons.
Can you provide a small example macro showing what you mean bin “low edge” in the case of TH2Poly.

Hi,

Thanks for the reply. Here is an example:

``````>>> h1 = ROOT.TH1F('h1', '', 10, 0, 10)
>>> h1.FindBin(0)
1``````

but

``````>>> h = ROOT.TH2Poly()
1
>>> h.FindBin(0., 0.)
-7
>>> h.FindBin(1e-10, 1e-10)
1``````

Bruno

Ok, I guess I can only repeat what I already said:
With TH2Poly there is no concept of “low edge” of a bin as the bins can be any polygons. (see help)
TMath::IsInside() is used to compute if a point is inside a bin or not.

I don’t see the problem in defining the edge of a polygon, suffice to replace > by >=. But it doesn’t matter, I added 1e-10 by hand…

The point is that for TH2Poly the concept of Low and Up edge doesn’t exist . You mentioned the TH1 help:

bin = 1; first bin with low-edge xlow INCLUDED
bin = nbins; last bin with upper-edge xup EXCLUDED

We cannot do that with TH2Poly. There is no lower and upper edge. How do you define the lower and upper edge when a bin has several thousands of edges ?

Ok, I understand that this could work only for simple cases. A flag could change the default to include whatever touches any line but it would not follow the TH1 convention anyway.

Exactly.