# How to read a std::vector values stored in TTree branch?

**URL:** <https://root-forum.cern.ch/t/how-to-read-a-std-vector-values-stored-in-ttree-branch/57212>\
**Category:** Newbie\
**Created:** [November 22, 2023, 1:26pm UTC](https://root-forum.cern.ch/t/how-to-read-a-std-vector-values-stored-in-ttree-branch/57212 "2023-11-22T13:26:59Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [November 22, 2023, 2:43pm UTC](https://root-forum.cern.ch/t/how-to-read-a-std-vector-values-stored-in-ttree-branch/57212/2 "2023-11-22T14:43:53Z")

</div>

> [@utkarsh-2000](#):
>
> Does it mean its plotting all the entries in all the vectors ?

Do

```auto
root [] B5->GetEntries()

```

and if this number is lower than what you see in the plot, yes (unless all vectors have only 1 element or there are many empty vectors! but you get the idea).  
To read the vectors and access each element, there are many examples searching this forum, for instance this:

> [@Reading vectors from a tree](https://root-forum.cern.ch/t/reading-vectors-from-a-tree/44801/5):
>
> Please note that [TTree::GetVal](https://root.cern/doc/master/classTTree.html#a3ad3433f279c1b6f54083e40b8fcc717) retrieves the results of the most recent [TTree::Draw](https://root.cern/doc/master/classTTree.html#a73450649dc6e54b5b94516c468523e45) and nothing else. Something like this should work: vector\<double\> \*Station = 0; t-\>SetBranchAddress("Station", &Station); Long64\_t n = t-\>GetEntries(); for (Long64\_t i = 0; i \< n; i++) { t-\>GetEntry(i); ULong\_t nsig = Station-\>size(); // MUST be done for every tree entry double \*sig = Station-\>data(); // MUST be done for every tree entry for (ULong\_t j = 0; j \< nsig; j++) { std::cout \<\< i \<\< " : " \<\<…

---

_[View the full topic](https://root-forum.cern.ch/t/how-to-read-a-std-vector-values-stored-in-ttree-branch/57212)._
