ROOT THn without over/underflow bins

I am working with a very densely populated multi-dimensional output object for which I employ ROOT’s THn functionality. It seems to me that under/overflow bins are included in the THn, which, for multidimensional objects, can cost quite a bit of memory. I actually don’t need any bookkeeping of under/overflow. Is there some simple way of initialising a THn without that (but retaining all other functionality)? I tried to look through the docs but there doesn’t seem to be a way to do that currently - please let me know if I am missing something. Thank you very much!

So my pedestrian follow-up to my question is: I could write a method to initialise the THn manually via SetBinEdges for each dimension, manually defining the edges from edge[1] to edge[n-2] for each dimension. I could then check if all dimensions are within edge[0] to edge[n-1] and only fill if that’s true, and then unpack the new “under/overflows” into the desired information. But… this is very pedestrian. I am hoping there’s a better way :slight_smile:

Hi, welcome back to the forum! Let’s invite @moneta to take a look here, maybe he has an idea on how to do this?

Hi @jonas thanks a lot! So, what I found out while inspecting the THn and THnBase code is that the InitStorage method of THn.cxx (see here) seems to include a commented-out addOverflow option, indicating that at some point someone did think of making this an option. Which is pretty cool! One should try to come up with a way to add an option to the THnT constructor for enabling that IMHO. Time permitting, I can take a look at it myself in the future, but if someone smarter and wiser than me can look that would be super :smiley: - generally this does not look super complicated, with the main holdup being adequately implementing a “discard value” option in the no-overflow operation mode somehow… as far as I can tell, at least :slight_smile:

In the meantime, in my specific application, I have created a “collapsed” THn in my code that I can expand by simply copying the bin contents [0..N[ (note: 0 is underflow!) into a full THn later on, when I have ample memory available. In my specific 5-dimensional THn, this reduces the memory consumption by a factor 2, so it’s very very meaningful. We can do a lot more fun stuff with that extra freed memory, too!

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