I try to retrieve information about the background estimation as calculated with the ‘TH1 *TSpectrum::Background’ function. As far as I understand the background is return as a histogram and replace the source data, but I can not retrieve this information.
I would like to substract the estimated background from my data (histo): here is the code I use for this:
TH1I *histo = new TH1I("histo", "My histo", 300, 100, 300.);
// y[i] are my data
for (int i = 0; i < 300; i++){
histo->SetBinContent(i,y[i]);
}
TH1F h2 = (TH1F)histo->Clone(“h2”);
//Use TSpectrum to find the peak candidates
//max_peak is the number of searched peaks
TSpectrum *s = new TSpectrum(max_peak,2);
Int_t nfound = s->Search(histo,2,“new”);
s->Background(histo,n_iter,“same”);
for (int i = 0; i < 300; i++){
h2->SetBinContent(i,h2->GetBinContent(i)- histo->GetBinContent(i));
}
I am sorry because I am a very new user and I am not quite sure that the histogram I use to compute the background on is replaced by the estimated background itself. Is it the case? When I remove the background from my data and fit the new data, the fitted heights are equivalent to the heights before background removal (see my file).
If you would confirm me that, then I would search to understand better how works my fitting part.
Here is my script and the corresponding datafile. You can just type the following command to reproduce my problem:
.x test1sig.c(“gaas.gup”,10,30);
apparently, everything is going well, except that I expect to fit gauss peaks with sligtly lower heights than in the raw data, which is not the case . test1sig.C (3.74 KB)