Hi, I am using a TIterator to loop over a TClonesArray I read from a tree (structure similar to ATLFast code). I do something like the following hit is an Object of type Hit* and fHits is a TClonesArray of Hit's for (i = 0; i < nb_events; i++) { tree->GetEvent(i); TIter next(fHits) while ((hit = (Hit*)next())) { // do stuff } // do a clear of the Arrays here } The problem is, that if the TClonesArray is empty (which happens quite often for one of my branches), a loop over the tree is really slow :350 events per second. If I add the following however for (i = 0; i < nb_events; i++) { tree->GetEvent(i); TIter next(fHits) if (fHits->GetEntriesFast()) { while ((hit = (Hit*)next())) { // do stuff } } // do a clear of the arrays here } the loop is speeded up by quite a big factor : 2900 events per second. In case of a brach without empty arrays, the performace is about 2500 evts. per second. The while loop is in fact not entered for empty arrays in the first case -> why does the call to next() take so much time if the TClonesArray is empty? Cheers, Christian Hilbes IPP - ETH Zuerich
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:44 MET