RooDataSet with RooCategories

Hi,

I want to do a simultaneous fit. Therefore I composed a RooDataSet from three different subsamples:

sample.defineType("signal");
sample.defineType("bkg2");
sample.defineType("bkg3");
RooDataSet* dataSet_composed = new RooDataSet("dataSet_composed","dataSet_composed",RooArgSet(var1,var2,var3),Index(sample),Import("signal",*dataSet_signal),Import("bkg2",*dataSet_bkg2),Import("bkg3",*dataSet_bkg3));

The sizes of the different subsamples are:
signal sample: 2020
bkg3 sample: 5759
bkg2 sample: 407 -> total: 8186

But the size of the composited sample is only 4467 ?!?!??!

Is this a bug? Or do I probably completely misunderstand what my code is doing?

Thanks in advance,

Peter

I have a further question concerning this topic. I tried to construct the same composited sample manually by generating a temporary sample containing only the label {signal, bkg2, bkg3} and merge it with the initial data sample for signal, bkg2 and bkg3. My code is:

RooDataSet* tmp = new RooDataSet("composed","composed",RooArgList(sample));

sample.setLabel("signal"); 
for(int i=0; i<dataSet_signal->sumEntries();i++) tmp->add(sample); 
dataSet_signal->merge(tmp);
delete tmp;
tmp = new RooDataSet("composed","composed",RooArgList(sample));
sample.setLabel("bkg2"); 
for(int i=0; i<dataSet_bkg2->sumEntries();i++) tmp->add(sample); 
dataSet_bkg2->merge(tmp); 
delete tmp;
tmp = new RooDataSet("composed","composed",RooArgList(sample));
sample.setLabel("bkg3"); 
for(int i=0; i<dataSet_bkg3->sumEntries();i++) tmp->add(sample); 
dataSet_bkg3->merge(tmp); 
delete tmp;
RooDataSet* dataSet_composed = new RooDataSet("dataSet_composed","dataSet_composed",RooArgSet(sample,var1,var2,var3));
dataSet_composed->append(*dataSet_signal); 
dataSet_composed->append(*dataSet_bkg2); 
dataSet_composed->append(*dataSet_bkg3); 

Is this a complementary way?