RooDataSet from TTree

Hi experts,

I always get annoying ERROR msgs (see later) when creating a RooDataSet from a TTree. What am I doing wrong ?
Here’s how I create the RooDataSet:

TFile *f = new TFile("SU3SM-10M.root", "READ");
TTree *BkgTree = (TTree*)f->Get("BkgTree");

RooRealVar meff("MEFF","MEFF", 0.0, 5000.e3);
RooRealVar mT("MT","MT", 0.0, 800.e3);

RooDataSet *dataset1 = new RooDataSet( "data_bg","data SM bkg",BkgTree, RooArgSet(meff,mT) );

and this is the ERROR msgs

Error in <TTree::Fill>: Failed filling branch:BkgTree.MEFF, nbytes=-1
 This error is symptomatic of a Tree created as a memory-resident Tree
 Instead of doing:
    TTree *T = new TTree(...)
    TFile *f = new TFile(...)
 you should do:
    TFile *f = new TFile(...)
    TTree *T = new TTree(...)

that I get for every entry. After all the errors, the RooDataSet seems to be ok, i can see all the entries, can make plots etc.

Btw. I get the same error when I add RooDataSets together via the append method.

I am using ROOT 5.18.00d.

Thanks for any help :slight_smile:


These message are in all cases that I have encountered harmless.
A fix has been introduced in 5.21 to make them go away.