Where is stored the background estimation?

Hello,

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));
}

Is there anyone who can help?

Many thanks.

Guillaume
c1.pdf (29.2 KB)

Guillaume,

I do not understand your question. TSpectrum::Background returns the background histogram.
See:http://root.cern.ch/root/htmldoc/TSpectrum.html#TSpectrum:Background

Rene

Hi,

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.

Guillaume,

To make progress it would be good if you couls send a self-contained script that explain/reproduce your problem.

Rene

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)

here is my data
(extension changed from .gup to .txt)
GAAS.txt (7.34 KB)

Hi René,

Now I understand. In the Background function the data corresponding to the estimated background are stored in *source:

Float_t * source = new float[size of my histo];
source[i] = my histo->GetBinContent(i + first);

and are deleted just before exiting the function.


delete [] source;
return hb; // (copy of my histo + estimated background)

I guess that I have to create my own background function if ever I want to access these data.

Thanks anyway.

Guillaume,

As I already told you above, the background histogram is returned when you call TSpectrum::Background.
Simply replace your statement

s->Background(histo,n_iter,"same"); by

TH1 *background = s->Background(histo,n_iter,"same");
Rene