> You should not declare the variable as int* if it is an int. > In your case, if you just want to read the branch "EventNo", do: > static int evtnr; > TBranch *branch = amstree->GetBranch("EventNo"); > branch->SetAddress(&evtnr); > branch->GetEntry(0); to read the first entry > now the variable evtnr should contain the value of EventNo for the first > entry. > It is in general a bad idea to use local variables to store the result > of a Tree entry. You better put your variable(s) inside a class. > That is what TTree::MakeClass is doing for you. > > It is likely that you did not declare int evtnr as a static variable. > In case you exit/enter again from/in the function where this variable is > declared, the variable has been destroyed meanwhile. Yes, I know! This is just a tiny test CINT program to check the action of GetEntry. I don't believe the int gets destroyed because it never leaves the scope (doesn't matter if I put address of int or of pointer, tried both, still nothing read). .. I am not understanding something, though.. what does SetBranchAddress do in the two cases? In the main compiled code I'm trying to debug, the variable to be read is static. The read still does not work (supposedly it *used* to work, though, which I do not understand!) Kate.
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:51 MET