Hi,
I’m running RooFit for doing toyMC study with RooMCStudy and RooSimultaneous.
My strategy is,
- Get information of signal and background PDF coefficients from file
(my signal PDF is histogram PDF with RooHistPDF, and background PDF is combination of 1 gaussian + 1 linear function.) - Generate MC with background PDF
- Fit them with signal + background PDF
- Get value and error of signal PDF constant
- Draw figure of 1000 entries of ‘value’ and ‘error’
I expected that the result of 5(especially, value of constant) may be distributed gaussian-like distribution with near 0 mean (like figure below).
But my result is,
I can’t understand why double peaked distribution occurs. Doesn’t RooMCStudy work with RooSimultaneous, or not?
Does anyone help me?
Or if it is not clear then please let me know.
Thank you.
Best regards,
Kyungho Kim
ps. I attached my code and my PDF coefficient variables :
fit_semi_2_1.root (10.6 KB) fit_semi_2_2.root (10.6 KB) rooMC.C (6.9 KB)
Main point of my code is in below :
// signal MC constant setting for simultaneous fit
RooRealVar c_sig("c_sig", "c_sig", 0, -100, 100);
RooRealVar c_e1("c_e1", "c_e1", mode_coef[0]);
RooRealVar c_m1("c_m1", "c_m1", mode_coef[1]);
RooFormulaVar cesig("cesig", "cesig", "c_sig*c_e1/(c_e1+c_m1)", RooArgList(c_sig, c_e1, c_m1));
RooFormulaVar cmsig("cmsig", "cmsig", "c_sig*c_e1/(c_e1+c_m1)", RooArgList(c_sig, c_e1, c_m1));
//// mode 1
// signal PDF
RooHistPdf sig_ehpdf("sig_ehpdf", "sig_ehpdf", RooArgList(pl), *sig_edh, 2);
// background PDF part
RooGaussian gauss_e("gauss_e", "gauss_e", pl, gmean_e, gsigma_e);
RooPolynomial poly("poly", "poly", pl, polycep);
RooAddPdf allpdf("allpdf", "allpdf", pdfs, coefs);
RooRealVar cebkg("cebkg", "cebkg", neb, neb-nee, neb+nee ); // bkg coefficient
// signal + bkg PDF
RooArgList mode_e(sig_ehpdf, allpdf, "mode_e");
RooArgList coef_e(cesig, cebkg, "coef_e");
RooAddPdf e_pdf("e_pdf", "e_pdf", mode_e, coef_e);
//// mode 2
// signal PDF
RooHistPdf sig_mhpdf("sig_mhpdf", "sig_mhpdf", RooArgList(pl), *sig_mdh, 2);
// background PDF
RooGaussian gauss_m("gauss_m", "gauss_m", pl, gmean_m, gsigma_m);
RooPolynomial poly2("poly2", "poly2", pl, polycep2);
RooAddPdf alzpdf("alzpdf", "alzpdf", pdfz, coefz);
RooRealVar cmbkg("cmbkg", "cmbkg", nmb, nmb-nme, nmb+nme);
// signal+bkg PDF
RooArgList mode_m(sig_mhpdf, alzpdf, "mode_m");
RooArgList coef_m(cmsig, cmbkg, "coef_m");
RooAddPdf m_pdf("m_pdf", "m_pdf", mode_m, coef_m);
// simultaneous fit setting
// for fitting
RooCategory sample("sample", "sample");
sample.defineType("emode");
sample.defineType("mmode");
RooSimultaneous *simPdf = new RooSimultaneous("simPdf", "simultaneous pdf", sample);
simPdf->addPdf(e_pdf, "emode");
simPdf->addPdf(m_pdf, "mmode");
// for generation
RooCategory sp2("sp2", "sp2");
sp2.defineType("em");
sp2.defineType("mm");
RooSimultaneous *modPdf = new RooSimultaneous("modPdf", "simultaneous bkg pdf", sp2);
modPdf->addPdf(allpdf, "em");
modPdf->addPdf(alzpdf, "mm");
// RooMCStudy
RooMCStudy* mcstudy = new RooMCStudy(*modPdf, RooArgSet(pl, sp2, sample), FitModel(*simPdf), Binned(kFALSE), Extended(), Silenc e(), FitOptions(Save(kTRUE), PrintEvalErrors(0))) ;
mcstudy->generateAndFit(1000);
(including after this question is solved)
I should set same categories for generating PDF and fitting PDF.