Problems with Background()

Hello! I have a gamma spec histogram which I’d like to fit & remove the background of. I tried using the Background() function from TSpectrum, following the class reference example (ROOT: TSpectrum Class Reference), but the result I’m getting is that the supposed background fit is the same as the original histogram.
I’m modifying the bin number, but in the background-removed histogram I end up getting negative counts.
This is the snippet of code I’m using for the background fit:

TH1 *bHist = new TH1F ("bHist", "Simulated Background Histogram", simBinNumber, 0, 700);
TH1F *noBckgHist = (TH1F*)simHist->Clone("noBckgHist");

for (int i=0;i<simBinNumber;i++) source[i] = simHist->GetBinContent(i);

TSpectrum *spec = new TSpectrum();	
bHist = spec->Background(simHist, 7, ""); 
noBckgHist->Add(bHist, -1.0); `

Any help is appreciated, thanks!


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Hi,

Thanks for the post. Clearly, the background estimation is affected by some uncertainty, and therefore, also its subtraction.
In a sense, it’s not overly surprising that for some bins, the background subtraction can be a bit aggressive.
I hope this helps.

Cheers,
D

That does help! After changing some parameters I’m able to perform the analysis I’ve been meaning to. Thanks again for your answer!

1 Like