Histogram sum

Hi guys,

I have an histo h giving the energy distribution in a given material. On the x axis I have the energy value and on the Y axis the corresponding number of occurrence. If I want to get the total energy, how should I do? Should I take the integral, namely h->Integral()?

Thanks

I used
h->IntegralAndError(first_bin,last_bin,error,“width”));

with:
int first_bin = hist->FindFirstBinAbove(E_threshold,1); //1 for x axis
int last_bin = hist->FindLastBinAbove(E_threshold,1);

Is it correct?

Try (sensitive to user’s changes to the current x-axis range):
std::cout << h->GetMean() * h->Integral() << "\n";
and/or (valid only for the “entire” x-axis range):
std::cout << h->GetMean() * h->GetSumOfWeights() << "\n";

Hi @Wile_E_Coyote,

Why should I do GetMean()? And what do you mean by *?

Do you think what I did is wrong?

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