Re: [ROOT] writing ntuple to root file

From: Rene Brun (Rene.Brun@cern.ch)
Date: Sat Jun 29 2002 - 15:48:42 MEST


Ed,

I do not understand this problem. Coiuld you send me a complete
test example?

Rene Brun

On Fri, 28 Jun 2002, Ed Oltman wrote:

> Hello,
> 
> I am getting some Error messages when I write an TNtuple to a root file that
> I
> don't understand.   The good news is that the write operation works.
> However, I suspect that I am missing something important here.
> 
> Here is what I do:
> 
>     TFile *f = new TFile("c:\\root\\ap.root");
>     TNtuple *pIn = (TNtuple *)f->Get("pntup");
>              .
>              .
>              .
>     TNtuple *pOut = new TNtuple("pOut","x:y:z:a");
>     pOut->SetDirectroy(0);	// keep ntuple "memory resident"
>              .
>            use pIn data to populate pOut ntuple
>              .
> 
>     At some point, I decide to save pOut.  This is what I do:
> 
>     TDirectory *pSave = gDirectory;
>     gDirectory->pwd();
>     TFile *pF = new TFile("fft0600_0600.root","RECREATE");
>     gDirectory->pwd();
>     TNtuple *pClone = (TNtuple *)pOut->CloneTree();
>     pClone->Write();
>     pF->Close();
>     delete pF;
>     gDirectory = pSave;
>     gDirectory->pwd();
> 
> and here is the output I get when I execute save-to-file code:
> 
> c:\root\ap.root:/
> fft0600_0600.root:/
> Error in <TBranch::Write>: File c:\root\ap.root is not writable
> Error in <TBranch::Write>: File c:\root\ap.root is not writable
> Error in <TBranch::Write>: File c:\root\ap.root is not writable
> Error in <TBranch::Write>: File c:\root\ap.root is not writable
> c:\root\ap.root:/
> 
> It is true that c:\root\ap.root is not writable, but why do I get this
> error?
> When I later try to open fft0600_0600.root, I can read the ntuple withoug
> problem.
> 
> 
> Thanks,
> 
> Ed Oltman
> 
> 



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