Re: Replacing existing histogram

From: zaldy <zaldy_at_neutrino.kek.jp>
Date: Tue, 11 Oct 2005 18:09:29 +0900 (JST)

Dear Monika,

To me it looks like that the hname1 in

h1[niso] = new TH1F(hname1,htitle1,1000,0.,4000.);

is always the same every time you create a histogram, which in this case

hname1=h

I suggest you use an array of characters or string.

   char hname1[100];
   char htitle1[100];

Hope that helps.

Zaldy N.

>
> Hi Rooter!,
>
> I have an array of 1D histograms and whenever I run the program it says :
>
> Warning in <TH1::Build>: Replacing existing histogram: h1_[array_#]
> (Potential memory leak).
>
> Since I have 300K histograms, it writes the warning this many number of
> times. Can I somehow get rid of the warning.
>
> I am also writing my peace of code here :
>
> ###################################################################
> char hname1;
> char htitle1;
> Int_t niso;
> TH1F *h1 = new TH1F[300000];
>
> for(Int_t i1=12; i1<kmaxsm;i1++) {
> for(Int_t j1=0; j1<kmaxrow;j1++) {
> for(Int_t k1=0; k1<kmaxcol;k1++) {
> niso = (i1*10000) + j1*100 + k1;
> sprintf(hname1,"h1%d",niso);
> sprintf(htitle1,"%d",niso);
> h1[niso] = new TH1F(hname1,htitle1,1000,0.,4000.);
> }
> }
> }
> #####################################################################
>
> I'll appreciate any help.
>
> Thanks
> Monika
>

-- 
Zaldy A. Nawang
Received on Tue Oct 11 2005 - 11:11:08 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:12 MET