Dear experts,
I would like to read data from a TTree that contains objects of a custom class (inherited from TObject) without knowing the exact definition of that class. If possible, I would like to avoid reimplementing the class that was used for the tree creation since I do not have this part of the code under control.
Also without knowing the class, ROOT can obviously access the data – using a TBrowser, i see all the members I am interested in as branches.
However, the following example code does not work:
TFile* inFile = new TFile("./myTree.root", "READ");
TTree* inTree = inFile->Get("tree");
Float_t vertexZ = 0;
inTree->SetBranchAddress("VertexZ", &vertexZ);
inTree->GetEntry(0);
std::cout << vertexZ << std::endl;
VertexZ is the correct branch name, and there is no error message. But the value of vertexZ is just not reset when using GetEntry(0) (or other tree indices).
Am I missing something? Is “custom-class-agnostic” reading of trees possible at all?
NB: I am using ROOT5.
Thanks & best,
Rudiger