Re: [ROOT] Array of histograms

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Feb 17 2003 - 17:23:54 MET


Hi Niels,

You do not show enough information, in particular the crucial line where
you declare the array ntp is missing.
Check that the allocation for ntp is large enough to accomodate the characters
in your sprintf statements.

Rene Brun

Niels Madsen wrote:
> 
> Dear ROOTers,
> 
> I've made an array of some histograms :
> TH1F *ap[5];
> for (i=0; i<nset; i++) {
>     sprintf(ntp,"ap_%d",i);
>     ap[i] = new TH1F(ntp,"Antiprotons into mixing",100,0,15000);
> }
> 
> And now I seem to have problems filling them we doing it like this
> (from an array of ntuples) :
>   for (i=0; i<nset; i++) {
>     c3->cd(i);
>     sprintf(ntp,"pbars>>ap_%d",i);
>     mixi[i]->Draw(ntp,cuta&&cutac,"");
>   }
> 
> It does do something - and then crashes - is this supposed to work ? -
> is there some
> more intelligent way to name the entries ?
> 
> Thanks,
> Niels
> 
> -----------------------------------------
> Dr. Niels Madsen
> CERN - EP/LR - 15-R-023
> CH-1211 Geneva 23
> Switzerland
> Tel. +41 22 767 2387    Fax. +41 22 767 8955
> Lab. +41 22 767 9814    Mob. +41 79 201 0835
> 
>



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:09 MET