RootTalk


ROOT Discussion Forums

reading THashList from a TTree

Discuss installing and running ROOT here. Please post bug reports here.

Moderator: rootdev

reading THashList from a TTree

Unread postby sfarrell » Tue Mar 22, 2011 19:45

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
sfarrell
 
Posts: 2
Joined: Tue Mar 22, 2011 1:26

Re: reading THashList from a TTree

Unread postby pcanal » Tue Mar 22, 2011 22:16

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.
pcanal
 
Posts: 6147
Joined: Wed Aug 27, 2003 14:22
Location: Fermilab


Return to ROOT Support

Who is online

Users browsing this forum: No registered users and 4 guests