Hello,
I am trying to validate the use of RooSimultaneous by comparing to the minimization of the summed negative likelihoods over three ranges, but am running into various inconsistencies most likely due to my misunderstanding of how to implement this.
Eventually, I mean to do a 2D fit of ‘cossun’ and ‘nhits’ where I’ll have three separate models defined in three ranges of nhits but over the same range of ‘cossun’. As I’m just trying to understand how to properly implement this, I’m doing a 1D fit over nhits of these three models in each range of nhits and over the full range.
I define three nhits ranges which each have their own signal and background PDFs, model, and mock data set such as (for the first of the three):
// defining variable and range
RooRealVar nhits("nhits", "nhits", 0,2000);
nhits.setRange("full",0,2000);
nhits.setRange("lowE", 0, 600);
RooRealVar nhits_lowE("nhits_lowE", "nhits_lowE", 0,600);
// imported sig and bkg PDFs
RooDataHist heng_sig_hist_lowE("heng_sig_hist_lowE", "heng_sig_lowE", nhits_lowE, Import(*heng_sig_lowE));
RooHistPdf hpdf_sig_lowE("hpdf_sig_lowE", "Hist PDF from heng_sig_lowE", RooArgSet(nhits_lowE),heng_sig_hist_lowE);
...
RooDataHist heng_bkg_hist_lowE("heng_bkg_hist_lowE", "heng_bkg_lowE", nhits_lowE, Import(*heng_bkg_lowE));
RooHistPdf hpdf_bkg_lowE("hpdf_bkg_lowE", "Hist PDF from heng_bkg_lowE", RooArgSet(nhits_lowE),heng_bkg_hist_lowE);
...
// model = s*pdf_sig + b*pdf_bkg
RooRealVar s_lowE("s_lowE","signal events",1e3,0,10e3);
RooRealVar b_lowE("b_lowE","background events",1e3,0,10e3);
RooAddPdf model_lowE("model_lowE","s*hpdf_sig_lowE + b*hpdf_bkg_lowE", RooArgList(hpdf_sig_lowE, hpdf_bkg_lowE), RooArgList(s_lowE,b_lowE));
model_lowE.setNormRange("lowE");
...
// setting up mock dataset
RooDataSet *hData1 = hpdf_sig_lowE.generate(nhits_lowE,6500);
RooDataSet *hDatabkg1 = hpdf_bkg_lowE.generate(nhits_lowE,3500);
static_cast<RooDataSet&>(*hData1).append(static_cast<RooDataSet&>(*hDatabkg1));
...
And I do the same for my other two regions “peak” and “highE”. Now I set up my NLLs for each and sum them in this way:
RooAbsReal *nll_lowE = model_lowE.createNLL(*hData1, Extended(kTRUE));
RooAbsReal *nll_peak = model_peak.createNLL(*hData2, Extended(kTRUE));
RooAbsReal *nll_highE = model_highE.createNLL(*hData3, Extended(kTRUE));
// constructing sum total nll and minimising nll_tot
RooAddition nll_tot("nll_tot","nll_tot", RooArgSet(*nll_lowE,*nll_peak,*nll_highE));
RooMinimizer minim_tot(nll_tot);
minim_tot.minimize("Minuit", "migrad");
As for the parallel method of using RooSimultaneous, I do:
RooCategory index_nhits("index_nhits", "index_nhits");
index_nhits.defineType("rlowE");
index_nhits.defineType("rpeak");
index_nhits.defineType("rhighE");
index_nhits.setRange("lowE","rlowE");
index_nhits.setRange("peak","rpeak");
index_nhits.setRange("highE","rhighE");
RooSimultaneous simPDF("simPDF","simultaneous PDF",index_nhits);
simPDF.addPdf(model_lowE, "rlowE");
simPDF.addPdf(model_peak, "rpeak");
simPDF.addPdf(model_highE, "rhighE");
RooDataSet combData("combData", "combined data", nhits, Index(index_nhits), Import({{"rlowE",hData1}, {"rpeak",hData2},{"rhighE",hData3}}));
RooFitResult *simFit = simPDF.fitTo(combData, Save(), Range("full"),SplitRange());
While the individual fits and plots for each region look reasonable, and though RooSimultaneous seems to converge, several ‘Evaluation errors’ occur such as “RooAddPdf: sum of coefficients is zero.” and “RooNLLVar: combData function value is NAN”. I am not sure where I am going wrong. Am I somehow trying to get RooSimultaneous to fit in an empty bin? Should I specify NormRange()?
Thank you in advance for any suggestions and help!!