Warning: split mode on a class ... with a custom Streamer

Hello!

I’m using an interface layer between TTree and my program; to create a branch, I use a thing like:

TBranch* MakeBranchLikeOnlyYou(TTree* pTree, const char* classname, void* addobj);

which will eventually call

TBranch* Branch(const char* name, const char* classname, void* addobj, Int_t bufsize, Int_t splitlevel);

Ay, that is the rub. For if I use a ROOT object (I did use TLorentzVector) I get that warning in the subject. Now, documentation says that I should use split level -1 if class has a custom streamer, but I still want to use default splitlevel=99 in all other cases.

Now, the question is: how can I know whether “classname” named class has a custom streamer or not?

Thank you.

[quote]Now, the question is: how can I know whether “classname” named class has a custom streamer or not? [/quote]ifTClass::GetClass(classname)->GetStreamer()!=0 || TClass::GetClass(classname)->GetClassInfo()->RootFlag() & 1() is true.

Cheers,
Philippe

Thank you very much; I missed the simpler part, the GetStreamer().
There is a little syntax error with a bracket above, it should be:

TClass::GetClass(classname)->GetStreamer()!=0 || (TClass::GetClass(classname)->GetClassInfo()->RootFlag() & 1)

I had to

#include <Api.h>

for G__ClassInfo type. If there is a more canonical header to be included, please let me know.

You did the correct corrections :slight_smile:

Cheers,
Philippe

I’m sorry, I realize now that the description of my problem was wrong.

I actually have the problem with objects like std::vector.
Summary: if I use splitlevel -1 or 0, no sub-branch is created; if I use a positive (e.g. 99) splitlevel, all branches ae produced but I get that streamer warning:

Using split mode on a class: TLorentzVector with a custom Streamer

The final question is this: which split mode/alchemy have I to use to have all the branches of a std::vector and no complain by ROOT?

Thank you again.

In attach, an example producing a tree of std::vector and one of std::vector (a custom, CLASSDEFined class) and printing the resulting branch structure.

Hi,

Currently we allow for the content of TClonesArray and stl collection to be split eventhough they do have a custom streamer. This do indeed induce the warning message you are talking about. In some case (like in particular) TLorentzVector, this warning can be safely ignored since the Streamer does not contain any code that is needed in your case (the only additional code is to support read older version of TLorentzVector (file produced by version of ROOT prior to 2002)).

Cheers,
Philippe.

PS. We plan on introduce a new feature to TClass to allow the class implementer to tell whether the custom streamer should cancel splitting or not, this would remove the (spurrious) error message.