Rebinning in THnSparse

Hi,
I’ve got a very simple problem,
I am trying to rebin in THnSparse with the following code:
THnSparseD *fSparse = …

THnSparse *rebinned = fSparse->Rebin(bins);
fSparse->Reset();
fSparse = rebinned;

fSparse is fine but when I rebin the program brings up the following error:

invalid conversion from ‘THnSparse*’ to ‘THnSparseD*’

I can understand the problem but I cant see how to resolve it

thanks alot

Maki

Hi,

two options: either declare "THnSparse fSparse =…" (who cares what it really holds, and THnSparseD derives from THnSparse) or cast rebinned, e.g. like this: fSparse = (THnSparseD) rebinned; or if you think there could be the slightest possibility that rebinned is not a THnSparseD* use fSparse = dynamic_cast<THnSparseD*>(rebinned) and check for the result being 0.

Cheers, Axel.