RE: Replacing existing histogram

From: <monika_at_rcf.rhic.bnl.gov>
Date: Wed, 12 Oct 2005 03:21:35 -0400 (EDT)

Hello everyone,

Thanks for your inputs. I finally donot get any warning messages. I appreciate you help.

Thanks
Monika
.
>
> -----Original Message-----
> From: owner-roottalk_at_pcroot.cern.ch [mailto:owner-roottalk_at_pcroot.cern.ch]
> On Behalf Of monika_at_rcf.rhic.bnl.gov
> Sent: Tuesday, October 11, 2005 3:34 AM
> To: bold_at_fatcat.ftj.agh.edu.pl
> Cc: roottalk_at_pcroot.cern.ch
> Subject: Re: [ROOT] Replacing existing histogram
>
>
>
> Hi!
>
> Sorry about the mistake in the code, please see the corrected code again :
>
> ###########################################################################
> char hname_iso[120];
> char htitle1[120];
> Int_t niso;
> TH1F *hadc_iso = 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(hname_iso,"hadc_iso%d",niso);
> sprintf(htitle1,"%d",niso);
> hadc_iso[niso] = new TH1F(hname1,htitle1,1000,0.,4000.);
> }
> }
> }
> ###########################################################################
>
> Thanks for any help.
>
> Monika
>
>> Hi,
>> I am also interested in the answer about supressing Warning
>> messages.
>> Anyway looking at your code I noticed that the histograms have different
>> names. This is strange. ROOT never complained in that case.
>> One more comment. The code you are ataching is sort of danger. Namely
>> you write to unallocated memory space.
>>
>> You should have char hname1[256] and htitle1[256].
>> I noticed that people use sort of that code:
>>
>> TString hname1;
>> TString htitle1;
>> for (....) {
>> hname1.Resize(0); htitle1.Resize();
>> hname1.Form("h1%d", niso); htitle1.Form("h1%d", niso);
>>
>> t = new TH1F(hname1.Data(), htitle1.Data(), ....)
>> }
>>
>> Anyway It would be good to know how to suppress that messages anyway. It
>> is sometimes unavoidable to reuse names.
>> Regards,
>> Tomasz Bold
>>
>> monika_at_rcf.rhic.bnl.gov wrote:
>>
>>>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 Wed Oct 12 2005 - 09:21:47 MEST

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