YODA is hosted by Hepforge, IPPP Durham
YODA::Axis2D< BIN2D, DBN > Class Template Reference

2D bin container More...

#include <Axis2D.h>

Public Types

typedef BIN2D Bin
 Typedefs. More...
 
typedef std::vector< BinBins
 A vector containing 2D bins. Not used for searching. More...
 
typedef std::vector< double > Edges
 
typedef std::pair< double, double > EdgePair1D
 
typedef std::pair< EdgePair1D,
EdgePair1D
EdgePair2D
 
typedef std::vector< EdgePair2DEdgePair2Ds
 
typedef std::vector< DBN > Outflow
 
typedef std::vector< OutflowOutflows
 

Public Member Functions

Constructors
 Axis2D ()
 
 Axis2D (const Edges &xedges, const Edges &yedges)
 A constructor with specified x and y axis bin cuts. More...
 
 Axis2D (size_t nbinsX, const std::pair< double, double > &rangeX, size_t nbinsY, const std::pair< double, double > &rangeY)
 
 Axis2D (const Bins &bins)
 Constructor accepting a list of bins. More...
 
 Axis2D (const Bins &bins, const DBN &totalDbn, const Outflows &outflows)
 State-setting constructor for persistency. More...
 
void reset ()
 
size_t numBins () const
 Get the number of bins. More...
 
size_t numBinsX () const
 
size_t numBinsY () const
 
Statistics accessor functions
Outflowoutflow (int ix, int iy)
 Get the outflow by x-index and y-index (non-const version) More...
 
const Outflowoutflow (int ix, int iy) const
 Get the outflow by x-index and y-index (const version) More...
 
void scaleX (double xscale)
 Scale each bin as if the entire x-axis had been scaled by this factor. More...
 
void scaleY (double yscale)
 Scale each bin as if the entire y-axis had been scaled by this factor. More...
 
void scaleXY (double sx, double sy)
 
void scaleW (double scalefactor)
 
void eraseBin (size_t i)
 
void eraseBins (const size_t from, const size_t to)
 Erase a rectangle of bins. More...
 
void eraseBins (const std::pair< double, double > &xrange, const std::pair< double, double > &yrange)
 
void eraseBins (const std::vector< bool > &deleteMask)
 
void rebin (unsigned int n)
 Rebin with the same rebinning factor n in x and y. More...
 
void rebinXY (unsigned int nx, unsigned int ny)
 Rebin with separate rebinning factors nx, ny in x and y. More...
 
void rebinX (unsigned int nx)
 Rebin in x by factor nx. More...
 
void rebinY (unsigned int ny)
 Rebin in y by factor ny. More...
 
double xMin () const
 Return the lowest-valued bin edge along the x-axis. More...
 
double xMax () const
 Return the highest-valued bin edge along the x-axis. More...
 
double yMin () const
 Return the lowest-valued bin edge along the y-axis. More...
 
double yMax () const
 Return the highest-valued bin edge along the y-axis. More...
 
void addBin (EdgePair1D xrange, EdgePair1D yrange)
 Add a bin, providing its x- and y- edge ranges. More...
 
void addBins (const Bins &bins)
 Add a vector of pre-made bins. More...
 
void addBins (const std::vector< double > &xedges, const std::vector< double > &yedges)
 Add a contiguous set of bins to an axis, via their list of edges. More...
 
Binbin (size_t i)
 Access bin by index. More...
 
const Binbin (size_t i) const
 Access bin by index (const) More...
 
int binIndexAt (double x, double y) const
 Get the bin index of the bin containing point (x, y). More...
 
BinbinAt (double x, double y)
 Get the bin containing point (x, y). More...
 
const BinbinAt (double x, double y) const
 Get the bin containing point (x, y) (const). More...
 
DBN & totalDbn ()
 Return the total distribution (non-const) More...
 
const DBN & totalDbn () const
 Return the total distribution (const) More...
 
Binsbins ()
 Return the bins vector (non-const) More...
 
const Binsbins () const
 Return the bins vector (const) More...
 
bool operator== (const Axis2D &other) const
 
bool operator!= (const Axis2D &other) const
 Non-equality operator. More...
 
Axis2D< BIN2D, DBN > & operator+= (const Axis2D< BIN2D, DBN > &toAdd)
 Addition operator. More...
 
Axis2D< BIN2D, DBN > & operator-= (const Axis2D< BIN2D, DBN > &toSubtract)
 Subtraction operator. More...
 

