Error in <TTree::SetBranchAddress>: Unable to determine the type given for the address for "cohGraphs[2]". This is probably due to a missing dictionary, the original data class for this branch is TGraph.
Error in <TTree::SetBranchAddress>: Unable to determine the type given for the address for "deconvGraphs[2]". This is probably due to a missing dictionary, the original data class for this branch is TGraph.
TTree::SetBranchAddress() is overloaded, am I supposed to have another input variable? I have also tried #include "TGraph.h" beforehand.
When I call cohGraphs, I get reference address inside of the vector, in contrast to when I try cohGraphs[2], where I get an empty vector of size 2.
However, with the above lines I get
Error in <TTree::Branch>: The class requested (TGraph) for "cohGraphs[2]" is different from the type of the object passed (vector<TGraph>)
Warning in <TTree::Bronch>: Using split mode on a class: TGraph with a custom Streamer
Error in <TTree::Branch>: The class requested (TGraph) for "deconvGraphs[2]" is different from the type of the object passed (vector<TGraph>)
Warning in <TTree::Bronch>: Using split mode on a class: TGraph with a custom Streamer
Even if I know what the size of the vectors should be beforehand, should I not assign sizes beforehand and a vector’s “push_back()” to add in the graphs later?
Thank you for the response. I tried implementing Philippes’ suggestion below, so that will likely change what waveformGraphTree->Print(); returns. What it now returns is
Even if I know what the size of the vectors should be beforehand, should I not assign sizes beforehand and a vector’s “push_back()” to add in the graphs later?
Both will work.
Error in TTree::Branch: The class requested (TGraph) for “cohGraphs[2]” is different from the type of the object passed (vector)
The message is correct. You can just skip specifying the type.
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
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?