RE: [ROOT] closing TTree files

From: Philippe Canal (pcanal@fnal.gov)
Date: Fri Jul 18 2003 - 00:25:42 MEST


Hi John,

It all depends on how you allocated the TFile containing the TTree.

A guess would be that you should replace
	fChain->Delete();
by
	delete fChain;

You may also have to do:
	if (fChain) delete fChain->GetCurrentFile();

But both are wild guesses :) ... The bottom line is that you have to insure
that the 'owner' of the file of the tree closes and delete its file.

Cheers,
Philippe.

-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Dr. John Krane
Sent: Thursday, July 17, 2003 4:36 PM
To: roottalk@pcroot.cern.ch
Subject: [ROOT] closing TTree files


Hi,

I want to open a Tree, loop over it creating histograms, close the histo
file, close the Tree.  Without leaving Root, I want to repeat the entire
process with a different Tree and make a separate histo file.

I have most of what I need I think, but I don't know how to close the
Tree when I'm done with it.  I do:

    // Write histos to disk.  Close all files.
    histofile->Write();
    histofile->Close();
    delete histofile;

    fChain->Delete();

And this works as I expect with the histofile but not with the Tree.  I
get through my loop twice and then seg fault.  When I check the
TBrowser, I see both the first and second trees in there, which would
cause a seg fault in my code all right.  Can anybody tell me how to get
rid of the first Tree?

	- John


#################################################################
#################################################################
#################################################################
#####
#####
#####
#################################################################
#################################################################
#################################################################



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:13 MET