Using TBranch::SetBufferAddress(TBuffer&)

Dear ROOT developers,

here is a use case. I have a sort of a copier application, which is getting serialized objects from elswhere (a server, database, etc.) in a form of a bytestream, which was prepared by someone else by running proper streamers against various persistent classes. My copier would fill TBuffer from that input bytestream. My ultimate goal is to to put the contents of the TBuffer into TTree w/o going through an intermediate stage of deserializing an object. And of course I have (my application is linked against) a proper dictionary for the relevant persisent classes (though, ideally I’d like not to do it at all). Now I’m trying to use the following operation:

TBranch::SetBufferAddress(TBuffer&)

which is supposed to do what I need. A problem is that I also need to create a branch where I’ll be storing my objects. I’ve looked at a contract of the TTree class and it appears that all relevant factory methods for TBranch require me to prepare a pointer of a valid persistent class. Needless to say that I don’t want to do it in my application. If I’m trying to pass a pointer of “void”, “TObject”, etc. types then the branch creation method is failing complainig about a missmatch between a type of a pointer and a type of a final persistent class (which I also know).

What would be a technique for creating branches in this case? Is this possible at all?

My second question - which ‘splitlevel’ I need to set for this case to make working the above mentioned method ‘SetBufferAddress()’?

BTW, I’m using ROOT v5.10 if this matters.

Thank you for the help!
Igor

Hi,

[quote]If I’m trying to pass a pointer of “void”, “TObject”, etc. types then the branch creation method is failing complainig about a missmatch between a type of a pointer and a type of a final persistent class (which I also know).[/quote]The type that would work would be (void*) :slight_smile:

Since you get the whole object serialized in a single buffer, you need to use split level 0.

Cheers,
Philippe

Hi Philippe,

unfortunatelly your suggestion hasn’t helped me. I’m having the following complain even if I set the splitlevel = 0 (note that Im using ROOT v5.10):

Setting the level to -1 (AKA “custom streamer”) results in disformed objects stored in the tree. Some of my classes have STL containesr as data members. Apparently ‘splitlevel = -1’ doesn’t work for them.

Is there anything else I should try?

Thanks,
Igor

Hi,

Yes :slight_smile: The next test is to send a small running example reproducing this case. With level 0 you should not have had any such message. With level -1 you should still get consistent data (please include an explanation on how to see that the data is ‘disformed’).

Cheers,
Philippe