Reading THashList from a TTree

Hello,

I have a simple trigger class which resides on a THashList which is on a branch of a TTree. For each event we wanted an efficient way to access the triggers by name, so we use the trigger name (which should be unique per event) as the hash value. The tree is filled just fine while writing, but when reading from the tree there is a problem. It seems that when we call branch->GetEntry(i), the hash list does not clear itself of the old objects, and so the size of the list grows with every event! If we explicitly clear the hash table before calling GetEntry it works, but we’d prefer it done automatically. I understand there is an AutoDelete option for the branch which will delete the object and make a new one each time, but I think this hurts performance because we really only want to delete and clear the objects on the list, not the whole list itself.

I’m hoping the issue is clear enough as I’ve described it. Is this an understood feature? If so, can somebody suggest a workaround? If not, I can try and provide more info. Thanks

Steve

Hi Steve,

Indeed the Streamer of TList (from which THashList derives) was missing a call to Clear to avoid the ‘adding’ behavior your noticed. This is fixed by revision 38559 of the trunk.

As a work-around, you will need to call Clear explicitly on the THashList object before the GetEntry.

Cheers,
Philippe.