Hi Nicolas, Use TTree::CopyTree, not CopyAddresses TFile f("~/nico/PH176/Analyse/fl18_cd2_coinc_#5.root"); TTree *old = (TTree*) f.Get("h900"); TFile *newfile = new TFile("newfile.root","recreate"); TTree *newTree = old->CopyTree("myselection"); newTree->Write(); Rene Brun On Thu, 25 Apr 2002, Nicolas de Sereville wrote: > Dear Rooters, > > I have a TTree with 10 branches containing experimental datas. What I want > to do is to create another TTree with the same branches and perform a > selection within the data. > > I tried to use the CopyAdresses() method, but I failed : > > root [0] TFile f("~/nico/PH176/Analyse/fl18_cd2_coinc_#5.root") > root [1] TTree *old = (TTree*) f.Get("h900") > root [2] h900->Print() > ****************************************************************************** > *Tree :h900 : Coinc > * > *Entries : 16335 : Total = 730540 bytes File Size = > 469856 * > * : : Tree compression factor = 1.69 > * > ****************************************************************************** > *Br 0 :strip_le : > * > *Entries : 16335 : Total Size= 63992 bytes File Size = > 26187 * > *Baskets : 8 : Basket Size= 8000 bytes Compression= 2.44 > * > *............................................................................* > *Br 1 :Adc_leda : > * > *Entries : 16335 : Total Size= 63992 bytes File Size = > 34334 * > *Baskets : 8 : Basket Size= 8000 bytes Compression= 1.86 > * > *............................................................................* > *Br 2 :strip_la : > * > *Entries : 16335 : Total Size= 63992 bytes File Size = > 22936 * > *Baskets : 8 : Basket Size= 8000 bytes Compression= 2.79 > * > *............................................................................* > *Br 3 :Adc_lamp : > * > *Entries : 16335 : Total Size= 63992 bytes File Size = > 35032 * > *Baskets : 8 : Basket Size= 8000 bytes Compression= 1.83 > * > *............................................................................* > > > ...... more branches ........... > > > > root [4] TTree *new = new TTree("new", "new") > root [5] new->CopyAddresses(old) > root [6] new->Print() > ****************************************************************************** > *Tree :new : new > * > *Entries : 0 : Total = 0 bytes File Size = > 0 * > * : : Tree compression factor = 1.00 > * > ****************************************************************************** > > > So I am not abble to see the branches for the new TTree. > Is it a normal behavior or did I miss something?? > > I read the 2 tutorials copytree.C but in my case I'm not interested in > copying the whole tree or only a few branches. > > any hint is welcomed > > thanks > > Nicolas > > P.S : I'm using root 3.02/03 on RH7.2 > -- > :-------------------------------: > : Nicolas de SEREVILLE : > : C.S.N.S.M. : > : Batiment 104 : > : 91405 ORSAY Campus : > : Tel : (+ 33) (0)1 69 15 52 29 : > : Fax : (+ 33) (0)1 69 15 50 08 : > :-------------------------------: > >
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:51 MET