MINT2
Public Member Functions | Private Attributes | List of all members
UniformBinning Class Reference

#include <UniformBinning.h>

Inheritance diagram for UniformBinning:
BinningBase

Public Member Functions

 UniformBinning (HyperCuboid limits, int nLocalBins)
 The only constructor. More...
 
 UniformBinning (HyperCuboid limits, std::vector< int > nLocalBins)
 
virtual ~UniformBinning ()
 
int getNumLocalBins (int dimension) const
 
int getGlobalBinNumber (std::vector< int > localBinNumbers) const
 
std::vector< int > getLocalBinNumbers (int globalBinNumber) const
 
int getLocalBinNumber (int dim, double val) const
 
std::vector< int > getLocalBinNumbers (const HyperPoint &coords) const
 
double getLowBinEdgeLocal (int dim, int localBinNum) const
 
double getHighBinEdgeLocal (int dim, int localBinNum) const
 
HyperPoint getLowCorner (int globalBinNum) const
 
HyperPoint getHighCorner (int globalBinNum) const
 
virtual void load (TString filename, TString option="READ")
 
virtual BinningBaseclone () const
 
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 HyperVolume getBinHyperVolume (int binNumber) const
 
virtual HyperPoint getAverageBinWidth () const
 
virtual HyperCuboid getLimits () const
 
- Public Member Functions inherited from BinningBase
 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
 
virtual ~BinningBase ()
 
virtual void reserveCapacity (int nElements)
 
virtual std::vector< int > getBinNum (const HyperPointSet &coords) const
 

Private Attributes

HyperCuboid _limits
 
std::vector< int > _nLocalBins
 

Additional Inherited Members

- Protected Member Functions inherited from BinningBase
virtual void setDimension (int dimension)
 
void setBinningType (TString binningType)
 

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

Uniform binning

Definition at line 44 of file UniformBinning.h.

Constructor & Destructor Documentation

◆ UniformBinning() [1/2]

UniformBinning::UniformBinning ( HyperCuboid  limits,
int  nLocalBins 
)

The only constructor.

Definition at line 5 of file UniformBinning.cpp.

5  :
6  _limits (limits),
7  _nLocalBins(_limits.getDimension(), nLocalBins)
8 {
9  setBinningType("UniformBinning");
11 
12  WELCOME_LOG << "Hello from the UniformBinning() Constructor";
13 }
virtual void setDimension(int dimension)
Definition: BinningBase.cpp:34
HyperCuboid _limits
const int & getDimension() const
Definition: HyperCuboid.h:45
void setBinningType(TString binningType)
Definition: BinningBase.cpp:16
#define WELCOME_LOG
std::vector< int > _nLocalBins

◆ UniformBinning() [2/2]

UniformBinning::UniformBinning ( HyperCuboid  limits,
std::vector< int >  nLocalBins 
)

Definition at line 16 of file UniformBinning.cpp.

16  :
17  _limits (limits),
18  _nLocalBins(nLocalBins)
19 {
20  setBinningType("UniformBinning");
22 
23  WELCOME_LOG << "Hello from the UniformBinning() Constructor";
24 }
virtual void setDimension(int dimension)
Definition: BinningBase.cpp:34
HyperCuboid _limits
const int & getDimension() const
Definition: HyperCuboid.h:45
void setBinningType(TString binningType)
Definition: BinningBase.cpp:16
#define WELCOME_LOG
std::vector< int > _nLocalBins

◆ ~UniformBinning()

UniformBinning::~UniformBinning ( )
virtual

Definition at line 203 of file UniformBinning.cpp.

203  {
204 
205 
206 }

Member Function Documentation

◆ clone()

BinningBase * UniformBinning::clone ( ) const
virtual

Implements BinningBase.

Definition at line 133 of file UniformBinning.cpp.

133  {
134  return new UniformBinning(*this);
135 }
UniformBinning(HyperCuboid limits, int nLocalBins)
The only constructor.

◆ getAverageBinWidth()

HyperPoint UniformBinning::getAverageBinWidth ( ) const
virtual

Implements BinningBase.

Definition at line 189 of file UniformBinning.cpp.

189  {
190 
192  for (int i = 0; i < getDimension(); i++){
193  binwidth.at(i)/= double(getNumLocalBins(i));
194  }
195  return binwidth;
196 
197 }
int getNumLocalBins(int dimension) const
HyperCuboid _limits
const HyperPoint & getHighCorner() const
Definition: HyperCuboid.h:89
const int & getDimension() const
Definition: BinningBase.cpp:30
const double & at(int i) const
Definition: HyperPoint.cpp:433
const HyperPoint & getLowCorner() const
Definition: HyperCuboid.h:87

◆ getBinHyperVolume()

