Evaluate errors by using weighted THnSparse histograms

Dear experts, I hope you are all well and safe.

I have a naive question, I am filling THnSparse histograms with some weight, for example:

Int_t bins4D[4] = {100, 48, 64, 500};
Double_t xmin4D[4] = {0.0, -2.4, -3.2, 0.};
Double_t xmax4D[4] = {10.0, 2.4, 3.2, 500.};
Double_t weight=50; //related with trigger reweighing

THnSparseD *histo = new THnSparseD(“histo”,“histo”,4,bins4D,xmin4D,xmax4D);
histo->Sumw2();

…In the loop…
Double_t x4D[3]={pT,eta,phi,multiplicity};
histo->Fill(x4D, weight);

I know that the weight is working fine, because of the multiplicity distribution.
However as the weight is applied and > 0, my error bars are smaller than the expected.

I checked here in TH1::Fill|(x,w) - https://root.cern.ch/doc/master/classTH1.html#a498de8e0804e75fc75e62dc14a3bb62d
and is mentioned:
If the weight is not equal to 1, the storage of the sum of squares of weights is automatically triggered and the sum of the squares of weights is incremented by 𝑤2 in the bin corresponding to x

Is there any way to not take this weight into account in the error bars?

Thank you in advance,

Dener

Well, you see what you see, but I’m not aware of such an issue (and this is one of the most used functionalities in ROOT). To make progress, please share code that represents what you do, in a form that allows us to reproduce the issue.

As you (fortunately!) execute histo->Sumw2(); before filling, the THnSparse error per bin should be the sqrt(sum of bin squares of weights), otherwise the error per bin would be the sqrt(bin content), where bin content = sum of bin weights.

Hi Axel, Hi Wile_E_Coyote,

thanks for the reply. And I am so sorry for the late reply (I had some problems with my computer).
I made some cross-checks and actually I have founded my mistake.

The problem is not in the newest histograms, the problem were in the old ones. This happened because I was not including the sumw2(), so the errors in THnSparse was evaluated as sqrt(bin content) and when I added the weight the sumw2() is automatically triggered. So, now I will use Sumw2() always.

Thank you so much, and sorry to bother you.

1 Like

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