Operation: SetBranchAddress

Hi,

Also, am I missing a preferred method of doing this properly?

Yes :slight_smile:. Check the TTreeReader.

What I observe are the following:

This observation seems to match the expectation (the 3 point looks like CINT and should be improved in v6).

Is there a reason for this?

The two use cases for both are slightly different, but as importantly they were developed at different time. For example, the interface taking the address to pointer was first developed at a time when C++ template were not in usable state.

The leaflist list technique (the one where you pass the address of a struct) was developed first. The resulting branch is sub-optimal but predates the implementation of the split and was a convenient way to quickly create branch based on a existing set of variable, but however requires the use to specify (again) the list of variable and their type [and one has to be weary of variable alignment].

The syntax creating a branch from an object is newer and we needed at the time a way to share the ownership of the object between the TTree and the user, the only way (at the time) was via a pointer (whose address was passed as a void*). We improve greatly the syntax (using C++ template technique now implemented in compiler) to make the calls much more type safe (for example you can now pass an object when creating a branch and you no longer need to specify the type when creating the branch and SetBranchAddress can usually detect if you are passing it the wrong pointer type).

We still want to significantly improve the interface in TTree itself (and have to deal with backward compatibility). We also have introduced new interfaces that hides most of the complexity of setting the branch address, namely the TTreeReader (see the result of MakeSelector when run with v6.06).

Cheers,
Philippe.