YODA is hosted by Hepforge, IPPP Durham
YODA::Dbn2D Class Reference

A 2D distribution. More...

#include <Dbn2D.h>

Public Member Functions

Constructors
 Dbn2D ()
 Default constructor of a new distribution. More...
 
 Dbn2D (unsigned long numEntries, double sumW, double sumW2, double sumWX, double sumWX2, double sumWY, double sumWY2, double sumWXY)
 
 Dbn2D (const Dbn2D &toCopy)
 
Dbn2Doperator= (const Dbn2D &toCopy)
 
Modifiers
void fill (double valX, double valY, double weight=1.0)
 Fill, providing the fill coordinates as two different numbers. More...
 
void fill (std::pair< double, double > val, double weight=1.0)
 Fill, providing the fill coordinates as a pair. More...
 
void reset ()
 Reset the distribution to an unfilled state. More...
 
void scaleW (double scalefactor)
 Rescale as if all fill weights had been different by factor scalefactor. More...
 
void scaleX (double xscale)
 Rescale x: needed if x histo bin edges are rescaled. More...
 
void scaleY (double yscale)
 Rescale y: needed if y histo bin edges are rescaled. More...
 
void scaleXY (double xscale, double yscale)
 Rescale x and y: needed if histo bin edges are rescaled. More...
 
Distribution statistics
double errW () const
 The absolute error on sumW. More...
 
double relErrW () const
 The relative error on sumW. More...
 
double xMean () const
 Weighted mean, $ \bar{x} $, of distribution. More...
 
double yMean () const
 Weighted mean, $ \bar{y} $, of distribution. More...
 
double xVariance () const
 Weighted $ x $ variance, $ \sigma_x^2 $, of distribution. More...
 
double yVariance () const
 Weighted $ y $ variance, $ \sigma_y^2 $, of distribution. More...
 
double xStdDev () const
 Weighted $ x $ standard deviation, $ \sigma_x $, of distribution. More...
 
double yStdDev () const
 Weighted $ y $ standard deviation, $ \sigma_y $, of distribution. More...
 
double xStdErr () const
 Weighted standard error on the $ x $ mean, $ \sim \sigma_x/\sqrt{N-1} $, of distribution. More...
 
double yStdErr () const
 Weighted standard error on the $ y $ mean, $ \sim \sigma_y/\sqrt{N-1} $, of distribution. More...
 
double xRMS () const
 Weighted RMS, $ \sqrt{ \sum{w x^2}/\sum{w} } $, of distribution. More...
 
double yRMS () const
 Weighted RMS, $ \sqrt{ \sum{w y^2}/\sum{w} } $, of distribution. More...
 
Raw distribution running sums
unsigned long numEntries () const
 Number of entries (number of times fill was called, ignoring weights) More...
 
double effNumEntries () const
 Effective number of entries $ = (\sum w)^2 / \sum w^2 $. More...
 
double sumW () const
 The sum of weights. More...
 
double sumW2 () const
 The sum of weights squared. More...
 
double sumWX () const
 The sum of x*weight. More...
 
double sumWX2 () const
 The sum of x^2*weight. More...
 
double sumWY () const
 The sum of y*weight. More...
 
double sumWY2 () const
 The sum of y^2*weight. More...
 
double sumWXY () const
 The sum of x*y*weight. More...
 
Operators
Dbn2Doperator+= (const Dbn2D &d)
 Add two dbns. More...
 
Dbn2Doperator-= (const Dbn2D &d)
 Subtract one dbn from another. More...
 
void flipXY ()
 Interchange X and Y subdistributions. More...
 
Dbn1D transformX ()
 
Dbn1D transformY ()
 

Protected Member Functions

Dbn2Dadd (const Dbn2D &d)
 Add two dbns (internal, explicitly named version) More...
 
Dbn2Dsubtract (const Dbn2D &d)
 Subtract one dbn from another (internal, explicitly named version) More...
 

Detailed Description

A 2D distribution.

Definition at line 16 of file Dbn2D.h.

Constructor & Destructor Documentation

YODA::Dbn2D::Dbn2D ( )
inline

Default constructor of a new distribution.

Definition at line 23 of file Dbn2D.h.

References reset().

23  {
24  reset();
25  }
void reset()
Reset the distribution to an unfilled state.
Definition: Dbn2D.h:80
YODA::Dbn2D::Dbn2D ( unsigned long  numEntries,
double  sumW,
double  sumW2,
double  sumWX,
double  sumWX2,
double  sumWY,
double  sumWY2,
double  sumWXY 
)
inline

Constructor to set a distribution with a pre-filled state.

Principally designed for internal persistency use.

Definition at line 31 of file Dbn2D.h.

33  : _dbnX(numEntries, sumW, sumW2, sumWX, sumWX2),
34  _dbnY(numEntries, sumW, sumW2, sumWY, sumWY2),
35  _sumWXY(sumWXY)
36  { }
double sumWX2() const
The sum of x^2*weight.
Definition: Dbn2D.h:191
double sumW() const
The sum of weights.
Definition: Dbn2D.h:176
unsigned long numEntries() const
Number of entries (number of times fill was called, ignoring weights)
Definition: Dbn2D.h:166
double sumWY2() const
The sum of y^2*weight.
Definition: Dbn2D.h:201
double sumW2() const
The sum of weights squared.
Definition: Dbn2D.h:181
double sumWY() const
The sum of y*weight.
Definition: Dbn2D.h:196
double sumWX() const
The sum of x*weight.
Definition: Dbn2D.h:186
double sumWXY() const
The sum of x*y*weight.
Definition: Dbn2D.h:206
YODA::Dbn2D::Dbn2D ( const Dbn2D toCopy)
inline

Copy constructor

Sets all the parameters using the ones provided from an existing Dbn2D.

Definition at line 42 of file Dbn2D.h.

42  {
43  _dbnX = toCopy._dbnX;
44  _dbnY = toCopy._dbnY;
45  _sumWXY = toCopy._sumWXY;
46  }

Member Function Documentation

Dbn2D& YODA::Dbn2D::add ( const Dbn2D d)
inlineprotected

Add two dbns (internal, explicitly named version)

Definition at line 256 of file Dbn2D.h.

Referenced by operator+=().

256  {
257  _dbnX += d._dbnX;
258  _dbnY += d._dbnY;
259  _sumWXY += d._sumWXY;
260  return *this;
261  }
double YODA::Dbn2D::effNumEntries ( ) const
inline

Effective number of entries $ = (\sum w)^2 / \sum w^2 $.

Definition at line 171 of file Dbn2D.h.

Referenced by YODA::Profile1D::effNumEntries(), and YODA::Histo2D::effNumEntries().

171  {
172  return _dbnX.effNumEntries();
173  }
double YODA::Dbn2D::errW ( ) const
inline

The absolute error on sumW.

Definition at line 124 of file Dbn2D.h.

124 { return _dbnX.errW(); }
void YODA::Dbn2D::fill ( double  valX,
double  valY,
double  weight = 1.0 
)
inline

Fill, providing the fill coordinates as two different numbers.

Definition at line 66 of file Dbn2D.h.

Referenced by fill().

66  {
67  _dbnX.fill(valX, weight);
68  _dbnY.fill(valY, weight);
69  _sumWXY += weight*valX*valY;
70  }
void YODA::Dbn2D::fill ( std::pair< double, double >  val,
double  weight = 1.0 
)
inline

Fill, providing the fill coordinates as a pair.

Definition at line 74 of file Dbn2D.h.

References fill().

74  {
75  fill(val.first, val.second, weight);
76  }
void fill(double valX, double valY, double weight=1.0)
Fill, providing the fill coordinates as two different numbers.
Definition: Dbn2D.h:66
void YODA::Dbn2D::flipXY ( )
inline

Interchange X and Y subdistributions.

Mostly used for operations on total distribution of an Axis

Definition at line 229 of file Dbn2D.h.

229  {
230  Dbn1D temp(_dbnX);
231  _dbnX = _dbnY;
232  _dbnY = temp;
233  }
unsigned long YODA::Dbn2D::numEntries ( ) const
inline

Number of entries (number of times fill was called, ignoring weights)

Definition at line 166 of file Dbn2D.h.

Referenced by YODA::Profile1D::numEntries(), YODA::Histo2D::numEntries(), YODA::WriterYODA::writeHisto2D(), and YODA::WriterYODA::writeProfile1D().

166  {
167  return _dbnX.numEntries();
168  }
Dbn2D& YODA::Dbn2D::operator+= ( const Dbn2D d)
inline

Add two dbns.

Definition at line 217 of file Dbn2D.h.

References add().

217  {
218  return add(d);
219  }
Dbn2D & add(const Dbn2D &d)
Add two dbns (internal, explicitly named version)
Definition: Dbn2D.h:256
Dbn2D& YODA::Dbn2D::operator-= ( const Dbn2D d)
inline

Subtract one dbn from another.

Definition at line 222 of file Dbn2D.h.

References subtract().

222  {
223  return subtract(d);
224  }
Dbn2D & subtract(const Dbn2D &d)
Subtract one dbn from another (internal, explicitly named version)
Definition: Dbn2D.h:264
Dbn2D& YODA::Dbn2D::operator= ( const Dbn2D toCopy)
inline

Copy assignment

Sets all the parameters using the ones provided from an existing Dbn2D.

Definition at line 52 of file Dbn2D.h.

52  {
53  _dbnX = toCopy._dbnX;
54  _dbnY = toCopy._dbnY;
55  _sumWXY = toCopy._sumWXY;
56  return *this;
57  }
double YODA::Dbn2D::relErrW ( ) const
inline

The relative error on sumW.

Definition at line 127 of file Dbn2D.h.

127 { return _dbnX.relErrW(); }
void YODA::Dbn2D::reset ( )
inline

Reset the distribution to an unfilled state.

Definition at line 80 of file Dbn2D.h.

Referenced by Dbn2D().

80  {
81  _dbnX.reset();
82  _dbnY.reset();
83  _sumWXY = 0;
84  }
void YODA::Dbn2D::scaleW ( double  scalefactor)
inline

Rescale as if all fill weights had been different by factor scalefactor.

Definition at line 88 of file Dbn2D.h.

88  {
89  _dbnX.scaleW(scalefactor);
90  _dbnY.scaleW(scalefactor);
91  _sumWXY *= scalefactor;
92  }
void YODA::Dbn2D::scaleX ( double  xscale)
inline

Rescale x: needed if x histo bin edges are rescaled.

Definition at line 96 of file Dbn2D.h.

Referenced by scaleXY().

96  {
97  _dbnX.scaleX(xscale);
98  _sumWXY *= xscale;
99  }
void YODA::Dbn2D::scaleXY ( double  xscale,
double  yscale 
)
inline

Rescale x and y: needed if histo bin edges are rescaled.

Definition at line 110 of file Dbn2D.h.

References scaleX(), and scaleY().

110  {
111  scaleX(xscale);
112  scaleY(yscale);
113  }
void scaleY(double yscale)
Rescale y: needed if y histo bin edges are rescaled.
Definition: Dbn2D.h:103
void scaleX(double xscale)
Rescale x: needed if x histo bin edges are rescaled.
Definition: Dbn2D.h:96
void YODA::Dbn2D::scaleY ( double  yscale)
inline

Rescale y: needed if y histo bin edges are rescaled.

Definition at line 103 of file Dbn2D.h.

Referenced by scaleXY().

103  {
104  _dbnY.scaleX(yscale);
105  _sumWXY *= yscale;
106  }
Dbn2D& YODA::Dbn2D::subtract ( const Dbn2D d)
inlineprotected

Subtract one dbn from another (internal, explicitly named version)

Definition at line 264 of file Dbn2D.h.

Referenced by operator-=().

264  {
265  _dbnX -= d._dbnX;
266  _dbnY -= d._dbnY;
267  _sumWXY -= d._sumWXY;
268  return *this;
269  }
double YODA::Dbn2D::sumW ( ) const
inline

The sum of weights.

Definition at line 176 of file Dbn2D.h.

Referenced by YODA::toTProfile(), YODA::WriterYODA::writeHisto2D(), and YODA::WriterYODA::writeProfile1D().

176  {
177  return _dbnX.sumW();
178  }
double YODA::Dbn2D::sumW2 ( ) const
inline

The sum of weights squared.

Definition at line 181 of file Dbn2D.h.

Referenced by YODA::WriterYODA::writeHisto2D(), and YODA::WriterYODA::writeProfile1D().

181  {
182  return _dbnX.sumW2();
183  }
double YODA::Dbn2D::sumWX ( ) const
inline

The sum of x*weight.

Definition at line 186 of file Dbn2D.h.

Referenced by YODA::WriterYODA::writeHisto2D(), and YODA::WriterYODA::writeProfile1D().

186  {
187  return _dbnX.sumWX();
188  }
double YODA::Dbn2D::sumWX2 ( ) const
inline

