Hi Frank, Before calling CopyEntries, you must also call CopyAddresses. See example of logic in TTree::CloneTree. Rene Brun On Wed, 28 Apr 2004, Frank Winklmeier wrote: > Hi, > > I am trying to copy a bunch of entries from one TTree to another tree. The > two trees are not identical in the sense that they are cloned, but they > are created by the same program and do have exactly the same branch > structure. Both trees have 100 entries. I clone the first tree and then > copy all the entries of the second tree into that cloned tree. If I look > at the result, the tree has 200 entries as expected, but all entries from > 100-199 are just a pure copy of the last entry (row 99) from the first > tree. > > Is that problem due to the fact that the two trees are not clones of each > other? What other way does exist to do this? > > Thanks a lot, > Frank > > > Here is the dump of what I did: > > > root [0] TFile f1("tree1.root") > root [1] TFile f2("tree2.root") > root [3] TTree *t1 = (TTree*)f1.Get("xtree0") > root [4] TTree *t2 = (TTree*)f2.Get("xtree0") > root [10] TTree *t = t1.CloneTree() > root [13] t->CopyEntries(t2) > > > root [27] t1.Scan("event:runNumber:m0Pi0") > ************************************************ > * Row * event * runNumber * m0Pi0 * > ************************************************ > * 0 * 9 * 2001390 * 0.1335917 * > * 1 * 9 * 2001390 * 0.1256038 * > * 2 * 9 * 2001390 * 0.1335917 * > * 3 * 9 * 2001390 * 0.1256038 * > * 4 * 23 * 2001390 * 0.1468004 * > * 5 * 23 * 2001390 * 0.1468004 * > * 6 * 51 * 2001390 * 0.1362163 * > * 7 * 51 * 2001390 * 0.1362163 * > * 8 * 51 * 2001390 * 0.1356228 * > * 9 * 51 * 2001390 * 0.1345639 * > * 10 * 51 * 2001390 * 0.1345639 * > * 11 * 51 * 2001390 * 0.1385371 * > * 12 * 51 * 2001390 * 0.1371339 * > * 13 * 51 * 2001390 * 0.1362163 * > * 14 * 51 * 2001390 * 0.1362163 * > * 15 * 51 * 2001390 * 0.1356228 * > * 16 * 51 * 2001390 * 0.1345639 * > * 17 * 51 * 2001390 * 0.1345639 * > [...] > * 87 * 57 * 2001390 * 0.1214628 * > * 88 * 57 * 2001390 * 0.1445160 * > * 89 * 57 * 2001390 * 0.1413400 * > * 90 * 57 * 2001390 * 0.1165381 * > * 91 * 57 * 2001390 * 0.1186514 * > * 92 * 57 * 2001390 * 0.1197978 * > * 93 * 57 * 2001390 * 0.1495328 * > * 94 * 57 * 2001390 * 0.1340009 * > * 95 * 57 * 2001390 * 0.1446459 * > * 96 * 57 * 2001390 * 0.1280189 * > * 97 * 57 * 2001390 * 0.1156140 * > * 98 * 57 * 2001390 * 0.1295630 * > * 99 * 57 * 2001390 * 0.1490336 * > Type <CR> to continue or q to quit ==> > ************************************************ > (Int_t)100 > > > root [28] t2.Scan("event:runNumber:m0Pi0") > ************************************************ > * Row * event * runNumber * m0Pi0 * > ************************************************ > * 0 * 1 * 3108727 * 0.1276106 * > * 1 * 1 * 3108727 * 0.1447114 * > * 2 * 1 * 3108727 * 0.1456810 * > * 3 * 1 * 3108727 * 0.1407276 * > * 4 * 1 * 3108727 * 0.1185576 * > * 5 * 1 * 3108727 * 0.1172628 * > * 6 * 1 * 3108727 * 0.1307614 * > * 7 * 1 * 3108727 * 0.1276106 * > * 8 * 1 * 3108727 * 0.1447114 * > * 9 * 1 * 3108727 * 0.1456810 * > * 10 * 1 * 3108727 * 0.1407276 * > * 11 * 1 * 3108727 * 0.1315951 * > * 12 * 1 * 3108727 * 0.1176189 * > * 13 * 1 * 3108727 * 0.1307017 * > * 14 * 1 * 3108727 * 0.1185576 * > * 15 * 1 * 3108727 * 0.1172628 * > * 16 * 1 * 3108727 * 0.1307614 * > * 17 * 1 * 3108727 * 0.1276106 * > * 18 * 1 * 3108727 * 0.1315951 * > * 19 * 1 * 3108727 * 0.1176189 * > * 20 * 1 * 3108727 * 0.1307017 * > [...] > * 88 * 3 * 3108727 * 0.1259598 * > * 89 * 3 * 3108727 * 0.1259598 * > * 90 * 3 * 3108727 * 0.1259598 * > * 91 * 3 * 3108727 * 0.1327762 * > * 92 * 3 * 3108727 * 0.1218557 * > * 93 * 3 * 3108727 * 0.1459794 * > * 94 * 3 * 3108727 * 0.1330480 * > * 95 * 3 * 3108727 * 0.1344597 * > * 96 * 3 * 3108727 * 0.1311320 * > * 97 * 3 * 3108727 * 0.1332011 * > * 98 * 3 * 3108727 * 0.1438569 * > * 99 * 3 * 3108727 * 0.1477233 * > Type <CR> to continue or q to quit ==> > ************************************************ > (Int_t)100 > > > root [31] t.Scan("event:runNumber:m0Pi0") > ************************************************ > * Row * event * runNumber * m0Pi0 * > ************************************************ > * 0 * 9 * 2001390 * 0.1335917 * > * 1 * 9 * 2001390 * 0.1256038 * > * 2 * 9 * 2001390 * 0.1335917 * > * 3 * 9 * 2001390 * 0.1256038 * > * 4 * 23 * 2001390 * 0.1468004 * > * 5 * 23 * 2001390 * 0.1468004 * > * 6 * 51 * 2001390 * 0.1362163 * > * 7 * 51 * 2001390 * 0.1362163 * > * 8 * 51 * 2001390 * 0.1356228 * > * 9 * 51 * 2001390 * 0.1345639 * > * 10 * 51 * 2001390 * 0.1345639 * > * 11 * 51 * 2001390 * 0.1385371 * > * 12 * 51 * 2001390 * 0.1371339 * > * 13 * 51 * 2001390 * 0.1362163 * > * 14 * 51 * 2001390 * 0.1362163 * > * 15 * 51 * 2001390 * 0.1356228 * > * 16 * 51 * 2001390 * 0.1345639 * > [...] > * 95 * 57 * 2001390 * 0.1446459 * > * 96 * 57 * 2001390 * 0.1280189 * > * 97 * 57 * 2001390 * 0.1156140 * > * 98 * 57 * 2001390 * 0.1295630 * > * 99 * 57 * 2001390 * 0.1490336 * > Type <CR> to continue or q to quit ==> > * 100 * 57 * 2001390 * 0.1490336 * > * 101 * 57 * 2001390 * 0.1490336 * > * 102 * 57 * 2001390 * 0.1490336 * > * 103 * 57 * 2001390 * 0.1490336 * > * 104 * 57 * 2001390 * 0.1490336 * > * 105 * 57 * 2001390 * 0.1490336 * > [...] > * 195 * 57 * 2001390 * 0.1490336 * > * 196 * 57 * 2001390 * 0.1490336 * > * 197 * 57 * 2001390 * 0.1490336 * > * 198 * 57 * 2001390 * 0.1490336 * > * 199 * 57 * 2001390 * 0.1490336 * > Type <CR> to continue or q to quit ==> > ************************************************ > (Int_t)200 > > >
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:07 MET