Background subtraction help

Hi all,

I have fitted a background to a spectrum using the “ShowBackground” function, producing a h_temp background spectrum. Is it possible to subtract this off the spectrum and produce a new spectrum?

Thanks in advance,


Well, try … "MySpectrumTH1->Add(MyBackgroundTH1, -1.0);"
But see also [url]Background Subtraction ShowBackground


I tried this and got this error

Error: Symbol gE is not defined in current scope (tmpfile):1:
Error: Failed to evaluate gE->Add(htemp_background,-1.0)
*** Interpreter error recovered ***

gE is a Tbranch in a TTree known as spectra. Will that make a difference?


You can only “add” histograms or functions -> see different “Add” methods:
So, you need to make a projection of your “gE” first, e.g. using “Project” or “Draw” (search for the string “>>” inside):