Weighting unbinned datasets

Hi,

I am trying to apply a weight to an unbinned dataset as follows:

RooFormulaVar wTrig(“wTrig”,“wTrig”,"(TMath::Exp((5.17464-muonPt)/ 1.78100) + 1.0 ) / 0.907275",muonPt) ;
///Add column with parameterization values to dataset
RooRealVar* weight = (RooRealVar*) wdata0->addColumn(wTrig) ;
wdata0->Print() ;
//wdata->RooAbsData::setWeightVar(weight) ;
///Instruct dataset wdata to interpret w as event weight rather than an observable
RooDataSet
wdata = new RooDataSet(wdata0->GetName(), wdata0->GetTitle(), wdata0, *wdata0->get(),0, weight->GetName()) ;
wdata->Print() ;

however, when I plot the dataset wdata, the weighting doesn’t seem to be applied. Any help is appreciated.

I’m actually just trying to scale the pT of the tracks in the range 0<pT<30GeV by the given Fermi-like function above, while leaving pT>30GeV tracks in the RooDataSet untouched. I’m doing this by creating two subsets of the original RooDataSet (one for each pT range), and then applying a scale factor (the Fermi function) to the lower pT dataset. I then combine the two datasets and perform an unbinned ML fit. But like I said above, it doesn’t seem the lower pT dataset is being scaled like I want. Does anyone know a simpler way to do this?

Hi,

What root version are you using? In 5.32 I see your example working all right, e.g.

RooWorkspace w(“w”,1) ;
w.factory(“Gaussian::g(x[-10,10],m[-10,10],s[3,0.1,10])”) ;

RooDataSet* d = w::g.generate(w::x,1000) ;
RooFormulaVar wgt(“wgt”,“wgt”,“abs(x)*0.1”,w::x) ;
d->addColumn(wgt) ;

RooDataSet d2(“d2”,“d2”,d,*d->get(),0,“wgt”) ;

RooDataSet::d2[x,weight:wgt] = 1000 entries (244.908 weighted)

Wouter

Hi Wouter,

Thanks for replying. I am using Root version 5.28.00e with RooFit v3.14.

–Thomas

Hi Thomas,

Thanks. There were some issues with weights a long time ago. ROOT 5.30 should be fine (or 5.32)

Wouter