Reading user info from a TChain

I use a TChain to read multiple files, which also contain user info objects. After creating the chain I read the user info object with

userInfoObj = chain->GetTree()->GetUserInfo()->At(0);

but what happens when the current file is changed during the event loop? Do I need to manually update userInfoObj to the user info object of the new file or can this operation be automated?
Thanks.

I don’t think there is an automatic in place, but perhaps @pcanal can tell you more.

Yes, you need to reload the object for each file/tree. This can be ‘somewhat’ automated by adding a callback object to the TTree via TChain/TTree::SetNotify and having that callback object override the Notify member function (which will be called by the TChain at each file transition).