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,
Chloe.
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,
Chloe.
Well, try … "MySpectrumTH1->Add(MyBackgroundTH1, -1.0);"
But see also [url]Background Subtraction ShowBackground
Hi,
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?
Chloe
You can only “add” histograms or functions -> see different “Add” methods:
http://root.cern.ch/root/html/TH1.html#TH1:Add
So, you need to make a projection of your “gE” first, e.g. using “Project” or “Draw” (search for the string “>>” inside):
http://root.cern.ch/root/html/TTree.html#TTree:Project
http://root.cern.ch/root/html/TTree.html#TTree:Draw@2