Error reading a tree

Hello Rooters,

I am trying to print all entries from a branch. But the program crushes with a "*** Break *** segmentation violation"
after it finished printing all numbers.
I already checked the variable “cl_eta_topo_em” in the ntuple and it is definetly a “float”.

What I found out is that if I declare my variable “eta_cl” as a float ARRAY with size>4 and always print the first entry of the array (eta_cl[0]) then it works!!
I don’t understand this behaviour, can anybody explain what is happening?

Thank you very much for your help!
Cheers,
Gerolf

PS: I am using ROOT 4.01/02

void test() { TFile * f = TFile::Open("ntuple/r2101257.root"); f->cd("TB"); float eta_cl; tree->SetBranchAddress("cl_eta_topo_em",&eta_cl); for(int i=1;i<400;i++){ tree->GetEntry(i); printf("%f \n",eta_cl); } }

Hi,

[quote]I already checked the variable “cl_eta_topo_em” in the ntuple and it is definetly a “float”. [/quote]Did you check whether it is an array of floats (or contained in an object inside a colletion)?
One way to better guess the type you need is to do:

TFile * f = TFile::Open("ntuple/r2101257.root"); f->cd("TB"); tree->MakeClass("fortree"); and look for the declaration and usage of cl_eta_topo_em in fortree.h

Cheers,
Philippe

Hi Philippe!

Thanks a lot! Your “MakeClass” helped! It was an array!

Cheers,
Gerolf