CopyTree Documentation Misleading

In the documentation for CopyTree:

The examples pointed to are all called “copytree (1,2,3).C” but these do not use CopyTree and in fact use CloneTree and therefore without a selection. Searching the root/tutorials directory I find only one usage of this actually:

tutorials/tree/treefriend.C: TTree *TF = T->CopyTree(“z<10”);

It would perhaps be better to point to a relevant example or name them so. Whilst the doxygen description for the function is adequate, an example is crucial to see how to deal with the ROOT-style memory management.

The important note in the documentation points out that branch address are linked - fine. But does one need to do this or is this only in the case that you are setting branch address on a memory resident object? I want to skim a tree from one file to another new one copying all branches according to a selection. From the example in treefriend.C it looks like this isn’t relevant?

Is this done event by event or all selected events have to be memory-resident first, then written to file?

Cheers,
Laurie

Hi @bleu65,
sorry for the delay, we need @pcanal for this, let’s ping him.

Cheers,
Enrico

It is done event by event. For each event the same memory location will be use to stage the data (read, use in expression then write).

The important note in the documentation points out that branch address are linked - fine. But does one need to do this or is this only in the case that you are setting branch address on a memory resident object?

When a TTree is “CloneTree’d”, the original and the copy have their user-object/user-data/content-pointer linked. This is true both when the TTree is allocating the location or if the user does. i.e. the Branch’s address is be linked (i.e. the same for both TTree) whether you call SetBranchAddress or not.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.