Hello,
I am trying to use a weighted unbinned data set. I do the following:
TFile *f = new TFile(“somefile.root”);
TTree ltr = (TTree)f->Get(“mytree”);
RooRealVar deltam(“dm”,"#Delta M",0.135, 0.17);
RooRealVar w1(“w1”,“pt weight”,0.5, 1.5);
RooCategory c(“cate”,“cate”);
c.defineType(“RC”,+1);
c.defineType(“WC”,-1);
Float_t dm, pt, ptw1;
Int_t rc;
ltr->SetBranchAddress(“dm”,&dm);
ltr->SetBranchAddress(“isrc”,&rc);
ltr->SetBranchAddress(“pt”,&pt);
ltr->SetBranchAddress(“ptwgt1”,&ptw1);
RooDataSet *databin0=new RooDataSet(“databin0”,“All, integrated”,RooArgSet(deltam,w1,c),WeightVar(w1));
Int_t nent=(Int_t)ltr->GetEntries();
for (Int_t i=0; i<nent; i++)
{
ltr->GetEntry(i);
w1=ptw1;
if(rc==1){c.setLabel("RC");
deltam=dm;}
if(rc==0){c.setLabel("WC");
deltam=dm;}
databin0->add(RooArgSet(deltam, w1, c));
w1.Print();
databin0->Print();
cout<<"data weight: "<<databin0->weight()<<endl;
}
The output looks like this:
RooRealVar::w1 = 0.87292 L(0.5 - 1.5)
RooDataSet::databin0[dm,cate,weight:w1] = 2209 entries (2209 weighted)
data weight: 1
To me, it looks like it reads the proper value of the weight, but it fails to consider it as such. Could someone please tell me what am I doing wrong?
Thank you,
Monica