Problem getting proper value of area after fitting


_ROOT Version: 6.17/01
_Platform: linuxx8664gcc
_Compiler: gcc version 8.3.1


Hi,

I am using attached macro to search and then fit transitions in a spectrum resulting from HPGe detector. The macro is same as given in example peaks.C.

I am executing the macro as follows:

TFile *f = new TFile("pFit.root");
.L pfit_bg.C++
pfit_bg("pY_451_his2D_clean",690,720);

This gives the following result:

Found 1 candidate peaks to fit
Found 1 useful peaks to fit
Now fitting: Be patient
 FCN=11695.8 FROM MIGRAD    STATUS=CONVERGED     185 CALLS         186 TOTAL
                     EDM=4.35888e-08    STRATEGY= 1      ERROR MATRIX ACCURATE 
  EXT PARAMETER                                   STEP         FIRST   
  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE 
   1  Area[1]      1.03041e+05   2.27058e+02   1.19814e+01  -2.26166e-07
   2  Mean[1]      7.00052e+02   2.37794e-03   3.33811e-04   1.14612e-01
   3  Sigma[1]     1.07731e+00   2.06480e-03   1.31165e-04  -3.63132e-02

The problem is that the area given by the macro is: 1.03041e+05. This value is much smaller than one (205821) found from another spectrum analysis tool (gf3 of RADWARE).

Also, cout << pY_451_his2D_clean->Integral(1380,1440) << endl; gives value 211772.

This clearly shows that the area that we get from the fit using the macro is not correct. What is it that I am doing wrong? Please let me know.

Thanking you.

With best regards,

Ajay
pfit_bg.C (4.5 KB) pFit.root (36.0 KB)

It seems to me that RADWARE doesn’t take the histogram’s “bin width” into account (it assumes that it is 1). Try:

std::cout << h2->Integral(h2->FindFixBin(696.), h2->FindFixBin(704.)) << std::endl;
std::cout << h2->Integral(h2->FindFixBin(696.), h2->FindFixBin(704.), "width") << std::endl;
std::cout << h2->GetBinWidth(h2->FindFixBin(696.)) << std::endl;

Dear Wile,

Thank you very much for your reply.

How to “ignore” the bin width (and set it to 1) in the macro which I have attached earlier while fitting the peaks? Is there a simple way?

Regards,

Ajay

If you have a “fix bin size” histogram, you can simply divide your fitted “Area” and “Sigma” (and their errors) by e.g.: h2->GetBinWidth(1)

Thank you! That is working manually.

But, I am not able to incorporate the division by " h2->GetBinWidth(1)" in the macro.

Isn’t this as simple as:

const double binWidth = h2->GetBinWidth(1);

and dividing everything that is related to this by binWidth?

Hi,

I have tried to do it. It works as expected.

But, I am not sure whether that is the elegant way of coding. I am attaching the modified macro. Please let me know if it requires refinements. You can run the macro as follows. The root file can be found in the first post.

TFile *f = new TFile("pFit.root");
.x pfit_bg.C("pY_451_his2D_clean",660,710);

Thanking you.

With best regards,

Ajay

pfit_bg.C (5.3 KB)

Well, if you need to divide by a value multiple times, there’s nothing better than to retrieve it, assign it to a variable, and use that to scale all other numbers.
[Computationally speaking, it’s better to multiply with the inverse, but that’s only necessary if that part runs billions of times.]

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