Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members | Related Pages

BinningFun Class Reference

#include <BinningFun.h>

Inheritance diagram for BinningFun:

Inheritance graph
[legend]
Collaboration diagram for BinningFun:

Collaboration graph
[legend]
List of all members.

Detailed Description

Abstract base class for function objects that sort events into bins.

The purpose of a BinningFun is to sort histogram entries into mutually exclusive bins (or non-exclusive bins, see blow). BinningFun objects are mainly used by SetOfHistogram and MatrixOfHistogram objects.

operator() has to return a value between -1 and n-1 (where n is the number of bins returned by getNBins), where -1 stands for "outside any bin" and the other values designate the bins.

The destructor is protected to ensure BinningFun objects can only be created on the heap (with "new"). The resulting memory leak is acknowledged.

getBinName() and getBinTitle() return strings that are used to automatically create histogram names (ids) and titles by SetOfHistogram and MatrixOfHistogram objects. The have to create new C-style strings that are deleted by the consumer.

A BinningFun can collaborate with a FillIterator object if more than one entry per event (e.g. if we have several D* mesons in one event).

The class FloatFunBinning can be used to generate a BinningFun in an easy way from a FloatFun, which delivers the value (e.g., t) that is used for binning, and some strings that are used to construct the name and title strings.

Exclusive and Non-exclusive Binnings

We distinguish between exclusive and non-exclusive binnings.

For an exclusive binning, an event (or particle) belongs at most to one bin. Therefore, in the Fill() method of a SFSetOfHistograms or SFMatrixOfHistograms, at most one histogram is filled. An exclusive binning is usefule e.g. to plot a quantity differentially in another quantity.

For an non-exclusive binning, an event may belong to several bins. In this case, the Fill() method of a SFSetOfHistograms or SFMatrixOfHistograms has to iterate over the possible values between 0 and getNBins()-1, and evaluate operator()(int) for each bin to see whether it should make an entry in the corrersponding histogram. Such non-exclusive binning are useful for cut-flow applications.

For non-exclusive binnings, operator()() makes really no sense. It must be implemented nevertheless.

Author: Jenny Böhme, Benno List

Date
2005/06/11 11:31:11
Author
blist

Changelog:

Definition at line 75 of file BinningFun.h.

Public Member Functions

 BinningFun ()
 Default: Create an empty binning.

 BinningFun (int nbins, float xlow, float xup, const char *name=0)
 Create an equidistant binning.

 BinningFun (int nbins, float xlow, float xup, const std::string &name)
 Create an equidistant binning.

 BinningFun (int nbins, const float binedges[], const char *name=0)
 Create an nonequidistant binning, taking floats.

 BinningFun (int nbins, const float binedges[], const std::string &name)
 Create an nonequidistant binning, taking floats.

 BinningFun (int nbins, const double binedges[], const char *name=0)
 Create an nonequidistant binning, taking doubles.

 BinningFun (int nbins, const double binedges[], const std::string &name)
 Create an nonequidistant binning, taking doubles.

 BinningFun (const Binning &binning_, const char *name=0)
 Create a binning from a Binning object.

virtual int operator() () const=0
 Returns a bin number between -1 and getNBins()-1.

virtual bool operator() (int i) const
 Returns whether an event belongs to bin i.

virtual bool isExclusive () const
 Returns whether a BinningFun is exclusive.

virtual const char * getBinName (int i) const=0
 returns a name string.

virtual const char * getBinTitle (int i) const=0
 returns a title string.

virtual int getMaxBins () const
 Gets the maximal return value of operator() plus 1, or the higest "sensible" value for a bin number.


Protected Member Functions

virtual ~BinningFun ()
 Protected destructor to ensure creation on the heap.


Constructor & Destructor Documentation

BinningFun::BinningFun int  nbins,
float  xlow,
float  xup,
const char *  name = 0
[inline]
 

Create an equidistant binning.

The binning will have nbins bins between xlow and xup.

Parameters:
nbins  The number of bins
xlow  The lowest bin edge
xup  The highest bin edge
name  The object name

