Hello,
I ran into a problem when trying to compute a statistical error in a residual histogram.
What I have is a data histogram that is fitted with two signal functions and a background function, from which I create a residual histogram (Minus the background) using:
RooHist *hresid = frameFitA->residHist("data", "Bkg");
I hope to extract the signal from this histogram by counting the bins, and a statistical error for this value. For this, I run the following loop:
for(Int_t k=1;k<hresid->GetN();k++){
if((hresid->GetPointX(k)>=left_integral_limit) && (hresid->GetPointX(k)<=right_integral_limit)){
jpsibincounting+=hresid->GetPointY(k);
jpsibincounting_error+=std::pow(hresid->GetErrorY(k),2);
dhData.get(k); // Select bin for "weight()" in next line
jpsibincounting_bkg+=dhData.weight() - hresid->GetPointY(k); // Calculate background for signal to noise ratio
}
... // Down here another if statement that mirrors the first, but for second signal
}
This loop is supposed to run over the whole histogram, and then select the bins which match the integration interval for the signal peak. It should then increment jpsibincounting
by the residual entries in this bin (hresid->GetPointY(k);
). Up to this point, everything seems to go well, as I get results that match my expectations.
The next line jpsibincounting_error+=std::pow(hresid->GetErrorY(k),2);
is supposed do add all the statistical errors of each residual bin together quadratically (I take the root after the loop with jpsibincounting_error = std::pow(jpsibincounting_error, 0.5);
).
The problem is that no matter which background function or signal function I use for the fit before creating the residual histogram, the statistical error I get from this method is always the same. This is highly unexpected, since the values of the entries themselves deviate (comparatively) heavily from each other. To illustrate the problem, here are some values with errors for different fitting methods:
11939 pm 146.034 TemplateFit-Signals Pol2-Bkg
11979.5 pm 146.034 TemplateFit-Signals Exp-Bkg
12267.7 pm 146.034 CBFit-Signals Pol2-Bkg
12396.8 pm 146.034 CBFit-Signals Exp-Bkg
This is definitely no coincidence, as this problem replicates many times on other datasets and methods.
I would therefore like to know if this is the right way to compute a statistical error for such a bincounting integral over a residHist, or what method I should use to get the error from the residHist, so it varies for different signal- and background-functions like the values themselves do.
I already tried avoiding the double variable usage in jpsibincounting_error = std::pow(jpsibincounting_error, 0.5);
, and using GetErrorXHigh
, GetErrorXLow
, GetEX
and GetErrorY
, but to no avail (As I implemented them at least…).
I would be thankful for any help.
All the best, thanks
Lucas
ROOT Version: ROOT 6.24/06
Platform: Manjaro 21.3.7 Ruah
Compiler: c++ (GCC) 11.2.0