HybridCalculator, combining channels with HLFactory

Dear all,
I premise that I am new in roostats and roofit.
I am trying to use HLFactory in order to combine channels and get an upper limit with the HybridCalculator.
When I try to retrieve the results with:
HybridResult* myHybridResult = myHybridCalc.GetHypoTest();

I get the error:
[#0] PROGRESS:Generation – Test Statistic on data: 5298.47
[#1] INFO:InputArguments – Using a ToyMCSampler. Now configuring for Null.
[#1] INFO:InputArguments – Using randomized nuisance parameters.
Exception: RooAbsTestStatistic::initSimMode() ERROR, index category of simultaneous pdf is missing in dataset, aborting
*** Interpreter error recovered ***

I suppose that I don’t set correctly all the needed information, but I don’t know which is the right way.
Below I’m reporting in a generic way the main steps I’ve followed, I can provide further details if it helps.

I define the categories:
RooCategory *categ = new RooCategory(“categ”,“selection cat.”);

I take from a data card the yields and pdfs for the S+B and only B hypoteses for the 4 categories, then I extend the bkg pdfs and from those I generate the datasets, one for each category, the syntax I use is:

RooDataSet* data_cat0 = ext_pdf_bkg0.generate(RooArgSet(*x,*categ),bkg_cat0->getVal(),Extended());

the same for the other three categories

After the creation of HLF I add the 4 channels with:

and I get the total pdfs (*combinedPDF_bg and *combinedPDF_sgbg),
dataset ( *data) and category (*thecat).
I use such resulting pdfs to create the models with ModelConfig (called sb_model, bkg_model) and to create the test statistics with
SimpleLikelihoodRatioTestStat lratio(*combinedPDF_bg, *combinedPDF_sgbg);

then I create the HybridCalculator with
HybridCalculator hc(*data, sb_model, bkg_model);
ToyMCSampler toymcs = (ToyMCSampler)hc.GetTestStatSampler();

without calling
no errors appear and all the printed information are consistent with what I expect.

many thanks in advance for any advice you can give me,