Hi,
Where do you find the copied Tree to be written? If you want is loaded in memory do:
    f = new TFile("test.root"); // This opens a read-only file
    tree = (TTree*)(f->FindObjectAny("tree"));  // *
    gROOT->cd();
    TTree* tr = tree->CopyTree("");
Otherwise do:
    f = new TFile("test.root"); // *
    tree = (TTree*)(f->FindObjectAny("tree"));  // *
    TFile *output = new TFile("copy.root","RECREATE");
    TTree* tr = tree->CopyTree("");   
Cheers,
Philippe.
-----Original Message-----
From: owner-roottalk_at_pcroot.cern.ch [mailto:owner-roottalk_at_pcroot.cern.ch]
On Behalf Of Hajo Molegraaf
Sent: Monday, April 03, 2006 11:56 AM
To: roottalk_at_pcroot.cern.ch
Subject: [ROOT] TTree::CopyTree problem
Hi,
Sorry to bug you again, but I get errors with the following macro:
{
    TFile* f = new TFile("test.root","RECREATE");
    TTree* tree = new TTree("tree","some tree");
    double line;
    tree->Branch("line",&line,"line/D");
    for( int i = 0; i < 10000; ++i )
    {
        line = i;
        tree->Fill();
Several times I get the message:
Error in <TTree::Fill>: Failed filling branch:tree.line, nbytes=-1
If I fill the tree with fewer points (say 1000), there is no problem. With 
more points the error shows more often.
If I delete the lines marked with // *, then there is no problem for any 
tree size.
I'm using root Version 5.11/01 3 March 2006 CINT/ROOT C/C++ Interpreter version 5.16.10, March 30, 2006
Thanks,
Hajo Molegraaf.
This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:58 MET