GetBinContent gives a nonzero value even though the bin index is out of range

While checking my TH3D object, I found something strange.

Its number of the bin was 2, 6, and 4 respectively for x, y, and z axis.

root [25] myhisto->GetNbinsX()
(int) 2
root [26] myhisto->GetNbinsY()
(int) 6
root [27] myhisto->GetNbinsZ()
(int) 4

But when I tried to get the content of the bin which is out of range, I got a nonzero value.

root [28] myhisto->GetBinContent(1,1,1999999999)
(double) 1.0000000

which I expected to be zero.

I think it’s not normal, or is it?

I’d like to know what makes this situation.


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.20/04
Platform: Not Provided
Compiler: Not Provided

You get the content of the z “overflow bin” for bin_x=bin_y=1. Try: myhisto->Print("all");

1 Like

As @Wile_E_Coyote you get the overflow bin. Very likely at filling time somecalls to the Fill() method have z values outside of the z-range. You should check that.

1 Like

Okay now I see. I thought only nbins+1 bin gives overflow.