# Writing single objects to a TTree

**URL:** <https://root-forum.cern.ch/t/writing-single-objects-to-a-ttree/10865>\
**Category:** ROOT\
**Created:** [August 31, 2010, 10:59am UTC](https://root-forum.cern.ch/t/writing-single-objects-to-a-ttree/10865 "2010-08-31T10:59:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![krasznaa](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/krasznaa/32/35517_2.png) [@krasznaa](https://root-forum.cern.ch/u/krasznaa)\
**Post date:** [August 31, 2010, 10:59am UTC](https://root-forum.cern.ch/t/writing-single-objects-to-a-ttree/10865/1 "2010-08-31T10:59:58Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [August 31, 2010, 12:45pm UTC](https://root-forum.cern.ch/t/writing-single-objects-to-a-ttree/10865/2 "2010-08-31T12:45:35Z")

</div>

[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.