Detailed Description

template<typename BIN2D, typename DBN>
class YODA::Axis2D< BIN2D, DBN >

2D bin container

This class handles most of the low-level operations on an axis of bins arranged in a 2D grid (including gaps).

Definition at line 21 of file Axis2D.h.

Member Typedef Documentation

template<typename BIN2D, typename DBN>
typedef BIN2D YODA::Axis2D< BIN2D, DBN >::Bin

Typedefs.

Bin type

Definition at line 28 of file Axis2D.h.

template<typename BIN2D, typename DBN>
typedef std::vector<Bin> YODA::Axis2D< BIN2D, DBN >::Bins

A vector containing 2D bins. Not used for searching.

Definition at line 31 of file Axis2D.h.

template<typename BIN2D, typename DBN>
typedef std::pair<double, double> YODA::Axis2D< BIN2D, DBN >::EdgePair1D

Definition at line 35 of file Axis2D.h.

template<typename BIN2D, typename DBN>
typedef std::pair<EdgePair1D, EdgePair1D> YODA::Axis2D< BIN2D, DBN >::EdgePair2D

Definition at line 36 of file Axis2D.h.

template<typename BIN2D, typename DBN>
typedef std::vector<EdgePair2D> YODA::Axis2D< BIN2D, DBN >::EdgePair2Ds

Definition at line 37 of file Axis2D.h.

template<typename BIN2D, typename DBN>
typedef std::vector<double> YODA::Axis2D< BIN2D, DBN >::Edges

Definition at line 34 of file Axis2D.h.

template<typename BIN2D, typename DBN>
typedef std::vector<DBN> YODA::Axis2D< BIN2D, DBN >::Outflow

Definition at line 40 of file Axis2D.h.

template<typename BIN2D, typename DBN>
typedef std::vector<Outflow> YODA::Axis2D< BIN2D, DBN >::Outflows

Definition at line 41 of file Axis2D.h.

Constructor & Destructor Documentation

template<typename BIN2D, typename DBN>
YODA::Axis2D< BIN2D, DBN >::Axis2D ( )
inline

Definition at line 49 of file Axis2D.h.

References YODA::Axis2D< BIN2D, DBN >::reset().

50  : _locked(false)
51  {
52  reset();
53  }
void reset()
Definition: Axis2D.h:94
template<typename BIN2D, typename DBN>
YODA::Axis2D< BIN2D, DBN >::Axis2D ( const Edges xedges,
const Edges yedges 
)
inline

A constructor with specified x and y axis bin cuts.

Definition at line 56 of file Axis2D.h.

References YODA::Axis2D< BIN2D, DBN >::addBins(), and YODA::Axis2D< BIN2D, DBN >::reset().

57  : _locked(false)
58  {
59  addBins(xedges, yedges);
60  reset();
61  }
void reset()
Definition: Axis2D.h:94
void addBins(const Bins &bins)
Add a vector of pre-made bins.
Definition: Axis2D.h:296
template<typename BIN2D, typename DBN>
YODA::Axis2D< BIN2D, DBN >::Axis2D ( size_t  nbinsX,
const std::pair< double, double > &  rangeX,
size_t  nbinsY,
const std::pair< double, double > &  rangeY 
)
inline

Constructor accepting X/Y ranges and number of bins on each of the axis. Both axes are divided linearly.

Definition at line 65 of file Axis2D.h.

References YODA::Axis2D< BIN2D, DBN >::addBins(), YODA::linspace(), and YODA::Axis2D< BIN2D, DBN >::reset().

67  : _locked(false)
68  {
69  addBins(linspace(nbinsX, rangeX.first, rangeX.second),
70  linspace(nbinsY, rangeY.first, rangeY.second));
71  reset();
72  }
std::vector< double > linspace(size_t nbins, double start, double end, bool include_end=true)
Make a list of nbins + 1 values equally spaced between start and end inclusive.
Definition: MathUtils.h:248
void reset()
Definition: Axis2D.h:94
void addBins(const Bins &bins)
Add a vector of pre-made bins.
Definition: Axis2D.h:296
template<typename BIN2D, typename DBN>
YODA::Axis2D< BIN2D, DBN >::Axis2D ( const Bins bins)
inline

Constructor accepting a list of bins.

Definition at line 75 of file Axis2D.h.

