Sumw2 before adding histograms

Hi, I am required to add two (independent) histograms (h1 and h2, say) and do a fit on the resulting histogram (h3). I was checking ROOT: TH1 Class Reference, which mentions “If you intend to use the errors of this histogram later you should call Sumw2 before making this operation. This is particularly important if you fit the histogram after TH1::Add”.

I was wondering if I need to use Sumw2 for h1 and h2 before adding them, and why is it important if I go for the fitting of h3.
Thank you so much for any help.
_ROOT Version: 6.24/02

Hi @paulan; I am sure @couet can answer your question.


1 Like

Yes I think it is important as the help says. But for more precise explanation lets ask @moneta. May be the help of the Add function might need to be more explicit.

1 Like

Maybe this is not so clear in the documentation, but it is important to call TH1::Sumw2 if you are using coefficient c1 and c2 different than 1, i.e. you are scaling the histograms. If you are just adding the content (but not subtracting them) without scaling then the default bin error computation is still valid on the resulting histogram and you don’t need to call TH1::Sumw2.



This makes it clearer, thank you so much for the clarification @moneta !

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