Histogram Add and kCanRebin

Hello,

it is well known that TH1::Add method is protected against any attempt to add two histograms which do not match in the binning.
I have the impression that this constraint could be relaxed for histograms which have the kCanRebin flag set and which were booked with the same original binning and, indeed, were (automatically) rebinned at the filling time. When such a pair of histograms have to be added they can be rebinned in order to match each other and then added.
So, I’d like to know if:

  • what I am saying make sense,

  • if it is already like that in root (I vaguely remember that i tried once and it did not work)

  • if it is somehow foreseen to have such a feature in future releases

  • anyone has ever tried , privately, to do something like that.

                                       Thanks in advance and cheers
    
                                               Andrea

Andre,

see: root.cern.ch/root/html522/TH1.html#TH1:Merge

Rene

Hi Rene,

thanks for the prompt answer. Indeed it does what I was asking for. I have not undestood why the resulting histogram has to be created as a copy of one of the addendum: I have tried with a default-constructed histogram and after the merge I got just two big bins (with the correct axis range and bin content in any case). In any case it is not a problem.
Does it work, properly, also for profile histograms?

                                 Thanks

                                Andrea

The Merge function should work for any TH1, ie TH1x, TH2x, TH3x, TProfile, TProfile2D
and THnSparse

Rene