Leaf error when calling TTree->GetEntry

Hi,

I am reading a branch of a ROOT tree, which holds one array of Int_t’s. I have constructed an array (of a size which should be big enough), attached the array to a branch, and copied the pointer to an array into a vector, like:

int *buf = new int[WORDS_IN_BUFFER];
theTTree->SetBranchAddress(theBranchName,buf);
theVectorOfBuffers.push_back(buf);

I do this for a couple of branches, so that the vector holds two pointers to two different buffers.

When I try to get an entry from the TTree, like:
theTTree->GetEntry(i);

I occasionally get the following error on the screen:
ERROR leaf:RU_1, len=84008961 and max=12530

The len is different each time I get the error, but the max is fixed (and is equal to the WORDS_IN_BUFFER variable above, which I use to define the size of the array).

Can anyone tell me what this error means? I can make a reasonable guess, and that it means the buffer I’m reading from the branch is too big. But I’m not sure…

Also, the error doesn’t happen all the time, only for a few % of the times when I do theTTree->GetEntry(i);

Thanks in advance,

Cheers,
Matthew

Matt,

Could you provide the shortest possible running script showing the problem (including a small data file)?

Rene

Hi Rene,

I’ve actually solved the problem now. I think it was due to the use of vectors to hold the variables/pointers attached to the TBranches. Is this a known problem? I fixed it by simply avoiding using stl vectors, and just attaching non-stl class data members to the branches.

What I was trying to do was something like:

//Get ROOT Tree from TFile.
theTTree = (TTree*)theTFile->Get(TREENAME);
//Find the branch names, and put them in a vector theBranchNames, which is a data member of the class.
findBranches();
//Now loop over theBranchNames vector
for (int i = …) {
//Create a buffer
int x = new int[SIZE];
//Put the buffer pointer into a vector<int
>, which is a class data member.
theBuffers.push_back(x);
//Now attach buffer pointer to the TBranch
theTTree->SetBranchAddress(theBranchNames[i].c_str(), theBuffers.back());
}

//Then SetBranchStatus for all the branches, then call theTTree->GetEntry() for all the events in the TTree.

So I want my code to be able to work with a TTree which has n branches. However, I couldn’t get the above to work properly. If I avoid the use of vectors, and simply have n class data member pointers attached to the branches instead, then it works perfectly.

Cheers,
Matthew