# Histogram entries

Hi guys,
I have a question about how to get the total number of entries from an histo related to the distribution of energy. If I want to take the entries of an histrogram only if the energy is larger than 0, how can I do?
Generally speaking, I want to take the total number of entries only if I have a non null energy deposit.

thanks

May be something like that:

``````TH1F *hist = ...;
int totalEntries = 0;
for (int i = 1; i <= hist->GetNbinsX(); i++) {
if (hist->GetBinContent(i) > 0) {
totalEntries += hist->GetBinContent(i);
}
}

``````

?

It is unclear what you have and what you want.
Is it a 1-D, 2-D, or 3-D histogram?
Is the “energy” the histogram’s “x-axis”?
Has your histogram any bins with “negative content”?

I have a given number of 1D histos. The X axis has only positive values starting from 0 up to a maximum value. Each histogram has a total number of entries equal to 65k, but for some histos all these entries are equal to 0, so the histo is empty. What I want to do is taking the number of entries from each histo.
If I simply use the command GetEntries() I get the same number 65000 for all of them. But I am interested only in the histrograms with non null entries.

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