Roofit: Kernel model with a RooFormulaVar as parameter

Dear Experts,

I am trying to build a model from the data, using both a Gaussian fit and a Kernel estimation of data (t,energy). This model has to depend on RooFormulaVar tModified:

RooFormulaVar tModified("tModified","@0-@1*@2",RooArgList(t,energy,tau));

I can easily define a Gaussian model with RooFormulaVar tModified, setting tau and energy constant. But building a KDE model the same way, with a RooFormulaVar as parameter, just don’t work (compiling, but crashing during execution).
See script toto.C and fake data totodata.root

Replacing tModified by t in l.70 make the Kernel estimation work:
RooKeysPdf kde2("kde2","kde2",t,*templateTimeData,RooKeysPdf::NoMirror) ;
However, I need this model to have tModified as an argument as I later fit the parameter tau, part of the RooFormulaVar tModified with an other set of data (t, energy).

Does someone know a proper way of building a KDE model with a RooFormulaVar as parameter?

Many thanks for your support.

toto.C (2.29 KB)
totodata.root (8.36 KB)

Anwering my own question: the functionality I need is actually implemented in the latest ROOT 5 release (5.34):

RooDataSet& data is for building the shape, RooAbsReal& x for using the PDF.