HyperPlot  v1
Bin and visualise multidimensional datasets
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
HyperBinningMemRes Class Reference

Detailed Description

HyperPlot, Author: Sam Harnew, sam.h.nosp@m.arne.nosp@m.w@gma.nosp@m.il.c.nosp@m.om , Date: Dec 2015

HyperBinningMemRes is a binning scheme where each bin volume is defined by a HyperVolume.

Finding the correct bin number is quite a compuationally slow process if one has to loop over every bin and check if a HyperPoint falls within that bin volume. It's not unusual to have millions of HyperPoints that need to be sorted into tens of thousands of bins. This would require billions of calulations. To speed this process up there is the option to build a hierarchy of bins. A schematic below shows a 1D example.

HyperVolume Numbers
|-------------0-------------|
|------1------|------2------|
|--3---|---4--|---5---|--6--|
|-7-|-8|
Bin Numbers
| 0 | 1| 2 | 3 | 4 |

Imagine we have a HyperPoint that falls into Bin 0. One would first check if it falls into HyperVolume 0 (note the distiction here between Bin/HyperVolume Numbers as indicated by the figure). First we check if it falls into HyperVolume 0, then HyperVolume 1 or 2, then HyperVolume 3 or 4, then HyperVolume 7 or 8.

In this simple example, it took 7 operations, whereas checking each Bin would have taken

  1. Clearly as the number of bins increases, it becomes computationally much less expensive to follow this hierarchy approach.

The

Definition at line 80 of file HyperBinningMemRes.h.

#include <HyperBinningMemRes.h>

Inheritance diagram for HyperBinningMemRes:
HyperBinning BinningBase

Public Member Functions

 HyperBinningMemRes ()
 The only constructor.
 
virtual ~HyperBinningMemRes ()
 
virtual void reserveCapacity (int nElements)
 
virtual std::vector< int > getPrimaryVolumeNumbers () const
 
virtual void setDimension (int dim)
 
virtual void addPrimaryVolumeNumber (int volumeNumber)
 
virtual bool addHyperVolume (const HyperVolume &hyperVolume, std::vector< int > linkedVolumes=std::vector< int >(0, 0))
 
virtual int getNumHyperVolumes () const
 
virtual HyperVolume getHyperVolume (int volumeNumber) const
 
virtual std::vector< int > getLinkedHyperVolumes (int volumeNumber) const
 
virtual int getNumPrimaryVolumes () const
 
virtual int getPrimaryVolumeNumber (int i) const
 
virtual void load (TString filename, TString option="READ")
 
virtual BinningBaseclone () const
 
- Public Member Functions inherited from HyperBinning
 HyperBinning ()
 The only constructor.
 
bool isPrimaryVolume (int volumeNumber) const
 
int getHyperVolumeNumber (int binNumber) const
 
int getBinNum (int volumeNumber) const
 
virtual ~HyperBinning ()
 
virtual void save (TString filename) const
 
virtual void save () const
 
virtual void mergeBinnings (const BinningBase &other)
 
virtual int getNumBins () const
 
virtual int getBinNum (const HyperPoint &coords) const
 
virtual std::vector< int > getBinNum (const HyperPointSet &coords) const
 
std::vector< int > getBinNumAlt (const HyperPointSet &coords) const
 
virtual HyperVolume getBinHyperVolume (int binNumber) const
 
virtual HyperPoint getAverageBinWidth () const
 
virtual HyperCuboid getLimits () const
 
- Public Member Functions inherited from BinningBase
void setNames (HyperName names)
 
HyperName getNames () const
 
const int & getDimension () const
 
double getMin (int dimension) const
 
double getMax (int dimension) const
 
TString getBinningType () const
 
bool isSameBinningType (const BinningBase &other) const
 
virtual bool isDiskResident () const
 
virtual TString filename () const
 

Protected Member Functions

void setBranchAddresses (TTree *tree, int *binNumber, double *lowCorner, double *highCorner, std::vector< int > **linkedBins) const
 
void loadPrimaryVolumeNumbers (TFile *file)
 
- Protected Member Functions inherited from HyperBinning
int followBinLinks (const HyperPoint &coords, int binNumber) const
 
void updateCash () const
 
void updateBinNumbering () const
 
void updateAverageBinWidth () const
 
void updateMinMax () const
 
int getHyperBinningDimFromTree (TTree *tree)
 
void createBranches (TTree *tree, int *binNumber, double *lowCorner, double *highCorner, std::vector< int > **linkedBins) const
 
void saveHyperVolumeToTree (TTree *tree, double *lowCorner, double *highCorner, const HyperVolume &hyperVolume) const
 
void savePrimaryVolumeNumbers () const
 
