I have a naive question about GetMinimum() method for TH1F and TH2F. Does it take into account the unfilled bins ?
ChatGPT and Claude give me different answers. ChatGPT says for TH2F histograms, unfilled bins are not taken into account with GetMinimum() while for TH1F, they are taken into account. Claude says by default, unfilled bins for both TH1F and TH2F are not taken into account. If one wants to take into account the unfilled bins or bins filled with 0, GetMinimum(0) should be called.
My experience is closer to ChatGPT. When I call GetMinimum() for TH2F where it has unfilled bins, it finds a minimum greater than 0. That’s also my expectation. However, when I call the same method for TH1F which also has unfilled bins, it returns 0 and other than the unfilled bins, there is no bin filled explicitly with 0.
Go to the official documentation. Bookmark that page to look for documentation on any of ROOT’s classes, or from this forum, click on the Home link at the top, then click on Reference, and search from there.
the answer is yes, the GetMinimum() member function does take the unfilled bins into account. That is, if there is at least one unfilled bin, then GetMinimum() will return 0 both for TH1 and TH2 classes.
Do you mind sharing an example that demonstrates this? Here is one that disproves that:
root [0] TH2F myH{"myH", ";X;Y;Z", 5, 0, 5, 5, 0, 5};
root [1] myH.Fill(2, 3); // filling only one bin
root [2] myH.GetMinimum()
(double) 0.0000000
This does not make any sense at all. GetMinimum(0) is not about accounting or not accounting for bins filled with the given value (0 in this case), it is about accounting for bins filled with any value larger than the given value. This is especially useful when dealing with 1D histograms with SetLogy() enabled (or with 2D histograms with SetLogz() enabled).