The method GetHistogram() of THStack

Hi,
I attached an example which is modified from one example on the page:
http://root.cern.ch/root/html/THStack.html#THStack:description
My example is to test how THStack can get histogram. But it seems that my code doesn’t work:

  1. If I run the codes in the command line mode (cint interface), the first graphs are good, the 3rd one is empty.
  2. If I run them in a mode of macros (say, root testTHStack.C), no graph comes up.

Any hint?

Thanks,
Zhiyi.
testTHStack.C (668 Bytes)

Could you explain what you are trying to do?
-THStack draws several histograms. The one obtained via GetHistogram
is an empty histogram used to draw the frame.
-You should use new THStack otherwise your THStack object will be deleted at the end of the script and all associated histograms deleted too.

Rene

Thanks.

As you know, the object of THStack is not a histogram, what I am trying to do is to get a histogram corresponding to this THStach, which means I want to convert THStack to a histogram. Yes, I agree I can use another way such as histogram->Merge(), histogram->Add(otherHistos); to get this kind of histogram, however, since I have THStack already, so I would like to convert it to a histogram.

Cheers,
Zhiyi.

[quote=“brun”]Could you explain what you are trying to do?
-THStack draws several histograms. The one obtained via GetHistogram
is an empty histogram used to draw the frame.
-You should use new THStack otherwise your THStack object will be deleted at the end of the script and all associated histograms deleted too.

Rene[/quote]