Hi!
Sorry about the mistake in the code, please see the corrected code again :
###########################################################################char hname_iso[120];
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.); }
###########################################################################
I don't want root to write the warning message 300K times : Warning in <TH1::Build>: Replacing existing histogram
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 Tue Oct 11 2005 - 10:35:00 MEST
This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:12 MET