AddFriend with MakeSelector?

Hi, my plan is to add a number of branches from one tree to another.

I can do this quite laboriously by updating the file with the new branches written.

However, the AddFriend method seems to be preferable. Would it be possible to use this in conjunction with the MakeSelector class, i.e. to condition entries in the file dependent on the added branches? If so a few lines of code as an example would be great.

Cheers, Ben.

The MakeSelector generates code only for one Tree, not for its friend. However, you can call MakeSelector for each Tree and in the code generated for your main Tree declare friend a Tree with the code generated in another file.


Hi Rene, thankyou for the quick reply. The trees in question are the raw and the treated, but have the same event number.

It would not be possible to use the same makeselector on both trees as the selector uses conditions that are applied on the treated data.

It seems I will have to physically add the branches.

Thanks anyway, Ben.


You misunderstood my recommendation. I was proposing to generate a different file/selector for each Tree (2 different classes).


Hi Rene,
Could you specify more how to do this with MakeSelector? I manage to do this with MakeClass, generating classes for both trees and then I followed some prescriptions on this forum (without making them friends). But in class generated with MakeSelector where should I make the other tree a friend?


In the MakeSelector you should call the 2nd selector’s Init method from the first selector Init. You should setup the 2nd selector either in the constructor or in the SlaveBegin of the first selector.


Thanks for reply!
Could you be anyway more specific, how to do this?