Hi Philip,
Thanks for reporting this problem. All the TLeaf classes have been updated (revision 30076) with the missing code (that was present only in TLeafI).
Cheers,
Philippe.
Philip Rodrigues wrote:
> 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 Sep 09 2009 - 02:35:23 CEST
This archive was generated by hypermail 2.2.0 : Wed Sep 09 2009 - 17:50:03 CEST