Public Member Functions | Protected Member Functions | Protected Attributes

nxyter::DistFunc Class Reference

Stores a set of values in the form of a distribution function. More...

#include <DistFunc.h>

Collaboration diagram for nxyter::DistFunc:
Collaboration graph
[legend]

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

Detailed Description

Stores a set of values in the form of a distribution function.

Definition at line 14 of file DistFunc.h.


Constructor & Destructor Documentation

nxyter::DistFunc::DistFunc ( int  cap = 0  )  [explicit]

Constructor, reserves an inital capacity of cap entries.

Parameters:
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.


Member Function Documentation

void nxyter::DistFunc::addEntry ( float  val  ) 

Adds an entry with value val to distribution.

Parameters:
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.

References fData, fFull, and fSorted.

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.

See also:
setMaxEntries()

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]

Returns number of entries.

Definition at line 48 of file DistFunc.h.

References fData.

float nxyter::DistFunc::operator() ( float  prob  ) 

Returns inverse of distribution function for probability prob.

Definition at line 77 of file DistFunc.cxx.

References fData, and sort().

float nxyter::DistFunc::operator[] ( int  ind  ) 

Returns entry with index ind.

Parameters:
ind entry number, between 0 and numEntries()-1
Exceptions:
std::out_of_range if ind out of range

Definition at line 119 of file DistFunc.cxx.

References fData, and sort().

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.

Note:
Don't confuse with setMaxEntries(), which sets the maximum number of entries which will be accepted.

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.

Parameters:
max maximum number of entries
See also:
full().

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[]().


Field Documentation

std::vector<float> nxyter::DistFunc::fData [protected]
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().

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().


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