The sum of x^2*weight.

Definition at line 191 of file Dbn2D.h.

Referenced by YODA::WriterYODA::writeHisto2D(), and YODA::WriterYODA::writeProfile1D().

191  {
192  return _dbnX.sumWX2();
193  }
double YODA::Dbn2D::sumWXY ( ) const
inline

The sum of x*y*weight.

Definition at line 206 of file Dbn2D.h.

Referenced by YODA::WriterYODA::writeHisto2D().

206  {
207  return _sumWXY;
208  }
double YODA::Dbn2D::sumWY ( ) const
inline

The sum of y*weight.

Definition at line 196 of file Dbn2D.h.

Referenced by YODA::toTProfile(), YODA::WriterYODA::writeHisto2D(), and YODA::WriterYODA::writeProfile1D().

196  {
197  return _dbnY.sumWX();
198  }
double YODA::Dbn2D::sumWY2 ( ) const
inline

The sum of y^2*weight.

Definition at line 201 of file Dbn2D.h.

Referenced by YODA::toTProfile(), YODA::WriterYODA::writeHisto2D(), and YODA::WriterYODA::writeProfile1D().

201  {
202  return _dbnY.sumWX2();
203  }
Dbn1D YODA::Dbn2D::transformX ( )
inline

Transform into a Dbn1D parallel to X axis (dropping Y term)

Todo:
Rename

Definition at line 238 of file Dbn2D.h.

238  {
239  Dbn1D ret(_dbnX);
240  return ret;
241  }
Dbn1D YODA::Dbn2D::transformY ( )
inline

Transform into a Dbn1D parallel to Y axis (dropping X term)

Todo:
Rename

Definition at line 246 of file Dbn2D.h.

246  {
247  Dbn1D ret(_dbnY);
248  return ret;
249  }
double YODA::Dbn2D::xMean ( ) const
inline

Weighted mean, $ \bar{x} $, of distribution.

Definition at line 130 of file Dbn2D.h.

130 { return _dbnX.xMean();}
double YODA::Dbn2D::xRMS ( ) const
inline

Weighted RMS, $ \sqrt{ \sum{w x^2}/\sum{w} } $, of distribution.

Definition at line 154 of file Dbn2D.h.

154 { return _dbnX.xRMS(); }
double YODA::Dbn2D::xStdDev ( ) const
inline

Weighted $ x $ standard deviation, $ \sigma_x $, of distribution.

Definition at line 142 of file Dbn2D.h.

142 { return _dbnX.xStdDev(); }
double YODA::Dbn2D::xStdErr ( ) const
inline

Weighted standard error on the $ x $ mean, $ \sim \sigma_x/\sqrt{N-1} $, of distribution.

Definition at line 148 of file Dbn2D.h.

148 { return _dbnX.xStdErr(); }
double YODA::Dbn2D::xVariance ( ) const
inline

Weighted $ x $ variance, $ \sigma_x^2 $, of distribution.

Definition at line 136 of file Dbn2D.h.

136 { return _dbnX.xVariance(); }
double YODA::Dbn2D::yMean ( ) const
inline

Weighted mean, $ \bar{y} $, of distribution.

Definition at line 133 of file Dbn2D.h.

Referenced by YODA::toTH1D().

133 { return _dbnY.xMean(); }
double YODA::Dbn2D::yRMS ( ) const
inline

Weighted RMS, $ \sqrt{ \sum{w y^2}/\sum{w} } $, of distribution.

Definition at line 157 of file Dbn2D.h.

157 { return _dbnY.xRMS(); }
double YODA::Dbn2D::yStdDev ( ) const
inline

Weighted $ y $ standard deviation, $ \sigma_y $, of distribution.

Definition at line 145 of file Dbn2D.h.

145 { return _dbnY.xStdDev(); }
double YODA::Dbn2D::yStdErr ( ) const
inline

Weighted standard error on the $ y $ mean, $ \sim \sigma_y/\sqrt{N-1} $, of distribution.

Definition at line 151 of file Dbn2D.h.

Referenced by YODA::toTH1D().

151 { return _dbnY.xStdErr(); }
double YODA::Dbn2D::yVariance ( ) const
inline

Weighted $ y $ variance, $ \sigma_y^2 $, of distribution.

Definition at line 139 of file Dbn2D.h.

139 { return _dbnY.xVariance(); }

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