Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Mantid::Kernel::BinFinder Class Reference

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ BinFinder()

Mantid::Kernel::BinFinder::BinFinder ( const std::vector< double > &  binParams)

Constructor.

Sets up the calculation for later.

Parameters
binParamsthe 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.

Member Function Documentation

◆ bin()

int Mantid::Kernel::BinFinder::bin ( double  x)

Find the bin index for a value.

Parameters
xx-value to histogram
Returns
an int corresponding to the bin index to use, or -1 if out of bounds.

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.

◆ lastBinIndex()

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.

Member Data Documentation

◆ boundaries

std::vector<double> Mantid::Kernel::BinFinder::boundaries
private

Boundaries between binning regions.

Definition at line 40 of file BinFinder.h.

Referenced by bin(), and BinFinder().

◆ endBinIndex

std::vector<int> Mantid::Kernel::BinFinder::endBinIndex
private

Index of the last boundary in the bins.

Definition at line 48 of file BinFinder.h.

Referenced by bin(), BinFinder(), and lastBinIndex().

◆ logBoundaries

std::vector<double> Mantid::Kernel::BinFinder::logBoundaries
private

Log of the boundary (used by log binning)

Definition at line 46 of file BinFinder.h.

Referenced by bin(), and BinFinder().

◆ logSteps

std::vector<double> Mantid::Kernel::BinFinder::logSteps
private

Log of the step size (used by log binning)

Definition at line 44 of file BinFinder.h.

Referenced by bin(), and BinFinder().

◆ numRegions

int Mantid::Kernel::BinFinder::numRegions
private

How many regions?

Definition at line 50 of file BinFinder.h.

Referenced by bin(), and BinFinder().

◆ stepSizes

std::vector<double> Mantid::Kernel::BinFinder::stepSizes
private

Step sizes in binning regions; 1 smaller than boundaries.

Definition at line 42 of file BinFinder.h.

Referenced by bin(), and BinFinder().


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