Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4StatDouble Class Reference

#include <G4StatDouble.hh>

Public Member Functions

 G4StatDouble ()
 
 G4StatDouble (G4double)
 
virtual ~G4StatDouble ()
 
G4StatDoubleoperator= (const G4double &rhs)
 
G4StatDoubleoperator= (const G4StatDouble &rhs)
 
G4StatDoubleoperator+= (const G4double &rhs)
 
G4StatDoubleoperator+= (const G4StatDouble &rhs)
 
void reset ()
 
void fill (G4double x, G4double weight=1.)
 
void scale (G4double)
 
G4double mean () const
 
G4double rms ()
 
G4double mean (G4double ext_sum_w) const
 
G4double rms (G4double ext_sum_w, G4int ext_n)
 
void add (const G4StatDouble *)
 
G4int n () const
 
G4double sum_w () const
 
G4double sum_w2 () const
 
G4double sum_wx () const
 
G4double sum_wx2 () const
 

Protected Member Functions

G4double rms (G4double sum_wx, G4double sum_wx2, G4double sum_w, G4int n)
 

Protected Attributes

G4double m_sum_wx
 
G4double m_sum_wx2
 
G4int m_n
 
G4double m_sum_w
 
G4double m_sum_w2
 
G4double m_scale
 

Detailed Description

Definition at line 45 of file G4StatDouble.hh.

Constructor & Destructor Documentation

G4StatDouble::G4StatDouble ( )

Definition at line 39 of file G4StatDouble.cc.

40 {
41  reset();
42 }

Here is the call graph for this function:

G4StatDouble::G4StatDouble ( G4double  x)

Definition at line 44 of file G4StatDouble.cc.

45 {
46  reset();
47  fill(x);
48 }
void fill(G4double x, G4double weight=1.)
Definition: G4StatDouble.cc:63

Here is the call graph for this function:

G4StatDouble::~G4StatDouble ( )
virtual

Definition at line 60 of file G4StatDouble.cc.

61 {}

Member Function Documentation

void G4StatDouble::add ( const G4StatDouble ptr)

Definition at line 167 of file G4StatDouble.cc.

168 {
169  m_n += ptr->n();
170  m_sum_w += ptr->sum_w();
171  m_sum_w2 += ptr->sum_w2();
172  m_sum_wx += ptr->sum_wx();
173  m_sum_wx2 += ptr->sum_wx2();
174 }
G4double sum_wx2() const
Definition: G4StatDouble.hh:99
G4double sum_w2() const
Definition: G4StatDouble.hh:97
G4double m_sum_wx
G4double sum_w() const
Definition: G4StatDouble.hh:96
G4double m_sum_wx2
G4double m_sum_w2
G4double sum_wx() const
Definition: G4StatDouble.hh:98
G4double m_sum_w
G4int n() const
Definition: G4StatDouble.hh:95

Here is the call graph for this function:

Here is the caller graph for this function:

void G4StatDouble::fill ( G4double  x,
G4double  weight = 1. 
)

Definition at line 63 of file G4StatDouble.cc.

64 {
65  m_sum_wx += value * weight;
66  m_sum_wx2 += value * value * weight;
67  if(m_n < INT_MAX) { ++m_n; }
68  m_sum_w += weight;
69  m_sum_w2 += weight * weight;
70 
71  if (weight <= 0.)
72  {
73  G4cout << "[G4StatDouble::fill] WARNING: weight<=0. "
74  << weight << G4endl;
75  }
76 }
G4double m_sum_wx
G4double m_sum_wx2
G4double m_sum_w2
G4GLOB_DLL std::ostream G4cout
const XML_Char int const XML_Char * value
Definition: expat.h:331
#define INT_MAX
Definition: templates.hh:111
G4double m_sum_w
#define G4endl
Definition: G4ios.hh:61

Here is the caller graph for this function:

G4double G4StatDouble::mean ( ) const

Definition at line 83 of file G4StatDouble.cc.

84 {
85  G4double mean_val = 0.;
86  if (m_sum_w > 0.)
87  {
88  mean_val = m_sum_wx / m_sum_w;
89  }
90  return m_scale * mean_val;
91 }
G4double m_sum_wx
G4double m_sum_w
G4double m_scale
double G4double
Definition: G4Types.hh:76

Here is the caller graph for this function:

G4double G4StatDouble::mean ( G4double  ext_sum_w) const

Definition at line 93 of file G4StatDouble.cc.

94 {
95  G4double factor = 0.;
96  // factor to rescale the Mean for the requested number
97  // of events (or sum of weights) ext_sum_w
98 
99  if (ext_sum_w > 0)
100  {
101  factor = m_sum_w;
102  factor /= ext_sum_w;
103  }
104  return mean() * factor;
105 
106 }
G4double m_sum_w
G4double mean() const
Definition: G4StatDouble.cc:83
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

G4int G4StatDouble::n ( ) const
inline

Definition at line 95 of file G4StatDouble.hh.

95 { return m_n; }

Here is the caller graph for this function:

G4StatDouble& G4StatDouble::operator+= ( const G4double rhs)
inline

Definition at line 70 of file G4StatDouble.hh.

71  { fill(rhs); return *this; }
void fill(G4double x, G4double weight=1.)
Definition: G4StatDouble.cc:63

Here is the call graph for this function:

G4StatDouble& G4StatDouble::operator+= ( const G4StatDouble rhs)
inline

Definition at line 72 of file G4StatDouble.hh.

73  { add(&rhs); return *this; }
void add(const G4StatDouble *)

Here is the call graph for this function:

G4StatDouble& G4StatDouble::operator= ( const G4double rhs)
inline

Definition at line 54 of file G4StatDouble.hh.

55  {
56  reset();
57  fill(rhs);
58  return *this;
59  }
void fill(G4double x, G4double weight=1.)
Definition: G4StatDouble.cc:63

Here is the call graph for this function:

G4StatDouble& G4StatDouble::operator= ( const G4StatDouble rhs)
inline

Definition at line 60 of file G4StatDouble.hh.

61  {
62  m_sum_wx = rhs.m_sum_wx;
63  m_sum_wx2 = rhs.m_sum_wx2;
64  m_n = rhs.m_n;
65  m_sum_w = rhs.m_sum_w;
66  m_sum_w2 = rhs.m_sum_w2;
67  m_scale = rhs.m_scale;
68  return *this;
69  }
G4double m_sum_wx
G4double m_sum_wx2
G4double m_sum_w2
G4double m_sum_w
G4double m_scale
void G4StatDouble::reset ( )

Definition at line 50 of file G4StatDouble.cc.

51 {
52  m_sum_wx = 0.;
53  m_sum_wx2 = 0.;
54  m_n = 0;
55  m_sum_w = 0.;
56  m_sum_w2 = 0.;
57  m_scale = 1.;
58 }
G4double m_sum_wx
G4double m_sum_wx2
G4double m_sum_w2
G4double m_sum_w
G4double m_scale

Here is the caller graph for this function:

G4double G4StatDouble::rms ( )

Definition at line 146 of file G4StatDouble.cc.

147 {
148  // this method computes the RMS with "all internal" parameters:
149  // all the sums are the internal ones: m_sum_wx, m_sum_wx2, m_sum_w, m_n
150 
151  return rms(m_sum_wx, m_sum_wx2, m_sum_w, m_n);
152 }
G4double m_sum_wx
G4double m_sum_wx2
G4double m_sum_w
G4double rms()

Here is the caller graph for this function:

G4double G4StatDouble::rms ( G4double  ext_sum_w,
G4int  ext_n 
)

Definition at line 154 of file G4StatDouble.cc.

155 {
156  // this method computes the RMS with sum_w and n coming from outside:
157  // ext_sum_w and ext_n:
158  // this means that the result is normalised to the external events
159  // it is useful when, given a number ext_n of events with sum of the weights
160  // ext_sum_w, only m_n (with sum of weights m_sum_w) are actually accumulated
161  // in the internal summation (e.g. for a dose variable in a volume, because
162  // only a few particles reach that volume)
163 
164  return rms(m_sum_wx, m_sum_wx2, ext_sum_w, ext_n);
165 }
G4double m_sum_wx
G4double m_sum_wx2
G4double rms()

