Hello!
I am using the RooFit package in python to fit 3 fractional histograms to another 4th histogram
I would then like to extract the 3 fitted histograms and write them to a *.root file, so ideally I would like to convert them back to TH1.
I just can’t find any way to handle this, can anyone give me a hint?
dimlist = RooArgList(self.var)
dimset = RooArgSet(self.var)
#create RooDataHists from TH1 histograms
hist_data = RooDataHist("hist_data", "", dimlist, self.h1_in_data)
hist_l = RooDataHist("hist_l", "", dimlist, self.h1_in_l)
hist_c = RooDataHist("hist_c", "", dimlist, self.h1_in_c)
hist_b = RooDataHist("hist_b", "", dimlist, self.h1_in_b)
#create RooHistPdf from RooDataHists
pdf_l = RooHistPdf("pdf_l", "", dimset, hist_l)
pdf_c = RooHistPdf("pdf_c", "", dimset, hist_c)
pdf_b = RooHistPdf("pdf_b", "", dimset, hist_b)
#add coefficients
coeffs = RooArgList(self.nl, self.nc, self.nb)
#build pdf list
pdfs = RooArgList(pdf_l, pdf_c, pdf_b)
#build 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))