Skip to content
Snippets Groups Projects
Commit 3fbe3b84 authored by Rene Brun's avatar Rene Brun
Browse files

From Philippe;

This patch adds support in the new tree cloning scheme for
        TTree *clone = chain->GetTree()->CloneTree(0);
If chain is really a TChain, need to make sure that it keeps track of the clones even when the tree that was
actually cloned is deleted by LoadTree.


git-svn-id: http://root.cern.ch/svn/root/trunk@6848 27541ba8-7e3a-0410-8455-c3a389f83636
parent 871f7008
No related branches found
No related tags found
No related merge requests found
// @(#)root/tree:$Name: $:$Id: TTree.h,v 1.47 2003/06/30 15:45:52 brun Exp $ // @(#)root/tree:$Name: $:$Id: TTree.h,v 1.48 2003/07/04 13:27:35 brun Exp $
// Author: Rene Brun 12/01/96 // Author: Rene Brun 12/01/96
/************************************************************************* /*************************************************************************
...@@ -201,6 +201,7 @@ public: ...@@ -201,6 +201,7 @@ public:
virtual Double_t *GetIndexValues() {return &fIndexValues.fArray[0];} virtual Double_t *GetIndexValues() {return &fIndexValues.fArray[0];}
virtual TIterator*GetIteratorOnAllLeaves(Bool_t dir = kIterForward); virtual TIterator*GetIteratorOnAllLeaves(Bool_t dir = kIterForward);
virtual TLeaf *GetLeaf(const char *name); virtual TLeaf *GetLeaf(const char *name);
virtual TList *GetListOfClones() { return fClones; }
virtual TObjArray *GetListOfBranches() {return &fBranches;} virtual TObjArray *GetListOfBranches() {return &fBranches;}
virtual TObjArray *GetListOfLeaves() {return &fLeaves;} virtual TObjArray *GetListOfLeaves() {return &fLeaves;}
virtual TList *GetListOfFriends() const {return fFriends;} virtual TList *GetListOfFriends() const {return fFriends;}
......
// @(#)root/tree:$Name: $:$Id: TChain.cxx,v 1.71 2003/07/06 19:41:49 brun Exp $ // @(#)root/tree:$Name: $:$Id: TChain.cxx,v 1.72 2003/07/06 19:44:31 brun Exp $
// Author: Rene Brun 03/02/97 // Author: Rene Brun 03/02/97
/************************************************************************* /*************************************************************************
...@@ -750,6 +750,19 @@ Int_t TChain::LoadTree(Int_t entry) ...@@ -750,6 +750,19 @@ Int_t TChain::LoadTree(Int_t entry)
return fReadEntry; return fReadEntry;
} }
// If the tree has some clone, let migrate them into the chain so we can
// continue to keep track of it. This is to support the syntax:
// clone = (TTree*)chain->GetTree()->CloneTree(0)
if (fTree && fTree->GetListOfClones()) {
TObjLink *lnk = fTree->GetListOfClones()->FirstLink();
while (lnk) {
TTree *clone = (TTree*)lnk->GetObject();
AddClone(clone);
lnk = lnk->Next();
}
fTree->GetListOfClones()->Clear();
}
//Delete current tree and connect new tree //Delete current tree and connect new tree
TDirectory *cursav = gDirectory; TDirectory *cursav = gDirectory;
//delete file unless the file owns this chain !! //delete file unless the file owns this chain !!
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment