Code HistFactory Models in JSON.
With the HS3 standard, it is possible to code RooFit-Models of any kind as JSON files. In this tutorial, you can see how to code up a (simple) HistFactory-based model in JSON and import it into a RooWorkspace.
import ROOT
ws = ROOT.RooWorkspace("workspace")
tool = ROOT.RooJSONFactoryWSTool(ws)
tool.importJSON(ROOT.gROOT.GetTutorialDir().Data() + "/roofit/rf515_hfJSON.json")
ws.Print()
model = ws["ModelConfig"]
pdf = model.GetPdf()
result = pdf.cloneTree().fitTo(ws["observed"], Save=True, GlobalObservables=model.GetGlobalObservables(), PrintLevel=-1)
result.Print()
tool.exportJSON("myWorkspace.json")
ws2 = ROOT.RooWorkspace("workspace")
tool2 = ROOT.RooJSONFactoryWSTool(ws2)
tool2.importJSON("myWorkspace.json")
model2 = ws2["main_modelConfig"]
result = model.GetPdf().fitTo(ws2["observed"], Save=True, GlobalObservables=model.GetGlobalObservables(), PrintLevel=-1)
result.Print()
- Date
- November 2021
- Author
- Carsten Burgard
Definition in file rf515_hfJSON.py.