<- 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.
Classes | |
struct | CompareAsc |
struct | CompareDesc |
Public Types | |
enum | { kAdjustBinEdges = BIT(14) } |
![]() | |
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) | |
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). | |
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). | |
~TKDTreeBinning () | |
Class's destructor. | |
void | FillBinData (ROOT::Fit::BinData &data) const |
Fill the bin data set (class ROOT::Fit::BinData) with the result of the TKDTree binning. | |
UInt_t | FindBin (const Double_t *point) const |
find the corresponding bin index given the coordinate of a point | |
const Double_t * | GetBinCenter (UInt_t bin) const |
Returns the geometric center of of the bin. | |
UInt_t | GetBinContent (UInt_t bin) const |
Returns the number of points in bin. 'bin' is between 0 and fNBins - 1. | |
Double_t | GetBinDensity (UInt_t bin) const |
Returns the density in bin. | |
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. | |
UInt_t | GetBinMaxDensity () const |
Return the bin with maximum density. | |
const Double_t * | GetBinMaxEdges (UInt_t bin) const |
Returns the bin's maximum edges. 'bin' is between 0 and fNBins - 1. | |
UInt_t | GetBinMinDensity () const |
Return the bin with minimum density. | |
const Double_t * | GetBinMinEdges (UInt_t bin) const |
Returns the bin's minimum edges. 'bin' is between 0 and fNBins - 1. | |
std::pair< const Double_t *, const Double_t * > | GetBinsEdges () const |
Returns a pair of an array with all bins minimum and maximum edges. | |
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}. | |
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}. | |
Double_t | GetBinVolume (UInt_t bin) const |
Returns the (hyper)volume of bin. 'bin' is between 0 and fNBins - 1. | |
const Double_t * | GetBinWidth (UInt_t bin) const |
Returns a pointer to the vector of the bin widths. | |
Double_t | GetDataMax (UInt_t dim) const |
Returns the maximum of the data in the dim coordinate. 'dim' is between 0 and fDim - 1. | |
Double_t | GetDataMin (UInt_t dim) const |
Returns the minimum of the data in the dim coordinate. 'dim' is between 0 and fDim - 1. | |
UInt_t | GetDim () const |
Returns the number of dimensions. | |
const Double_t * | GetDimData (UInt_t dim) const |
UInt_t | GetNBins () const |
Returns the number of bins. | |
const Double_t * | GetOneDimBinEdges () const |
Returns a pointer to the vector of the bin edges for one dimensional binning only. | |
std::vector< std::vector< Double_t > > | GetPointsInBin (UInt_t bin) const |
Return the corresponding point belonging to the bin i. | |
TKDTreeID * | GetTree () const |
Returns the kD-Tree structure of the binning. | |
void | SetNBins (UInt_t bins) |
Sets binning inner structure. | |
void | SortBinsByDensity (Bool_t sortAsc=kTRUE) |
Sorts bins by their density. | |
const Double_t * | SortOneDimBinEdges (Bool_t sortAsc=kTRUE) |
Sort the one-dimensional bin edges and retuns a pointer to them. | |
![]() | |
TObject () | |
TObject constructor. | |
TObject (const TObject &object) | |
TObject copy ctor. | |
virtual | ~TObject () |
TObject destructor. | |
void | AbstractMethod (const char *method) const |
Use this method to implement an "abstract" method that you don't want to leave purely abstract. | |
virtual void | AppendPad (Option_t *option="") |
Append graphics object to current pad. | |
virtual void | Browse (TBrowser *b) |
Browse object. May be overridden for another default action. | |
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. | |
virtual const char * | ClassName () const |
Returns name of class to which the object belongs. | |
virtual void | Clear (Option_t *="") |
virtual TObject * | Clone (const char *newname="") const |
Make a clone of an object using the Streamer facility. | |
virtual Int_t | Compare (const TObject *obj) const |
Compare abstract method. | |
virtual void | Copy (TObject &object) const |
Copy this to obj. | |
virtual void | Delete (Option_t *option="") |
Delete this object. | |
virtual Int_t | DistancetoPrimitive (Int_t px, Int_t py) |
Computes distance from point (px,py) to the object. | |
virtual void | Draw (Option_t *option="") |
Default Draw method for all objects. | |
virtual void | DrawClass () const |
Draw class inheritance tree of the class to which this object belongs. | |
virtual TObject * | DrawClone (Option_t *option="") const |
Draw a clone of this object in the current selected pad for instance with: gROOT->SetSelectedPad(gPad) . | |
virtual void | Dump () const |
Dump contents of object on stdout. | |
virtual void | Error (const char *method, const char *msgfmt,...) const |
Issue error message. | |
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. | |
virtual void | Execute (TMethod *method, TObjArray *params, Int_t *error=0) |
Execute method on this object with parameters stored in the TObjArray. | |
virtual void | ExecuteEvent (Int_t event, Int_t px, Int_t py) |
Execute action corresponding to an event at (px,py). | |
virtual void | Fatal (const char *method, const char *msgfmt,...) const |
Issue fatal error message. | |
virtual TObject * | FindObject (const char *name) const |
Must be redefined in derived classes. | |
virtual TObject * | FindObject (const TObject *obj) const |
Must be redefined in derived classes. | |
virtual Option_t * | GetDrawOption () const |
Get option used by the graphics system to draw this object. | |
virtual const char * | GetIconName () const |
Returns mime type name of object. | |
virtual const char * | GetName () const |
Returns name of object. | |
virtual char * | GetObjectInfo (Int_t px, Int_t py) const |
Returns string containing info about the object at position (px,py). | |
virtual Option_t * | GetOption () const |
virtual const char * | GetTitle () const |
Returns title of object. | |
virtual UInt_t | GetUniqueID () const |
Return the unique object id. | |
virtual Bool_t | HandleTimer (TTimer *timer) |
Execute action in response of a timer timing out. | |
virtual ULong_t | Hash () const |
Return hash value for this object. | |
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. | |
virtual void | Info (const char *method, const char *msgfmt,...) const |
Issue info message. | |
virtual Bool_t | InheritsFrom (const char *classname) const |
Returns kTRUE if object inherits from class "classname". | |
virtual Bool_t | InheritsFrom (const TClass *cl) const |
Returns kTRUE if object inherits from TClass cl. | |
virtual void | Inspect () const |
Dump contents of this object in a graphics canvas. | |
void | InvertBit (UInt_t f) |
Bool_t | IsDestructed () const |
IsDestructed. | |
virtual Bool_t | IsEqual (const TObject *obj) const |
Default equal comparison (objects are equal if they have the same address in memory). | |
virtual Bool_t | IsFolder () const |
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects). | |
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. | |
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). | |
virtual Bool_t | Notify () |
This method must be overridden to handle object notification. | |
void | Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const |
Use this method to declare a method obsolete. | |
void | operator delete (void *ptr) |
Operator delete. | |
void | operator delete[] (void *ptr) |
Operator delete []. | |
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. | |
virtual void | Paint (Option_t *option="") |
This method must be overridden if a class wants to paint itself. | |
virtual void | Pop () |
Pop on object drawn in a pad to the top of the display list. | |
virtual void | Print (Option_t *option="") const |
This method must be overridden when a class wants to print itself. | |
virtual Int_t | Read (const char *name) |
Read contents of object with specified name from the current directory. | |
virtual void | RecursiveRemove (TObject *obj) |
Recursively remove this object from a list. | |
void | ResetBit (UInt_t f) |
virtual void | SaveAs (const char *filename="", Option_t *option="") const |
Save this object in the file specified by filename. | |
virtual void | SavePrimitive (std::ostream &out, Option_t *option="") |
Save a primitive as a C++ statement(s) on output stream "out". | |
void | SetBit (UInt_t f) |
void | SetBit (UInt_t f, Bool_t set) |
Set or unset the user status bits as specified in f. | |
virtual void | SetDrawOption (Option_t *option="") |
Set drawing option for object. | |
virtual void | SetUniqueID (UInt_t uid) |
Set the unique object id. | |
virtual void | SysError (const char *method, const char *msgfmt,...) const |
Issue system error message. | |
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. | |
virtual void | Warning (const char *method, const char *msgfmt,...) const |
Issue warning message. | |
virtual Int_t | Write (const char *name=0, Int_t option=0, Int_t bufsize=0) |
Write this object to the current directory. | |
virtual Int_t | Write (const char *name=0, Int_t option=0, Int_t bufsize=0) const |
Write this object to the current directory. | |
Private Member Functions | |
TKDTreeBinning (TKDTreeBinning &bins) | |
TKDTreeBinning | operator= (TKDTreeBinning &bins) |
Disallowed copy constructor. | |
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. | |
void | SetTreeData () |
Private Attributes | |
std::vector< Double_t > | fBinMaxEdges |
The minimum values for the bins' edges for each dimension. | |
std::vector< Double_t > | fBinMinEdges |
[fDataSize*fDim] The data from which a KDTree partition is computed for binning | |
std::vector< UInt_t > | fBinsContent |
Flags if the bin edges are sorted densitywise (or by bin-edge for 1D) in ascending order. | |
std::vector< std::vector< std::pair< Bool_t, Bool_t > > > | fCheckedBinEdges |
Minimum and maximum data values. | |
std::vector< std::map< Double_t, std::vector< UInt_t > > > | fCommonBinEdges |
! Auxiliary structure for readjusting the bin edges. Keeps the common bin boundaries | |
std::vector< Double_t > | fData |
TKDTreeID * | fDataBins |
Index of the bins in the kd-tree (needed when bins are sorted) | |
UInt_t | fDataSize |
The data dimension. | |
std::vector< std::pair< Double_t, Double_t > > | fDataThresholds |
The data size. | |
UInt_t | fDim |
The number of bins. | |
std::vector< UInt_t > | fIndices |
The maximum values for the bins' edges for each dimension. | |
Bool_t | fIsSorted |
Bool_t | fIsSortedAsc |
Flags if the bin edges are sorted densitywise (or by bin endges in case of 1-dim ) | |
UInt_t | fNBins |
Friends | |
struct | CompareAsc |
! Predicate for ascending sort | |
struct | CompareDesc |
! Predicate for descending sort | |
Additional Inherited Members | |
![]() | |
static Longptr_t | GetDtorOnly () |
Return destructor only flag. | |
static Bool_t | GetObjectStat () |
Get status of object stat flag. | |
static void | SetDtorOnly (void *obj) |
Set destructor only flag. | |
static void | SetObjectStat (Bool_t stat) |
Turn on/off tracking of objects in the TObjectTable. | |
![]() | |
enum | { kOnlyPrepStep = BIT(3) } |
![]() | |
virtual void | DoError (int level, const char *location, const char *fmt, va_list va) const |
Interface to ErrorHandler (protected). | |
void | MakeZombie () |
#include <TKDTreeBinning.h>
anonymous enum |
Enumerator | |
---|---|
kAdjustBinEdges |
Definition at line 66 of file TKDTreeBinning.h.
|
private |
TKDTreeBinning::TKDTreeBinning | ( | ) |
Default constructor (for I/O)
Definition at line 112 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 73 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 97 of file TKDTreeBinning.cxx.
TKDTreeBinning::~TKDTreeBinning | ( | ) |
Class's destructor.
Definition at line 122 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 615 of file TKDTreeBinning.cxx.
find the corresponding bin index given the coordinate of a point
Definition at line 625 of file TKDTreeBinning.cxx.
Returns the geometric center of of the bin.
'bin' is between 0 and fNBins - 1, Array must be deleted as "delete [] res"
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 428 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 474 of file TKDTreeBinning.cxx.
Returns a pir with the bin's edges. 'bin' is between 0 and fNBins - 1.
Definition at line 405 of file TKDTreeBinning.cxx.
UInt_t TKDTreeBinning::GetBinMaxDensity | ( | ) | const |
Return the bin with maximum density.
Definition at line 585 of file TKDTreeBinning.cxx.
Returns the bin's maximum edges. 'bin' is between 0 and fNBins - 1.
Definition at line 392 of file TKDTreeBinning.cxx.
UInt_t TKDTreeBinning::GetBinMinDensity | ( | ) | const |
Return the bin with minimum density.
Definition at line 600 of file TKDTreeBinning.cxx.
Returns the bin's minimum edges. 'bin' is between 0 and fNBins - 1.
Definition at line 379 of file TKDTreeBinning.cxx.
Returns a pair of an array with all bins minimum and maximum edges.
Definition at line 369 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 359 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 349 of file TKDTreeBinning.cxx.
Returns the (hyper)volume of bin. 'bin' is between 0 and fNBins - 1.
Definition at line 487 of file TKDTreeBinning.cxx.
Returns a pointer to the vector of the bin widths.
'bin' is between 0 and fNBins - 1 Array must be deleted as "delete [] res"
Definition at line 570 of file TKDTreeBinning.cxx.
Returns the maximum of the data in the dim coordinate. 'dim' is between 0 and fDim - 1.
Definition at line 464 of file TKDTreeBinning.cxx.
Returns the minimum of the data in the dim coordinate. 'dim' is between 0 and fDim - 1.
Definition at line 455 of file TKDTreeBinning.cxx.
UInt_t TKDTreeBinning::GetDim | ( | ) | const |
Returns the number of dimensions.
Definition at line 423 of file TKDTreeBinning.cxx.
Definition at line 446 of file TKDTreeBinning.cxx.
UInt_t TKDTreeBinning::GetNBins | ( | ) | const |
Returns the number of bins.
Definition at line 418 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 504 of file TKDTreeBinning.cxx.
Return the corresponding point belonging to the bin i.
Definition at line 640 of file TKDTreeBinning.cxx.
TKDTreeID * TKDTreeBinning::GetTree | ( | ) | const |
Returns the kD-Tree structure of the binning.
Definition at line 438 of file TKDTreeBinning.cxx.
|
private |
Disallowed copy constructor.
Definition at line 328 of file TKDTreeBinning.cxx.
Definition at line 299 of file TKDTreeBinning.cxx.
Definition at line 266 of file TKDTreeBinning.cxx.
|
private |
Definition at line 241 of file TKDTreeBinning.cxx.
|
private |
Definition at line 250 of file TKDTreeBinning.cxx.
Definition at line 278 of file TKDTreeBinning.cxx.
Definition at line 223 of file TKDTreeBinning.cxx.
Disallowed assign operator.
Definition at line 210 of file TKDTreeBinning.cxx.
Sets binning inner structure.
Definition at line 128 of file TKDTreeBinning.cxx.
|
private |
Definition at line 235 of file TKDTreeBinning.cxx.
Sorts bins by their density.
Definition at line 158 of file TKDTreeBinning.cxx.
Sort the one-dimensional bin edges and retuns a pointer to them.
Definition at line 515 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.