I have used a TKDE (root.cern.ch/root/htmldoc/TKDE.html) to describe an invariant mass distribution in Monte Carlo which is not easily described by analytical PDFs in RooFit. This has the advantage over a RooKeysPdf that one can bin internally, which greatly increases the speed.
I am wondering whether it is possible in some way to form a RooFit PDF (preferably a parametric one) from a TKDE? It was suggested in this post that it may be possible:
but I am not exactly sure how to do it. Any help would be greatly appreciated!
If you want a KDE sampled in n points, you should call the TKDE::GetFunction method to return the TKDE as a TF1. You can then transform the TF1 in a RooAbsPdf using the RooTfnPdfBinding class
(see root.cern.ch/root/htmldoc/RooTFnPdfBinding.html )
If you want to use directly the TKDE, without sampling it, but re-computing it every time, you can then first use the ROOT::Math::Functor1D class to transform the TKDE in a 1D function interface ( ROOT::Math::IBaseFunctionOneDim),
which can then be used by the class RooFunctor1DPdfBinding to be transformed in a RooAbsPdf.
If you need I could you provide an example on how to do this,