# Vector in Branch

**URL:** <https://root-forum.cern.ch/t/vector-in-branch/12796>\
**Category:** ROOT\
**Created:** [July 20, 2011, 4:09pm UTC](https://root-forum.cern.ch/t/vector-in-branch/12796 "2011-07-20T16:09:17Z")\
**Posts on this page:** 1\
**Showing post:** 5

<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:** [July 20, 2011, 11:03pm UTC](https://root-forum.cern.ch/t/vector-in-branch/12796/5 "2011-07-20T23:03:48Z")

</div>

[quote]ptree-\>SetBranchAddress(“wave\_model”,&(&wave\_model));  
seems to work…[/quote]Unfortunately it only appears to work. This call pass the address of a transient pointer (i.e. it last only as long as the statement)) but the function keep a copy of this value … resulting in the TTree essentially using random memory (because this address _will_ be reused).  
You need:`std::vector<float> * wave_model = 0;               
ptree->SetBranchAddress("wave_model",&wave_model);`

Cheers,  
Philippe.

---

_[View the full topic](https://root-forum.cern.ch/t/vector-in-branch/12796)._
