Re: comment in file

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Thu, 21 Jun 2007 12:27:16 +0200


Nicolas,

This functionality is already in ROOT without creating an additional object, eg
  TFile hfile("hsimple.root","RECREATE","Demo ROOT file with histograms"); see doc of TFile.

Rene Brun

Nicolas Produit wrote:
> Hi,
>
> I want to put a string in each TFile I create to describe what the
> file is about.
> I want that it should be simple for the user to retrieve it and print
> it just using plain root simple command line.
> I see that I cannot just stream out a TString as it does not derive from
> TObject. In fact I need something derived from a TNamed as I want
> this explanation to have a constant obvious name in every file.
>
> I see that I can use a TNamed achieving what I want:
> a=new TFile("test.root","recreate");
> t=new TNamed("comment","here is my very long comment\nthat can even
> span many lines");
> t->Write();
> delete a;
> a=new TFile("test.root");
> cout<<a->Get("comment")->GetTitle()<<endl;
>
> giving:
> here is my very long comment
> that can even span many lines
>
> But it looks rather like an abuse of title in TNamed
> and it is annoying when the command
> a->ls()
> is issued the full comment that could be very long will be printed
> each time.
>
> The best will be that end user can do:
> a=new TFile("test.root");
> then
> a->ls()
> will tell them that there is an object called comment
> so that they will try the obvious:
> a->Get("comment")->Print()
> and have a nice output (it almost works with the TNamed except for the
> ugly OBJ: TNamed that come in front)
>
> Another suggestion?
>
>
>
>
> ---
> Nicolas Produit
> INTEGRAL Science Data Center Phone: +41 22 379 2140
> 16, Chemin d'Ecogia Fax: +41 22 379 2133
> CH-1290 Versoix www:
> http://isdc.unige.ch/~produit
>
>
Received on Thu Jun 21 2007 - 12:27:23 CEST

This archive was generated by hypermail 2.2.0 : Mon Jun 25 2007 - 23:50:01 CEST