Writing single objects to a TTree

Dear All,

I have a strange observation with writing single objects to a TTree. If I try to write out an std::vector of my custom objects, then everything works as I would expect. The names of the sub-branches within the main branch look like

.

But if I just add a single one of my custom objects to the TTree, the sub-branches get a name that doesn’t contain the main branch name.

Reading the TTree documentation, I tried adding a dot after the branch name. If I do this, the created TTree now contains sub-branches which are called ., but now the name of the main branch is “.”. So the main branch now has a dot in its name.

To make the situation even stranger, if I give a name with a dot for a branch of an std::vector of my class, everything still works correctly. So the main branch’s name doesn’t contain a dot, and the sub-branches are still named correctly.

I guess writing out single custom objects is not the most usual use case. I have to admit that I’m only looking at the issue because somebody told me about it. I would need the usual naming (.) for these branches because my analysis code only activates the branches which are to be read by the analysis. So if the sub-branches don’t have a name that begin with the name of the main branch, then the code doesn’t know how to activate these branches.

Any insight would be greatly appreciated. Cheers,

            Attila

[quote] but now the name of the main branch is “.”[/quote]This is indeed the expected behavior.

[quote]To make the situation even stranger, if I give a name with a dot for a branch of an std::vector of my class, everything still works correctly.[/quote]This is also the expected behavior, indeed a bit confusing.

[quote]I guess writing out single custom objects is not the most usual use case. [/quote]It is relatively common and what you described in the expected (working) behavior.

Cheers,
Philippe.