Re: [ROOT] Resetting histograms stored in TObjArray

From: Rene Brun (Rene.Brun@cern.ch)
Date: Sun Oct 14 2001 - 11:48:41 MEST


Hi  Bernhard,

If your TObjArray contain only histograms, you can do:
TObjArray *myarray;
TIter next(myarray);
TH1 *h;
while((h=(TH1*)next())) h->Reset();

If your TObjArray contains objects of classes that do not have a Reset
function, you can do:
TIter next(myarray);
TObject *obj;
TH1 *h;
while((obj=next())) {
   if (obj->InheritsFrom("TH1")) ((TH1*)obj)->Reset();
}

Rene Brun


On Sun, 14 Oct 2001, Bernhard KETZER wrote:

> Hi Rooters,
> 
> I store many histograms (TH1 and TH2) in a TObjArray to make it easier
> to loop over. Now I would like to call a method of TH1 and TH2, e.g.
> Reset(), for all TObjects in the TObjArray. Unfortunately, this doesn't
> seem to work, since Reset() is not a method of TObjArray. Is there a way
> to access the method Reset() of the TH1/TH2 for these objects?
> 
> Thank you for your help,
> 
> 	Bernhard



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:02 MET