Re: clone tree

Rene Brun (Rene.Brun@cern.ch)
Fri, 19 Jun 1998 15:36:11 +0200


Ren=E9 Scholte wrote:
> =

> Hello ROOTERS,
> =

> I want to make a copy of a tree, and want this new tree to be filled wi=
th a
> number of last events from the original tree.
> =

> Now, as I understand it, the CloneTree(nevents) - function makes a clon=
e of
> a tree (structure) and then fills this new tree with events starting fr=
om
> zero to nevents.
> Is this true ?
> =

> If so, how can I clone the tree and fill it with a number of last event=
s ?

This one is easy. do

TTree *newTree =3D oldTree->CloneTree(0);
Int_t nentries =3D oldTree->GetEntries();
for (Int_t i=3Dnentries-1000;i<nentries;i++) { //to copy last 1000
oldTree->GetEvent(i);
newTree->Fill();
}

Rene Brun