References YODA::Axis2D< BIN2D, DBN >::addBins(), and YODA::Axis2D< BIN2D, DBN >::reset().

75  {
76  addBins(bins);
77  reset();
78  }
Bins & bins()
Return the bins vector (non-const)
Definition: Axis2D.h:374
void reset()
Definition: Axis2D.h:94
void addBins(const Bins &bins)
Add a vector of pre-made bins.
Definition: Axis2D.h:296
template<typename BIN2D, typename DBN>
YODA::Axis2D< BIN2D, DBN >::Axis2D ( const Bins bins,
const DBN &  totalDbn,
const Outflows outflows 
)
inline

State-setting constructor for persistency.

Definition at line 81 of file Axis2D.h.

References YODA::Axis2D< BIN2D, DBN >::addBins().

84  : _dbn(totalDbn), _outflows(outflows),
85  _locked(false) // Does this make sense?
86  {
87  if (_outflows.size() != 8) {
88  throw Exception("Axis2D outflow containers must have exactly 8 elements");
89  }
90  addBins(bins);
91  }
Bins & bins()
Return the bins vector (non-const)
Definition: Axis2D.h:374
DBN & totalDbn()
Return the total distribution (non-const)
Definition: Axis2D.h:363
void addBins(const Bins &bins)
Add a vector of pre-made bins.
Definition: Axis2D.h:296

Member Function Documentation

template<typename BIN2D, typename DBN>
void YODA::Axis2D< BIN2D, DBN >::addBin ( EdgePair1D  xrange,
EdgePair1D  yrange 
)
inline

Add a bin, providing its x- and y- edge ranges.

Definition at line 288 of file Axis2D.h.

288  {
289  _checkUnlocked();
290  Bins newBins = _bins;
291  newBins.push_back(Bin(xrange, yrange));
292  _updateAxis(newBins);
293  }
std::vector< Bin > Bins
A vector containing 2D bins. Not used for searching.
Definition: Axis2D.h:31
BIN2D Bin
Typedefs.
Definition: Axis2D.h:28
template<typename BIN2D, typename DBN>
void YODA::Axis2D< BIN2D, DBN >::addBins ( const Bins bins)
inline

Add a vector of pre-made bins.

Definition at line 296 of file Axis2D.h.

Referenced by YODA::Axis2D< BIN2D, DBN >::Axis2D().

296  {
297  if (bins.size() == 0) return;
298  _checkUnlocked();
299 
300  Bins newBins = _bins;
301  BOOST_FOREACH(const Bin& b, bins) newBins.push_back(b);
302 
303  _updateAxis(newBins);
304  }
Bins & bins()
Return the bins vector (non-const)
Definition: Axis2D.h:374
std::vector< Bin > Bins
A vector containing 2D bins. Not used for searching.
Definition: Axis2D.h:31
BIN2D Bin
Typedefs.
Definition: Axis2D.h:28
template<typename BIN2D, typename DBN>
void YODA::Axis2D< BIN2D, DBN >::addBins ( const std::vector< double > &  xedges,
const std::vector< double > &  yedges 
)
inline

Add a contiguous set of bins to an axis, via their list of edges.

Definition at line 308 of file Axis2D.h.

308  {
309  if (xedges.size() == 0) return;
310  if (yedges.size() == 0) return;
311  _checkUnlocked();
312 
313  Bins newBins = _bins;
314  for (size_t xi = 0; xi < xedges.size()-1; xi++) {
315  for (size_t yi = 0; yi < yedges.size()-1; yi++) {
316  const std::pair<double,double> xx = std::make_pair(xedges[xi], xedges[xi+1]);
317  const std::pair<double,double> yy = std::make_pair(yedges[yi], yedges[yi+1]);
318  // std::cout << "New bin with edges: [(" << xx.first << "," << xx.second << "), " << yy.first << "," << yy.second << ")]" << std::endl;
319  newBins.push_back(Bin(xx, yy));
320  }
321  }
322 
323  _updateAxis(newBins);
324  }
std::vector< Bin > Bins
A vector containing 2D bins. Not used for searching.
Definition: Axis2D.h:31
BIN2D Bin
Typedefs.
Definition: Axis2D.h:28
template<typename BIN2D, typename DBN>
const Bin& YODA::Axis2D< BIN2D, DBN >::bin ( size_t  i) const
inline

Access bin by index (const)

Definition at line 333 of file Axis2D.h.

