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) ;
///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()) ;
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?
What root version are you using? In 5.32 I see your example working all right, e.g.
RooWorkspace w(“w”,1) ;
RooDataSet* d = w::g.generate(w::x,1000) ;
RooFormulaVar wgt(“wgt”,“wgt”,“abs(x)*0.1”,w::x) ;
RooDataSet d2(“d2”,“d2”,d,*d->get(),0,“wgt”) ;
RooDataSet::d2[x,weight:wgt] = 1000 entries (244.908 weighted)
Thanks for replying. I am using Root version 5.28.00e with RooFit v3.14.
Thanks. There were some issues with weights a long time ago. ROOT 5.30 should be fine (or 5.32)