Adding classname afterwards to a branch


We have a certain number of files containing trees which were produced using a few calls to Branch(name, address, leaflist), ie simple data mode.

How could one apply some methods on these branches (eg as summing of an array) and use them in a TTree:Draw, without recreating everything ?

Is there a way for exemple to give a classname ?

Merci d’avance.

Vincent Boudry.


You can use the skeleton produced using TTree::MakeSelector (or TTree::MakeClass).

In TTree::Draw you can also call a method that takes numerical
arguments and return numerical arguments. For example:


Thank you for your answer,

I do use the MakeClass, my point was more to have a practical use of the Draw call for interactive building work.

Concerning the code:

As far as I can deduce, the branch variable is in effect an alias of the first variable in that branch. Is that true ?

Can I then assume that the all the elements of the branch are contiguous in memory ?

best regards, Vincent.

This is absolutely correct.

Not in this context. In the memory allocated by the branches for its data, the elements are usually contiguous in memory. When TTree::Draw calls a sub-functions, it sends a copy of the numerical value (and the rest of the data is NOT contiguous with that temporary).