-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Description
I wanted to perform a chi^2 comparison between two TH2 histograms (h1 and h2), making use of the TH1::Chi2Test method. I hoped to get access to the individual residuals as follows:
TH2D h_res {*h1};
h_res.Reset();
h1->Chi2Test(h2, "OF UF" , h_res.GetArray());
//h_res should now contain the residuals
It really took me some time to understand why this is not working. It turns out this is a bug(?) in the code. The expression that fills the residuals only considers one dimension (x, lookp variable i) and simply ignores y (j) and z (k):
Line 2256 in 9c4a8d2
| if (res) res[i - i_start] = (cnt1 - nexp1) / TMath::Sqrt(nexp1); |
I understand that a higher dimensional res array layout is more complicated, especially if custom limits are involved. Nevertheless I would expect at least the full 2D/3D case (as sketched above) to work.