THStack with Option "stack"?

Hi!

If the option “stack” is used while drawing an THStack object I get a smooth curve although I have a fixed binning (same binning in each histogram that I want to stack). If I instead don´t use any option here I get the expected result (a stacked histogram). When I just write anything in there the histogram remains empy (also as expected). So my question is: Is this smooth curve I get while using the option “stack” (which is not documented) a bug or a feature? So far I don´t see any reason to get the observerd result…

Thanks for your help!
Stefan Kasselmann

Can you send a small running example showing the problem ?

Hi!

No problem.

First I have:

THStack* hs = new THStack(“hs”,"");

Then just think of having some histograms: h1-h6 of type TH1F. They are added to a new histogram via

TH1F* H = h1->Clone();
H->Add(h2,1);
H->Add(h3,1);

And also

TH1F* Z = h4->Clone();
Z->Add(h5,1);
Z->Add(h6,1);

They are finally added to the THStack histogram:

hs->Add(H);
hs->Add(Z);

And if I then want to draw hs via

hs->Draw(“stack”)

I get this smooth curve instead of a binned stacked histogram.
Without any parameter

hs->Draw() it works fine.

And when I type e.g.

hs->Draw(“xyz”) nothing is (of course) drawn. So there is obviously an option “stack” (which then is not documented). But why does it have this strange behaviour drawing a smooth curve out of binned histograms filled in?

Cheers,
Stefan

Sorry, but the “example” I have reads in files which are stored locally. So it would take some time to modify it to be able to work elsewhere. But my explanation hopefully explains the “core problem”…
If not I will try to adapt it :slight_smile:

Cheers,
Stefan

Are you sure this option exist for a stack ? where did you find it ? I found the option “nostack” but not the option stack.

Yes, you are right. There is no documented option “stack”. Obviously I just thought that if an option nostack exists also an option “stack” must exist. I just tried it and found the described behaviour.
It seems that the option “stack” is checked in any way because it gives a different result that any other “text” used as an option (in that case the canvas just stays empty).

Cheers,
Stefan

The option stack doesn’t exist because, as it should be, histogram in a THStack are painted as a stack by default so there is no need for an option. But “stack” contains “s” which is the option for smoothing. That is why you got a smooth curve.

Ok, that sounds reasionable :slight_smile:
I guess that can not be catched (for dummies like me?) :wink: ?

Thanks,
Stefan

no, that cannot be catched because options can be combined. It would be very inefficient to disable all the unused options.