333  {
334  return _bins[i];
335  }
template<typename BIN2D, typename DBN>
Bin& YODA::Axis2D< BIN2D, DBN >::binAt ( double  x,
double  y 
)
inline

Get the bin containing point (x, y).

Definition at line 348 of file Axis2D.h.

References YODA::Axis2D< BIN2D, DBN >::bin(), and YODA::Axis2D< BIN2D, DBN >::binIndexAt().

348  {
349  const int ret = binIndexAt(x, y);
350  if (ret == -1) throw RangeError("No bin found!!");
351  return bin(ret);
352  }
Bin & bin(size_t i)
Access bin by index.
Definition: Axis2D.h:328
int binIndexAt(double x, double y) const
Get the bin index of the bin containing point (x, y).
Definition: Axis2D.h:338
template<typename BIN2D, typename DBN>
const Bin& YODA::Axis2D< BIN2D, DBN >::binAt ( double  x,
double  y 
) const
inline

Get the bin containing point (x, y) (const).

Definition at line 355 of file Axis2D.h.

References YODA::Axis2D< BIN2D, DBN >::bin(), and YODA::Axis2D< BIN2D, DBN >::binIndexAt().

355  {
356  const int ret = binIndexAt(x, y);
357  if (ret == -1) throw RangeError("No bin found!!");
358  return bin(ret);
359  }
Bin & bin(size_t i)
Access bin by index.
Definition: Axis2D.h:328
int binIndexAt(double x, double y) const
Get the bin index of the bin containing point (x, y).
Definition: Axis2D.h:338
template<typename BIN2D, typename DBN>
int YODA::Axis2D< BIN2D, DBN >::binIndexAt ( double  x,
double  y 
) const
inline

Get the bin index of the bin containing point (x, y).

Definition at line 338 of file Axis2D.h.

Referenced by YODA::Axis2D< BIN2D, DBN >::binAt().

338  {
339  size_t xi = _binSearcherX.index(x) - 1;
340  size_t yi = _binSearcherY.index(y) - 1;
341  if (xi > _nx) return -1;
342  if (yi > _ny) return -1;
343 
344  return _indexes[_index(_nx, xi, yi)];
345  }
template<typename BIN2D, typename DBN>
Bins& YODA::Axis2D< BIN2D, DBN >::bins ( )
inline

Return the bins vector (non-const)

Definition at line 374 of file Axis2D.h.

Referenced by YODA::Axis2D< BIN2D, DBN >::eraseBins(), YODA::Axis2D< BIN2D, DBN >::operator+=(), and YODA::Axis2D< BIN2D, DBN >::operator-=().

374  {
375  return _bins;
376  }
template<typename BIN2D, typename DBN>
const Bins& YODA::Axis2D< BIN2D, DBN >::bins ( ) const
inline

Return the bins vector (const)

Definition at line 379 of file Axis2D.h.

379  {
380  return _bins;
381  }
template<typename BIN2D, typename DBN>
void YODA::Axis2D< BIN2D, DBN >::eraseBin ( size_t  i)
inline

Remove the bin at the given index. If many bins need to be removed, prefer eraseBins(vector[size_t] &) over many calls to this, as recreating the binhash is comparatively expensive.

Definition at line 181 of file Axis2D.h.

References YODA::Axis2D< BIN2D, DBN >::numBins().

181  {
182  if (i >= numBins())
183  throw RangeError("Bin index is out of range");
184 
185  // Temporarily unlock the axis during the update
186  _bins.erase(_bins.begin() + i);
187  _updateAxis(_bins);
188  }
size_t numBins() const
Get the number of bins.
Definition: Axis2D.h:103
template<typename BIN2D, typename DBN>
void YODA::Axis2D< BIN2D, DBN >::eraseBins ( const size_t  from,
const size_t  to 
)
inline

Erase a rectangle of bins.

Definition at line 192 of file Axis2D.h.

References YODA::Axis2D< BIN2D, DBN >::bin(), and YODA::Axis2D< BIN2D, DBN >::numBins().

Referenced by YODA::Axis2D< BIN2D, DBN >::eraseBins().

