Belle II Software  release-08-01-10
MinMaxCollector< DataType > Class Template Reference

A container for collecting data, where min- and max-quantiles near q(0) and q(1) are to be found. More...

#include <MinMaxCollector.h>

Collaboration diagram for MinMaxCollector< DataType >:

Public Member Functions

 BELLE2_DEFINE_EXCEPTION (Quantile_out_of_bounds, "The quantileCut (%1%) you gave is illegal (only allowed between 0-1)")
 returns true, if the valueContainers were increased in size. More...
 
 BELLE2_DEFINE_EXCEPTION (Illegal_quantile, "The quantiles you asked for (%1% and %2%) are not within the collected range of data (0-%3% and %4%-1) to prevent this happening, you have to pass a bigger value for QuantileCut when constructing a MinMaxCollector-Instance!")
 exception shall be thrown if the requested quantiles are not within the ranges collected
 
 BELLE2_DEFINE_EXCEPTION (Request_in_empty_Container, "Data of an empty container was requested!")
 exception shall be thrown if value is not between 0-1 and therefore not normalized
 
 MinMaxCollector (DataType quantileCut=0.025, unsigned warmUpThreshold=10)
 constructor. More...
 
std::pair< DataType, DataType > getMinMax (DataType minQuantile=0., DataType maxQuantile=1.) const
 for given pair of quantiles, the according cuts (min, max) will be returned.
 
void insert (DataType newVal)
 for convenience reasons, pipe to append.
 
void push_back (DataType newVal)
 for convenience reasons, pipe to append.
 
void append (DataType newVal)
 append new value
 
void merge (const MinMaxCollector< DataType > &other)
 fill the stuff of the other one with this one

 
unsigned totalSize () const
 returns the combined size of the containers storing the values
 
unsigned size () const
 returns the size (in a sense of roughly collected data)
 
bool empty () const
 returns if internal containers are empty
 
void clear ()
 deletes all values collected so far and resets to constructor-settings.
 
unsigned sampleSize () const
 returns actual sampleSize
 
void print (bool printFull=false) const
 print an overview of the entries collected. More...
 
std::string getName (bool printFull=false) const
 return a string of an overview of the entries collected. More...
 

Protected Member Functions

bool addMin (DataType newVal, bool allow2Grow)
 add entry to minContainer if it fits in
 
bool addMax (DataType newVal, bool allow2Grow)
 add entry to maxContainer if it fits in
 
bool addEntry (DataType newVal, bool isMinContainer, bool allow2Grow)
 add entry to container if it fits in
 
void sortIn (DataType newVal, bool isMinContainer)
 add newVal to appropriate container More...
 
unsigned getIndex (DataType aQuantile) const
 the correct access-index for given quantile will be determined
 
bool checkVectorSize (const std::deque< DataType > &container)
 returns true, if vector is allowed to grow
 

Protected Attributes

std::deque< DataType > m_smallestValues
 collects smallest values occured so far
 
std::deque< DataType > m_biggestValues
 collects biggest values occured so far
 
unsigned m_sampleSize
 counts numbre of values added so far
 
DataType m_quantileCut
 sets the threshold for storing data. More...
 
unsigned m_warmUpThreshold
 sets a threshold for warm-up. More...
 

Friends

std::ostream & operator<< (std::ostream &out, const MinMaxCollector &mmCol)
 overloaded '<<' stream operator. More...
 

Detailed Description

template<class DataType>
class Belle2::MinMaxCollector< DataType >

A container for collecting data, where min- and max-quantiles near q(0) and q(1) are to be found.

can only approximatly find actual quantiles and is sensitive to sorted data . -> random samples have to be used! Always exact for min and max, but the nearer the requested quantiles to the given quantileCut, the more sensitive it is to sorted data. For random input, the quantiles always stay very near to the real ones (if they are not the correct ones already). Prerequisites for DataType:

  • has to be one supported by std::numeric_limits

Definition at line 42 of file MinMaxCollector.h.

Constructor & Destructor Documentation

◆ MinMaxCollector()

MinMaxCollector ( DataType  quantileCut = 0.025,
unsigned  warmUpThreshold = 10 
)
inline

constructor.

quantileCut determines the fraction of the sample to be stored (0-1). warmUpThreshold pays some overhead for sample sizes to get more accuracy (for bigger sample sizes the overhead and the advantage of warmUp vanish (since then the results converge to the real ones anyway).

Definition at line 166 of file MinMaxCollector.h.

166  :
167  m_sampleSize(0),
168  m_quantileCut(quantileCut),
169  m_warmUpThreshold(warmUpThreshold)
170  {
171  if (0 > quantileCut or 0.5 < quantileCut) { throw (Quantile_out_of_bounds() << quantileCut); }
172  }
DataType m_quantileCut
sets the threshold for storing data.
unsigned m_warmUpThreshold
sets a threshold for warm-up.
unsigned m_sampleSize
counts numbre of values added so far

Member Function Documentation

◆ BELLE2_DEFINE_EXCEPTION()

BELLE2_DEFINE_EXCEPTION ( Quantile_out_of_bounds  ,
"The quantileCut (%1%) you gave is illegal (only allowed between 0-1)"   
)

returns true, if the valueContainers were increased in size.

exception shall be thrown if value is not between 0-1 and therefore not normalized

◆ getName()

std::string getName ( bool  printFull = false) const
inline

return a string of an overview of the entries collected.

if parameter given is 'true' full print will be done, if false, the values will be sketched with means.

Definition at line 290 of file MinMaxCollector.h.

◆ print()

void print ( bool  printFull = false) const
inline

print an overview of the entries collected.

if parameter given is 'true' full print will be done, if false, the values will be sketched with means.

Definition at line 284 of file MinMaxCollector.h.

◆ sortIn()

void sortIn ( DataType  newVal,
bool  isMinContainer 
)
inlineprotected

add newVal to appropriate container

TODO

replace deque with vector and implement individual sort functions for smallest- and biggestValues.

Definition at line 97 of file MinMaxCollector.h.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const MinMaxCollector< DataType > &  mmCol 
)
friend

overloaded '<<' stream operator.

Print secID to stream by converting it to string

Definition at line 177 of file MinMaxCollector.h.

Member Data Documentation

◆ m_quantileCut

DataType m_quantileCut
protected

sets the threshold for storing data.

min- and max-container will store the smalles/biggest quantileCut*100 (== %) of the total sample.

Definition at line 55 of file MinMaxCollector.h.

◆ m_warmUpThreshold

unsigned m_warmUpThreshold
protected

sets a threshold for warm-up.

The higher the value, the more accurate the quantiles will be, but the more overhead for small sample sizes will be too.

Definition at line 59 of file MinMaxCollector.h.


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