Hello,
I would like to link multiple variables to a single tree branch.
It seems to work in interactive, but I have to use TTree::SetMakeClass(1);
{
TTree *t1 = _file0->Get("mytree");
double Zvtx, Zvtx2;
t1->SetMakeClass(1);
t1->SetBranchAddress("vertex.z", &Zvtx);
t1->SetBranchAddress("vertex.z", &Zvtx2);
t1->GetEntry(0);
cout << Zvtx << " " << Zvtx2 << endl;
}
0.00 -0.244
In practive the second setbranchaddress is called within a class. So I cannot just play with pointers in order to copy Zvtx pointer into Zvtx2. Of course this would be easy to do.
Knowing that the 2 zvtx variables might not exists at the same moment. Is there a way to copy it safely?
Edit: I saw it is possible to set an alias, but it seems I cannot use it with SetBranchAddress
Edit-2: I tried to use TBranchElement::GetAddress(), it returns a char* but I don’t know how to use it to get the corresponding object