# Roofit : weight in the fit of a RooDataHist or a RooDataSet

Hello,

i would have questions on the weighting of binned or unbinned datasets in roofit.

Let’s consider some observables : the discriminating variable (here a mass) and a weight of the event
(for a Monte-Carlo) :

observables=new RooArgSet(RooRealVar_InvariantMass,RooRealVar_global_weight);

Let’s consider a binned histogram imported from a root histogram (called hist_InvariantMass), that was filled with the weight : hist_InvariantMass->Fill(mass_gg_corrected/1000.,global_weight);

so we have the definition :
RooDataHist Datahist_InvariantMass(“Datahist_InvariantMass”,“Datahist_InvariantMass”,
*observables,RooFit::Import(*hist_InvariantMass));

Let’s consider the variante of a unbinned dataset, imported from a tree, that contains the weight (and the mass) :
RooDataSet tmp(“tmp”,“tmp”,*observables,RooFit::Import(*tree_InvariantMass[index_mass][index_process]));
roodataset_InvariantMass[index_mass][index_process]=new RooDataSet(name_roodataset,name_roodataset,
*observables,RooFit::WeightVar(“global_weight”),RooFit::Import(tmp));

*Do these two cases take into account correctly the weights ?

*in particular, when doing a fit, does it take into account the weight ?
-for the roodataset :
roofitresult=myPdf_mgg->fitTo(*roodataset_InvariantMass,RooFit::Strategy(1));

-for the RooHistDataset :
roofitresult=myPdf_mgg->fitTo(Datahist_InvariantMass,RooFit::Strategy(1));