How can I convert a histogram (2D) into 2 pdf in zfit?

158 Views Asked by At

I am trying to do some 2d spectra fitting with the help of zfit. The pdf I want to use comes from ROOT TH2D. Is there any method to convert the input Th2D into a 2D pdf directly in zfit?

Thanks a lot!

1

There are 1 best solutions below

0
On BEST ANSWER

Update

zfit supports now binned PDFs (see here) in the newest version (to be installed with pip install -U zfit --pre) and allows to load histograms. They should be a Histogram from hist if possible, using uproot you should be able to convert one to another.

An introductory tutorial to binned fits can be found here

Old answer

There is currently no direct way but there is Work In Progress to implement binned fitting.

In general, I would advise to use hist within Python, as it can be used directly with zfit in the future.

A way to implement this now is to use the hists density, create a custom PDF (such as here) in zfit and set zfit.run.set_graph_mode(False) and zfit.run.set_autograd_mode(False).