Don't understand TEntryList behavior with chains

Hello fellow Rooters,

I’m trying to use a TEntryList with a TChain, and I do not understand why it has been implemented the way it was. To me, it seems that TEntryLists have broken the inheritance of chains from trees!

In particular, it’s documented that, when working with chains, you can’t use Next() or GetEntry(n), but rather you have to call

int treenum;
long localentry = elist->GetEntryAndTree(ev, treenum);
chain->GetEntry(localentry = chain->GetTreeOffset()[treenum]

But this means that, if I have a generic function accepting a TTree*, I then have to do some check to find out if it’s actually a chain if I want to use it’s associated TEntryList… Moreover, since the GetEntryAndTree function exists, why not keep the behavior of GetEntry consistent in the two cases?

Sorry to to make needless noise, but I just received a lot of flak after telling some people how useful entry lists are, and I could not come up with a single plausible explanation of why the current implementation is as it is…

Thanks for your patience and much appreciated efforts! (I really try not to sound belligerent…)
~Ben

Hi Ben,

Yes this is a bit awkward. TEntryList for TChains is not really (intended to) be used without the instance of the TChain. In particular this is necessary to know which file that are described/accounted for in the TEntryList but not in the TChain (in turn this is a useful feature in other to be able to use the TEntryList on partial version of the chain that are spread across multiple executing nodes). In particular see the non-trivial implementation of TChain::SetEntryList.

So the technically the recommend syntax is the same for both TTree and TChain:treechain->SetEntryList(elist); .... for (entry=start;entry<end;entry++) { entryNumber = treechain->GetEntryNumber(entry); if (entryNumber < 0) break; localEntry = fTree->LoadTree(entryNumber); if (localEntry < 0) break; // then either call branch->GetEntry(localEntry); // or entryNumber->GetEntry(entryNumber); // In the later case the LoadTree is then somewhat redudant. ...

Cheers,
Philippe.

Dear Phillipe,

Thank you! This seems to me much simpler than the recommended method described on the TEntryList documentation. It might be worth adding this, or at least a mention in the TEntryList documentation that the GetEntryNumber method returns the “global” entry number in the case of an elist.

~Ben

Hi Ben,

Thanks for the suggestion, I extended the documentation in the trunk.

Cheers,
Philippe.

Dear Philippe,

Hopefully this message finds you from this old thread. The html is broken in the documentation for this tip, making it rather confusing :slight_smile: .

Cheers,
~Ben

Hi Ben,

What do you mean (i.e. can you point to the page/part of page that is broken)?

Thanks,
Philippe.

On my browser (firefox 13.0 on win7) for the 5.34 version (root.cern.ch/root/html534/TEntryList.html), it reads

Looks like some of the ‘<’ aren’t properly escaped and are being interpreted as html tags.

Hi Ben,

Thanks for reporting this issue. A fix has been uploaded in the trunk and v5.34 patch branch.

Thanks,
Philippe.