192  {
193  if (from >= numBins())
194  throw RangeError("Initial bin index is out of range");
195  if (from >= numBins())
196  throw RangeError("Final bin index is out of range");
197 
198  Bin& fromBin = bin(from);
199  Bin& toBin = bin(to);
200 
201  eraseBins(std::make_pair(fromBin.xMin(), toBin.xMax()),
202  std::make_pair(fromBin.yMin(), toBin.yMax()));
203  }
void eraseBins(const size_t from, const size_t to)
Erase a rectangle of bins.
Definition: Axis2D.h:192
Bin & bin(size_t i)
Access bin by index.
Definition: Axis2D.h:328
BIN2D Bin
Typedefs.
Definition: Axis2D.h:28
size_t numBins() const
Get the number of bins.
Definition: Axis2D.h:103
template<typename BIN2D, typename DBN>
void YODA::Axis2D< BIN2D, DBN >::eraseBins ( const std::pair< double, double > &  xrange,
const std::pair< double, double > &  yrange 
)
inline

Erase bins in an x- and y-range. Any bins which lie entirely within the region are deleted. If any part of the bin lies outside this range, the bin remains, so this has similar behaviour to select tools in vector graphics GUI packages.

Todo:
How to test this?
Todo:
Beware the specialisation problems with vector<bool>...

Definition at line 211 of file Axis2D.h.

References YODA::Axis2D< BIN2D, DBN >::bin(), YODA::Axis2D< BIN2D, DBN >::eraseBins(), and YODA::Axis2D< BIN2D, DBN >::numBins().

213  {
214  size_t xiLow = _binSearcherX.index(xrange.first) - 1;
215  size_t xiHigh = _binSearcherX.index(xrange.second) - 1;
216 
217  size_t yiLow = _binSearcherY.index(yrange.first) - 1;
218  size_t yiHigh = _binSearcherY.index(yrange.second) - 1;
219 
221  std::vector<bool> deleteMask(numBins(), false);
222 
223  for (size_t yi = yiLow; yi < yiHigh; yi++) {
224  for (size_t xi = xiLow; xi < xiHigh; xi++) {
225  ssize_t i = _indexes[_index(_nx, xi, yi)];
226  if (i == -1 || deleteMask[i]) continue;
227  if (bin(i).fitsInside(xrange, yrange)) deleteMask[i] = true;
228  }
229  }
230 
231  // Now we just update
232  eraseBins(deleteMask);
233  }
void eraseBins(const size_t from, const size_t to)
Erase a rectangle of bins.
Definition: Axis2D.h:192
Bin & bin(size_t i)
Access bin by index.
Definition: Axis2D.h:328
size_t numBins() const
Get the number of bins.
Definition: Axis2D.h:103
template<typename BIN2D, typename DBN>
void YODA::Axis2D< BIN2D, DBN >::eraseBins ( const std::vector< bool > &  deleteMask)
inline

Erase using a vector<bool>, where true represents that a bin will be deleted, and false means it will be kept.

Definition at line 238 of file Axis2D.h.

References YODA::Axis2D< BIN2D, DBN >::bins(), and YODA::Axis2D< BIN2D, DBN >::numBins().

238  {
239  Bins newBins;
240  for (size_t i = 0; i < numBins(); i++)
241  if (!deleteMask[i]) newBins.push_back(bins(i));
242  _update(newBins);
243  }
Bins & bins()
Return the bins vector (non-const)
Definition: Axis2D.h:374
std::vector< Bin > Bins
A vector containing 2D bins. Not used for searching.
Definition: Axis2D.h:31
size_t numBins() const
Get the number of bins.
Definition: Axis2D.h:103
template<typename BIN2D, typename DBN>
size_t YODA::Axis2D< BIN2D, DBN >::numBins ( ) const
inline

Get the number of bins.

Definition at line 103 of file Axis2D.h.

Referenced by YODA::Axis2D< BIN2D, DBN >::eraseBin(), YODA::Axis2D< BIN2D, DBN >::eraseBins(), and YODA::Axis2D< BIN2D, DBN >::operator==().

103  {
104  return _bins.size();
105  }
template<typename BIN2D, typename DBN>
size_t YODA::Axis2D< BIN2D, DBN >::numBinsX ( ) const
inline

Get the number of bins on the x-axis. This is only sensible for perfectly regular gridded bins. For irregular binnings, this is the number of cuts that were necessary to grid the data.

Definition at line 110 of file Axis2D.h.

110  {
111  return _nx;
112  }
template<typename BIN2D, typename DBN>
size_t YODA::Axis2D< BIN2D, DBN >::numBinsY ( ) const
inline

Get the number of bins on the y-axis. This is only sensible for perfectly regular gridded bins. For irregular binnings, this is the number of cuts that were necessary to grid the data.

