#include <BinningFun.h>
Inheritance diagram for BinningFun:
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
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. |
|
Create an equidistant binning. The binning will have nbins bins between xlow and xup.
Definition at line 83 of file BinningFun.h. References NamedO::str(). |
|
Create an equidistant binning. The binning will have nbins bins between xlow and xup.
Definition at line 95 of file BinningFun.h. |
|
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.
Definition at line 112 of file BinningFun.h. References NamedO::str(). |
|
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.
Definition at line 128 of file BinningFun.h. |
|
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.
Definition at line 145 of file BinningFun.h. References NamedO::str(). |
|
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.
Definition at line 162 of file BinningFun.h. |
|
Create a binning from a Binning object.
Definition at line 171 of file BinningFun.h. References NamedO::str(). |
|
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
Reimplemented in CutBinning. Definition at line 191 of file BinningFun.h. |
|
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".
Implemented in CutBinning, FloatFunBinning, and IntFunBinning. Referenced by SetOfH::genBinName(), and MatrixOfH::genBinName(). |
|
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".
Implemented in CutBinning, FloatFunBinning, and IntFunBinning. Referenced by SetOfH::genBinTitle(), and MatrixOfH::genBinTitle(). |