Stores a set of values in the form of a distribution function. More...
#include <DistFunc.h>
Public Member Functions | |
DistFunc (int cap=0) | |
Constructor, reserves an inital capacity of cap entries. | |
virtual | ~DistFunc () |
void | setMaxEntries (int max) |
Set maximum number of entries accepted to max. | |
void | setCapacity (int cap) |
Reserve capacity to hold cap entries. | |
void | clear () |
Drop all entries. numEntries() will be 0 afterwards. | |
void | addEntry (float val) |
Adds an entry with value val to distribution. | |
int | numEntries () |
Returns number of entries. | |
bool | full () |
Returns the 'full' flag. | |
float | operator() (float prob) |
Returns inverse of distribution function for probability prob. | |
float | operator[] (int ind) |
Returns entry with index ind. | |
float | getMedian () |
Returns median of distribution. | |
float | getWidth (float cut) |
Returns width of distribution at +- cut level. | |
float | getMin () |
Returns lowest entry value. | |
float | getMax () |
Returns hightest entry value. | |
Protected Member Functions | |
void | sort () |
Sorts the entries array. if (fData.size() == 0) return 0.;. | |
Protected Attributes | |
std::vector< float > | fData |
data array | |
int | fMaxEntries |
max number of entries | |
bool | fFull |
max number of entries reached | |
bool | fSorted |
is sorted flag |
Stores a set of values in the form of a distribution function.
Definition at line 14 of file DistFunc.h.
nxyter::DistFunc::DistFunc | ( | int | cap = 0 |
) | [explicit] |
Constructor, reserves an inital capacity of cap entries.
cap | initial capacity of the internal data. If more than cap entries will be added, the capacity will be automatically increased. cap should be specified when the total number of entries is known at ctor time, this avoids reallocations and improves performance. |
Definition at line 28 of file DistFunc.cxx.
References fData.
nxyter::DistFunc::~DistFunc | ( | ) | [virtual] |
Definition at line 38 of file DistFunc.cxx.
void nxyter::DistFunc::addEntry | ( | float | val | ) |
Adds an entry with value val to distribution.
val | value to be added to the distribution |
Definition at line 66 of file DistFunc.cxx.
References fData, fFull, fMaxEntries, and fSorted.
Referenced by cmd_scanvbiasf(), and get_vbiass_data().
void nxyter::DistFunc::clear | ( | ) | [inline] |
Drop all entries. numEntries() will be 0 afterwards.
Definition at line 42 of file DistFunc.h.
bool nxyter::DistFunc::full | ( | ) | [inline] |
Returns the 'full' flag.
If true
is returned, addEntry() was called more often than the limit setup by setMaxEntries() and these additional entries were discarded.
Definition at line 58 of file DistFunc.h.
References fFull.
float nxyter::DistFunc::getMax | ( | ) |
Returns hightest entry value.
Definition at line 153 of file DistFunc.cxx.
References fData.
Referenced by print_dfa_ent_med_w50().
float nxyter::DistFunc::getMedian | ( | ) |
Returns median of distribution.
Definition at line 128 of file DistFunc.cxx.
Referenced by get_vbiass_data(), and print_dfa_ent_med_w50().
float nxyter::DistFunc::getMin | ( | ) |
Returns lowest entry value.
Definition at line 144 of file DistFunc.cxx.
References fData.
Referenced by print_dfa_ent_med_w50().
float nxyter::DistFunc::getWidth | ( | float | cut | ) |
Returns width of distribution at +- cut level.
Definition at line 136 of file DistFunc.cxx.
Referenced by print_dfa_ent_med_w50().
int nxyter::DistFunc::numEntries | ( | ) | [inline] |
float nxyter::DistFunc::operator() | ( | float | prob | ) |
Returns inverse of distribution function for probability prob.
Definition at line 77 of file DistFunc.cxx.
float nxyter::DistFunc::operator[] | ( | int | ind | ) |
Returns entry with index ind.
ind | entry number, between 0 and numEntries()-1 |
std::out_of_range | if ind out of range |
Definition at line 119 of file DistFunc.cxx.
void nxyter::DistFunc::setCapacity | ( | int | cap | ) | [inline] |
Reserve capacity to hold cap entries.
Increases the size of the internal data area such that cap entries can be stored. If more are added, the capacity will be automatically increased. This method improves performance and should be used when the total number of expected entries is known before data accumulation starts.
Definition at line 38 of file DistFunc.h.
References fData.
void nxyter::DistFunc::setMaxEntries | ( | int | max | ) |
Set maximum number of entries accepted to max.
When addEntry() is called more than max times, the 'full' flag is set and further entries are discarded. Using a max of 0 will disable the 'full' flag logic.
max | maximum number of entries |
Definition at line 53 of file DistFunc.cxx.
References fData, fFull, and fMaxEntries.
void nxyter::DistFunc::sort | ( | ) | [protected] |
Sorts the entries array. if (fData.size() == 0) return 0.;.
Definition at line 162 of file DistFunc.cxx.
References fData, and fSorted.
Referenced by operator()(), and operator[]().
std::vector<float> nxyter::DistFunc::fData [protected] |
data array
Definition at line 16 of file DistFunc.h.
Referenced by addEntry(), clear(), DistFunc(), getMax(), getMin(), numEntries(), operator()(), operator[](), setCapacity(), setMaxEntries(), and sort().
bool nxyter::DistFunc::fFull [protected] |
max number of entries reached
Definition at line 18 of file DistFunc.h.
Referenced by addEntry(), clear(), full(), and setMaxEntries().
int nxyter::DistFunc::fMaxEntries [protected] |
max number of entries
Definition at line 17 of file DistFunc.h.
Referenced by addEntry(), and setMaxEntries().
bool nxyter::DistFunc::fSorted [protected] |
is sorted flag
Definition at line 19 of file DistFunc.h.
Referenced by addEntry(), clear(), and sort().