Re: [ROOT] Two dimension array of histogram

From: Luiz Martins Mundim Filho (mundim@uerj.br)
Date: Mon Nov 25 2002 - 14:02:07 MET






  


Hi Rene

Would the option with "*" delete only the object I created or also the pointer to opened files and so? I would like just delete
the hundreds of histos created by the previous execution. Would the command below do the samething:

gDirectory->Delete("adc*");

I can test it by myself, it is just to have the problem registered on the mailing list.

Thanks a lot.

Luiz

Rene Brun wrote:
Hi Stanislas,

There are no restrictions concerning the name of objects.
I recommend to not use blanks in the name.
Could you tell me which type of problems you had that require a
clarification?

In case you want to delete all objects stored in the current
directory in memory, you can do
  gDirectory->Delete("*");

Rene Brun

On Fri, 22 Nov 2002, Stanislav NESTEROV wrote:

  
    Hi Luiz,

    Here problem is that the name of the object (not title) can't be 
arbitrary. In your case that means you might not use square brackets in 
histogram name. I suppose you to do somthing like this:

     Creation:
________________________________
	TH1F *hist[maxi][maxj];
	for(int i=0;i<maxi;i++)
	  for(int j=0;j<maxj;j++)
	     hist[i][j] = new TH1F(Form("hist%d%d",i,j),
			"Title",nbins,lowX,hiX); 
_________________________________
    Clean up:

        gDirectory->Delete(Form("hist%d%d",I,J));
_________________________________

  In this case TDirectory::Delete() method will find your histogram 
without any problems.

  I think Rene should clear up things about allowed names of the objects. 
I've eventually got some troubles with it too.

			Best regards,
					Stanislav.
   
On Thu, 21 Nov 2002, Luiz Martins Mundim Filho wrote:

    
I could create the array os histogram as told by Rene:

TH1F *x;

x[i][k] = new TH1F("x[i][k]","title",...)

But now I want to put a protection at the begining of the program, that 
means, deleting the
histogram before creating it again. I used to do:

gDirectory->Delete("h");

It work for a normal histogram (h), but it is not working for the array 
above, ROOT keeps warning me about recreation of existing histo and 
about potential memory leakage. As argument to the Delete command above, 
I used a Char_t variable, as:

sprintf(var,"histoname[%d][%d",i,j);
gDirectory->Delete(var);

Could some of you give me some help?

Thanks in advance.

Luiz

Luiz Martins Mundim Filho wrote:

      
Hi rooters

In my analysis program, I need a two dimension array of histograms. I 
found how to define and fill an one dimension array, but could not 
define one the way I really need. I searched the root site also and 
found nothing like this.

Could you help me?

Thanks

Luiz

        

      

  



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:20 MET