Re: question about SetNormfactor in THStack

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Tue, 17 Oct 2006 16:44:28 +0200 (MEST)


SetNormFactor will not work for a THStack. The function stores one parameter in the object to normalize the histogram at drawing time. It cannot cope with the case of multiple normalization factors. Instead you should use TH1::Scale. This function will recompute the bin contents according the specified scale factor. It will be ok with a THStack.

Rene Brun

On
Tue,
17 Oct 2006, Zhijun Liang wrote:

> dear rooters:
> I have question about how to normalize 1D histograms and then add them to THStack,
> could you help me?
> here is my code :
> {
> TH1F *h1=new TH1F("h1","h1",50,-6,6);
> TH1F *h2=new TH1F("h2","h2",50,-6,6);
> h1->FillRandom("gaus",1000);
> h2->FillRandom("gaus",1000);
> h1->SetNormFactor(10);
> h2->SetNormFactor(10);
> THStack *hs=new THStack("hs","hs");
> hs->Add(h1);
> hs->Add(h2);
> hs->Draw();
> }
>
> I found that the THStack object failed to be normalized,
> do you know how to solve it ?
> manys thanks in advance.
> best regards
> liang
>
Received on Tue Oct 17 2006 - 16:44:32 MEST

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:32:01 MET