[RooFit]: random weights when doing RooDataSet->append?


I am puzzled by the following problem I am encountering in rootfit from root 5.26.
I have a macro divided in two steps. In a first step, I am creating weighted RooDataSets, one for the signal, and six for backgrounds. I am saving them in one single workspace together with the RooRealVar
of the variable and of the weight.
In a second step, I am opening this workspace. I retrieve these RooDataSets and I am trying to merge
a few of them together with “append”, and the weights seem to be lost in the process.

To do so, I am doing:
RooRealVar aVariable = *ws_MC->var(“MTPF”);
RooRealVar wVariable = *ws_MC->var(“w”);
RooDataSet *data =new RooDataSet(“Data_TotMC”,"",RooArgSet(aVariable,wVariable),“w”);

Then, I am doing a look over the RooDataSets, retrieve them from the file in a
loop [i]{

RooDataSet * datatmp=(RooDataSet*)ws_MC->data(toto.c_str())->Clone();

When I loop over the entries of “data”, I see the correct weights; while when I loop over “datatmp”,
the weight is the same for all events and is incorrect.

  1. 0x1b2d640 RooRealVar:: MTPF = 54.9405 L(0 - 120) B(120) // [GeV] "MTPF"
    datatmp->get(i)->getVal(“MTPF”) 54.9405 datatmp->weight() : 0.0615332 CORRECT
    data->get(i)->getVal(“MTPF”) 54.9405 data->weight(): [color=#FF0000] 5000 [/color] Where does this 5000 come from ?

Would you have any idea of what I am doing wrong ?


PS: the files to reproduce the problem can be found in


Apologies, I just noticed I had overlooked this posting.
The problem you describe is due to a bug in the weight handling
of dataset in ROOT 5.26. This has been fixed in ROOT 5.27/04