Hi roottalk,
I'm trying to access the values of variable-sized arrays using
TLeaf::GetValue, with code like the following:
TTree* t = [[ some tree ]];
// branch "dir" has title "dir[nring][3]/F"
// where "nring" has type "nring/I"
TBranch* b_dir=t->FindBranch("dir");
TLeaf* l_dir=t->FindLeaf("dir");
dir->GetEntry(0);
// Should get dir[0][1] in the 0th entry
l_dir->GetValue(1);
I noticed that this fails for "dir", which is a float variable, but succeeds for integer variables. I found the necessary workaround, which is to do:
l_dir->GetLeafCount()->GetBranch()->GetEntry(0);
before dir->GetEntry(0), but I'm wondering if I'm misunderstanding how this is supposed to work. Should it be necessary to put this extra line in?
Thanks,
Philip
PS The reason it *does* work for integer variables is because TLeafI::ReadBasket looks like:
if (!fLeafCount && fNdata == 1) {
b >> fValue[0];
} else {
if (fLeafCount) { /**/ Long64_t entry = fBranch->GetReadEntry(); /**/ if (fLeafCount->GetBranch()->GetReadEntry() != entry) { /**/ fLeafCount->GetBranch()->GetEntry(entry); /**/ } Int_t len = Int_t(fLeafCount->GetValue()); if (len > fLeafCount->GetMaximum()) { printf("ERROR leaf:%s, len=%d and max=%d\n",GetName(),len,fLeafCount->GetMaximum()); len = fLeafCount->GetMaximum(); }
so it does the GetEntry on the necessary branch. The corresponding function in TLeafF lacks the lines I've marked with a /**/ Received on Wed Aug 26 2009 - 14:51:34 CEST
This archive was generated by hypermail 2.2.0 : Wed Sep 09 2009 - 05:50:20 CEST