Rene,
Here is a complete(ly contrived) test example that displays the error
messages from my previous post. hsimple is from the tutorials. Note: I
call pOut->SetDirectory(0) for 2 reasons: (1)to force the ntuple to be
memory resident - my app generates ntuples that hundreds of MB and
performance is much better if ntuple is memory resident, and (2)when pOut
reaches a certian size, it tries to write it to the current directory which
is opened for read access only.
{
TFile *f = new TFile("hsimple.root");
TNtuple *pIn = (TNtuple *)f->Get("ntuple");
TNtuple *pOut = new TNtuple("pOut","test","a:b:x");
pOut->SetDirectory(0);
for(int i=0;i<pIn->GetEntries();i++)
{
pIn->GetEntry(i);
Float_t *p = pIn->GetArgs();
Float_t a = p[0]*p[1];
Float_t b = p[1]*p[2];
Float_t c = p[2]*p[3];
pOut->Fill(a,b,c);
}
// In my application, following gets called only after I've examined
// pOut and decided I want to save it.
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();
}
I am running root v3.02/07 on Windows 2k. Thank you for your attention.
Ed
>
> 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