Misaligned branches in TTree

Hello, is it possible to hve a misaligned branch in a TTree? I would need to have an “info” branch with only one entry, and other branches with one entry per event. I’m trying to not replicate event informations that are common to all events; I know I could write them on an info object and just write it on the TFile, but to read it back I should heavily modify my file reading API. I could do it but writing it on a branch would be more straightforward (and I must admit also a bit awkward).
I tried to make a branch, fill it with the info object and then call ResetBranchAddress and DropBranchFromCache, but when I subsequently call TTree::Fill, I get this message:

Error in <TBranchElement::Fill>: attempt to fill branch CHADH4EINFO while addresss is not set

Maybe I’m doing something wrong, maybe I’m trying to do something that is not possible. Can anybody give me some help, please?


For the case of objects that have a single value for a whole TTree, you can use the list of user object (tree->GetUserInfo() ). Even though it is technically possible to have a TTree with unbalanced branch is strongly discouraged (and intentionally ‘hard’ to do). In most cases, if you need partially filled branches, you would be better served by using an additional TTree that you make a ‘Friend’ of the original tree.


Thanks Philippe, I figured that misaligning branches would be against the intended behavior. One possible solution that came into my mind after opening this thread is to inherit a “TInfoTree” class from TTree, adding an info member object to store the single valued fields. I will also give a look to GetUserInfo() (didn’t know about that, thanks again).

[quote] is to inherit a “TInfoTree” class from TTree, adding an info member object to store the single valued fields.[/quote]Don’t :slight_smile:. Inheriting from TTree opens yet another can of worms … and GetUserInfo is actually exactly what you would do/add in TInfoTree :slight_smile:


Yes, I am looking right now to GetUserInfo and it really sounds like the solution to my problem. Thanks also for the word of caution about inheriting from TTree :slight_smile: