Moments Class Reference

#include <Moments.h>

List of all members.

Public Member Functions

 Moments ()
void AddPoint (const Double_t x, const Double_t w=1.0)
Double_t GetMean () const
Double_t GetRMS () const

Private Attributes

Long64_t n
Double_t sum
Double_t sum2
Double_t sumw

Detailed Description

Definition at line 26 of file Moments.h.


Constructor & Destructor Documentation

Moments::Moments (  ) 

Definition at line 21 of file Moments.cxx.

00021 : n(0), sum(0), sum2(0), sumw(0) {}


Member Function Documentation

void Moments::AddPoint ( const Double_t  x,
const Double_t  w = 1.0 
)

Definition at line 23 of file Moments.cxx.

References n, sum, sum2, and sumw.

Referenced by MadMKAnalysis::CreatePAN(), and MadTVAnalysis::CreatePAN().

00023                                                         {
00024   if(w<=0.0) return;
00025   n++;
00026   sum+=(x*w);
00027   sum2+=(x*x*w);
00028   sumw+=w;
00029 }

Double_t Moments::GetMean (  )  const

Definition at line 31 of file Moments.cxx.

References n, sum, and sumw.

Referenced by GetRMS().

00031                                 {
00032   if(n==0) return 0;
00033   else return sum/sumw;
00034 }

Double_t Moments::GetRMS (  )  const

Definition at line 36 of file Moments.cxx.

References GetMean(), n, sum2, and sumw.

Referenced by MadMKAnalysis::CreatePAN(), and MadTVAnalysis::CreatePAN().

00036                                {
00037   if(n<=1) return 0;
00038   else{
00039     Double_t mean = GetMean();
00040     Double_t var= (sum2 - mean*mean*sumw)/( (n-1)*sumw/double(n));
00041     return std::sqrt( std::abs(var) );
00042   }
00043 }


Member Data Documentation

Long64_t Moments::n [private]

Definition at line 33 of file Moments.h.

Referenced by AddPoint(), GetMean(), and GetRMS().

Double_t Moments::sum [private]

Definition at line 34 of file Moments.h.

Referenced by AddPoint(), and GetMean().

Double_t Moments::sum2 [private]

Definition at line 35 of file Moments.h.

Referenced by AddPoint(), and GetRMS().

Double_t Moments::sumw [private]

Definition at line 36 of file Moments.h.

Referenced by AddPoint(), GetMean(), and GetRMS().


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1