fChain->GetTree()->GetEntry(entry, getall)

Can someone tell me why MakeSelector generate a code with this line:

fChain->GetTree()->GetEntry(entry, getall)

in the function GetEntry instead of a simpler:

fChain->GetEntry(entry, getall)

I’m asking it because I have too use a TSelector without proof with a custom code (so no TTree.Process) and I’ve some problem because I don’t know when the TChain::LoadTree has to be called.

Hi,

Because LoadTree is already called by ROOT (TTreePlayer::Process) or by PROOF (TEventIterTree).
LoadTree has to be called before you need that entry.
Using

fChain->GetEntry(entry, getall);

should be OK in your case.

G. Ganis

NB: this is not really a PROOF issue; please continue the discussion on the main thread to get help for your custom code

[quote=“ganis”]Hi,

Because LoadTree is already called by ROOT (TTreePlayer::Process) or by PROOF (TEventIterTree).
LoadTree has to be called before you need that entry.
Using

fChain->GetEntry(entry, getall);

should be OK in your case.

G. Ganis

NB: this is not really a PROOF issue; please continue the discussion on the main thread to get help for your custom code[/quote]

I want a code that work in proof and outside, I think it is much easiest if everybody use only one funciont fChain->GetEntry().

I had a look to TTreePlayer::Process, and it is really compicated (I don’t understand why so complicated). You said that LoadTree is already called by other functions, but so why you can’t use fChain->GetEntry ? If needed it call LoadTree otherwise not.

[quote=“wiso”]I want a code that work in proof and outside, I think it is much easiest if everybody use only one funciont fChain->GetEntry().
[/quote]
And why do you want/need to use TChain in your own code if you do not want to use Process?
The only point to use TChain is to exploit the automatic handling of files for Process and Draw. If you handle files by yourself you better work directly with TTree. And in such a case you do not have any problem: you load your own TTree from the file with Get() and you read entries with TSelector::GetEntry. This will always work because TTree has an implementation of GetTree() which returns itself.

G. Ganis

Ps: I am still convinced that this is a subject only marginally connected with PROOF. So you should continue elsewhere.

[quote]fChain->GetTree()->GetEntry(entry, getall)
in the function GetEntry instead of a simpler:
fChain->GetEntry(entry, getall)[/quote]So the two are not interchangeable. The definition of ‘entry’ is very different! In the first case the entry value is a number between 0 and the number of entries in the current tree (i.e. fChain->GetTree()->GetEntries()) while in the 2nd one the entry is a number between 0 and the number of entries in the chain (i.e. the sum of the number of entries in all the trees in the chain).
So if you replace the first by the second and fChain points to a TChain with more than one TTree, you would end up reading multiple time the entries of only the first files (-/+ edge effects).

Cheers,
Philippe.

[quote=“pcanal”][quote]fChain->GetTree()->GetEntry(entry, getall)
in the function GetEntry instead of a simpler:
fChain->GetEntry(entry, getall)[/quote]So the two are not interchangeable. The definition of ‘entry’ is very different! In the first case the entry value is a number between 0 and the number of entries in the current tree (i.e. fChain->GetTree()->GetEntries()) while in the 2nd one the entry is a number between 0 and the number of entries in the chain (i.e. the sum of the number of entries in all the trees in the chain).
So if you replace the first by the second and fChain points to a TChain with more than one TTree, you would end up reading multiple time the entries of only the first files (-/+ edge effects).

Cheers,
Philippe.[/quote]

Yes, I know it. The point that I don’t understand is why proof is using the more complicated one

Hi,

The intent is to propagate (user) code that works in all cases (i.e. single tree, TChain and Proof).

Cheers,
Philippe.

[quote=“pcanal”]Hi,

The intent is to propagate (user) code that works in all cases (i.e. single tree, TChain and Proof).

Cheers,
Philippe.[/quote]

Exaclty, so why you don’t write TTree* fChain and next fChain->GetEntry(i) ?

[quote]Exaclty, so why you don’t write TTree* fChain and next fChain->GetEntry(i) ?[/quote]Without more context/more changes, this would be wrong (for the chain case) since ‘i’ is ‘entry number within the current TTree’, wouldn’t it not?

Philippe.

[quote=“pcanal”][quote]Exaclty, so why you don’t write TTree* fChain and next fChain->GetEntry(i) ?[/quote]Without more context/more changes, this would be wrong (for the chain case) since ‘i’ is ‘entry number within the current TTree’, wouldn’t it not?

Philippe.[/quote]

yes, probably this is the point, why here (inside TProofPlayer for example) i is the entry number of the current ttree and not the number of the entry in the full chain?

Hi,

An additional important is that in order to do partial read, the best way is to call branch->GetEntry which can only take the entry number within a TTree (i.e. in both the TTree and the TChain case), which lead to the value being passed to TSelector::Process needing to be the 'entry number within a TTree.

Cheers,
Philippe.