[ROOT] How do I copy an ntuple into a file

From: Ed Oltman (eoltman@imago.com)
Date: Fri Jan 18 2002 - 00:23:53 MET


Hi,
  I am having trouble writing an TNtuple object that lives in one directory
to a new file.  For example,
using the hsimple.root file made by the hsimple.c macro in  tutorials:

      TFile *file1 = new TFile("hsimple.root");
      TFile *file2 = new TFile("new.root","RECREATE");
      TNtuple *pNtup = (TNtuple *)file1->Get("ntuple");
      pNtup->SetDirectory(file2);
      file2->Write();

 I get the following error (5 times) on file2->Write()

Error in <TBranch::Write>: File hsimple.root is not writeable

Why is that?


meanwhile,

      file2->ls()

shows

TFile**           new.root
 TFile*           new.root
   OBJ: TNtuple   ntuple   Demo ntuple  : 0
   KEY: TNtuple   ntuple;1         Demo ntuples

When I start a new root session and type

	TFile *file = new TFile("new.root");
      file->ls()

It shows:

TFile**           new.root
 TFile*           new.root
   KEY: TNtuple   ntuple;1         Demo ntuples

however, when I try to do something (e.g. ntuple->Draw("px")

I get a huge number of following:

Error in <TFile::ReadBiuffer>: error reading all requested bytes from file
new.root, got 0 of 29594


What am I doing wrong???  I am using version 3.02/07 on Windows 2000.

Thanks!


Ed Oltman



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:38 MET