RE: [ROOT] How to separate tree friends

From: Philippe Canal (pcanal@fnal.gov)
Date: Thu Apr 15 2004 - 00:43:41 MEST


Hi Christian,

In your case the TFriendElements owns the TTree object (and the file)
and is deleted when RemoveFriend is called.

You will need to record the name of the TTree and the name of the
file before Removing the friendship from the previous tree.

Cheers,
Philippe.

-----Original Message-----
From: cstrato [mailto:cstrato@aon.at]
Sent: Wednesday, April 14, 2004 4:55 PM
To: Philippe Canal
Cc: Rene Brun; roottalk@pcroot.cern.ch
Subject: Re: [ROOT] How to separate tree friends


Dear Philippe,

I have tried to implement your suggestion in the attached
macro "macroFriends.C". Sorrowly, I get the following output:
root [0] .x macroFriends.C
------MyClass::MyClass------
------MyClass::CreateTrees------
------MyClass::CreateTrees------
------MyClass::AddTree------
------MyClass::AddTree------
------MyClass::AddTree------
------MyClass::AddTree------
------MyClass::AddTree------
------MyClass::AddTree------
------MyClass::AddTree------
------MyClass::AddTree------
------MyClass::MoveTree------
Error in <TMemberInspector::Streamer>: version id <=0 in ClassDef, dummy 
Streamer() called
Error in <TMemberInspector::Streamer>: version id <=0 in ClassDef, dummy 
Streamer() called
Error in <TMemberInspector::Streamer>: version id <=0 in ClassDef, dummy 
Streamer() called
------MyClass::GetTreeX------
nfriends(treeX) = 3
------MyClass::GetTreeY------

  *** Break *** bus error
Root > Function macroFriends() busy flag cleared
Function GetTreeY() busy flag cleared

Can you tell me, why I cannot add the selected trees to fTreeY?

Thank you in advance
Christian


Philippe Canal wrote:
> Hi Christian,
> 
> The TTree object has one list of friend and it always
> uses all the friends on the list.
> 
> However you can manipulate the list as you see fit after
> getting it from TTree::GetListOfFriends.
> 
> For example you could extract (Remove) from it, TreeA,
> TreeB, TreeC etc ... and add them to the list of friends
> of TTreeA.
> 
> Cheers,
> Philippe.
> 
> -----Original Message-----
> From: owner-roottalk@pcroot.cern.ch
> [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of cstrato
> Sent: Tuesday, April 13, 2004 1:00 PM
> To: Rene Brun
> Cc: roottalk@pcroot.cern.ch
> Subject: Re: [ROOT] How to separate tree friends
> 
> 
> Dear Rene
> 
> Thank you, but this is not what I want:
> I have a method:
>      myclass-AddTrees("treename", "filename", "group")
> where the user can add trees from different root files.
> These trees are stored as friends to the first tree fTree.
> 
> fTree is then passed to different methods, where I would
> like to separate these trees based on their "groups",
> and create e.g. two trees with friends for:
> "group1": fTree("Tree1") with friends Tree2, Tree3, Tree4
> "group2": atree("TreeA") with friends TreeB, TreeC
> (These separate tree groups are then again passed to
> different methods.)
> 
> Best regards
> Christian
> 
> 
> Rene Brun wrote:
> 
>>Hi Christian,
>>
>>As I am not sure to understand your question (or what you want to do),
>>I can only give a naive answer
>>
>>    fTree = (TTree*)gDirectory->Get("Tree1");
>>    fTree->AddFriend("Tree2", "file2.root");
>>    fTree->AddFriend("Tree3", "file3.root");
>>    fTree->AddFriend("Tree4", "file4.root");
>>
>>    aTree = (TTree*)gDirectory->Get("TreeA");
>>    aTree->AddFriend("TreeB", "fileB.root");
>>    aTree->AddFriend("TreeC", "fileC.root");
>>
>>Rene Brun
>>
>>
>>cstrato wrote:
>>
>>
>>>Dear Rooters
>>>
>>>Suppose that I have a tree with following friends:
>>>   fTree = (TTree*)gDirectory->Get("Tree1");
>>>   fTree->AddFriend("Tree2", "file2.root");
>>>   fTree->AddFriend("Tree3", "file3.root");
>>>   fTree->AddFriend("TreeA", "fileA.root");
>>>   fTree->AddFriend("Tree4", "file4.root");
>>>   fTree->AddFriend("TreeB", "fileB.root");
>>>   fTree->AddFriend("TreeC", "fileC.root");
>>>
>>>How can I separate fTree into the following two treefriends:
>>>1, fTree("Tree1") with friends Tree2, Tree3, Tree4
>>>2, aTree("TreeA") with friends TreeB, TreeC
>>>
>>>Thank you in advance for your help.
>>>
>>>Best regards
>>>Christian
>>>-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
>>>C.h.r.i.s.t.i.a.n. .S.t.r.a.t.o.w.a
>>>V.i.e.n.n.a.         .A.u.s.t.r.i.a
>>>-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-

> 
> 



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:07 MET