Re: removing objects from gDirectory without deleting them

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Mar 22 2000 - 09:05:47 MET


Hi Peter,
Victor has already posted the solution using TH1::SetDirectory(0).
Currently TH1 objects and TTree objects are automatically added (by
their constructors) to the list of objects in memory in the current
directory.
This has the advantage that histograms in particular can be
automatically
written to the file in one call.
We could provide a function to disable this feature. I see several
possibilities:
 1- gROOT->SetAutoAppend(Bool_t append=kTRUE);
    This will set a global switch for all directories
 2- gDirectory->SetAutoAppend(Bool_t append=kTRUE);
    apply only to the specified directory
 3- TH1::SetAutoAppend(Bool_t append=kTRUE);
    a static function in TH1.
    same in TTree.

My prefered solution would be 1. Please give me your suggestions.

Rene Brun

    
Peter Steinberg wrote:
> 
> Hello -
> 
> I have an object which creates a set of histograms with distinct
> names.  In order to let other users find these histograms by
> gROOT->FindObject(), I put them in the top ROOT directory by
> hand (gDirectory->Append(h), etc.) since I have disabled
> the automatic appending in my object.
> 
> However, my object owns these histograms; thus, I would like to be able to
> tell the gDirectory to "forget" them, without touching the object.
> This is not exactly what gDirectory->Delete() does, since this actually
> performs an object->Delete()...
> 
> Is there any way to do this?  I do not seem to see a "remove" method
> in TDirectory.
> 
> - Peter
> 
> --
> 
> ---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
> Dr. Peter A. Steinberg                        Brookhaven National Laboratory
> Assistant Scientist                                Bldg 555, Upton NY, 11973
> ---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
> Office: 631-344-4335                          mailto:Peter.Steinberg@bnl.gov
> Mobile: 917-549-3094                       http://www.rhic.bnl.gov/~steinber
> SMS:    9175493094@messaging.sprintpcs.com (<100 characters)
> ---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:21 MET