HyperVolume UniformBinning::getBinHyperVolume ( int  binNumber) const
virtual

Implements BinningBase.

Definition at line 182 of file UniformBinning.cpp.

182  {
183  HyperCuboid cube( getLowCorner(binNumber), getHighCorner(binNumber) );
184  return HyperVolume(cube);
185 }
HyperPoint getHighCorner(int globalBinNum) const
HyperPoint getLowCorner(int globalBinNum) const

◆ getBinNum()

int UniformBinning::getBinNum ( const HyperPoint coords) const
virtual

Implements BinningBase.

Definition at line 176 of file UniformBinning.cpp.

176  {
177 
178  return getGlobalBinNumber( getLocalBinNumbers(coords) );
179 
180 }
int getGlobalBinNumber(std::vector< int > localBinNumbers) const
std::vector< int > getLocalBinNumbers(int globalBinNumber) const

◆ getGlobalBinNumber()

int UniformBinning::getGlobalBinNumber ( std::vector< int >  localBinNumbers) const

Definition at line 41 of file UniformBinning.cpp.

41  {
42 
43  int dimension = getDimension();
44 
45  int multiplier = 1;
46  int binNumber = 0;
47 
48  for (int i = 0; i < dimension; i++){
49  binNumber += localBinNumbers.at(i)*multiplier;
50  multiplier *= getNumLocalBins(i);
51  }
52 
53  return binNumber;
54 
55 }
int getNumLocalBins(int dimension) const
const int & getDimension() const
Definition: BinningBase.cpp:30

◆ getHighBinEdgeLocal()

double UniformBinning::getHighBinEdgeLocal ( int  dim,
int  localBinNum 
) const

Definition at line 97 of file UniformBinning.cpp.

97  {
98 
99  double low = _limits.getLowCorner ().at(dim);
100  double high = _limits.getHighCorner().at(dim);
101  double nbins = _nLocalBins .at(dim);
102  double width = (high - low)/nbins;
103 
104  return low + width*(localBinNum + 1.0);
105 
106 }
HyperCuboid _limits
const HyperPoint & getHighCorner() const
Definition: HyperCuboid.h:89
const double & at(int i) const
Definition: HyperPoint.cpp:433
const HyperPoint & getLowCorner() const
Definition: HyperCuboid.h:87
std::vector< int > _nLocalBins

◆ getHighCorner()

HyperPoint UniformBinning::getHighCorner ( int  globalBinNum) const

Definition at line 117 of file UniformBinning.cpp.

117  {
118  HyperPoint corner(getDimension());
119  std::vector<int> localBinNum = getLocalBinNumbers(globalBinNum);
120  for (int i = 0; i < getDimension(); i++){
121  corner.at( i ) = getHighBinEdgeLocal( i, localBinNum.at(i) );
122  }
123  return corner;
124 }
double getHighBinEdgeLocal(int dim, int localBinNum) const
std::vector< int > getLocalBinNumbers(int globalBinNumber) const
const int & getDimension() const
Definition: BinningBase.cpp:30

◆ getLimits()

HyperCuboid UniformBinning::getLimits ( ) const
virtual

Implements BinningBase.

Definition at line 199 of file UniformBinning.cpp.

199  {
200  return _limits;
201 }
HyperCuboid _limits

◆ getLocalBinNumber()

int UniformBinning::getLocalBinNumber ( int  dim,
double  val 
) const

Definition at line 153 of file UniformBinning.cpp.

153  {
154 
155  double low = _limits.getLowCorner ().at(dim);
156  double high = _limits.getHighCorner().at(dim);
157  double nbins = _nLocalBins .at(dim);
158  double width = (high - low)/nbins;
159 
160  return floor( val - low )/width;
161 
162 }
HyperCuboid _limits
const HyperPoint & getHighCorner() const
Definition: HyperCuboid.h:89
const double & at(int i) const
Definition: HyperPoint.cpp:433
const HyperPoint & getLowCorner() const
Definition: HyperCuboid.h:87
std::vector< int > _nLocalBins

◆ getLocalBinNumbers() [1/2]

std::vector< int > UniformBinning::getLocalBinNumbers ( int  globalBinNumber) const

Definition at line 57 of file UniformBinning.cpp.

57  {
58 
59  int nBins = getNumBins();
60 
61  if ( globalBinNumber >= nBins || globalBinNumber < 0 ){
62  ERROR_LOG << "UniformBinning::getLocalBinNumbers - The global bin number you have given is out of range = " << globalBinNumber << std::endl;
63  }
64 
65  int dimension = getDimension();
66 
67  std::vector<int> localBinNums(dimension, -1.0);
68 
69  int multiplier = nBins;
70 
71  for (int i = dimension - 1; i >= 0; i--){
72 
73  multiplier = multiplier/getNumLocalBins(i);
74 
75  int localBinNum = floor(double(globalBinNumber)/double(multiplier));
76 
77  globalBinNumber -= multiplier*localBinNum;
78 
79  localBinNums.at(i) = localBinNum;
80  }
81 
82  return localBinNums;
83 
84 }
#define ERROR_LOG
int getNumLocalBins(int dimension) const
const int & getDimension() const
Definition: BinningBase.cpp:30
virtual int getNumBins() const

