Is there an option for the last non-overflow bin in a say 1-D histogram such as TH1F to include information about its upper edge. Usually the upper edge is excluded and lumped together with the overflow bin but I’d like to INCLUDE it instead. Thank you for any help.
I am not sure I have understood your question. Where would you like to include this information ? For what ?
When filling an histogram, you would like when x=upper-edge that that entry is considered in the last bin instead of the overflow bin ?
Search for “Convention for numbering bins” in the TH1 class description.
Thank you for your comments.
Yes, I would like that if x = (upper edge of last non-overflow bin), that it contribute to the entries in the last bin instead of the overflow bin. I believe this is the default behavior of histograms in matplotlib in python. I’m interested in this because if I have a 1-D histogram where the x-axis is cos(theta) ranging from -1 to 1, cos(theta) = 1 will not be included in the bins of the histogram and will be put into the overflow bin.
Dear Pepe Le Pew,
In the section “Convention for numbering bins”, it is mentioned that:
bin = 0; underflow bin
bin = 1; first bin with low-edge xlow INCLUDED
bin = nbins; last bin with upper-edge xup EXCLUDED
bin = nbins+1; overflow bin.
I would like “bin = nbins” to INCLUDE the upper-edge xup instead of EXCLUDING it.
ROOT explicitly says “low-edge INCLUDED” and “upper-edge EXCLUDED”.
I’m sorry but it MUST be the same for ALL bins. No exceptions.
You can simply make your “xup” slightly bigger (something like “xup + small_delta” or “xup * 1.00000000001” if xup > 0 or “xup * 0.99999999999” if xup < 0).
Okay, thank you.
I just thought there might be a simple option to enable this behavior.
Your suggestion is well taken.