Re: TStrings

Rene Brun (Rene.Brun@cern.ch)
Tue, 25 Aug 1998 08:44:14 +0200


Wouter Hulsbergen wrote:
>
> Dear developpers,
>
> Two questions:
> A. For some reason it was decided that every TH1 object must have a
> unique name. Why ? It is quite inconvenient, as one always needs to
> make up a new name, even when a histogram exists only temproary.
> B. All TH1 constructors have `Text_t*' arguments for name and title.
> Unfortunately TString.Data() returns a `const char*'. Consequently, I
> cannot use a TString for name and title, unless I first copy it into a
> non-const char*. (At least, this is so for TProfile). Why not replace all
> `Text_t*' in TH1 with `const Text_t*'? (Or by TStrings..!)
>

By default TH1, TProfile and TTree objects are inserted by their
constructors in the list of objects in memory associated to the
current directory/file. When the objects are introduced in the list,
a check is made for a unique name in the list.
This feature allows in an interactive session to draw an histogram
by name (CINT automatically creates a pointer with the same name).
You can disable this feature if after having created the object,
you set his directory pointer to 0. Example
TH1F *h1 = new TH1F("h1",...
h1->SetDirectory(0);

In the version coming this week (2.00/11), we have already cleaned most
calls including Text_t and Option_t. The complete list of changes
is included in the version news.

Concerning your problem with TString.Data(), you can always cast
the parameter to a char*.

Rene Brun