Re: how to get the precise mean value of data in a bin ?

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Wed, 31 Jan 2007 06:47:29 +0100


see class TProfile.

http://root.cern.ch/root/htmldoc/TProfile.html

Rene Brun

X. Lu, Peking Univ. wrote:
> Hi rooters,
>
> I am trying to get mean values of data in different bins but meet some
> problems.
>
> Is there any function like TH1F::GetBinMean(ibin) ?
>
> Learning from TH1::GetMean(), I find a way to do so,
> but as you can see, the result is wrong.
>
> root [0] h=new TH1F("h","",2,0,2)
> (class TH1F*)0x9cfdab8
> root [1] h->Fill(0.25)
> (Int_t)1
> root [2] a=h->GetXaxis()
> (const class TAxis*)0x9cfdaf8
> root [3] a->SetRange(1,1)
> root [4] Double_t stats[4]
> root [5] h->GetStats(stats)
> root [6] Double_t mean=stats[2]/stats[0]
> root [7] mean
> (Double_t)5.00000000000000000e-01
>
> I have been looking in the ROOT reference guide, and I noticed that
> the TH1 and its
> inheritance do NOT record individual data values, NOR their sum in
> each bin when Fill()
> is called. So it is impossible to get the true mean values in bins, right?
>
> If so, is something going to be done for improvement?
> If no, how to get the precise mean values in bins?
>
> Thanks a lot !
>
> Ciao~
> Xianguo
>
> --
> Take flight into the sky, beyond the moon, beyond my mind.
>
> Xianguo LU
> Physics Department, Peking University
> Beijing, China
> Tel: 0086-10-62753888(o)
Received on Wed Jan 31 2007 - 06:47:35 CET

This archive was generated by hypermail 2.2.0 : Wed Jan 31 2007 - 11:50:01 CET