Error in <TBufferFile::CheckByteCount> writing RooDataSet

Hi,

I have a RooDataSet which contains 6 variables and about 4M events. After a long process to add a RooCategory variable, see below) I cannot write it anymore:

Is there a solution?

Otherwise, it there a more efficient method to add a RooCategory variable to a dataset than splitting it according to some cuts and merging again? (like in hep.by/root/tutorials/roofit … pdf.C.html but with tens of categories)

Thanks in advance,
Bruno