Fitting peaks above the background generated by TSpectrum::Background


_ROOT Version: 5.34/09
_Platform: Linux 3.11.10-100.fc18.x86_64
_Compiler: gcc version 4.7.2 20121109 (Red Hat 4.7.2-8) (GCC)


Hello,

With the help of excellent ROOT Support I have learned how to search and fit the peaks in a gamma-spectrum using TSpectrum, and also to estimate background. The way the background is estimated is excellent, as visible from the top Pad on executing the attached macro.

In the present version of the macro the (linear) background is generated as a part of a fit function.
But then where is the use of the excellent background estimation from “TSpectrum::Background”?

I want to use the background generated by “TSpectrum::Background” instead of linear (in the attached macro) or quadratic or any other type. Can someone please help me?

You can run the attached macro as follows:
++++++++++++++++++++++++++++++++++++
root [0] TFile *f = new TFile(“hist.root”);
root [1] .L pfit.C++
root [2] pfit(“Addbackspectra00”,200,3000);
++++++++++++++++++++++++++++++++++++

With best regards,

Ajay

pfit.C (3.0 KB)

hist.root (9.6 KB)

Hi,

I guess you would need to create a TF1 function used for fitting based on the Background histograms returned by TSpectrum. For example you could create something like this

auto my function = [&](double *x, double *p){ return p[0]+TMath::Gaus(x[0],p[1],p[2]) + hb->GetBinContent( hb->FindBin(x[0] ) ); };

and used to create a TF1 for fitting. (hb is your histogram returned by Spectrum::Background )

Lorenzo

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