# Question about TTrees

**URL:** <https://root-forum.cern.ch/t/question-about-ttrees/16744>\
**Category:** ROOT\
**Created:** [October 10, 2013, 4:22pm UTC](https://root-forum.cern.ch/t/question-about-ttrees/16744 "2013-10-10T16:22:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Francesco\_Loparco](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/f/8baadc/32.png) [@Francesco\_Loparco](https://root-forum.cern.ch/u/Francesco_Loparco)\
**Post date:** [October 10, 2013, 4:22pm UTC](https://root-forum.cern.ch/t/question-about-ttrees/16744/1 "2013-10-10T16:22:01Z")

</div>

Dear ROOTers,

I am writing a Monte Carlo code in which, for each event, I evaluate the induced current signals on a detector and I want to store these signals in a ROOT tree.

For each event, I have a vector of N time values (let’s call them t\_k) and, at each time t\_k I evaluate the corresponding current i\_k=i(t\_k).

To save my data in a TTree, I defined a structure with the time and the current vectors, and, at the end of each event, I fill my tree with the command tree-\>Fill(). This procedure works, but, since the time vector is the same for all the simulated events, I am wondering whether there is a smarter way to fill the tree. Now I am storing the same time values at each event, while I would like to store them only once. Can I do that? And, in positive case, can you suggest me any example that I can use as a guide?

Thanks for your help  
Francesco

---

<div class="post-metadata">

**Author:** ![jfcaron](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/7c8e57/32.png) [@jfcaron](https://root-forum.cern.ch/u/jfcaron)\
**Post date:** [October 11, 2013, 7:00pm UTC](https://root-forum.cern.ch/t/question-about-ttrees/16744/2 "2013-10-11T19:00:03Z")

</div>

If your TTree is stored in a TFile, it should be compressed intelligently enough that static values from entry to entry do not significantly add to the size of the TFile. Similarly if you have a TBranch that just stores mostly-contiguous sequences of numbers (like event numbers), these should compress to a very small size.

If you are really worried about redundant data, you can store the data as separate objects in the TFile alongside the TTree (like TObjStrings). There is also a way to set the so-called “User Info” in a TList in the TTree itself. I don’t know more than that, but it should give you some useful search terms to find out.

Jean-François

---

<div class="post-metadata">

**Author:** ![Francesco\_Loparco](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/f/8baadc/32.png) [@Francesco\_Loparco](https://root-forum.cern.ch/u/Francesco_Loparco)\
**Post date:** [October 14, 2013, 8:05am UTC](https://root-forum.cern.ch/t/question-about-ttrees/16744/3 "2013-10-14T08:05:16Z")

</div>

Hi Jean-Francois,

thanks for your help. Indeed I needed to store the times because, when making plots, I want to build a current vs time graph for each event, and I thought that the easiest way to do this was with tree-\>Draw().

However I found that I can bypass this problem without storing the times in my tree, just defining a vector of times only when I read the tree and make the plots.
