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
So returning to the initial question, what I have tried now that the TGraphs are being properly stored is
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
vector<TGraph> cohGraphs(2);
Now returns
error: cannot initialize a parameter of type 'const TGraph *' with an rvalue of type
'vector<TGraph> *'
Things appear to work if I do
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
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