Hi Ed,
Instead of
> if (fNtCorr)
> ....
> gDirectory->Write();
You might be able to just do:
fNtCorr->Write();
The gDirectory->Write(); might have some weird side effect where
it might try to rewrite the current key (the one for the CAnalysis
object) while in the myst of it. [And any it seems to save a copy :)]
Cheers,
Philippe.
-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Ed Oltman
Sent: Wednesday, March 06, 2002 3:58 PM
To: Philippe Canal; Roottalk@Pcroot. Cern. Ch
Subject: RE: [ROOT] R__unzip error
Philippe,
Thank you for the TTree::SetDirectory(0) tip!
On the second point: the ntuple is saved only once. CAnalysis
has a pointer, fNtCorr, to the ntuple. I modified the rootcint
generated CAnalysis::Streamer() to save the ntuple - thats what
the code I included was. I did this so that CAnalysis::Write()
would save CAnalysis would save everything. [I also modified
CAnalysis::Streamer() so that (CAnalysis *)file->Get("CAnalysis")
would read in the ntupe]
The puzzling thing is that CAnalysis is much smaller than 16MB
On output CAnalysis::Streamer() successfully wrote out the ntuple,
but evidently not itself.
Any more hints would are greatly appreciated.
Meanwhile, I will look into TRef to see if it will do what I need..
Thanks,
Ed
>
> Hi Ed,
>
> Currently the maximum size for a buffer to be compressed is 16Mb.
> In practice this means no single object can use more than that.
>
> If I am guessing correctly, your intend is to be able to
> analyze the ntuple in memory (since you have enough) space and
> then write it in one zip on the file.
>
> > when it is created, the current directory is not writable.
> > [this is the only way I know how to make an ntuple memory resident]
>
> the following:
> mytree = new TTree(...); (or TNtuple)
> mytree->SetDirectory(0);
> will have the same effect.
>
> > Note2: I can succesfully read the the ntuple from the root file:
>
> Since your ntuple is already properly saved on the file, I recommend
> to not save it a second time inside your CAnalysis object (is that
> really what you doing or am I missing something).
>
> Also, If you wish to have a convenient 'pointer' to the TNtuple from
> within the saved CAnalysis, you should consider using a TRef (i.e.
> the CAnalysis object contains a TRef that reference the TNtuple).
>
> Cheers,
> Philippe.
>
> -----Original Message-----
> From: owner-roottalk@pcroot.cern.ch
> [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Ed Oltman
> Sent: Tuesday, March 05, 2002 11:25 AM
> To: Roottalk@Pcroot. Cern. Ch
> Subject: [ROOT] R__unzip error
>
>
> Hello,
> I encounter the following error when reading a (user) object
> derived from
> TObject from a root
> file:
>
> R__unzip: error in header
> [ the header words checked are 0,9,0 instead of 67,83,8]
>
> My object CAnalysis contains a pointer to TNtuple - I modified
> CAnalysis::Streamer() (see below)
> to save the TNtuple when the object is saved and restore the pointer when
> the object is read in.
> Note: the above error only occurs when the TNtuple is large (I have not
> characterized the exact
> size which triggers the problem - 10's of MB does not cause a
> proble, 100's
> of MB does I have 1GB
> of ram)
>
> Here's the modification of the CAnalysis::Streamer() for OUTPUT (
> CAnalysis::Streamer was
> never called on input - the R__unzip error occured in
> TKey::ReadObj() before
> the streamer is
> called - fNtCorr is a pointer to TNtuple member variable
>
> .
> .
> .
> R__b << (TObject*)fVoltProf;
> R__b << (TObject*)fTofMap;
> R__b.SetByteCount(R__c, kTRUE);
> if (fNtCorr)
> {
> TNtuple *pNcopy = new
> TNtuple("ntCorr",fPchTitle,kNTCORR);
> for(int i=0;i<fNtCorr->GetEntries();i++)
> {
> fNtCorr->GetEntry(i);
> Float_t *args = fNtCorr->GetArgs();
> pNcopy->Fill(args);
> }
> }
> gDirectory->Write();
> }
>
> Note1: fNtCorr is MEMORY RESIDENT - that is, when it is created,
> the current
> directory is
> not writable. [this is the only way I know how to make an ntuple memory
> resident]
>
> Note2: I can succesfully read the the ntuple from the root file:
> TFile *f = new TFile("save.root");
> TNtuple *pNtup = (TNtuple *)f->Get("ntCorr"); //ok
>
> I just can't read CAnalysis
>
> CAnalysis *pAn = (CAnalysis *)f->Get("CAnalysis") // R__unzip error in
> header
>
>
> I am using 3.02/07 for Win32, my code compiled win VC++ version 6
>
> Any help would be greatly appreciated...
>
> Ed
>
>
>
>
>
>
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:44 MET