Changing the weight of a RooDataSet

hi all

i’m wondering if it’s possible to change the weights of a RooDataSet.

so what i have is a RooDataSet that i have written to a file. what i want to do is read the dataset, scan all events, change the value of the weight (for example multply by two), and then write to another file.

how can i do this?

fyi the dataset has one variable (“x”) and a weight variable (“w”). it has been created like this:

RooRealVar* x_ = new RooRealVar( “x”, “”, 0., xmax );
RooRealVar* w_ = new RooRealVar( “w”, “”, 0., 1000. );
RooDataSet* dataset = new RooDataSet( “datasetName”, “”, RooArgSet(*x_,*w_), w_->GetName() );

and then in each event it is filled like this:

dataset->add( RooArgList(*x_, *w_), this_w );

thanks a lot in advance!


Have you tried to create a new data set and copy in the new one the variables and the weight with the new values ?


ciao lorenzo

i’m trying but i’m not exactly sure on how to write it. what i’m trying to do is:

RooDataSet* newDataset = new RooDataSet( "newDataset", "", RooArgSet(*x_,*w_), w_->GetName() );

    for (int i = 0; i < oldDataset->numEntries(); i++) {
      w_->setVal( 2. * oldDataset->weight() );  // <--- is this correct?
      newDataset->add( RooArgList(*x_, *w_), w_->getVal() );

but it doesnt seem to work. any ideas?


sorry, my mistake. the above code actually works.

thanks a lot