Definition at line 117 of file Axis2D.h.

117  {
118  return _ny;
119  }
template<typename BIN2D, typename DBN>
bool YODA::Axis2D< BIN2D, DBN >::operator!= ( const Axis2D< BIN2D, DBN > &  other) const
inline

Non-equality operator.

Definition at line 401 of file Axis2D.h.

References YODA::Axis2D< BIN2D, DBN >::operator==().

401  {
402  return ! operator == (other);
403  }
bool operator==(const Axis2D &other) const
Definition: Axis2D.h:389
template<typename BIN2D, typename DBN>
Axis2D<BIN2D, DBN>& YODA::Axis2D< BIN2D, DBN >::operator+= ( const Axis2D< BIN2D, DBN > &  toAdd)
inline

Addition operator.

Definition at line 407 of file Axis2D.h.

References YODA::Axis2D< BIN2D, DBN >::bin(), and YODA::Axis2D< BIN2D, DBN >::bins().

407  {
408  if (*this != toAdd) {
409  throw LogicError("YODA::Axis2D: Cannot add axes with different binnings.");
410  }
411  for (size_t i = 0; i < bins().size(); ++i) {
412  bin(i) += toAdd.bin(i);
413  }
414  _dbn += toAdd._dbn;
415  return *this;
416  }
Bins & bins()
Return the bins vector (non-const)
Definition: Axis2D.h:374
Bin & bin(size_t i)
Access bin by index.
Definition: Axis2D.h:328
template<typename BIN2D, typename DBN>
Axis2D<BIN2D, DBN>& YODA::Axis2D< BIN2D, DBN >::operator-= ( const Axis2D< BIN2D, DBN > &  toSubtract)
inline

Subtraction operator.

Definition at line 419 of file Axis2D.h.

References YODA::Axis2D< BIN2D, DBN >::bin(), and YODA::Axis2D< BIN2D, DBN >::bins().

419  {
420  if (*this != toSubtract) {
421  throw LogicError("YODA::Axis2D: Cannot add axes with different binnings.");
422  }
423  for (size_t i = 0; i < bins().size(); ++i) {
424  bin(i) -= toSubtract.bin(i);
425  }
426  _dbn -= toSubtract._dbn;
427  return *this;
428  }
Bins & bins()
Return the bins vector (non-const)
Definition: Axis2D.h:374
Bin & bin(size_t i)
Access bin by index.
Definition: Axis2D.h:328
template<typename BIN2D, typename DBN>
bool YODA::Axis2D< BIN2D, DBN >::operator== ( const Axis2D< BIN2D, DBN > &  other) const
inline

Equality operator (on binning only)

Todo:
Change as discussed below if we expose the Axis classes for direct use

Definition at line 389 of file Axis2D.h.

References YODA::Axis2D< BIN2D, DBN >::bin(), YODA::fuzzyEquals(), YODA::Axis2D< BIN2D, DBN >::numBins(), and YODA::Axis2D< BIN2D, DBN >::xMin().

Referenced by YODA::Axis2D< BIN2D, DBN >::operator!=().

389  {
390  if (numBins() != other.numBins()) return false;
391  for (size_t i = 0; i < numBins(); i++)
392  if (!(fuzzyEquals(bin(i).xMin(), other.bin(i).xMin()) &&
393  fuzzyEquals(bin(i).xMax(), other.bin(i).xMax()) &&
394  fuzzyEquals(bin(i).yMin(), other.bin(i).yMin()) &&
395  fuzzyEquals(bin(i).yMax(), other.bin(i).yMax())))
396  return false;
397  return true;
398  }
Bin & bin(size_t i)
Access bin by index.
Definition: Axis2D.h:328
bool fuzzyEquals(double a, double b, double tolerance=1E-5)
Compare two floating point numbers for equality with a degree of fuzziness.
Definition: MathUtils.h:68
double xMin() const
Return the lowest-valued bin edge along the x-axis.
Definition: Axis2D.h:274
size_t numBins() const
Get the number of bins.
Definition: Axis2D.h:103
template<typename BIN2D, typename DBN>
Outflow& YODA::Axis2D< BIN2D, DBN >::outflow ( int  ix,
int  iy 
)
inline

Get the outflow by x-index and y-index (non-const version)

Indices are -1 = below range, 0 = in range, +1 = above range, e.g. (+1, -1) is in the "bottom right" position by being greater than the greatest x-edge and less than the lowest y-edge.

