GetBinContent() only given me 0 or 1

Hi experts!
I’m a beginner and I’m trying to get the value of bins from TH2D to put a threshold and do some things (see code).
The problem is that when I use GetBinContent() only given me 0 or 1 values and I’m sure the histogram has many different values between (0,1) because I can see it using the TBrowser. If any of you can help me Ill appreciate, thank a lot in advance.

Best, Dayron.

This is the part of de code:

int x,y;

for (x = 0; x < (h1->GetNbinsX())+1; ++x) {
for (y = 0; y < (h1->GetNbinsY())+1; ++y) {

	if (h1->GetBinContent(x,y) < 0.9) {
		cout << "Bin value: " << h1->GetBinContent(x,y)
			<< " ----- x position: " << x
			<< " ----- y position: " << y
			//<< " ----- z position: " << h1->GetZaxis()->GetBinLowEdge(bin_z)
			<< endl;
	}
}

}

Hi Dayron,

could you maybe share the ROOT file with your histogram? It’s not really clear to me how come using
if (h1->GetBinContent(x,y) < 0.9)
you get

I’d say getting 1 is not possible here…

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.