Re: [ROOT] Two dimension array of histogram

From: Stanislav NESTEROV (Stanislav.Nesterov@cern.ch)
Date: Fri Nov 22 2002 - 03:38:04 MET


    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