I now have to subtract this from the data to get the background free peak.
Do I need to create another histo with this fit function and then subtract it from h1?
Normally TF1 functions are easy to fill a histogram with. Does the RooFitResult work the same way?
ERROR:InputArguments -- RooDataHist::dh:plotOn: frame does not specify a plot variable
[#0] ERROR:Plotting -- RooAddPdf::fullModel:plotOn: frame does not specify a plot variable
[#0] ERROR:Plotting -- RooAddPdf::fullModel:plotOn: frame does not specify a plot variable
Hi,
I just realised that I had tried the same thing before but without Roofit. (I was the TMath CB and expo)
What I want to do now is to subtract the side-bands from the spectrum. For this
I fitted the two regions with an expo (The fit is not satisfactory) and made an extended pdf using it.
I created a RooDataSet using the extended pdf and converted it to a hist (Is there a direct way of converting an extended pdf to a histogram? I can’t get createHistogram to work!)
I now want to subtract the histo filled with the extended pdf from the spectrum histo. Ideally, I will be left with a Crystal ball (or a Gaussian or a BW); then I will fit the CB (or gaus or BW) accordingly.
My question is this: Is this the correct way of going about this? If so, how do I do step 3?
I would not try to subtract. It is possible, but you would get things like non-integer bin contents etc. RooFit can do a combined fit of signal plus background. It is as simple as:
fullPDF = signal + background
This is what I told you in my first reply. If you do that, you will have ALL parameters of both functions determined simultaneously and can extract both the number of signal and background events. If you still really really want to subtract, we can try to do this next week, but this week I’m travelling.
What I ultimately want to do is fit a BW / gaussian to the signal region alone. I tried the subtraction method, but it gives me bad fit. It could be that the background is not an expo or it could be the issue @StephanH raised.
I really think that the signal+background model does exactly what you want. If you can send me the data, I can try to make it work. Did you manage to fit the function I mentioned in my post above?