Project
Loading...
Searching...
No Matches
o2::tpc::FastHisto< T > Class Template Reference

templated 1D-histogram class. More...

#include <FastHisto.h>

Public Member Functions

 FastHisto (const unsigned int nBins=20, const float xmin=0.f, const float xmax=2.f, const bool useUnderflow=true, const bool useOverflow=true)
 
 ~FastHisto ()=default
 default destructor
 
void fill (const float val, T weight=1)
 
int findBin (const float val) const
 
void reset ()
 this function resets the bin content in the histogram
 
void fillBin (int index, T weight)
 
void print (const int prec=2) const
 
math_utils::StatisticsData getStatisticsData (const float low=0.05f, const float high=0.6f) const
 
getBinContent (unsigned int index) const
 
float getBinCenter (int bin) const
 
float getBinWidth () const
 
unsigned int getNBins () const
 
float getXmin () const
 
float getXmax () const
 
unsigned int getEntries () const
 
bool isUnderflowSet () const
 
bool isOverflowSet () const
 
bool checkBin (int bin) const
 
const FastHistooperator+= (const FastHisto &other)
 overload of operator +
 

Detailed Description

template<class T>
class o2::tpc::FastHisto< T >

templated 1D-histogram class.

This is a templated histogram class without any ROOT includes.

How to use: e.g.: create an array with 7 bins + underflow bin + overflow bins bin range is from xmin=0.4f to xmax=34.6f the values which will be filled are of the type float #define FMT_HEADER_ONLY; // to avoid undefined reference when using root shel o2::tpc::FastHisto<float> histo(7,0.4f,34.6f,true,true); histo.fill(4.5); histo.fill(20.2,3); histo.fill(35); histo.print() float mean = histo.getStatisticsData(0,1).mCOG; float TruncatedMean = histo.getStatisticsData(0.05,.6).mCOG;

Definition at line 51 of file FastHisto.h.

Constructor & Destructor Documentation

◆ FastHisto()

template<class T >
o2::tpc::FastHisto< T >::FastHisto ( const unsigned int  nBins = 20,
const float  xmin = 0.f,
const float  xmax = 2.f,
const bool  useUnderflow = true,
const bool  useOverflow = true 
)
inline

constructor this function is called when initializing the histogram object

Parameters
nBinsnumber of bins used in the histogram
xminminimum x value
xmaxmaximum x value (value is not included in the histogram. same as TH1 in ROOT)
useUnderflowuse underflow bin in the histogram
useOverflowuse overflow bin in the histogram

Definition at line 62 of file FastHisto.h.

◆ ~FastHisto()

template<class T >
o2::tpc::FastHisto< T >::~FastHisto ( )
default

default destructor

Member Function Documentation

◆ checkBin()

template<class T >
bool o2::tpc::FastHisto< T >::checkBin ( int  bin) const
inline
Returns
returns status wether the bin is in the histogram range

Definition at line 147 of file FastHisto.h.

◆ fill()

template<class T >
void o2::tpc::FastHisto< T >::fill ( const float  val,
weight = 1 
)
inline

this function fills the histogram with given value and weight

Parameters
valvalue which will be filled in the histogram
weightthe weight of the filled value

Definition at line 175 of file FastHisto.h.

◆ fillBin()

template<class T >
void o2::tpc::FastHisto< T >::fillBin ( int  index,
weight 
)
inline

this function increase the bin content for given index with given weight

Parameters
indexthe index (bin) for which the bin content is increased
weightweight of the filled content

Definition at line 88 of file FastHisto.h.

◆ findBin()

template<class T >
int o2::tpc::FastHisto< T >::findBin ( const float  val) const
inline

this function returns the index (bin) for the input value

Returns
the index of the bin
Parameters
valthe value for which the bin index will be returned

Definition at line 320 of file FastHisto.h.

◆ getBinCenter()

template<class T >
float o2::tpc::FastHisto< T >::getBinCenter ( int  bin) const
inline
Returns
returns the center of the bin
Parameters
binbin

Definition at line 118 of file FastHisto.h.

◆ getBinContent()

template<class T >
T o2::tpc::FastHisto< T >::getBinContent ( unsigned int  index) const
inline
Returns
this function returns the bin content for given index
Parameters
indexthe index (bin) for which the content is returned

Definition at line 107 of file FastHisto.h.

◆ getBinWidth()

template<class T >
float o2::tpc::FastHisto< T >::getBinWidth ( ) const
inline
Returns
the bin width used in the histogram

Definition at line 126 of file FastHisto.h.

◆ getEntries()

template<class T >
unsigned int o2::tpc::FastHisto< T >::getEntries ( ) const
inline
Returns
return number of entries in the histogram

Definition at line 138 of file FastHisto.h.

◆ getNBins()

template<class T >
unsigned int o2::tpc::FastHisto< T >::getNBins ( ) const
inline
Returns
returns the number of bins (excluding underflow/overflow)

Definition at line 129 of file FastHisto.h.

◆ getStatisticsData()

template<class T >
math_utils::StatisticsData o2::tpc::FastHisto< T >::getStatisticsData ( const float  low = 0.05f,
const float  high = 0.6f 
) const
inline
Returns
this function returns the truncated mean for the filled histogram
Parameters
lowlower truncation range
highupper truncation range

Definition at line 244 of file FastHisto.h.

◆ getXmax()

template<class T >
float o2::tpc::FastHisto< T >::getXmax ( ) const
inline
Returns
get the upper bound of the histogram

Definition at line 135 of file FastHisto.h.

◆ getXmin()

template<class T >
float o2::tpc::FastHisto< T >::getXmin ( ) const
inline
Returns
get the lower bound of the histogram

Definition at line 132 of file FastHisto.h.

◆ isOverflowSet()

template<class T >
bool o2::tpc::FastHisto< T >::isOverflowSet ( ) const
inline
Returns
returns if overflow bin is used in the histogram

Definition at line 144 of file FastHisto.h.

◆ isUnderflowSet()

template<class T >
bool o2::tpc::FastHisto< T >::isUnderflowSet ( ) const
inline
Returns
returns if underflow bin is used in the histogram

Definition at line 141 of file FastHisto.h.

◆ operator+=()

template<class T >
const FastHisto< T > & o2::tpc::FastHisto< T >::operator+= ( const FastHisto< T > &  other)
inline

overload of operator +

Definition at line 346 of file FastHisto.h.

◆ print()

template<class T >
void o2::tpc::FastHisto< T >::print ( const int  prec = 2) const
inline

this function prints out the histogram

Parameters
typeprinting type e.g 'vertical printing: type=0', 'horizontal printing: type=1'
precsets the precision of the x axis label

Definition at line 185 of file FastHisto.h.

◆ reset()

template<class T >
void o2::tpc::FastHisto< T >::reset ( )
inline

this function resets the bin content in the histogram

Definition at line 79 of file FastHisto.h.


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