To familiarize myself with RooFit I wrote up a simple Signal+Background model. In the workspace I define a scaling parameter for the signal and then let the background remain constant. When I check the yield of the background pre-fit it is exactly what I expect but the post-fit the yield has varied. Can anyone provide any information on how to keep my constant sample constant?
Sample code setting up the workspace after I randomly generate a signal and background sample:
TRooWorkspace* w = new TRooWorkspace("1","2");
ws->addObservable("x","x",200,-10,10);
ws->addChannel("Region 1","Region 1","x");
ws->addSamples("Signal","Signal");
ws->addSamples("Background","Background");
TRooAbsH1Fillable* sigWS = ws->sample("Signal","Region 1");
TRooAbsH1Fillable* bkgWS = ws->sample("Background","Region 1");
for(int i = 0; i <= data->GetNbinsX()+1; i++)
{
sigWS->SetBinContent(i,sig->GetBinContent(i));
sigWS->SetBinError(i,sig->GetBinError(i));
bkgWS->SetBinContent(i,bkg->GetBinContent(i));
bkgWS->SetBinError(i,bkg->GetBinError(i));
ws->Fill("Region 1",data->GetBinCenter(i),generator->Poisson(sigWS->GetBinContent(i))+generator->Poisson(bkgWS->GetBinContent(i)));
}
RooRealVar* p = ws->addParameter("muSig","muSig",1,0.0,10);
ws->Scale("Signal","*",*ws->var("muSig"));
Hi, welcome to the ROOT forum! Your question seems related to TRooFit, which is not part of ROOT but an extension of RooFit developed by Will Buttinger:
We can try to ping @will_cern here and invite him to answer this question, or you can try to reach out to him with other means.
If you can put your workspace somewhere I can confirm what I suspect is going on, but I my guess is that this is because MC-statistical uncertainties - if you removed the BinErrors (MC stat uncertainties) does it stay fixed? The bin errors in each sample contribute towards the definition of a set of nuisance parameters we tend to call the “MC statistical gamma factors” which are just a set of multiplicative factors, one for each bin. But by convention these are shared across all the samples in the channel (so avoid having nBins*nSamples parameters for stat uncertainties, just having nBins parameters). Because of this sharing, removing the BinError on the bkg wont be enough - if any samples in the channel have an mc-stat uncert they will all get the factors, I believe.
There are ways to get around this so that the factors aren’t shared. But I wont detail that unless you decide on the above information that is what you need. If you were just surprised to see the yield shift post-fit then I hope realising the effect of the MC-stat uncert explains it for you? And having your workspace would confirm it too if you want me to double-check…
Thanks for your response, I believed it was to do with the MC stat uncertainties. I was a little shocked to see that the yield was allowed to vary within the uncertainty since I figured the fit would only fluctuate the MC I want to scale when fitting to my pseudo-dataset. When I remove the error on the bkg the yields are the same pre and post fit.
I’ve moved a sample workspace here if you would like to look.