Re: [ROOT] copying chains

From: Thomas Hadig (hadig@SLAC.stanford.edu)
Date: Fri Aug 01 2003 - 00:47:44 MEST


Hi Philippe,

the newest I have available is 30505.
With this, the same problem:

kangaroo:inter 91> root -l combined.root 
root [0] 
Attaching file combined.root...
root [1] combined->ls()
TFile**         combined.root
 TFile*         combined.root
  KEY: TChain   main_scan;1
  KEY: TChain   calib_scan;1
root [2] main_scan->ls()
../inter/inter_file_date20021220_time202236.root tree:main_scan entries=1234567890
../inter/inter_file_date20021220_time234757.root tree:main_scan entries=1234567890
../inter/inter_file_date20021221_time31202.root tree:main_scan entries=1234567890
../inter/inter_file_date20021221_time63637.root tree:main_scan entries=1234567890
root [3] .q
kangaroo:inter 92> ls -altr inter_file_date2002122*[0-9].root full.root
-rw-rw-r--    1 mayankj  eb       48175034 May  9 00:43 inter_file_date20021220_time202236.root
-rw-rw-r--    1 mayankj  eb       41354484 May  9 01:48 inter_file_date20021220_time234757.root
-rw-rw-r--    1 mayankj  eb       45693757 May  9 02:53 inter_file_date20021221_time31202.root
-rw-rw-r--    1 mayankj  eb       49808619 May  9 03:58 inter_file_date20021221_time63637.root
-rw-r--r--    1 hadig    eb       392138752 Jul 31 15:44 full.root

using the following program:

komodo:inter 58> cat copy_tree.C 
#include <TROOT.h>
#include <TFile.h>
#include <TTree.h>

#include "main_scan.C"
#include "calib_scan.C"

main()
{ 
 TROOT root("a","a");

 TFile *oldfile = new TFile("combined.root");

 TTree *oldtreemain  = (TTree*)oldfile->Get("main_scan");
 TTree *oldtreecalib = (TTree*)oldfile->Get("calib_scan");

 main_scan  *bufmain  = new main_scan (oldtreemain);
 calib_scan *bufcalib = new calib_scan(oldtreecalib);
 oldtreemain ->SetBranchStatus("*",1);
 oldtreecalib->SetBranchStatus("*",1);

 TFile *newfile = new TFile("full.root","RECREATE");
 TTree *newtreemain  = oldtreemain ->CloneTree();
 //TTree *newtreemain  = oldtreemain ->CloneTree(0);
 //TTree *newtreecalib = oldtreecalib->CloneTree(0);

 //newtreemain ->CopyEntries(oldtreemain );
 //newtreecalib->CopyEntries(oldtreecalib);

 newfile->Write();
 newfile->Close();
 oldfile->Close();
}

The commented version works, this one I killed when the 
output file full.root got more than twice as big as it should.

I hope that we can get 30507 here at SLAC soon, so that I can test it.

Ciao
Thomas

> Hi Thomas,
> 
> > I also noticed that the number of entries in an
> >   oldtree->ls()
> > seems to be wrong for the second (and all following) files:
> 
> The number of entries 1234567890 indicates that the real number of entries
> are not yet been loaded in memory.  This should not be a problem.
> 
> > I did find some bug fixes mentioned in the release notes but I don't think
> > that any of those mentioned this problem specifically.
> 
> Nonetheless, please re-try with 3.05/07, the consequence of the bugs that
> were fixed are usually 'random' behavior.
> 
> Cheers,
> Philippe.
> 
> -----Original Message-----
> From: owner-roottalk@pcroot.cern.ch
> [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Thomas Hadig
> Sent: Thursday, July 31, 2003 3:59 PM
> To: roottalk@pcroot.cern.ch
> Subject: [ROOT] copying chains
> 
> 
> Hi all,
> 
> I just tried to copy a tree from a chain of files into a single file.
> I used the code
>   TTree *newtree = oldtree->CloneTree();
> in
> http://root.cern.ch/root/html/examples/copytree.C.html
> with ROOT Version 3.05/02 on Linux (RedHat 7.3).
> 
> Using one file or a chain with one file seems to work fine but
> for a chain of more than one file, the writing never ends.
> 
> Using the method in
> http://root.cern.ch/root/html/examples/copytree2.C.html
> with
>   TTree *newtree = oldtree->CloneTree(0);
>   newtree->CopyEntries(oldtree);
> seems to work for all cases.
> 
> I also noticed that the number of entries in an
>   oldtree->ls()
> seems to be wrong for the second (and all following) files:
> inter_file_date20030728_time120505.root tree:main_scan entries=571
> inter_file_date20030728_time174104.root tree:main_scan entries=1234567890
> inter_file_date20030728_time192411.root tree:main_scan entries=1234567890
> ....
> 
> If CloneTree uses this number, I am no longer astonished that the
> copying never ends ....
> 
> I did find some bug fixes mentioned in the release notes but I don't think
> that any of those mentioned this problem specifically.
> 
> Ciao
> Thomas
> 
> ----------------------------------------------------------------------------
> Thomas Hadig            MS 62, 2575 Sand Hill Road, Menlo Park CA 94025, USA
>        hadig@stanford.edu                              Tel.: +1 650 926 2810
>        http://www.slac.stanford.edu/~hadig/
> ----------------------------------------------------------------------------
>     In a world without walls and fences, who needs windows and gates ?
> ----------------------------------------------------------------------------

Ciao
Thomas

----------------------------------------------------------------------------
Thomas Hadig            MS 62, 2575 Sand Hill Road, Menlo Park CA 94025, USA
       hadig@stanford.edu                              Tel.: +1 650 926 2810
       http://www.slac.stanford.edu/~hadig/ 
----------------------------------------------------------------------------
    In a world without walls and fences, who needs windows and gates ?
----------------------------------------------------------------------------



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:14 MET