Re: Replacing existing histogram

From: Venkat <venkat_at_hepmail.uta.edu>
Date: Tue, 11 Oct 2005 03:30:12 -0500


Change the hname1 for each histogram
you can do something like Form("hname%d",i1) in your loop

h1[niso] = new TH1F(Form("hname%d",i1),htitle1,1000,0.,4000.);

>
> 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
>
Received on Tue Oct 11 2005 - 10:30:24 MEST

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