Definition at line 132 of file Axis2D.h.

Referenced by YODA::Axis2D< BIN2D, DBN >::scaleW(), and YODA::Axis2D< BIN2D, DBN >::scaleXY().

132  {
133  return _outflows[_outflowIndex(ix, iy)];
134  }
template<typename BIN2D, typename DBN>
const Outflow& YODA::Axis2D< BIN2D, DBN >::outflow ( int  ix,
int  iy 
) const
inline

Get the outflow by x-index and y-index (const version)

Indices are -1 = below range, 0 = in range, +1 = above range, e.g. (+1, -1) is in the "bottom right" position by being greater than the greatest x-edge and less than the lowest y-edge.

Definition at line 142 of file Axis2D.h.

142  {
143  return _outflows[_outflowIndex(ix, iy)];
144  }
template<typename BIN2D, typename DBN>
void YODA::Axis2D< BIN2D, DBN >::rebin ( unsigned int  n)
inline

Rebin with the same rebinning factor n in x and y.

Definition at line 247 of file Axis2D.h.

References YODA::Axis2D< BIN2D, DBN >::rebinXY().

247  {
248  rebinXY(n, n);
249  }
void rebinXY(unsigned int nx, unsigned int ny)
Rebin with separate rebinning factors nx, ny in x and y.
Definition: Axis2D.h:252
template<typename BIN2D, typename DBN>
void YODA::Axis2D< BIN2D, DBN >::rebinX ( unsigned int  nx)
inline

Rebin in x by factor nx.

Todo:
WRITE THIS!

Definition at line 258 of file Axis2D.h.

Referenced by YODA::Axis2D< BIN2D, DBN >::rebinXY().

258  {
260  }
template<typename BIN2D, typename DBN>
void YODA::Axis2D< BIN2D, DBN >::rebinXY ( unsigned int  nx,
unsigned int  ny 
)
inline

Rebin with separate rebinning factors nx, ny in x and y.

Definition at line 252 of file Axis2D.h.

References YODA::Axis2D< BIN2D, DBN >::rebinX(), and YODA::Axis2D< BIN2D, DBN >::rebinY().

Referenced by YODA::Axis2D< BIN2D, DBN >::rebin().

252  {
253  rebinX(nx);
254  rebinY(ny);
255  }
void rebinY(unsigned int ny)
Rebin in y by factor ny.
Definition: Axis2D.h:263
void rebinX(unsigned int nx)
Rebin in x by factor nx.
Definition: Axis2D.h:258
template<typename BIN2D, typename DBN>
void YODA::Axis2D< BIN2D, DBN >::rebinY ( unsigned int  ny)
inline

Rebin in y by factor ny.

Todo:
WRITE THIS!

Definition at line 263 of file Axis2D.h.

Referenced by YODA::Axis2D< BIN2D, DBN >::rebinXY().

263  {
265  }
template<typename BIN2D, typename DBN>
void YODA::Axis2D< BIN2D, DBN >::reset ( )
inline

Definition at line 94 of file Axis2D.h.

References YODA::Axis2D< BIN2D, DBN >::bin().

Referenced by YODA::Axis2D< BIN2D, DBN >::Axis2D().

94  {
95  _dbn.reset();
96  _outflows.assign(8, Outflow());
97  BOOST_FOREACH(Bin& bin, _bins) bin.reset();
98  _locked = false;
99  }
Bin & bin(size_t i)
Access bin by index.
Definition: Axis2D.h:328
BIN2D Bin
Typedefs.
Definition: Axis2D.h:28
void reset()
Definition: Axis2D.h:94
std::vector< DBN > Outflow
Definition: Axis2D.h:40
template<typename BIN2D, typename DBN>
void YODA::Axis2D< BIN2D, DBN >::scaleW ( double  scalefactor)
inline

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

Definition at line 169 of file Axis2D.h.

References YODA::Axis2D< BIN2D, DBN >::bin(), and YODA::Axis2D< BIN2D, DBN >::outflow().