- Protected Member Functions inherited from BinningBase
void setBinningType (TString binningType)
 

Protected Attributes

std::vector< HyperVolume_hyperVolumes
 
std::vector< int > _primaryVolumeNumbers
 
std::vector< std::vector< int > > _linkedHyperVolumes
 

Constructor & Destructor Documentation

HyperBinningMemRes::~HyperBinningMemRes ( )
virtual

Destructor

Definition at line 254 of file HyperBinningMemRes.cpp.

Member Function Documentation

bool HyperBinningMemRes::addHyperVolume ( const HyperVolume hyperVolume,
std::vector< int >  linkedVolumes = std::vector<int>(0, 0) 
)
virtual

Add a HyperVolume to the HyperBinningMemRes and add a set of empty HyperVolume links.

Implements HyperBinning.

Definition at line 65 of file HyperBinningMemRes.cpp.

void HyperBinningMemRes::addPrimaryVolumeNumber ( int  volumeNumber)
virtual

Add a primary volume number

Implements HyperBinning.

Definition at line 41 of file HyperBinningMemRes.cpp.

HyperVolume HyperBinningMemRes::getHyperVolume ( int  volumeNumber) const
virtual

get one of the HyperVolumes

Implements HyperBinning.

Definition at line 127 of file HyperBinningMemRes.cpp.

int HyperBinningMemRes::getNumHyperVolumes ( ) const
virtual

get the number of HyperVolumes

Implements HyperBinning.

Definition at line 49 of file HyperBinningMemRes.cpp.

std::vector< int > HyperBinningMemRes::getPrimaryVolumeNumbers ( ) const
virtual

Look at the tree that contains the HyperBinningMemRes and find the dimensionality

Reimplemented from HyperBinning.

Definition at line 134 of file HyperBinningMemRes.cpp.

void HyperBinningMemRes::load ( TString  filename,
TString  option = "READ" 
)
virtual

Load HyperBinningMemRes from a file

Implements HyperBinning.

Definition at line 141 of file HyperBinningMemRes.cpp.

void HyperBinningMemRes::loadPrimaryVolumeNumbers ( TFile *  file)
protected

Save the list of Primary Volume Numbers to the open (and in scope) TFile.

Definition at line 89 of file HyperBinningMemRes.cpp.

void HyperBinningMemRes::setBranchAddresses ( TTree *  tree,
int *  binNumber,
double *  lowCorner,
double *  highCorner,
std::vector< int > **  linkedBins 
) const
protected

Set branch addresses for loading HyperBinningMemRes from a file.

Definition at line 113 of file HyperBinningMemRes.cpp.

void HyperBinningMemRes::setDimension ( int  dim)
virtual

Set the dimension of the HyperBinningMemRes. This can only be called once, when it is known what dimesnion it is.

Reimplemented from HyperBinning.

Definition at line 15 of file HyperBinningMemRes.cpp.

Member Data Documentation

std::vector< HyperVolume > HyperBinningMemRes::_hyperVolumes
protected

std::vector containing all of the HyperVolumes. Usually, not all of these are bins, but part of the bin hierarchy that is discussed in the class description.

Definition at line 84 of file HyperBinningMemRes.h.

std::vector< std::vector<int> > HyperBinningMemRes::_linkedHyperVolumes
protected

Every HyperVolume has a _linkedHyperVolumes - if this is empty, this means the HyperVolume is a true Bin. If not it is part of the binning hierarchy. In the below, HyperVolume 0 would be linked to HyperVolume [1,2], although HyperVolume 4 would be linked to nothing.

HyperVolume Numbers
|-------------0-------------|
|------1------|------2------|
|--3---|---4--|---5---|--6--|
|-7-|-8|
Bin Numbers
| 0 | 1| 2 | 3 | 4 |

Definition at line 116 of file HyperBinningMemRes.h.

std::vector< int > HyperBinningMemRes::_primaryVolumeNumbers
protected

Usually all bins will be accessed through one primary volume i.e. volume 0 in the below example. If one wants to merge two binning schemes together e.g. Binning1 and Binning2 this involes appending the list of HyperVolumes from Binning2 to Binning1. This brings a problem when trying to sort a HyperPoint into a specific bin i.e. getBinNumber(HyperPoint) - if it belongs to Binning2, it will first have to check that it doesn't fall into any of the volumes in Binning1.

To remedy this problem we introduce the list of primary volumes. If this list exists i.e. its size is greater than 0, all the primary volumes will be checked first. The existance of this list also implies that ALL volumes are linked to the primary volumes.

   HyperVolume Numbers 

|----------—0----------—|

|---—1---—|---—2---—|

|–3—|—4–|—5—|–6–|

|-7-|-8|

Definition at line 90 of file HyperBinningMemRes.h.


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