◆ getLocalBinNumbers() [2/2]

std::vector< int > UniformBinning::getLocalBinNumbers ( const HyperPoint coords) const

Definition at line 164 of file UniformBinning.cpp.

164  {
165 
166  std::vector<int> localBinNums(getDimension(), -1);
167 
168  for (int i = 0; i < getDimension(); i++){
169  localBinNums.at(i) = getLocalBinNumber(i, coords.at(i));
170  }
171  return localBinNums;
172 
173 }
const int & getDimension() const
Definition: BinningBase.cpp:30
const double & at(int i) const
Definition: HyperPoint.cpp:433
int getLocalBinNumber(int dim, double val) const

◆ getLowBinEdgeLocal()

double UniformBinning::getLowBinEdgeLocal ( int  dim,
int  localBinNum 
) const

Definition at line 86 of file UniformBinning.cpp.

86  {
87 
88  double low = _limits.getLowCorner ().at(dim);
89  double high = _limits.getHighCorner().at(dim);
90  double nbins = _nLocalBins .at(dim);
91  double width = (high - low)/nbins;
92 
93  return low + width*localBinNum;
94 
95 }
HyperCuboid _limits
const HyperPoint & getHighCorner() const
Definition: HyperCuboid.h:89
const double & at(int i) const
Definition: HyperPoint.cpp:433
const HyperPoint & getLowCorner() const
Definition: HyperCuboid.h:87
std::vector< int > _nLocalBins

◆ getLowCorner()

HyperPoint UniformBinning::getLowCorner ( int  globalBinNum) const

Definition at line 108 of file UniformBinning.cpp.

108  {
109  HyperPoint corner(getDimension());
110  std::vector<int> localBinNum = getLocalBinNumbers(globalBinNum);
111  for (int i = 0; i < getDimension(); i++){
112  corner.at( i ) = getLowBinEdgeLocal( i, localBinNum.at(i) );
113  }
114  return corner;
115 }
double getLowBinEdgeLocal(int dim, int localBinNum) const
std::vector< int > getLocalBinNumbers(int globalBinNumber) const
const int & getDimension() const
Definition: BinningBase.cpp:30

◆ getNumBins()

int UniformBinning::getNumBins ( ) const
virtual

Implements BinningBase.

Definition at line 32 of file UniformBinning.cpp.

32  {
33  int nBins = 1;
34  for (int i = 0; i < getDimension(); i++){
35  nBins *= getNumLocalBins(i);
36  }
37  return nBins;
38 }
int getNumLocalBins(int dimension) const
const int & getDimension() const
Definition: BinningBase.cpp:30

◆ getNumLocalBins()

int UniformBinning::getNumLocalBins ( int  dimension) const

Definition at line 28 of file UniformBinning.cpp.

28  {
29  return _nLocalBins.at(dimension);
30 }
std::vector< int > _nLocalBins

◆ load()

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

Implements BinningBase.

Definition at line 126 of file UniformBinning.cpp.

126  {
127  //not implemented this yet so added these lines to stop
128  //compiler warnings
129  filename = filename;
130  option = option;
131 }
virtual TString filename() const
Definition: BinningBase.cpp:57

◆ mergeBinnings()

void UniformBinning::mergeBinnings ( const BinningBase other)
virtual

Implements BinningBase.

Definition at line 147 of file UniformBinning.cpp.

147  {
148  //not implemented this yet so added these lines to stop
149  //compiler warnings
150  other.getDimension();
151 }
const int & getDimension() const
Definition: BinningBase.cpp:30

◆ save() [1/2]

void UniformBinning::save ( TString  filename) const
virtual

Implements BinningBase.

Definition at line 137 of file UniformBinning.cpp.

137  {
138  //not implemented this yet so added these lines to stop
139  //compiler warnings
140  filename = filename;
141 }
virtual TString filename() const
Definition: BinningBase.cpp:57

◆ save() [2/2]

void UniformBinning::save ( ) const
virtual

Implements BinningBase.

Definition at line 143 of file UniformBinning.cpp.

143  {
144 
145 }

Member Data Documentation

◆ _limits

HyperCuboid UniformBinning::_limits
private

Definition at line 48 of file UniformBinning.h.

◆ _nLocalBins

std::vector<int> UniformBinning::_nLocalBins
private

Definition at line 49 of file UniformBinning.h.


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