Dear RooFit users
I have some problems saving to a file a pdf generated with RooFit.
I generated a cxx file using the RooClassFactory::makePdfInstance
function and then I modified the evaluate
method
import ROOT
from ROOT import RooWorkspace, RooRealVar
ROOT.gROOT.ProcessLineSync(".x super_novosibirsk.cxx+")
w = RooWorkspace("w")
Mass = RooRealVar("Mass", "Mass", 120, 600)
p0 = RooRealVar("p0", "p0", 0, 0.005)
p1 = RooRealVar("p1", "p1", 1600, 2000)
p3 = RooRealVar("p3", "p3", 30, 50)
p4 = RooRealVar("p4", "p4", 40, 80)
p5 = RooRealVar("p5", "p5", 0, 5)
p6 = RooRealVar("p6", "p6", -0.05, -0.001)
super_novosibirsk = ROOT.super_novosibirsk(
"super_novosibirsk", "super_novosibirsk", Mass, p0, p1, p3, p4, p5, p6)
frame = Mass.frame()
print("Retrieving data from tree")
data = RooDataSet("Mass", "Mass", tree, RooArgSet(Mass)) # I have a tree defined before
data.plotOn(frame, Binning(100))
print("Plotting and fitting stuff")
# super_novosibirsk.plotOn(frames[i])
# fitResult = super_novosibirsk.fitTo(
# data, ROOT.RooFit.Save(), ROOT.RooFit.PrintLevel(-1))
# fitResult.plotOn(frame)
super_novosibirsk.plotOn(frame)
getattr(w, 'import')(super_novosibirsk)
w.Print()
c = "output_file"
output_filename = c
output_filename = os.path.join(output_dir_fitted, c + ".root")
# out_file = TFile(os.path.join(output_dir_fitted, c + ".root"), "recreate")
w.writeToFile(output_filename, True)
# out_file.Close()
frame.Draw()
No errors are printed with this piece of code but when I try to get the workspace back I have the following errors
root -l super_novosibirsk.cxx output_file.root
root [0] TBrowser br
(I click on the saved workspace)
Error in <TBufferFile::CheckByteCount>: object of class super_novosibirsk read too few bytes: 22 instead of 4074
I also used some scripts to try to get my pdf back but none of them worked. What am I doing wrong?
Thank you