Creating a nll with a weighted dataset

Hi everybody,
I am fitting a model to a weighted dataset this way :

RooDataSet data(.......,RooArgSet(x,w));
RooDataSet wdata(data->GetName(),data->GetTitle(),data,*data->get(),0,w->GetName()) //interpret w as a weight
RooAbsReal* nll =model->createNLL(wdata) ; 
RooMinuit m(*nll) ;

but I am wondering if this likelihood takes into account the weights in my dataset?
If not, is there a way in the same feeling that “fitTo(…,SumW2Error(kTRUE))” which takes them into account in the computation. Maybe you’ll advise me to use this method instead but I have not found a way to change the ErrorLevel when using a “fitTo”.

Thanks in advance,


The weights will be taken into account in the computation of the errors after the fit, if you use the option SumW2Error(kTRUE)). The error level should be kept as for the unweighted data set (e.g. 0.5 for 68% errors on a niegatibel log-likelihood).
However for a weighted data set, you can’t compute the errors just looking at the likelihood values. You need to use the second derivatives of the likelihood (obtained from Hesse) and correct them for the effect of the weights. The correction is automatically applied in RooFit when you use the option SumW2Error(kTRUE).

Best Regards