Method to calculate integral in a THnD

Hi ROOTers!

I was trying to retrieve the integral of a THnD but I don’t find the right method.

Of course, I could project to a TH1D and calculate the integral as follows:

TH1D *h1 = hnd->Projection(0);

But, I tried to find a method doing the same in the documentation of THnD, and I didn’t find. There is no method to retrieve the integral directly from the THnD object?


Hi @Javier_Galan,

thanks for your question! No, there is no method to do this directly. But given that you have a workaround, is it really necessary that there is a function at this point? Even iterating over bins and summing them manually would not be that complicated.

If you really think this feature is needed, feel free to open a GitHub issue and suggest a new interface! But since you have a workaround already for your use case, that issue would probably not get top priority from the ROOT developers themselves. But since it’s not so complicated, it could be a nice one to be picked up by a first-time contributor for practice!


1 Like

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