169  {
170  _dbn.scaleW(scalefactor);
171  BOOST_FOREACH (Outflow& outflow, _outflows)
172  BOOST_FOREACH (DBN& dbn, outflow) dbn.scaleW(scalefactor);
173  BOOST_FOREACH (Bin &bin, _bins) bin.scaleW(scalefactor);
174  _updateAxis(_bins);
175  }
Bin & bin(size_t i)
Access bin by index.
Definition: Axis2D.h:328
void scaleW(double scalefactor)
Definition: Axis2D.h:169
BIN2D Bin
Typedefs.
Definition: Axis2D.h:28
std::vector< DBN > Outflow
Definition: Axis2D.h:40
Outflow & outflow(int ix, int iy)
Get the outflow by x-index and y-index (non-const version)
Definition: Axis2D.h:132
template<typename BIN2D, typename DBN>
void YODA::Axis2D< BIN2D, DBN >::scaleX ( double  xscale)
inline

Scale each bin as if the entire x-axis had been scaled by this factor.

Definition at line 147 of file Axis2D.h.

References YODA::Axis2D< BIN2D, DBN >::scaleXY().

147  {
148  scaleXY(xscale, 1.0);
149  }
void scaleXY(double sx, double sy)
Definition: Axis2D.h:158
template<typename BIN2D, typename DBN>
void YODA::Axis2D< BIN2D, DBN >::scaleXY ( double  sx,
double  sy 
)
inline

Scale each bin as if the entire x and y-axes had been scaled by their respective factors.

Definition at line 158 of file Axis2D.h.

References YODA::Axis2D< BIN2D, DBN >::bin(), and YODA::Axis2D< BIN2D, DBN >::outflow().

Referenced by YODA::Axis2D< BIN2D, DBN >::scaleX(), and YODA::Axis2D< BIN2D, DBN >::scaleY().

158  {
159  _dbn.scaleXY(sx, sy);
160  BOOST_FOREACH (Outflow& outflow, _outflows)
161  BOOST_FOREACH (DBN& dbn, outflow) dbn.scaleXY(sx, sy);
162  BOOST_FOREACH (Bin& bin, _bins) bin.scaleXY(sx, sy);
163  _updateAxis(_bins);
164  }
void scaleXY(double sx, double sy)
Definition: Axis2D.h:158
Bin & bin(size_t i)
Access bin by index.
Definition: Axis2D.h:328
BIN2D Bin
Typedefs.
Definition: Axis2D.h:28
std::vector< DBN > Outflow
Definition: Axis2D.h:40
Outflow & outflow(int ix, int iy)
Get the outflow by x-index and y-index (non-const version)
Definition: Axis2D.h:132
template<typename BIN2D, typename DBN>
void YODA::Axis2D< BIN2D, DBN >::scaleY ( double  yscale)
inline

Scale each bin as if the entire y-axis had been scaled by this factor.

Definition at line 152 of file Axis2D.h.

References YODA::Axis2D< BIN2D, DBN >::scaleXY().

152  {
153  scaleXY(1.0, yscale);
154  }
void scaleXY(double sx, double sy)
Definition: Axis2D.h:158
template<typename BIN2D, typename DBN>
DBN& YODA::Axis2D< BIN2D, DBN >::totalDbn ( )
inline

Return the total distribution (non-const)

Definition at line 363 of file Axis2D.h.

363  {
364  return _dbn;
365  }
template<typename BIN2D, typename DBN>
const DBN& YODA::Axis2D< BIN2D, DBN >::totalDbn ( ) const
inline

Return the total distribution (const)

Definition at line 368 of file Axis2D.h.

368  {
369  return _dbn;
370  }
template<typename BIN2D, typename DBN>
double YODA::Axis2D< BIN2D, DBN >::xMax ( ) const
inline

Return the highest-valued bin edge along the x-axis.

Definition at line 277 of file Axis2D.h.

277 { return _xRange.second; }
template<typename BIN2D, typename DBN>
double YODA::Axis2D< BIN2D, DBN >::xMin ( ) const
inline

Return the lowest-valued bin edge along the x-axis.

Definition at line 274 of file Axis2D.h.

Referenced by YODA::Axis2D< BIN2D, DBN >::operator==().

274 { return _xRange.first; }
template<typename BIN2D, typename DBN>
double YODA::Axis2D< BIN2D, DBN >::yMax ( ) const
inline

Return the highest-valued bin edge along the y-axis.

Definition at line 284 of file Axis2D.h.

284 { return _yRange.second; }
template<typename BIN2D, typename DBN>
double YODA::Axis2D< BIN2D, DBN >::yMin ( ) const
inline

Return the lowest-valued bin edge along the y-axis.

Definition at line 281 of file Axis2D.h.

281 { return _yRange.first; }

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