RE: creating trees

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Mon, 06 Feb 2006 11:15:58 -0600


Hi Alexander,

Please re-read the chapter on Object Ownership in the User's guide. TTree, Histrogram and TEventList are by default owned by the TFile that was current when they were created or where they are read from.

In addition we made sure that we are not double deleting objects created on the Stack (TH1I h(...);).

Cheers,
Philippe

-----Original Message-----
From: Alexander Bürger [mailto:buerger_at_iskp.uni-bonn.de] Sent: Monday, February 06, 2006 6:56 AM
To: Philippe Canal; roottalk_at_pcroot.cern.ch Subject: Re: [ROOT] creating trees

Hi Philippe,

> void SetOutputFile( const char* filename )
> {
> if( fFile ) {
> fFile->Write();
> delete fFile;
> fFile = 0;
> fTree = 0;

This does not crash, but I do not understand: there should not be a "delete fTree"? Is this special for trees? If I create histograms on the stack there is no problem/segfault when the destructor is called (like {TFile x(..); TH1I h(..); h->Fill(..); x.Write();}).

Should there be a "fFile = fTree->GetCurrentFile()"?

> for( int i=0; i<100000; ++i ) {
> SetOutputFile( "fileXY.root" );
>
> I suppose this is an artefact of your sample code (this seems
> to overwrite the same file 100000 times).

Yes, this is just for the example. I wanted to make clear that I want many trees. In the actual program there are at most 600.

> In the default contructor of TreeEvent did you make sure to
> initialize __every__ data member of TreeEvent to a valid value?

Yes.

Thanks for your help,

Alexander Received on Mon Feb 06 2006 - 18:29:08 MET

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:57 MET