ROOT 6.13/01 Reference Guide |
<- TKDTreeBinning - A class providing multidimensional binning ->
The class implements multidimensional binning by constructing a TKDTree inner structure from the data which is used as the bins. The bins are retrieved as two double*, one for the minimum bin edges, the other as the maximum bin edges. For one dimension one of these is enough to correctly define the bins. For the multidimensional case both minimum and maximum ones are necessary for the bins to be well defined. The bin edges of d-dimensional data is a d-tet of the bin's thresholds. For example if d=3 the minimum bin edges of bin b is of the form of the following array: {xbmin, ybmin, zbmin}. You also have the possibility to sort the bins by their density.
Details of usage can be found in $ROOTSYS/tutorials/math/kdTreeBinning.C
and more information on the embedded TKDTree documentation.
Definition at line 29 of file TKDTreeBinning.h.
Public Types | |
enum | { kAdjustBinEdges = BIT(14) } |
Public Member Functions | |
TKDTreeBinning () | |
Default constructor (for I/O) More... | |
TKDTreeBinning (UInt_t dataSize, UInt_t dataDim, Double_t *data, UInt_t nBins=100, bool adjustBinEdges=false) | |
Class's constructor taking the size of the data points, dimension, a data array and the number of bins (default = 100). More... | |
TKDTreeBinning (UInt_t dataSize, UInt_t dataDim, const std::vector< double > &data, UInt_t nBins=100, bool adjustBinEdges=false) | |
Class's constructor taking the size of the data points, dimension, a data vector and the number of bins (default = 100). More... | |
~TKDTreeBinning () | |
Class's destructor. More... | |
void | FillBinData (ROOT::Fit::BinData &data) const |
Fill the bin data set (class ROOT::Fit::BinData) with the result of the TKDTree binning. More... | |
UInt_t | FindBin (const Double_t *point) const |
find the corresponding bin index given the coordinate of a point More... | |
const Double_t * | GetBinCenter (UInt_t bin) const |
Returns the geometric center of of the bin. 'bin' is between 0 and fNBins - 1. More... | |
UInt_t | GetBinContent (UInt_t bin) const |
Returns the number of points in bin. 'bin' is between 0 and fNBins - 1. More... | |
Double_t | GetBinDensity (UInt_t bin) const |
Returns the density in bin. More... | |
std::pair< const Double_t *, const Double_t * > | GetBinEdges (UInt_t bin) const |
Returns a pir with the bin's edges. 'bin' is between 0 and fNBins - 1. More... | |
UInt_t | GetBinMaxDensity () const |
Return the bin with maximum density. More... | |
const Double_t * | GetBinMaxEdges (UInt_t bin) const |
Returns the bin's maximum edges. 'bin' is between 0 and fNBins - 1. More... | |
UInt_t | GetBinMinDensity () const |
Return the bin with minimum density. More... | |
const Double_t * | GetBinMinEdges (UInt_t bin) const |
Returns the bin's minimum edges. 'bin' is between 0 and fNBins - 1. More... | |
std::pair< const Double_t *, const Double_t * > | GetBinsEdges () const |
Returns a pair of an array with all bins minimum and maximum edges. More... | |
const Double_t * | GetBinsMaxEdges () const |
Returns an array with all bins' maximum edges The edges are arranges as xmax_1,ymax_1, xmax_2,ymax_2,....xmax_{nbin},ymax_{nbin}. More... | |
const Double_t * | GetBinsMinEdges () const |
Returns an array with all bins' minimum edges The edges are arranges as xmin_1,ymin_1, xmin_2,ymin_2,....xmin_{nbin},ymin_{nbin}. More... | |
Double_t | GetBinVolume (UInt_t bin) const |
Returns the (hyper)volume of bin. 'bin' is between 0 and fNBins - 1. More... | |
const Double_t * | GetBinWidth (UInt_t bin) const |
Returns a pointer to the vector of the bin widths. 'bin' is between 0 and fNBins - 1. More... | |
Double_t | GetDataMax (UInt_t dim) const |
Returns the maximum of the data in the dim coordinate. 'dim' is between 0 and fDim - 1. More... | |
Double_t | GetDataMin (UInt_t dim) const |
Returns the minimum of the data in the dim coordinate. 'dim' is between 0 and fDim - 1. More... | |
UInt_t | GetDim () const |
Returns the number of dimensions. More... | |
const Double_t * | GetDimData (UInt_t dim) const |
UInt_t | GetNBins () const |
Returns the number of bins. More... | |
const Double_t * | GetOneDimBinEdges () const |
Returns a pointer to the vector of the bin edges for one dimensional binning only. More... | |
std::vector< std::vector< Double_t > > | GetPointsInBin (UInt_t bin) const |
Return the corresponding point belonging to the bin i. More... | |
TKDTreeID * | GetTree () const |
Returns the kD-Tree structure of the binning. More... | |
void | SetNBins (UInt_t bins) |
Sets binning inner structure. More... | |
void | SortBinsByDensity (Bool_t sortAsc=kTRUE) |
Sorts bins by their density. More... | |
const Double_t * | SortOneDimBinEdges (Bool_t sortAsc=kTRUE) |
Sort the one-dimensional bin edges and retuns a pointer to them. More... | |
Private Member Functions | |
TKDTreeBinning (TKDTreeBinning &bins) | |
TKDTreeBinning | operator= (TKDTreeBinning &bins) |
Disallowed copy constructor. More... | |
void | ReadjustMaxBinEdges (Double_t *binEdges) |
void | ReadjustMinBinEdges (Double_t *binEdges) |
void | SetBinMinMaxEdges (Double_t *binEdges) |
void | SetBinsContent () |
void | SetBinsEdges () |
void | SetCommonBinEdges (Double_t *binEdges) |
void | SetData (Double_t *data) |
Disallowed assign operator. More... | |
void | SetData (const std::vector< double > &data) |
void | SetTreeData () |
Private Attributes | |
std::vector< Double_t > | fBinMaxEdges |
The minimum values for the bins' edges for each dimension. More... | |
std::vector< Double_t > | fBinMinEdges |
[fDataSize*fDim] The data from which a KDTree partition is computed for binning More... | |
std::vector< UInt_t > | fBinsContent |
Flags if the bin edges are sorted densitywise (or by bin-edge for 1D) in ascending order. More... | |
std::vector< std::vector< std::pair< Bool_t, Bool_t > > > | fCheckedBinEdges |
Minimum and maximum data values. More... | |
std::vector< std::map< Double_t, std::vector< UInt_t > > > | fCommonBinEdges |
! Auxiliary structure for readjusting the bin edges. Keeps the common bin boundaries More... | |
std::vector< Double_t > | fData |
TKDTreeID * | fDataBins |
Index of the bins in the kd-tree (needed when bins are sorted) More... | |
UInt_t | fDataSize |
The data dimension. More... | |
std::vector< std::pair< Double_t, Double_t > > | fDataThresholds |
The data size. More... | |
UInt_t | fDim |
The number of bins. More... | |
std::vector< UInt_t > | fIndices |
The maximum values for the bins' edges for each dimension. More... | |
Bool_t | fIsSorted |
Bool_t | fIsSortedAsc |
Flags if the bin edges are sorted densitywise (or by bin endges in case of 1-dim ) More... | |
UInt_t | fNBins |
Friends | |
struct | CompareAsc |
! Predicate for ascending sort More... | |
struct | CompareDesc |
! Predicate for descending sort More... | |
#include <TKDTreeBinning.h>
anonymous enum |
Enumerator | |
---|---|
kAdjustBinEdges |
Definition at line 67 of file TKDTreeBinning.h.
|
private |
TKDTreeBinning::TKDTreeBinning | ( | ) |
Default constructor (for I/O)
Definition at line 113 of file TKDTreeBinning.cxx.
TKDTreeBinning::TKDTreeBinning | ( | UInt_t | dataSize, |
UInt_t | dataDim, | ||
Double_t * | data, | ||
UInt_t | nBins = 100 , |
||
bool | adjustBinEdges = false |
||
) |
Class's constructor taking the size of the data points, dimension, a data array and the number of bins (default = 100).
It is reccomended to have the number of bins as an exact divider of the data size. The data array must be organized with a stride=1 for the points and = N (the dataSize) for the dimension.
Thus data[] = x1,x2,x3,......xN, y1,y2,y3......yN, z1,z2,...........zN,....
Note that the passed dataSize is not the size of the array but is the number of points (N) The size of the array must be at least dataDim*dataSize
Definition at line 74 of file TKDTreeBinning.cxx.
TKDTreeBinning::TKDTreeBinning | ( | UInt_t | dataSize, |
UInt_t | dataDim, | ||
const std::vector< double > & | data, | ||
UInt_t | nBins = 100 , |
||
bool | adjustBinEdges = false |
||
) |
Class's constructor taking the size of the data points, dimension, a data vector and the number of bins (default = 100).
It is reccomended to have the number of bins as an exact divider of the data size. The data array must be organized with a stride=1 for the points and = N (the dataSize) for the dimension.
Thus data[] = x1,x2,x3,......xN, y1,y2,y3......yN, z1,z2,...........zN,....
Note that the passed data vector may contains a larger size, in case extra coordinates are associated but not used in building the kdtree The size of thedata vector must be at least dataDim*dataSize
Definition at line 98 of file TKDTreeBinning.cxx.
TKDTreeBinning::~TKDTreeBinning | ( | ) |
Class's destructor.
Definition at line 123 of file TKDTreeBinning.cxx.
void TKDTreeBinning::FillBinData | ( | ROOT::Fit::BinData & | data | ) | const |
Fill the bin data set (class ROOT::Fit::BinData) with the result of the TKDTree binning.
Definition at line 614 of file TKDTreeBinning.cxx.
UInt_t TKDTreeBinning::FindBin | ( | const Double_t * | point | ) | const |
find the corresponding bin index given the coordinate of a point
Definition at line 624 of file TKDTreeBinning.cxx.
const Double_t * TKDTreeBinning::GetBinCenter | ( | UInt_t | bin | ) | const |
Returns the geometric center of of the bin. 'bin' is between 0 and fNBins - 1.
Definition at line 554 of file TKDTreeBinning.cxx.
UInt_t TKDTreeBinning::GetBinContent | ( | UInt_t | bin | ) | const |
Returns the number of points in bin. 'bin' is between 0 and fNBins - 1.
Definition at line 429 of file TKDTreeBinning.cxx.
Double_t TKDTreeBinning::GetBinDensity | ( | UInt_t | bin | ) | const |
Returns the density in bin.
'bin' is between 0 and fNBins - 1 The density is the bin content/ bin volume
Definition at line 475 of file TKDTreeBinning.cxx.
std::pair< const Double_t *, const Double_t * > TKDTreeBinning::GetBinEdges | ( | UInt_t | bin | ) | const |
Returns a pir with the bin's edges. 'bin' is between 0 and fNBins - 1.
Definition at line 406 of file TKDTreeBinning.cxx.
UInt_t TKDTreeBinning::GetBinMaxDensity | ( | ) | const |
Return the bin with maximum density.
Definition at line 584 of file TKDTreeBinning.cxx.
const Double_t * TKDTreeBinning::GetBinMaxEdges | ( | UInt_t | bin | ) | const |
Returns the bin's maximum edges. 'bin' is between 0 and fNBins - 1.
Definition at line 393 of file TKDTreeBinning.cxx.
UInt_t TKDTreeBinning::GetBinMinDensity | ( | ) | const |
Return the bin with minimum density.
Definition at line 599 of file TKDTreeBinning.cxx.
const Double_t * TKDTreeBinning::GetBinMinEdges | ( | UInt_t | bin | ) | const |
Returns the bin's minimum edges. 'bin' is between 0 and fNBins - 1.
Definition at line 380 of file TKDTreeBinning.cxx.
std::pair< const Double_t *, const Double_t * > TKDTreeBinning::GetBinsEdges | ( | ) | const |
Returns a pair of an array with all bins minimum and maximum edges.
Definition at line 370 of file TKDTreeBinning.cxx.
const Double_t * TKDTreeBinning::GetBinsMaxEdges | ( | ) | const |
Returns an array with all bins' maximum edges The edges are arranges as xmax_1,ymax_1, xmax_2,ymax_2,....xmax_{nbin},ymax_{nbin}.
Definition at line 360 of file TKDTreeBinning.cxx.
const Double_t * TKDTreeBinning::GetBinsMinEdges | ( | ) | const |
Returns an array with all bins' minimum edges The edges are arranges as xmin_1,ymin_1, xmin_2,ymin_2,....xmin_{nbin},ymin_{nbin}.
Definition at line 350 of file TKDTreeBinning.cxx.
Double_t TKDTreeBinning::GetBinVolume | ( | UInt_t | bin | ) | const |
Returns the (hyper)volume of bin. 'bin' is between 0 and fNBins - 1.
Definition at line 488 of file TKDTreeBinning.cxx.
const Double_t * TKDTreeBinning::GetBinWidth | ( | UInt_t | bin | ) | const |
Returns a pointer to the vector of the bin widths. 'bin' is between 0 and fNBins - 1.
Definition at line 569 of file TKDTreeBinning.cxx.
Double_t TKDTreeBinning::GetDataMax | ( | UInt_t | dim | ) | const |
Returns the maximum of the data in the dim coordinate. 'dim' is between 0 and fDim - 1.
Definition at line 465 of file TKDTreeBinning.cxx.
Double_t TKDTreeBinning::GetDataMin | ( | UInt_t | dim | ) | const |
Returns the minimum of the data in the dim coordinate. 'dim' is between 0 and fDim - 1.
Definition at line 456 of file TKDTreeBinning.cxx.
UInt_t TKDTreeBinning::GetDim | ( | ) | const |
Returns the number of dimensions.
Definition at line 424 of file TKDTreeBinning.cxx.
const Double_t * TKDTreeBinning::GetDimData | ( | UInt_t | dim | ) | const |
Definition at line 447 of file TKDTreeBinning.cxx.
UInt_t TKDTreeBinning::GetNBins | ( | ) | const |
Returns the number of bins.
Definition at line 419 of file TKDTreeBinning.cxx.
const double * TKDTreeBinning::GetOneDimBinEdges | ( | ) | const |
Returns a pointer to the vector of the bin edges for one dimensional binning only.
size of the vector is fNBins + 1 is the vector has been sorted in increasing bin edges N.B : if one does not call SortOneDimBinEdges the bins are not ordered
Definition at line 505 of file TKDTreeBinning.cxx.
std::vector< std::vector< Double_t > > TKDTreeBinning::GetPointsInBin | ( | UInt_t | bin | ) | const |
Return the corresponding point belonging to the bin i.
Definition at line 639 of file TKDTreeBinning.cxx.
TKDTreeID * TKDTreeBinning::GetTree | ( | ) | const |
Returns the kD-Tree structure of the binning.
Definition at line 439 of file TKDTreeBinning.cxx.
|
private |
Disallowed copy constructor.
|
private |
Definition at line 329 of file TKDTreeBinning.cxx.
|
private |
Definition at line 300 of file TKDTreeBinning.cxx.
|
private |
Definition at line 267 of file TKDTreeBinning.cxx.
|
private |
Definition at line 242 of file TKDTreeBinning.cxx.
|
private |
Definition at line 251 of file TKDTreeBinning.cxx.
|
private |
Definition at line 279 of file TKDTreeBinning.cxx.
|
private |
Disallowed assign operator.
Definition at line 211 of file TKDTreeBinning.cxx.
|
private |
Definition at line 224 of file TKDTreeBinning.cxx.
void TKDTreeBinning::SetNBins | ( | UInt_t | bins | ) |
Sets binning inner structure.
Definition at line 129 of file TKDTreeBinning.cxx.
|
private |
Definition at line 236 of file TKDTreeBinning.cxx.
void TKDTreeBinning::SortBinsByDensity | ( | Bool_t | sortAsc = kTRUE | ) |
Sorts bins by their density.
Definition at line 159 of file TKDTreeBinning.cxx.
const Double_t * TKDTreeBinning::SortOneDimBinEdges | ( | Bool_t | sortAsc = kTRUE | ) |
Sort the one-dimensional bin edges and retuns a pointer to them.
Definition at line 516 of file TKDTreeBinning.cxx.
|
friend |
! Predicate for ascending sort
Definition at line 46 of file TKDTreeBinning.h.
|
friend |
! Predicate for descending sort
Definition at line 48 of file TKDTreeBinning.h.
|
private |
The minimum values for the bins' edges for each dimension.
Definition at line 34 of file TKDTreeBinning.h.
|
private |
[fDataSize*fDim] The data from which a KDTree partition is computed for binning
Definition at line 33 of file TKDTreeBinning.h.
|
private |
Flags if the bin edges are sorted densitywise (or by bin-edge for 1D) in ascending order.
Definition at line 45 of file TKDTreeBinning.h.
|
private |
Minimum and maximum data values.
! Auxiliary structure for readjusting the bin edges. Flags if the bin edge was processed in the algorithm
Definition at line 41 of file TKDTreeBinning.h.
|
private |
! Auxiliary structure for readjusting the bin edges. Keeps the common bin boundaries
Definition at line 42 of file TKDTreeBinning.h.
|
private |
Definition at line 32 of file TKDTreeBinning.h.
|
private |
Index of the bins in the kd-tree (needed when bins are sorted)
! The binning inner structure.
Definition at line 36 of file TKDTreeBinning.h.
|
private |
The data dimension.
Definition at line 39 of file TKDTreeBinning.h.
|
private |
The data size.
Definition at line 40 of file TKDTreeBinning.h.
|
private |
The number of bins.
Definition at line 38 of file TKDTreeBinning.h.
|
private |
The maximum values for the bins' edges for each dimension.
Definition at line 35 of file TKDTreeBinning.h.
|
private |
Definition at line 43 of file TKDTreeBinning.h.
|
private |
Flags if the bin edges are sorted densitywise (or by bin endges in case of 1-dim )
Definition at line 44 of file TKDTreeBinning.h.
|
private |
Definition at line 37 of file TKDTreeBinning.h.