Definition at line 83 of file BinningFun.h.

References NamedO::str().

BinningFun::BinningFun int  nbins,
float  xlow,
float  xup,
const std::string &  name
[inline]
 

Create an equidistant binning.

The binning will have nbins bins between xlow and xup.

Parameters:
nbins  The number of bins
xlow  The lowest bin edge
xup  The highest bin edge
name  The object name

Definition at line 95 of file BinningFun.h.

BinningFun::BinningFun int  nbins,
const float  binedges[],
const char *  name = 0
[inline]
 

Create an nonequidistant binning, taking floats.

The binning will have nbins bins with binedges given by binedges. binedges[i] and binedges[i+1] are the lower and upper edges of bin i. It is assumed that the binedge values are monotonically increasing.

Parameters:
nbins  The number of bins
binedges  An array with binedges
name  The object name

Definition at line 112 of file BinningFun.h.

References NamedO::str().

BinningFun::BinningFun int  nbins,
const float  binedges[],
const std::string &  name
[inline]
 

Create an nonequidistant binning, taking floats.

The binning will have nbins bins with binedges given by binedges. binedges[i] and binedges[i+1] are the lower and upper edges of bin i. It is assumed that the binedge values are monotonically increasing.

Parameters:
nbins  The number of bins
binedges  An array with binedges
name  The object name

Definition at line 128 of file BinningFun.h.

BinningFun::BinningFun int  nbins,
const double  binedges[],
const char *  name = 0
[inline]
 

Create an nonequidistant binning, taking doubles.

The binning will have nbins bins with binedges given by binedges. binedges[i] and binedges[i+1] are the lower and upper edges of bin i. It is assumed that the binedge values are monotonically increasing.

Parameters:
nbins  The number of bins
binedges  An array with binedges
name  The object name

Definition at line 145 of file BinningFun.h.

References NamedO::str().

BinningFun::BinningFun int  nbins,
const double  binedges[],
const std::string &  name
[inline]
 

Create an nonequidistant binning, taking doubles.

The binning will have nbins bins with binedges given by binedges. binedges[i] and binedges[i+1] are the lower and upper edges of bin i. It is assumed that the binedge values are monotonically increasing.

Parameters:
nbins  The number of bins
binedges  An array with binedges
name  The object name

Definition at line 162 of file BinningFun.h.

BinningFun::BinningFun const Binning &  binning_,
const char *  name = 0
[inline]
 

Create a binning from a Binning object.

Parameters:
binning_  The binning
name  The object name

Definition at line 171 of file BinningFun.h.

References NamedO::str().


Member Function Documentation

virtual bool BinningFun::operator() int  i  )  const [inline, virtual]
 

Returns whether an event belongs to bin i.

The default implementation is valid only for exclusive binnings, i.e. binnings where an event belongs exactly to one bin

Parameters:
i  The bin number

Reimplemented in CutBinning.

Definition at line 191 of file BinningFun.h.

virtual const char* BinningFun::getBinName int  i  )  const [pure virtual]
 

returns a name string.

The name string MAY, and MUST, be destroyed by the user! therefore: you MUST NOT return a string constant here, like "dummy", but use new[] to allocate the string. The name string should be short, unique, and contain no spaces, like "tbin0".

Parameters:
i  The bin number

Implemented in CutBinning, FloatFunBinning, and IntFunBinning.

Referenced by SetOfH::genBinName(), and MatrixOfH::genBinName().

virtual const char* BinningFun::getBinTitle int  i  )  const [pure virtual]
 

returns a title string.

The name string MAY, and MUST, be destroyed by the user! therefore: you MUST NOT return a string constant here, like "dummy", but use new[] to allocate the string. The name string should describe the bin, like "0.1 < t < 0.5".

Parameters:
i  The bin number

Implemented in CutBinning, FloatFunBinning, and IntFunBinning.

Referenced by SetOfH::genBinTitle(), and MatrixOfH::genBinTitle().


The documentation for this class was generated from the following file:
Generated on Thu Oct 26 12:54:27 2006 for SFH by doxygen 1.3.2