Slice out of TH3


I have a TH3D*. How can I take a single slice out of it? Say I want the i-th element in Z dimension. So returning a TH2D*. I found TH3::Project3D(“xy”) but this sums along this axis, but there’s no way I can see to limit this to a range of indices.

In numpy for example, you could do array[:,:,i], or array[:,i,:] for xz. Obviously this isn’t numpy, but hopefully there’s functionality for this without having to write our own for loops on bin indices (and deal with overflow bins / global bin indexing).


Search for “SetRange” in the TH3::Project3D method description.

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