# TTree::SetBranchAddress() for a TGraph array branch

**URL:** <https://root-forum.cern.ch/t/ttree-setbranchaddress-for-a-tgraph-array-branch/29674>\
**Category:** ROOT\
**Tags:** tree\
**Created:** [July 6, 2018, 2:18am UTC](https://root-forum.cern.ch/t/ttree-setbranchaddress-for-a-tgraph-array-branch/29674 "2018-07-06T02:18:12Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![jwruss](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@jwruss](https://root-forum.cern.ch/u/jwruss)\
**Post date:** [July 6, 2018, 9:46pm UTC](https://root-forum.cern.ch/t/ttree-setbranchaddress-for-a-tgraph-array-branch/29674/7 "2018-07-06T21:46:23Z")

</div>

Thanks for the help, Philippe.

I looked into your comment

> SetBranchAddress expects the address of a pointer or the address a single object.  
> and found a response you provided earlier  
> [Vector in Branch - #5 by pcanal](https://root-forum.cern.ch/t/vector-in-branch/12796/5)

So returning to the initial question, what I have tried now that the TGraphs are being properly stored is

```auto
	vector<TGraph> * cohGraphs, * deconvGraphs;
	waveformGraphTree -> SetBranchAddress("cohGraphs[2]", cohGraphs);
	waveformGraphTree -> SetBranchAddress("deconvGraphs[2]", deconvGraphs);

```

Using `TTree::SetBranchAddress()` as above doesn’t throw any errors at this point, but now a function which I call later which referenced `& cohGraphs[0]` when I had

```auto
vector<TGraph> cohGraphs(2);

```

Now returns

```auto
error: cannot initialize a parameter of type 'const TGraph *' with an rvalue of type
      'vector<TGraph> *'

```

Things appear to work if I do

```auto
vector<TGraph> * cohGraphs[2], * deconvGraphs[2];

```

and then provide the function with the argument `cohGraphs[0] -> data()`, but is that the correct thing to do? What if instead I did

```auto
vector<TGraph> * cohGraphs, * deconvGraphs;

```

and then passed as argument `cohGraphs[0].data()`? Both of these seem to work, but are they effectively doing the same thing?

Best,  
John

---

_[View the full topic](https://root-forum.cern.ch/t/ttree-setbranchaddress-for-a-tgraph-array-branch/29674)._
