Memory-resident Tree error?

I am doing an analysis where I read a TTree from a TFile, and fill the processed quantities in a new TTree. My set-up code looks like:

f = ROOT.TFile("../rootfiles/Outputs/Run0504/standard_analysed.root") t = f.Get("standard_analyzed") tout = ROOT.TTree("tout","Output tree")

While running, I eventually get errors like this one every few thousand entries:

[quote]Error in TTree::Fill: Failed filling branch:tout.dedx2, nbytes=-1, entry=7981
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(…)[/quote]

In the end the code seems to work, and I can access the output tree. Should I be worried about this, is there a way to fix it/get rid of the error?

Hi,

this is beyond me, but if I’m to guess, then the problem has to do with with the tree being associated with the currently open file, which isn’t opened in “update” mode. But again, that’s just a guess: you’ll have better luck to get an answer on the ROOT support forum.

Cheers,
Wim

Hi,

If you want the TTree to be memory resident you need to tell it so explicitly by using:f = ROOT.TFile("../rootfiles/Outputs/Run0504/standard_analysed.root") t = f.Get("standard_analyzed") tout = ROOT.TTree("tout","Output tree") tout.SetDirectory(0);

Philippe.

Hi,

Yes, I also wanted to know how to make a tree, memory resident.

Thanks.