RooFit and SetFCN / Chi2

Hello everyone!

I am using the RooFit package in my python script to fit fractions of different jet flavors.
This fit is working fine, giving me a nice chi2, but there are two things remaining:

  1. I would like to modify the chi2 function in order to include MC errors. How can I set the fit fuction like for TMinuit with SetFCN?
    Currently my code looks like this:

[code]dimlist = RooArgList(self.var)
dimset = RooArgSet(self.var)

#create RooDataHists
hist_data = RooDataHist(“hist_data”, “”, dimlist, h1_in_data)
hist_l = RooDataHist(“hist_l”, “”, dimlist, h1_in_l)
hist_c = RooDataHist(“hist_c”, “”, dimlist, h1_in_c)
hist_b = RooDataHist(“hist_b”, “”, dimlist, h1_in_b)

#create RooHistPdfs
pdf_l = RooHistPdf(“pdf_l”, “”, dimset, hist_l)
pdf_c = RooHistPdf(“pdf_c”, “”, dimset, hist_c)
pdf_b = RooHistPdf(“pdf_b”, “”, dimset, hist_b)

#create coefficients and pdfs
coeffs = RooArgList(self.nl, self.nc, self.nb)
pdfs = RooArgList(pdf_l, pdf_c, pdf_b)

#create pdf sum
pdf_sum = RooAddPdf(“pdf_sum”, “”, pdfs, coeffs)

#perform actual fit
result = pdf_sum.fitTo(hist_data, RooFit.Extended(True), RooFit.Save(True), RooFit.PrintLevel(-1), RooFit.InitialHesse(True))
self.fit_status = result.covQual()
[/code]

  1. At the moment I plot the pdf_sum result on a frame in order to retrieve the chi2 afterwards. Can I somehow retrieve the chi2 without plotting the result before (since I am saving the histograms to a *.root file I would like to avoid plotting them during the fit)?
result.Print()

frame = self.var.frame()
hist_data.plotOn(frame)
pdf_sum.plotOn(frame, RooFit.LineColor(kBlack), RooFit.LineStyle(kDashed))
chi2 = frame.chiSquare(3)