is there a smart / short way to get the number of entries within a range without knowing the bin numbers? I have a histogram and want to know the number of entries below 165 GeV and above 185 GeV but I do not know which bins these correspond to. Originally the histogram was filled from a tree, but I do not want to make two separate event lists. Or can I ask the tree directly for these numbers?


1 Like

You can get the bin number corresponding to a value x by calling

int bin = myhist.GetXaxis()->FindBin(x).This will return the bin number corresponding to x (this is not necessarily
the low-edge of the bin).

From a TTree, you can obtain what you want directly with



Thanks, that is exactly what I was searching for!