Re: [ROOT] THStack

From: Rene Brun (Rene.Brun@cern.ch)
Date: Sun Jul 14 2002 - 12:34:07 MEST


Hi Matt,

On Tue, 9 Jul 2002, Matt Palmer wrote:

> Hi, 
> I've noticed a couple of problems with THStack.
> 1) If you try to add a histogram after having drawn the THStack, then try and 
> draw it, you get a seg fault.  The problem is that BuildStack just returns 
> fStack if it is already non-zero.  It should probably check that 
> fStack->GetEntriesFast() == fHists->GetEntriesFast()
> 

You are right. The simplest solution is to invalidate the stack by calling
the function THStack::Modified when calling THStack::Add.
I have added this mod to the development version in CVS.

> 2) The copy contructor is just the default .  This means that fStack gets 
> copied too.  If the above was fixed then the following code would show 
> identical output:

I have also implemented the copy constructor.

Thanks for all these suggestions.

Rene Brun


> 
> THStack s1 ("1", "1");
> s1.Add(h1);
> s1.Add(h2);
> THStack s2(s1);
> s2.Add(h3);
> s1.Draw("h");
> new TCanvas("c2", "c2");
> s2.Draw("h");
> 
> Matt
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:59 MET