Mantid
|
The BinFinder class is a helper class that allows one to quickly find a bin index for many events. More...
#include <BinFinder.h>
Public Member Functions | |
int | bin (double x) |
Find the bin index for a value. More... | |
BinFinder (const std::vector< double > &binParams) | |
Constructor. More... | |
int | lastBinIndex () |
Returns the last bin boundary index, which should be == to the size of the X axis. More... | |
Private Attributes | |
std::vector< double > | boundaries |
Boundaries between binning regions. More... | |
std::vector< int > | endBinIndex |
Index of the last boundary in the bins. More... | |
std::vector< double > | logBoundaries |
Log of the boundary (used by log binning) More... | |
std::vector< double > | logSteps |
Log of the step size (used by log binning) More... | |
int | numRegions |
How many regions? More... | |
std::vector< double > | stepSizes |
Step sizes in binning regions; 1 smaller than boundaries. More... | |
The BinFinder class is a helper class that allows one to quickly find a bin index for many events.
The class is constructed by giving it rebinning parameters. This sets it up to be called repeatedly later to return the bin index.
Only works for linear and logarithmic binning - not arbitrary.
Does work for consecutive bins of different steps, or mixing lin and log binning.
Definition at line 30 of file BinFinder.h.
Mantid::Kernel::BinFinder::BinFinder | ( | const std::vector< double > & | binParams | ) |
Constructor.
Sets up the calculation for later.
binParams | the binning parameters, as a vector of doubles. E.g. 0, 1.0, 100, -0.5, 1e7: bins in step to 1.0 from 0 to 100; then log steps up to 1e7 |
Definition at line 22 of file BinFinder.cpp.
References boundaries, endBinIndex, fabs, logBoundaries, logSteps, n, numRegions, and stepSizes.
int Mantid::Kernel::BinFinder::bin | ( | double | x | ) |
Find the bin index for a value.
x | x-value to histogram |
Log binning formula for bin index n: x_n = min * ( 1 + |step| ) ^ n log(x_n) = log(min) + n * log(1+|step|) therefore n = (log(x_n) - log(min))/log(1+|step|)
Definition at line 115 of file BinFinder.cpp.
References boundaries, endBinIndex, index, logBoundaries, logSteps, numRegions, stepSizes, and Mantid::Geometry::x.
int Mantid::Kernel::BinFinder::lastBinIndex | ( | ) |
Returns the last bin boundary index, which should be == to the size of the X axis.
Definition at line 104 of file BinFinder.cpp.
References endBinIndex.
|
private |
Boundaries between binning regions.
Definition at line 40 of file BinFinder.h.
Referenced by bin(), and BinFinder().
|
private |
Index of the last boundary in the bins.
Definition at line 48 of file BinFinder.h.
Referenced by bin(), BinFinder(), and lastBinIndex().
|
private |
Log of the boundary (used by log binning)
Definition at line 46 of file BinFinder.h.
Referenced by bin(), and BinFinder().
|
private |
Log of the step size (used by log binning)
Definition at line 44 of file BinFinder.h.
Referenced by bin(), and BinFinder().
|
private |
|
private |
Step sizes in binning regions; 1 smaller than boundaries.
Definition at line 42 of file BinFinder.h.
Referenced by bin(), and BinFinder().