Crash Due to Redundant Call to Sumw2

I have a compiled analyzer that accesses a pair of TH1F histograms that may or may not have Sumw2 set. The code calls:


And crashes if Sumw2 has already been called, throwing this message:

Fatal Root Error: @SUB=TH1F::Sumw2
Sum of squares of weights structure already created

When interpreted, the same code only gives a warning. Is the error a bug, or expected behavior. If it is indeed expected behavior, can you suggest a way to check if the structure already exists before calling Sumw2?



you can use TH1::GetSumw2N() to check whether Sumw2() has been called on a TH1. But "Fatal Root Error: @SUB=TH1F::Sumw2 " is not a ROOT error message; ROOT’s error message is the warning “Sum of squares of weights structure already created” - which is a warning only! So your framework (the one issuing the “@SUB” message) is the culprit. Repeated Sumw2() calls are not an issue.

Cheers, Axel.