Re: Histogram normalization

From: Tim Welters (welters@physik.rwth-aachen.de)
Date: Thu Jan 20 2000 - 09:44:29 MET


Christopher B. Lirakis wrote:
> 
> Hello all,
>         Is there an easy way to normalize a histogram? I have tried to do this by
> getting the array contents, dividing by a value, but have not yet found the
> correct method to return the scaled values to the bins.
> 
> Chris

Hi Cristopher,

I  normalize histograms like this :

  let's say h1 contains the TH1 descendant histogram you want to normalize (TH1F
*h1)
	
  if (h1->Integral()!=0)
    h1->Scale(1/h1->Integral());

Tim

------------------------------------------------------------------------
Tim Welters, III.Physikalisches Institut at the RWTH Aachen, Lehrstuhl B 
Room: H.116         Tel.: +49(241)80-6355          Fax: +49(241)8888-244
Postal Address:   Physikzentrum, RWTH Aachen, D-52056 Aachen
e-mail: welters@physik.rwth-aachen.de      or        Tim.Welters@cern.ch
------------------------------------------------------------------------



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:17 MET