Hi Jean-Eric int nbytes = m_branchMCH->GetEntry(eventId); nbytes will be 0 if eventId is not in the Tree. Reading an empty list will return nbytes > 0. Rene Brun Jean-Eric Campagne wrote: > > Dear developpers, > > I would like to ask you the following problem of EOF detection. > > Consider that I have managed to create a Tree with branch created via > the "Post a Tlist in a Folder" mechanism. > > Then, in a session where I am reading this Tree from a file I have made > the following sequences 1 & 2: > > 1) once for all: > ------------ > //Get the Tree of the MC hits > m_treeMCH = dynamic_cast<TTree*>(m_fileIn->Get("TreeMCH")); > ..... > m_branchMCH = m_treeMCH->FindBranch(".topFold.RunMC.EventMC.Hits.MCHitList"); > ..... > m_branchMCH->SetAddress(&m_mcHitList); > > where m_mcHitList is a TList > > 2) each event: > ---------- > //Get list of hits from the Root Tree > m_mcHitList->Delete(); > //Nb: eventId is managed by the main application > int nbytes = m_branchMCH->GetEntry(eventId); > > cout << " #of bytes read: " << nbytes << endl; > > //loop on Hit > TIter nextin(m_mcHitList); > DMMCHit* aDMHit; > while ( (aDMHit = (DMMCHit *)nextin()) ) { > .... > } > > It works perfectly, but I do not know how to get a feedback from the > GetEntry statement if it return 0 bytes, if really there is no hits > stored in m_mcHitList or if I am at the end of the file. > > Regards, > J.E Campagne > > ............................................................................. > .LAL - IN2P3 - CNRS > .LAL - B.P 34 - 91898 Orsay Cedex - France > .Piece 108 > .Tel +33 (0)1 64 46 84 29 > .Fax +33 (0)1 64 46 83 97 > ...........................................................................
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:51 MET