RE: TTree::CopyTree problem

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Mon, 03 Apr 2006 12:31:46 -0500


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();

    }
    tree->Write(); // *
    f->Close(); // *
    f = new TFile("test.root"); // *
    tree = (TTree*)(f->FindObjectAny("tree")); // *     TTree* tr = tree->CopyTree("");
}

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.



Speel online games via MSN Messenger
http://www1.imagine-msn.com/Messenger/Default2.aspx Received on Mon Apr 03 2006 - 19:37:55 MEST

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:58 MET