<- 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 Types inherited from TObject | |
enum | { kIsOnHeap = 0x01000000 , kNotDeleted = 0x02000000 , kZombie = 0x04000000 , kInconsistent = 0x08000000 , kBitMask = 0x00ffffff } |
enum | { kSingleKey = BIT(0) , kOverwrite = BIT(1) , kWriteDelete = BIT(2) } |
enum | EDeprecatedStatusBits { kObjInCanvas = BIT(3) } |
enum | EStatusBits { kCanDelete = BIT(0) , kMustCleanup = BIT(3) , kIsReferenced = BIT(4) , kHasUUID = BIT(5) , kCannotPick = BIT(6) , kNoContextMenu = BIT(8) , kInvalidObject = BIT(13) } |
Public Member Functions | |
TKDTreeBinning () | |
Default constructor (for I/O) 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 (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 () | |
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... | |
Public Member Functions inherited from TObject | |
TObject () | |
TObject constructor. More... | |
TObject (const TObject &object) | |
TObject copy ctor. More... | |
virtual | ~TObject () |
TObject destructor. More... | |
void | AbstractMethod (const char *method) const |
Use this method to implement an "abstract" method that you don't want to leave purely abstract. More... | |
virtual void | AppendPad (Option_t *option="") |
Append graphics object to current pad. More... | |
virtual void | Browse (TBrowser *b) |
Browse object. May be overridden for another default action. More... | |
ULong_t | CheckedHash () |
Check and record whether this class has a consistent Hash/RecursiveRemove setup (*) and then return the regular Hash value for this object. More... | |
virtual const char * | ClassName () const |
Returns name of class to which the object belongs. More... | |
virtual void | Clear (Option_t *="") |
virtual TObject * | Clone (const char *newname="") const |
Make a clone of an object using the Streamer facility. More... | |
virtual Int_t | Compare (const TObject *obj) const |
Compare abstract method. More... | |
virtual void | Copy (TObject &object) const |
Copy this to obj. More... | |
virtual void | Delete (Option_t *option="") |
Delete this object. More... | |
virtual Int_t | DistancetoPrimitive (Int_t px, Int_t py) |
Computes distance from point (px,py) to the object. More... | |
virtual void | Draw (Option_t *option="") |
Default Draw method for all objects. More... | |
virtual void | DrawClass () const |
Draw class inheritance tree of the class to which this object belongs. More... | |
virtual TObject * | DrawClone (Option_t *option="") const |
Draw a clone of this object in the current selected pad for instance with: gROOT->SetSelectedPad(gPad) . More... | |
virtual void | Dump () const |
Dump contents of object on stdout. More... | |
virtual void | Error (const char *method, const char *msgfmt,...) const |
Issue error message. More... | |
virtual void | Execute (const char *method, const char *params, Int_t *error=0) |
Execute method on this object with the given parameter string, e.g. More... | |
virtual void | Execute (TMethod *method, TObjArray *params, Int_t *error=0) |
Execute method on this object with parameters stored in the TObjArray. More... | |
virtual void | ExecuteEvent (Int_t event, Int_t px, Int_t py) |
Execute action corresponding to an event at (px,py). More... | |
virtual void | Fatal (const char *method, const char *msgfmt,...) const |
Issue fatal error message. More... | |
virtual TObject * | FindObject (const char *name) const |
Must be redefined in derived classes. More... | |
virtual TObject * | FindObject (const TObject *obj) const |
Must be redefined in derived classes. More... | |
virtual Option_t * | GetDrawOption () const |
Get option used by the graphics system to draw this object. More... | |
virtual const char * | GetIconName () const |
Returns mime type name of object. More... | |
virtual const char * | GetName () const |
Returns name of object. More... | |
virtual char * | GetObjectInfo (Int_t px, Int_t py) const |
Returns string containing info about the object at position (px,py). More... | |
virtual Option_t * | GetOption () const |
virtual const char * | GetTitle () const |
Returns title of object. More... | |
virtual UInt_t | GetUniqueID () const |
Return the unique object id. More... | |
virtual Bool_t | HandleTimer (TTimer *timer) |
Execute action in response of a timer timing out. More... | |
virtual ULong_t | Hash () const |
Return hash value for this object. More... | |
Bool_t | HasInconsistentHash () const |
Return true is the type of this object is known to have an inconsistent setup for Hash and RecursiveRemove (i.e. More... | |
virtual void | Info (const char *method, const char *msgfmt,...) const |
Issue info message. More... | |
virtual Bool_t | InheritsFrom (const char *classname) const |
Returns kTRUE if object inherits from class "classname". More... | |
virtual Bool_t | InheritsFrom (const TClass *cl) const |
Returns kTRUE if object inherits from TClass cl. More... | |
virtual void | Inspect () const |
Dump contents of this object in a graphics canvas. More... | |
void | InvertBit (UInt_t f) |
virtual Bool_t | IsEqual (const TObject *obj) const |
Default equal comparison (objects are equal if they have the same address in memory). More... | |
virtual Bool_t | IsFolder () const |
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects). More... | |
R__ALWAYS_INLINE Bool_t | IsOnHeap () const |
virtual Bool_t | IsSortable () const |
R__ALWAYS_INLINE Bool_t | IsZombie () const |
virtual void | ls (Option_t *option="") const |
The ls function lists the contents of a class on stdout. More... | |
void | MayNotUse (const char *method) const |
Use this method to signal that a method (defined in a base class) may not be called in a derived class (in principle against good design since a child class should not provide less functionality than its parent, however, sometimes it is necessary). More... | |
virtual Bool_t | Notify () |
This method must be overridden to handle object notification. More... | |
void | Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const |
Use this method to declare a method obsolete. More... | |
void | operator delete (void *ptr) |
Operator delete. More... | |
void | operator delete[] (void *ptr) |
Operator delete []. More... | |
void * | operator new (size_t sz) |
void * | operator new (size_t sz, void *vp) |
void * | operator new[] (size_t sz) |
void * | operator new[] (size_t sz, void *vp) |
TObject & | operator= (const TObject &rhs) |
TObject assignment operator. More... | |
virtual void | Paint (Option_t *option="") |
This method must be overridden if a class wants to paint itself. More... | |
virtual void | Pop () |
Pop on object drawn in a pad to the top of the display list. More... | |
virtual void | Print (Option_t *option="") const |
This method must be overridden when a class wants to print itself. More... | |
virtual Int_t | Read (const char *name) |
Read contents of object with specified name from the current directory. More... | |
virtual void | RecursiveRemove (TObject *obj) |
Recursively remove this object from a list. More... | |
void | ResetBit (UInt_t f) |
virtual void | SaveAs (const char *filename="", Option_t *option="") const |
Save this object in the file specified by filename. More... | |
virtual void | SavePrimitive (std::ostream &out, Option_t *option="") |
Save a primitive as a C++ statement(s) on output stream "out". More... | |
void | SetBit (UInt_t f) |
void | SetBit (UInt_t f, Bool_t set) |
Set or unset the user status bits as specified in f. More... | |
virtual void | SetDrawOption (Option_t *option="") |
Set drawing option for object. More... | |
virtual void | SetUniqueID (UInt_t uid) |
Set the unique object id. More... | |
virtual void | SysError (const char *method, const char *msgfmt,...) const |
Issue system error message. More... | |
R__ALWAYS_INLINE Bool_t | TestBit (UInt_t f) const |
Int_t | TestBits (UInt_t f) const |
virtual void | UseCurrentStyle () |
Set current style settings in this object This function is called when either TCanvas::UseCurrentStyle or TROOT::ForceStyle have been invoked. More... | |
virtual void | Warning (const char *method, const char *msgfmt,...) const |
Issue warning message. More... | |
virtual Int_t | Write (const char *name=0, Int_t option=0, Int_t bufsize=0) |
Write this object to the current directory. More... | |
virtual Int_t | Write (const char *name=0, Int_t option=0, Int_t bufsize=0) const |
Write this object to the current directory. 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 (const std::vector< double > &data) |
void | SetData (Double_t *data) |
Disallowed assign operator. More... | |
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... | |
Additional Inherited Members | |
Static Public Member Functions inherited from TObject | |
static Long_t | GetDtorOnly () |
Return destructor only flag. More... | |
static Bool_t | GetObjectStat () |
Get status of object stat flag. More... | |
static void | SetDtorOnly (void *obj) |
Set destructor only flag. More... | |
static void | SetObjectStat (Bool_t stat) |
Turn on/off tracking of objects in the TObjectTable. More... | |
Protected Member Functions inherited from TObject | |
virtual void | DoError (int level, const char *location, const char *fmt, va_list va) const |
Interface to ErrorHandler (protected). More... | |
void | MakeZombie () |
#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.
find the corresponding bin index given the coordinate of a point
Definition at line 624 of file TKDTreeBinning.cxx.
Returns the geometric center of of the bin. 'bin' is between 0 and fNBins - 1.
Definition at line 554 of file TKDTreeBinning.cxx.
Returns the number of points in bin. 'bin' is between 0 and fNBins - 1.
Definition at line 429 of file TKDTreeBinning.cxx.
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.
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.
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.
Returns the bin's minimum edges. 'bin' is between 0 and fNBins - 1.
Definition at line 380 of file TKDTreeBinning.cxx.
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.
Returns the (hyper)volume of bin. 'bin' is between 0 and fNBins - 1.
Definition at line 488 of file TKDTreeBinning.cxx.
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.
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.
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.
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.
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.
Definition at line 329 of file TKDTreeBinning.cxx.
Definition at line 300 of file TKDTreeBinning.cxx.
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.
Definition at line 279 of file TKDTreeBinning.cxx.
|
private |
Definition at line 224 of file TKDTreeBinning.cxx.
Disallowed assign operator.
Definition at line 211 of file TKDTreeBinning.cxx.
Sets binning inner structure.
Definition at line 129 of file TKDTreeBinning.cxx.
|
private |
Definition at line 236 of file TKDTreeBinning.cxx.
Sorts bins by their density.
Definition at line 159 of file TKDTreeBinning.cxx.
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 47 of file TKDTreeBinning.h.
|
friend |
! Predicate for descending sort
Definition at line 49 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.
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.
! 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.
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.