Here is the call graph for this function:

G4double G4StatDouble::rms ( G4double  sum_wx,
G4double  sum_wx2,
G4double  sum_w,
G4int  n 
)
protected

Definition at line 108 of file G4StatDouble.cc.

110 {
111  G4double vrms = 0.0;
112  if (nn > 1)
113  {
114  G4double vmean = ssum_wx / ssum_w;
115  G4double xn = nn;
116  G4double tmp =
117  // from GNU Scientific Library. This part is equivalent to N/(N-1)
118  // when w_i = w
119  // ((m_sum_w * m_sum_w) / (m_sum_w * m_sum_w - m_sum_w2))
120 
121  // from NIST "DATAPLOT Reference manual", Page 2-66
122  // http://www.itl.nist.gov/div898/software/dataplot/refman2/ch2/weightsd.pdf
123  // rewritten based on: SUM[w(x-m)^2]/SUM[w] = SUM[wx^2]/SUM[w] - m^2
124  // and dividing it by sqrt[n] to go from rms of distribution to the
125  // rms of the mean value
126 
127  (xn / (xn - 1))
128  * ((ssum_wx2 / ssum_w) - (vmean * vmean));
129 
130  tmp = std::max(tmp, 0.0); // this avoids observed computation problem
131  vrms = std::sqrt( tmp );
132 // G4cout << "[G4StatDoubleElement::rms] m_sum_wx: " << m_sum_wx
133 // << " m_sum_wx2: " << m_sum_wx2 << " m_sum_w: " << m_sum_w
134 // << " m_n: " << m_n << " tmp: " << tmp<< " rms: " << rms
135 // << G4endl;
136 // G4cout << "[G4StatDoubleElement::rms] (m_n / (m_n - 1)): " << (xn/(xn - 1))
137 // << " (m_sum_wx2 / m_sum_w): " << (m_sum_wx2 / m_sum_w)
138 // << " (mean * mean): " << (mean * mean)
139 // << " ((m_sum_wx2 / m_sum_w) - (mean * mean)): "
140 // << ((m_sum_wx2 / m_sum_w) - (mean * mean))
141 // << G4endl;
142  }
143  return vrms * m_scale;
144 }
T max(const T t1, const T t2)
brief Return the largest of the two arguments
G4double m_scale
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

void G4StatDouble::scale ( G4double  value)

Definition at line 78 of file G4StatDouble.cc.

79 {
80  m_scale = m_scale * value;
81 }
const XML_Char int const XML_Char * value
Definition: expat.h:331
G4double m_scale
G4double G4StatDouble::sum_w ( ) const
inline

Definition at line 96 of file G4StatDouble.hh.

96 { return m_sum_w; }
G4double m_sum_w

Here is the caller graph for this function:

G4double G4StatDouble::sum_w2 ( ) const
inline

Definition at line 97 of file G4StatDouble.hh.

97 { return m_sum_w2; }
G4double m_sum_w2

Here is the caller graph for this function:

G4double G4StatDouble::sum_wx ( ) const
inline

Definition at line 98 of file G4StatDouble.hh.

98 { return m_sum_wx; }
G4double m_sum_wx

Here is the caller graph for this function:

G4double G4StatDouble::sum_wx2 ( ) const
inline

Definition at line 99 of file G4StatDouble.hh.

99 { return m_sum_wx2; }
G4double m_sum_wx2

Here is the caller graph for this function:

Member Data Documentation

G4int G4StatDouble::m_n
protected

Definition at line 109 of file G4StatDouble.hh.

G4double G4StatDouble::m_scale
protected

Definition at line 112 of file G4StatDouble.hh.

G4double G4StatDouble::m_sum_w
protected

Definition at line 110 of file G4StatDouble.hh.

G4double G4StatDouble::m_sum_w2
protected

Definition at line 111 of file G4StatDouble.hh.

G4double G4StatDouble::m_sum_wx
protected

Definition at line 107 of file G4StatDouble.hh.

G4double G4StatDouble::m_sum_wx2
protected

Definition at line 108 of file G4StatDouble.hh.


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