class TKDTreeBinning: public TObject

```
```

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 can be found in http://root.cern.ch/lxr/source/math/mathcore/src/TKDTree.cxx or http://root.cern.ch/lxr/source/math/mathcore/inc/TKDTree.h.

Function Members (Methods)

public:
protected:
 virtual void TObject::DoError(int level, const char* location, const char* fmt, va_list va) const void TObject::MakeZombie()
private:
 TKDTreeBinning operator=(TKDTreeBinning& bins) 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) void SetTreeData() TKDTreeBinning(TKDTreeBinning& bins)

Data Members

public:
 static TKDTreeBinning::(anonymous) kAdjustBinEdges static TObject::(anonymous) TObject::kBitMask static TObject::EStatusBits TObject::kCanDelete static TObject::EStatusBits TObject::kCannotPick static TObject::EStatusBits TObject::kHasUUID static TObject::EStatusBits TObject::kInvalidObject static TObject::(anonymous) TObject::kIsOnHeap static TObject::EStatusBits TObject::kIsReferenced static TObject::EStatusBits TObject::kMustCleanup static TObject::EStatusBits TObject::kNoContextMenu static TObject::(anonymous) TObject::kNotDeleted static TObject::EStatusBits TObject::kObjInCanvas static TObject::(anonymous) TObject::kOverwrite static TObject::(anonymous) TObject::kSingleKey static TObject::(anonymous) TObject::kWriteDelete static TObject::(anonymous) TObject::kZombie
private:
 vector fBinMaxEdges The maximum values for the bins' edges for each dimension vector fBinMinEdges The minimum values for the bins' edges for each dimension vector fBinsContent Holds the contents of the bins vector > > fCheckedBinEdges Auxiliary structure for readjusting the bin edges. Flags if the bin edge was processed in the algorithm vector > > fCommonBinEdges Auxiliary structure for readjusting the bin edges. Keeps the common bin boundaries Double_t** fData The data from which a KDTree partition is computed for binning TKDTreeID* fDataBins The binning inner structure. UInt_t fDataSize The data size vector > fDataThresholds Minimum and maximum data values. UInt_t fDim The data dimension vector fIndices Index of the bins in the kd-tree (needed when bins are sorted) Bool_t fIsSorted Flags if the bin edges are sorted densitywise (or by bin endges in case of 1-dim ) Bool_t fIsSortedAsc Flags if the bin edges are sorted densitywise (or by bin-edge for 1D) in ascending order UInt_t fNBins The number of bins

Function documentation

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

```

``` Class's destructor
```
void SetNBins(UInt_t bins)
``` Sets binning inner structure
```
void SortBinsByDensity(Bool_t sortAsc = kTRUE)
``` Sorts bins by their density
```
void SetData(Double_t* data)
``` Sets the data and finds minimum and maximum by dimensional coordinate
```
void SetTreeData()
``` Sets the data for constructing the kD-tree
```
void SetBinsContent()
``` Sets the bins' content
```
void SetBinsEdges()
``` Sets the bins' edges
Double_t* rawBinEdges = fDataBins->GetBoundaryExact(fDataBins->GetNNodes());
```
void SetBinMinMaxEdges(Double_t* binEdges)
``` Sets the bins' minimum and maximum edges
```
void SetCommonBinEdges(Double_t* binEdges)
``` Sets indexing on the bin edges which have common boundaries
```
``` Readjusts the bins' minimum edge by shifting it slightly lower
to avoid overlapping with the data
```
``` Readjusts the bins' maximum edge
and shift it sligtly higher
```
const Double_t* GetBinsMinEdges() const
``` Returns the bins' minimum edges
```
const Double_t* GetBinsMaxEdges() const
``` Returns the bins' maximum edges
```
std::pair<const Double_t*, const Double_t*> GetBinsEdges() const
``` Returns the bins' edges
```
const Double_t* GetBinMinEdges(UInt_t bin) const
``` Returns the bin's minimum edges. 'bin' is between 0 and fNBins - 1
```
const Double_t* GetBinMaxEdges(UInt_t bin) const
``` Returns the bin's maximum edges. 'bin' is between 0 and fNBins - 1
```
std::pair<const Double_t*, const Double_t*> GetBinEdges(UInt_t bin) const
``` Returns the bin's edges. 'bin' is between 0 and fNBins - 1
```
UInt_t GetNBins() const
``` Returns the number of bins
```
UInt_t GetDim() const
``` Returns the number of dimensions
```
UInt_t GetBinContent(UInt_t bin) const
``` Returns the number of points in bin. 'bin' is between 0 and fNBins - 1
```
TKDTreeID* GetTree() const
``` Returns the kD-Tree structure of the binning
```
const Double_t* GetDimData(UInt_t dim) const
``` Returns the data in the dim coordinate. 'dim' is between 0 and fDim - 1
```
Double_t GetDataMin(UInt_t dim) const
``` Returns the data minimum in the dim coordinate. 'dim' is between 0 and fDim - 1
```
Double_t GetDataMax(UInt_t dim) const
``` Returns the data maximum in the dim coordinate. 'dim' is between 0 and fDim - 1
```
Double_t GetBinDensity(UInt_t bin) const
``` Returns the density in bin. 'bin' is between 0 and fNBins - 1
```
Double_t GetBinVolume(UInt_t bin) const
``` Returns the (hyper)volume of bin. 'bin' is between 0 and fNBins - 1
```
const double * GetOneDimBinEdges() const
``` Returns the minimum 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
```
const Double_t * SortOneDimBinEdges(Bool_t sortAsc = kTRUE)
const Double_t* GetBinCenter(UInt_t bin) const
``` Returns the geometric center of of the bin. 'bin' is between 0 and fNBins - 1
```
const Double_t* GetBinWidth(UInt_t bin) const
``` Returns the geometric center of of the bin. 'bin' is between 0 and fNBins - 1
```
UInt_t GetBinMaxDensity() const
``` Return the bin with maximum density
```
UInt_t GetBinMinDensity() const
``` Return the bin with minimum density
```
void FillBinData(ROOT::Fit::BinData& data) const
``` Fill the bin data set with the result of the TKDTree binning
```
UInt_t FindBin(const Double_t* point) const
``` find the corresponding bin index given a point
```
TKDTreeBinning(TKDTreeBinning& bins)