Number of entries in histogram bin with weighted submisisons?


Is there a way to figure out the number of entries in a bin of a histogram that has had its entries weighted? For example, is there a way to do something like:

TH1D *myHisto = new TH1D("myHisto","myHisto",5,0,5);
myHisto->FunctionThatReturnsNumberOfEntriesInBin(); // THIS IS WHAT I NEED

Is there something like FunctionThatReturnsNumberOfEntriesInBin() that would tell me that the bin containing 1 had 3 entries placed in it, even though the bin content is 0.2+0.23+0.9=1.33?

Thank you.

Hi @eggsAndCoffee ,
I think TH1 does not store an entry count for each bin separately from the bin contents, you might want to use a second histogram for that.

@moneta please correct me if I’m wrong.


The histogram does not collect that information, but a TProfile does it in order to compute the bin statistics, (see TProfile::GetBinEntries()). However, it will compute in Profile::GetBinContent the average of the second variable, in your case the weights.


Thank you!