Re: AddFriend

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Sun, 24 Jan 2010 22:55:20 +0100


see documentation of TTree::AddFriend. You can specify the treename in TTree::Draw, eg

   // tree.AddFriend("ft1","friendfile1.root");
   // tree.AddFriend("ft2","friendfile2.root");
   // tree.Draw("var:ft1.v1:ft2.v2");
   // tree.Draw("var:ft1.var:ft2.var")

When your Trees have the same name, specify an alias using the special AddFriend function
TFriendElement* TTree::AddFriend(TTree* tree, const char* alias, Bool_t warn)

Rene Brun

Marc Escalier wrote:
> Dear roottalkers,
>
> I have a question from Henso, who is not yet subscribed to this forum
>
> Let's suppose we have two trees (tree0 and tree1) which have a same
> given variable name inside : "myvariable"
>
> how to do something like
>
> tree0->Draw("myvariable_from_tree0 - myvariable_from_tree1")
>
> and how to do something like :
>
> mydifference = tree0->GetValueOf n-th event of
> myvariable_from_tree0 - myvariable_from_tree0"
>
> AddFriend would be useful if the two tree would have different name of
> variables, but here, the variables have the same names
>
> (where myvariable is the same name in the two trees)
>
> thanks in advance for Henso
>
> ================
>>>>> TFile *f0 = new TFile("f0.root");
>>>>> TTree *tree0 = (TTree*)f0->Get("tree");
>>>>> TFile *f1 = new TFile("f1.root");
>>>>> TTree *tree1 = (TTree*)f1->Get("tree");
>>>>>
>>>>> // get variable pt of tree0 and keep it in float pt0
>>>>> // get variable pt of tree0 and keep it in float pt1
>>>>> //we wish :
>>>>> // pt0 - pt1 .
>>>>>
>>>>> }
>
Received on Sun Jan 24 2010 - 22:55:26 CET

This archive was generated by hypermail 2.2.0 : Mon Jan 25 2010 - 17:50:01 CET