Create RooDataSet with RooFormulaVar as weight

This problem is very similar to this question: RooFit: problem in replacing the deprecated SetWeightVar I hope there is a better solution than to create two times the datasets.

When creating a new RooDataSet importing data from a TTree I need to set weights. The weights are not defined in a single branch but they are the product of two branches. I can define a RooFormulaVar but the problem is that RooFit::WeightVar takes as input a const RooRealVar& and it seems that a RooFormulaVar is not a RooRealVar. If I use RooFit::WeightVar(const char*) it returns “[#0] ERROR:InputArguments – RooAbsDataStore::initialize(data): Data set cannot contain non-fundamental types, ignoring weight”