npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
npstat::HistoND< Numeric, Axis > Class Template Reference

#include <HistoND.hh>

Public Types

enum  RebinType { SAMPLE = 0 , SUM , AVERAGE }
 
typedef Numeric value_type
 
typedef Axis axis_type
 

Public Member Functions

 HistoND (const std::vector< Axis > &axes, const char *title=0, const char *accumulatedDataLabel=0)
 
 HistoND (const Axis &xAxis, const char *title=0, const char *accumulatedDataLabel=0)
 
 HistoND (const Axis &xAxis, const Axis &yAxis, const char *title=0, const char *accumulatedDataLabel=0)
 
 HistoND (const Axis &xAxis, const Axis &yAxis, const Axis &zAxis, const char *title=0, const char *accumulatedDataLabel=0)
 
 HistoND (const Axis &a0, const Axis &a1, const Axis &a2, const Axis &a3, const char *title=0, const char *accumulatedDataLabel=0)
 
 HistoND (const Axis &a0, const Axis &a1, const Axis &a2, const Axis &a3, const Axis &a4, const char *title=0, const char *accumulatedDataLabel=0)
 
 HistoND (const Axis &a0, const Axis &a1, const Axis &a2, const Axis &a3, const Axis &a4, const Axis &a5, const char *title=0, const char *accumulatedDataLabel=0)
 
 HistoND (const Axis &a0, const Axis &a1, const Axis &a2, const Axis &a3, const Axis &a4, const Axis &a5, const Axis &a6, const char *title=0, const char *accumulatedDataLabel=0)
 
 HistoND (const Axis &a0, const Axis &a1, const Axis &a2, const Axis &a3, const Axis &a4, const Axis &a5, const Axis &a6, const Axis &a7, const char *title=0, const char *accumulatedDataLabel=0)
 
 HistoND (const Axis &a0, const Axis &a1, const Axis &a2, const Axis &a3, const Axis &a4, const Axis &a5, const Axis &a6, const Axis &a7, const Axis &a8, const char *title=0, const char *accumulatedDataLabel=0)
 
 HistoND (const Axis &a0, const Axis &a1, const Axis &a2, const Axis &a3, const Axis &a4, const Axis &a5, const Axis &a6, const Axis &a7, const Axis &a8, const Axis &a9, const char *title=0, const char *accumulatedDataLabel=0)
 
 HistoND (const ArrayShape &shape, const BoxND< double > &boundingBox, const char *title=0, const char *accumulatedDataLabel=0)
 
template<typename Num2 , class Functor >
 HistoND (const HistoND< Num2, Axis > &h, const Functor &f, const char *title=0, const char *accumulatedDataLabel=0)
 
template<typename Num2 >
 HistoND (const HistoND< Num2, Axis > &h, const unsigned *indices, unsigned nIndices, const char *title=0)
 
template<typename Num2 >
 HistoND (const HistoND< Num2, Axis > &h, const Axis &newAxis, unsigned newAxisNumber, const char *title=0)
 
template<typename Num2 >
 HistoND (const HistoND< Num2, Axis > &h, RebinType rType, const unsigned *newBinCounts, unsigned lenNewBinCounts, const double *shifts=0, const char *title=0)
 
 HistoND (const HistoND &)
 
HistoNDoperator= (const HistoND &)
 
unsigned dim () const
 
const std::string & title () const
 
const std::string & accumulatedDataLabel () const
 
const ArrayND< Numeric > & binContents () const
 
const ArrayND< Numeric > & overflows () const
 
Numeric underflowWeight (unsigned axisNumber) const
 
Numeric overflowWeight (unsigned axisNumber) const
 
Numeric inRangeOverWeight (unsigned axisNumber) const
 
const std::vector< Axis > & axes () const
 
const Axis & axis (const unsigned i) const
 
unsigned long nBins () const
 
unsigned long nFillsTotal () const
 
unsigned long nFillsInRange () const
 
unsigned long nFillsOver () const
 
bool isUniformlyBinned () const
 
std::vector< double > lowerAxisLimits () const
 
std::vector< double > upperAxisLimits () const
 
std::vector< double > axisLengths () const
 
void setTitle (const char *newtitle)
 
void setAccumulatedDataLabel (const char *newlabel)
 
void setAxisLabel (const unsigned axisNum, const char *newlabel)
 
double binVolume (unsigned long binNumber=0) const
 
void binCenter (unsigned long binNumber, double *coords, unsigned lenCoords) const
 
template<class Point >
void allBinCenters (std::vector< Point > *centers) const
 
void binBox (unsigned long binNumber, BoxND< double > *box) const
 
BoxND< double > boundingBox () const
 
double volume () const
 
double integral () const
 
void clear ()
 
void clearBinContents ()
 
void clearOverflows ()
 
bool operator== (const HistoND &) const
 
bool operator!= (const HistoND &) const
 
bool isSameData (const HistoND &) const
 
template<typename Num2 >
void fill (const double *coords, unsigned coordLength, const Num2 &weight)
 
template<typename Num2 >
void fill (const std::vector< double > &c, const Num2 &weight)
 
template<typename Num2 >
void fill (const std::vector< std::pair< double, Num2 > > &c)
 
template<typename Num2 >
void fill (const Num2 &weight)
 
template<typename Num2 >
void fill (double x0, const Num2 &weight)
 
template<typename Num2 >
void fill (double x0, double x1, const Num2 &weight)
 
template<typename Num2 >
void fill (double x0, double x1, double x2, const Num2 &weight)
 
template<typename Num2 >
void fill (double x0, double x1, double x2, double x3, const Num2 &weight)
 
template<typename Num2 >
void fill (double x0, double x1, double x2, double x3, double x4, const Num2 &weight)
 
template<typename Num2 >
void fill (double x0, double x1, double x2, double x3, double x4, double x5, const Num2 &weight)
 
template<typename Num2 >
void fill (double x0, double x1, double x2, double x3, double x4, double x5, double x6, const Num2 &weight)
 
template<typename Num2 >
void fill (double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, const Num2 &weight)
 
template<typename Num2 >
void fill (double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8, const Num2 &weight)
 
template<typename Num2 >
void fill (double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8, double x9, const Num2 &weight)
 
template<typename Num2 , class Functor >
void dispatch (const double *coords, unsigned coordLength, Num2 &weight, Functor &f)
 
template<typename Num2 , class Functor >
void dispatch (Num2 &weight, Functor &f)
 
template<typename Num2 , class Functor >
void dispatch (double x0, Num2 &weight, Functor &f)
 
template<typename Num2 , class Functor >
void dispatch (double x0, double x1, Num2 &weight, Functor &f)
 
template<typename Num2 , class Functor >
void dispatch (double x0, double x1, double x2, Num2 &weight, Functor &f)
 
template<typename Num2 , class Functor >
void dispatch (double x0, double x1, double x2, double x3, Num2 &weight, Functor &f)
 
template<typename Num2 , class Functor >
void dispatch (double x0, double x1, double x2, double x3, double x4, Num2 &weight, Functor &f)
 
template<typename Num2 , class Functor >
void dispatch (double x0, double x1, double x2, double x3, double x4, double x5, Num2 &weight, Functor &f)
 
template<typename Num2 , class Functor >
void dispatch (double x0, double x1, double x2, double x3, double x4, double x5, double x6, Num2 &weight, Functor &f)
 
template<typename Num2 , class Functor >
void dispatch (double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, Num2 &weight, Functor &f)
 
template<typename Num2 , class Functor >
void dispatch (double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8, Num2 &weight, Functor &f)
 
template<typename Num2 , class Functor >
void dispatch (double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8, double x9, Num2 &weight, Functor &f)
 
const Numeric & examine (const double *coords, unsigned coordLength) const
 
const Numeric & examine () const
 
const Numeric & examine (double x0) const
 
const Numeric & examine (double x0, double x1) const
 
const Numeric & examine (double x0, double x1, double x2) const
 
const Numeric & examine (double x0, double x1, double x2, double x3) const
 
const Numeric & examine (double x0, double x1, double x2, double x3, double x4) const
 
const Numeric & examine (double x0, double x1, double x2, double x3, double x4, double x5) const
 
const Numeric & examine (double x0, double x1, double x2, double x3, double x4, double x5, double x6) const
 
const Numeric & examine (double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7) const
 
const Numeric & examine (double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8) const
 
const Numeric & examine (double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8, double x9) const
 
const Numeric & closestBin (const double *coords, unsigned coordLength) const
 
const Numeric & closestBin () const
 
const Numeric & closestBin (double x0) const
 
const Numeric & closestBin (double x0, double x1) const
 
const Numeric & closestBin (double x0, double x1, double x2) const
 
const Numeric & closestBin (double x0, double x1, double x2, double x3) const
 
const Numeric & closestBin (double x0, double x1, double x2, double x3, double x4) const
 
const Numeric & closestBin (double x0, double x1, double x2, double x3, double x4, double x5) const
 
const Numeric & closestBin (double x0, double x1, double x2, double x3, double x4, double x5, double x6) const
 
const Numeric & closestBin (double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7) const
 
const Numeric & closestBin (double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8) const
 
const Numeric & closestBin (double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8, double x9) const
 
template<typename Num2 >
void fillC (const double *coords, unsigned coordLength, const Num2 &weight)
 
template<typename Num2 >
void fillC (const std::vector< double > &c, const Num2 &weight)
 
template<typename Num2 >
void fillC (const std::vector< std::pair< double, Num2 > > &c)
 
template<typename Num2 >
void fillC (const Num2 &weight)
 
template<typename Num2 >
void fillC (double x0, const Num2 &weight)
 
template<typename Num2 >
void fillC (double x0, double x1, const Num2 &weight)
 
template<typename Num2 >
void fillC (double x0, double x1, double x2, const Num2 &weight)
 
template<typename Num2 >
void fillC (double x0, double x1, double x2, double x3, const Num2 &weight)
 
template<typename Num2 >
void fillC (double x0, double x1, double x2, double x3, double x4, const Num2 &weight)
 
template<typename Num2 >
void fillC (double x0, double x1, double x2, double x3, double x4, double x5, const Num2 &weight)
 
template<typename Num2 >
void fillC (double x0, double x1, double x2, double x3, double x4, double x5, double x6, const Num2 &weight)
 
template<typename Num2 >
void fillC (double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, const Num2 &weight)
 
template<typename Num2 >
void fillC (double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8, const Num2 &weight)
 
template<typename Num2 >
void fillC (double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8, double x9, const Num2 &weight)
 
template<typename Num2 >
HistoNDoperator+= (const HistoND< Num2, Axis > &r)
 
template<typename Num2 >
HistoNDoperator-= (const HistoND< Num2, Axis > &r)
 
template<typename Num2 >
void setBin (const unsigned *index, unsigned indexLen, const Num2 &v)
 
template<typename Num2 >
void setBin (const Num2 &v)
 
template<typename Num2 >
void setBin (unsigned i0, const Num2 &v)
 
template<typename Num2 >
void setBin (unsigned i0, unsigned i1, const Num2 &v)
 
template<typename Num2 >
void setBin (unsigned i0, unsigned i1, unsigned i2, const Num2 &v)
 
template<typename Num2 >
void setBin (unsigned i0, unsigned i1, unsigned i2, unsigned i3, const Num2 &v)
 
template<typename Num2 >
void setBin (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, const Num2 &v)
 
template<typename Num2 >
void setBin (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, const Num2 &v)
 
template<typename Num2 >
void setBin (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6, const Num2 &v)
 
template<typename Num2 >
void setBin (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6, unsigned i7, const Num2 &v)
 
template<typename Num2 >
void setBin (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6, unsigned i7, unsigned i8, const Num2 &v)
 
template<typename Num2 >
void setBin (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6, unsigned i7, unsigned i8, unsigned i9, const Num2 &v)
 
template<typename Num2 >
void setLinearBin (const unsigned long index, const Num2 &v)
 
template<typename Num2 >
void setBinAt (const unsigned *index, unsigned indexLen, const Num2 &v)
 
template<typename Num2 >
void setBinAt (const Num2 &v)
 
template<typename Num2 >
void setBinAt (unsigned i0, const Num2 &v)
 
template<typename Num2 >
void setBinAt (unsigned i0, unsigned i1, const Num2 &v)
 
template<typename Num2 >
void setBinAt (unsigned i0, unsigned i1, unsigned i2, const Num2 &v)
 
template<typename Num2 >
void setBinAt (unsigned i0, unsigned i1, unsigned i2, unsigned i3, const Num2 &v)
 
template<typename Num2 >
void setBinAt (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, const Num2 &v)
 
template<typename Num2 >
void setBinAt (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, const Num2 &v)
 
template<typename Num2 >
void setBinAt (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6, const Num2 &v)
 
template<typename Num2 >
void setBinAt (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6, unsigned i7, const Num2 &v)
 
template<typename Num2 >
void setBinAt (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6, unsigned i7, unsigned i8, const Num2 &v)
 
template<typename Num2 >
void setBinAt (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6, unsigned i7, unsigned i8, unsigned i9, const Num2 &v)
 
template<typename Num2 >
void setLinearBinAt (const unsigned long index, const Num2 &v)
 
template<typename Num2 >
void setBinContents (const Num2 *data, unsigned long dataLength, bool clearOverflows=true)
 
template<typename Num2 >
void setOverflows (const Num2 *data, unsigned long dataLength)
 
template<typename Num2 >
void setBinsToConst (const Num2 &value)
 
template<typename Num2 >
void setOverflowsToConst (const Num2 &value)
 
void recalculateNFillsFromData ()
 
void setNFillsTotal (const unsigned long i)
 
void setNFillsOver (const unsigned long i)
 
template<typename Num2 >
HistoNDoperator*= (const Num2 &r)
 
template<typename Num2 >
HistoNDoperator/= (const Num2 &r)
 
template<typename Num2 >
void scaleBinContents (const Num2 *data, unsigned long dataLength)
 
template<typename Num2 >
void scaleOverflows (const Num2 *data, unsigned long dataLength)
 
template<typename Num2 >
void addToBinContents (const Num2 &weight)
 
template<typename Num2 >
void addToOverflows (const Num2 &weight)
 
template<typename Num2 >
void addToBinContents (const Num2 *data, unsigned long dataLength)
 
template<typename Num2 >
void addToOverflows (const Num2 *data, unsigned long dataLength)
 
template<typename Acc >
void accumulateBinsInBox (const BoxND< double > &box, Acc *acc, bool calculateAverage=false) const
 
template<typename Num2 , typename Num3 >
void addToProjection (HistoND< Num2, Axis > *projection, AbsArrayProjector< Numeric, Num3 > &projector, const unsigned *projectedIndices, unsigned nProjectedIndices) const
 
template<typename Num2 , typename Num3 >
void addToProjection (HistoND< Num2, Axis > *projection, AbsVisitor< Numeric, Num3 > &projector, const unsigned *projectedIndices, unsigned nProjectedIndices) const
 
HistoND transpose (unsigned axisNum1, unsigned axisNum2) const
 
unsigned long getModCount () const
 
void incrModCount ()
 
gs::ClassId classId () const
 
bool write (std::ostream &of) const
 

Static Public Member Functions

static const char * classname ()
 
static unsigned version ()
 
static HistoNDread (const gs::ClassId &id, std::istream &in)
 

Detailed Description

template<typename Numeric, class Axis = HistoAxis>
class npstat::HistoND< Numeric, Axis >

(Almost) arbitrary-dimensional histogram with binning determined by the second template parameter (typically HistoAxis or NUHistoAxis). The dimensionality must not exceed CHAR_BIT*sizeof(unsigned long)-1 which is normally 31/63 on 32/64-bit systems.

The template parameter class (Numeric) must be such that it can be used as the template parameter of ArrayND class. For a typical usage pattern, Numeric should also support operator += between itself and the weights with which the histogram is filled (see, however, the description of the "dispatch" method which is not subject to this recommendation).

If the "fillC" method is used to accumulate the data then the weights must support multiplication by a double, and then it must be possible to use the "+=" operator to add such a product to Numeric.

Note that there are no methods which would allow the user to examine the bin contents of the histogram using bin numbers. This is intentional: almost always such examinations are performed in a loop over indices, and it is more efficient to grab a reference to the underlying array using the "binContents()" method and then examine that array directly.

Constructor & Destructor Documentation

◆ HistoND() [1/17]

template<typename Numeric , class Axis = HistoAxis>
npstat::HistoND< Numeric, Axis >::HistoND ( const std::vector< Axis > &  axes,
const char *  title = 0,
const char *  accumulatedDataLabel = 0 
)
explicit

Main constructor for arbitrary-dimensional histograms

◆ HistoND() [2/17]

template<typename Numeric , class Axis = HistoAxis>
npstat::HistoND< Numeric, Axis >::HistoND ( const Axis &  xAxis,
const char *  title = 0,
const char *  accumulatedDataLabel = 0 
)
explicit

Convenience constructor for 1-d histograms

◆ HistoND() [3/17]

template<typename Numeric , class Axis = HistoAxis>
npstat::HistoND< Numeric, Axis >::HistoND ( const Axis &  xAxis,
const Axis &  yAxis,
const char *  title = 0,
const char *  accumulatedDataLabel = 0 
)

Convenience constructor for 2-d histograms

◆ HistoND() [4/17]

template<typename Numeric , class Axis = HistoAxis>
npstat::HistoND< Numeric, Axis >::HistoND ( const Axis &  xAxis,
const Axis &  yAxis,
const Axis &  zAxis,
const char *  title = 0,
const char *  accumulatedDataLabel = 0 
)

Convenience constructor for 3-d histograms

◆ HistoND() [5/17]

template<typename Numeric , class Axis = HistoAxis>
npstat::HistoND< Numeric, Axis >::HistoND ( const Axis &  a0,
const Axis &  a1,
const Axis &  a2,
const Axis &  a3,
const char *  title = 0,
const char *  accumulatedDataLabel = 0 
)

Convenience constructor for 4-d histograms

◆ HistoND() [6/17]

template<typename Numeric , class Axis = HistoAxis>
npstat::HistoND< Numeric, Axis >::HistoND ( const Axis &  a0,
const Axis &  a1,
const Axis &  a2,
const Axis &  a3,
const Axis &  a4,
const char *  title = 0,
const char *  accumulatedDataLabel = 0 
)

Convenience constructor for 5-d histograms

◆ HistoND() [7/17]

template<typename Numeric , class Axis = HistoAxis>
npstat::HistoND< Numeric, Axis >::HistoND ( const Axis &  a0,
const Axis &  a1,
const Axis &  a2,
const Axis &  a3,
const Axis &  a4,
const Axis &  a5,
const char *  title = 0,
const char *  accumulatedDataLabel = 0 
)

Convenience constructor for 6-d histograms

◆ HistoND() [8/17]

template<typename Numeric , class Axis = HistoAxis>
npstat::HistoND< Numeric, Axis >::HistoND ( const Axis &  a0,
const Axis &  a1,
const Axis &  a2,
const Axis &  a3,
const Axis &  a4,
const Axis &  a5,
const Axis &  a6,
const char *  title = 0,
const char *  accumulatedDataLabel = 0 
)

Convenience constructor for 7-d histograms

◆ HistoND() [9/17]

template<typename Numeric , class Axis = HistoAxis>
npstat::HistoND< Numeric, Axis >::HistoND ( const Axis &  a0,
const Axis &  a1,
const Axis &  a2,
const Axis &  a3,
const Axis &  a4,
const Axis &  a5,
const Axis &  a6,
const Axis &  a7,
const char *  title = 0,
const char *  accumulatedDataLabel = 0 
)

Convenience constructor for 8-d histograms

◆ HistoND() [10/17]

template<typename Numeric , class Axis = HistoAxis>
npstat::HistoND< Numeric, Axis >::HistoND ( const Axis &  a0,
const Axis &  a1,
const Axis &  a2,
const Axis &  a3,
const Axis &  a4,
const Axis &  a5,
const Axis &  a6,
const Axis &  a7,
const Axis &  a8,
const char *  title = 0,
const char *  accumulatedDataLabel = 0 
)

Convenience constructor for 9-d histograms

◆ HistoND() [11/17]

template<typename Numeric , class Axis = HistoAxis>
npstat::HistoND< Numeric, Axis >::HistoND ( const Axis &  a0,
const Axis &  a1,
const Axis &  a2,
const Axis &  a3,
const Axis &  a4,
const Axis &  a5,
const Axis &  a6,
const Axis &  a7,
const Axis &  a8,
const Axis &  a9,
const char *  title = 0,
const char *  accumulatedDataLabel = 0 
)

Convenience constructor for 10-d histograms

◆ HistoND() [12/17]

template<typename Numeric , class Axis = HistoAxis>
npstat::HistoND< Numeric, Axis >::HistoND ( const ArrayShape shape,
const BoxND< double > &  boundingBox,
const char *  title = 0,
const char *  accumulatedDataLabel = 0 
)

Simple constructor for uniformly binned histograms without axis labels. Sequence size returned by the size() method of both "shape" and "boundingBox" arguments must be the same.

◆ HistoND() [13/17]

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 , class Functor >
npstat::HistoND< Numeric, Axis >::HistoND ( const HistoND< Num2, Axis > &  h,
const Functor &  f,
const char *  title = 0,
const char *  accumulatedDataLabel = 0 
)

Converting constructor. The functor will be applied to all bins of the argument histogram to fill the bins of the constructed histogram. If the title and data label are not provided, they will be cleared.

◆ HistoND() [14/17]

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 >
npstat::HistoND< Numeric, Axis >::HistoND ( const HistoND< Num2, Axis > &  h,
const unsigned *  indices,
unsigned  nIndices,
const char *  title = 0 
)

A slicing constructor. The new histogram will be created by slicing another histogram. See the description of the slicing constructor in the "ArrayND" class for the meaning of arguments "indices" and "nIndices". The data of the newly created histogram is cleared.

◆ HistoND() [15/17]

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 >
npstat::HistoND< Numeric, Axis >::HistoND ( const HistoND< Num2, Axis > &  h,
const Axis &  newAxis,
unsigned  newAxisNumber,
const char *  title = 0 
)

A constructor that inserts a new axis into a histogram (as if the argument histogram was a slice of the new histogram). The "newAxisNumber" argument specifies the number of the new axis in the axis sequence of the constructed histogram. If the "newAxisNumber" exceeds the number of axes of the argument histogram, the new axis will become last. The data of the newly created histogram is cleared.

◆ HistoND() [16/17]

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 >
npstat::HistoND< Numeric, Axis >::HistoND ( const HistoND< Num2, Axis > &  h,
RebinType  rType,
const unsigned *  newBinCounts,
unsigned  lenNewBinCounts,
const double *  shifts = 0,
const char *  title = 0 
)

Create a rebinned histogram with the same axis coverage. Note that not all such operations will be meaningful if the bin contents do not belong to one of the floating point types. The "newBinCounts" argument specifies the new number of bins along each axis. The length of this array (provided by the "lenNewBinCounts" argument) should be equal to the input histogram dimensionality.

The "shifts" argument can be meaningfully specified with the "rType" argument set to "SAMPLE". These shifts will be added to the bin centers of the created histogram when the bin contents are looked up in the input histogram. This can be useful in case the bin center lookup without shifts would fall exactly on the bin edge. Naturally, the length of the "shifts" array should be equal to the input histogram dimensionality.

◆ HistoND() [17/17]

template<typename Numeric , class Axis = HistoAxis>
npstat::HistoND< Numeric, Axis >::HistoND ( const HistoND< Numeric, Axis > &  )

Copy constructor

Member Function Documentation

◆ accumulateBinsInBox()

template<typename Numeric , class Axis = HistoAxis>
template<typename Acc >
void npstat::HistoND< Numeric, Axis >::accumulateBinsInBox ( const BoxND< double > &  box,
Acc *  acc,
bool  calculateAverage = false 
) const

Add contents of all bins inside the given box to the accumulator. Note that Numeric type must support multiplication by a double in order for this function to work (it calculates the overlap fraction of each bin with the box and multiplies bin content by that fraction for subsequent accumulation). The operation Acc += Numeric must be defined.

◆ accumulatedDataLabel()

template<typename Numeric , class Axis = HistoAxis>
const std::string& npstat::HistoND< Numeric, Axis >::accumulatedDataLabel ( ) const
inline

Label associated with accumulated data

◆ addToBinContents() [1/2]

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 >
void npstat::HistoND< Numeric, Axis >::addToBinContents ( const Num2 &  weight)

In-place addition of a scalar to all bins. Equivalent to calling the "fill" function with the same weight once for every bin.

◆ addToBinContents() [2/2]

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 >
void npstat::HistoND< Numeric, Axis >::addToBinContents ( const Num2 *  data,
unsigned long  dataLength 
)

In-place addition of an array. Equivalent to calling the "fill" function once for every bin with the weight taken from the corresponding array element.

◆ addToProjection()

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 , typename Num3 >
void npstat::HistoND< Numeric, Axis >::addToProjection ( HistoND< Num2, Axis > *  projection,
AbsArrayProjector< Numeric, Num3 > &  projector,
const unsigned *  projectedIndices,
unsigned  nProjectedIndices 
) const

Code for projecting one histogram onto another. For now, this is done for bin contents only, not for overflows. The projection should be created in advance from this histogram with the aid of the slicing constructor. The indices used in that constructor should be provided here as well.

Note that you might want to recalculate the number of fills from data after performing all projections needed.

◆ allBinCenters()

template<typename Numeric , class Axis = HistoAxis>
template<class Point >
void npstat::HistoND< Numeric, Axis >::allBinCenters ( std::vector< Point > *  centers) const

Convenience function which fills out a vector of bin centers in the same order as the linear order of binContents(). The class "Point" must have a subscript operator, default constructor, copy constructor, and the size() method (use, for example, std::array).

◆ axes()

template<typename Numeric , class Axis = HistoAxis>
const std::vector<Axis>& npstat::HistoND< Numeric, Axis >::axes ( ) const
inline

Inspect histogram axes

◆ axis()

template<typename Numeric , class Axis = HistoAxis>
const Axis& npstat::HistoND< Numeric, Axis >::axis ( const unsigned  i) const
inline

Inspect a histogram axis for the given dimension

◆ binBox()

template<typename Numeric , class Axis = HistoAxis>
void npstat::HistoND< Numeric, Axis >::binBox ( unsigned long  binNumber,
BoxND< double > *  box 
) const

Bounding box for the given bin

◆ binCenter()

template<typename Numeric , class Axis = HistoAxis>
void npstat::HistoND< Numeric, Axis >::binCenter ( unsigned long  binNumber,
double *  coords,
unsigned  lenCoords 
) const

Position of the bin center. Length of the "coords" array (filled on return) should be equal to the dimensionality of the histogram.

◆ binContents()

template<typename Numeric , class Axis = HistoAxis>
const ArrayND<Numeric>& npstat::HistoND< Numeric, Axis >::binContents ( ) const
inline

Retrive a reference to the array of bin contents

◆ binVolume()

template<typename Numeric , class Axis = HistoAxis>
double npstat::HistoND< Numeric, Axis >::binVolume ( unsigned long  binNumber = 0) const

This method returns width/area/volume/etc. of a single bin. 1.0 is returned for a dimensionless histogram.

◆ boundingBox()

template<typename Numeric , class Axis = HistoAxis>
BoxND<double> npstat::HistoND< Numeric, Axis >::boundingBox ( ) const

Bounding box for the whole histogram

◆ classId()

template<typename Numeric , class Axis = HistoAxis>
gs::ClassId npstat::HistoND< Numeric, Axis >::classId ( ) const
inline

Method related to "geners" I/O

◆ clear()

template<typename Numeric , class Axis = HistoAxis>
void npstat::HistoND< Numeric, Axis >::clear ( )

Clear the histogram contents (both bins and overflows)

◆ clearBinContents()

template<typename Numeric , class Axis = HistoAxis>
void npstat::HistoND< Numeric, Axis >::clearBinContents ( )

This method clears the bin contents but not overflows

◆ clearOverflows()

template<typename Numeric , class Axis = HistoAxis>
void npstat::HistoND< Numeric, Axis >::clearOverflows ( )

This method clears overflows but not the bin contents

◆ closestBin() [1/2]

template<typename Numeric , class Axis = HistoAxis>
const Numeric& npstat::HistoND< Numeric, Axis >::closestBin ( ) const

Convenience "closestBin" method for histograms of corresponding dimensionality

◆ closestBin() [2/2]

template<typename Numeric , class Axis = HistoAxis>
const Numeric& npstat::HistoND< Numeric, Axis >::closestBin ( const double *  coords,
unsigned  coordLength 
) const

The "closestBin" functions are similar to the "examine" functions but always return a valid bin and never overflow. This can be useful for implementing lookup tables with constant extrapolation outside of the histogram range.

◆ dim()

template<typename Numeric , class Axis = HistoAxis>
unsigned npstat::HistoND< Numeric, Axis >::dim ( ) const
inline

Histogram dimensionality

◆ dispatch() [1/2]

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 , class Functor >
void npstat::HistoND< Numeric, Axis >::dispatch ( const double *  coords,
unsigned  coordLength,
Num2 &  weight,
Functor &  f 
)

Location-based dispatch method. The provided binary functor will be called with the approprite histogram bin value as the first argument and the weight as the second (functor return value is ignored). This allows for a very general use of the histogram binning functionality. For example, with a proper functor, the histogram bins can be filled with pointers to an arbitrary class (this is the only way to use classes which do not have default constructors as bin contents) and the functor can be used to dispatch class methods. Depending on the exact nature of the functor, multiple things might be modified as the result of this call: the bin value, the weight, and the functor internal state.

◆ dispatch() [2/2]

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 , class Functor >
void npstat::HistoND< Numeric, Axis >::dispatch ( Num2 &  weight,
Functor &  f 
)

Convenience "dispatch" method for histograms of corresponding dimensionality

◆ examine() [1/2]

template<typename Numeric , class Axis = HistoAxis>
const Numeric& npstat::HistoND< Numeric, Axis >::examine ( ) const

Convenience "examine" method for histograms of corresponding dimensionality

◆ examine() [2/2]

template<typename Numeric , class Axis = HistoAxis>
const Numeric& npstat::HistoND< Numeric, Axis >::examine ( const double *  coords,
unsigned  coordLength 
) const

The "examine" functions allow the user to access bin contents when bins are addressed by their coordinates. Use "binContents()" to access the data by bin numbers. Overflow bins will be accessed if the given coordinates fall outside the histogram range.

◆ fill() [1/4]

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 >
void npstat::HistoND< Numeric, Axis >::fill ( const double *  coords,
unsigned  coordLength,
const Num2 &  weight 
)

Fill function for histograms of arbitrary dimensionality. The length of the "coords" array should be equal to the histogram dimensionality. The Numeric type must have the "+=" operator defined with the Num2 type on the right side.

◆ fill() [2/4]

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 >
void npstat::HistoND< Numeric, Axis >::fill ( const Num2 &  weight)

Convenience "fill" method for histograms of corresponding dimensionality

◆ fill() [3/4]

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 >
void npstat::HistoND< Numeric, Axis >::fill ( const std::vector< double > &  c,
const Num2 &  weight 
)
inline

Fill (possibly) multiple times from a flat vector

◆ fill() [4/4]

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 >
void npstat::HistoND< Numeric, Axis >::fill ( const std::vector< std::pair< double, Num2 > > &  c)
inline

Fill a 1-d histogram from a flat vector of weighted coordinates. The first element of each pair is the coordinate and the second is the weight.

◆ fillC() [1/4]

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 >
void npstat::HistoND< Numeric, Axis >::fillC ( const double *  coords,
unsigned  coordLength,
const Num2 &  weight 
)

The "fillC" functions are similar to the "fill" methods but they preserve the centroid of the deposit. Note that, if the histogram dimensionality is high, "fillC" works significantly slower than the corresponding "fill". Also note that there must be at least 2 bins in each dimension in order for this function to work.

A word of caution. What is added to the bins is the input weight multiplied by another weight calculated using the bin proximity. If the input weight is just 1 (which happens quite often in practice), the product of the weights is normally less than 1. If the histogram template parameter is one of the integer types, operator += will convert this product to 0 before adding it to the bin! Therefore, it is best to use "fillC" only with floating point template parameters (float, double, etc).

Currently, the "fillC" methods work sensibly only in the case the binning is uniform (i.e., the second template parameter is HistoAxis rather than, let say, NUHistoAxis). They typically will not even compile if the binning is not uniform.

◆ fillC() [2/4]

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 >
void npstat::HistoND< Numeric, Axis >::fillC ( const Num2 &  weight)

Convenience "fillC" method for histograms of corresponding dimensionality

◆ fillC() [3/4]

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 >
void npstat::HistoND< Numeric, Axis >::fillC ( const std::vector< double > &  c,
const Num2 &  weight 
)
inline

Fill (possibly) multiple times from a flat vector

◆ fillC() [4/4]

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 >
void npstat::HistoND< Numeric, Axis >::fillC ( const std::vector< std::pair< double, Num2 > > &  c)
inline

Fill a 1-d histogram from a flat vector of weighted coordinates. The first element of each pair is the coordinate and the second is the weight.

◆ getModCount()

template<typename Numeric , class Axis = HistoAxis>
unsigned long npstat::HistoND< Numeric, Axis >::getModCount ( ) const
inline

This method returns the number of modifications performed on the histogram since its creation. This number is always increasing during the lifetime of the histogram object. Its main property is as follows: if the method "getModCount" returns the same number twice, there should be no changes in the histogram object (so that a drawing program does not need to redraw the histogram image).

This number is pure transient, it is not serialized and does not participate in histogram comparisons for equality.

◆ incrModCount()

template<typename Numeric , class Axis = HistoAxis>
void npstat::HistoND< Numeric, Axis >::incrModCount ( )
inline

Indicate that the histogram contents have changed. Should be used by any code which directly modifies histogram bins (after using const_cast on the relevant reference).

◆ inRangeOverWeight()

template<typename Numeric , class Axis = HistoAxis>
Numeric npstat::HistoND< Numeric, Axis >::inRangeOverWeight ( unsigned  axisNumber) const
inline

The sum of the weights when there was no overflow for the given axis but there was at least one overflow in any other axis

◆ integral()

template<typename Numeric , class Axis = HistoAxis>
double npstat::HistoND< Numeric, Axis >::integral ( ) const

Integral of the histogram

◆ isSameData()

template<typename Numeric , class Axis = HistoAxis>
bool npstat::HistoND< Numeric, Axis >::isSameData ( const HistoND< Numeric, Axis > &  ) const

Check data for equality (both bin contents and overflows). Do not compare axes, labels, fill counts, etc.

◆ isUniformlyBinned()

template<typename Numeric , class Axis = HistoAxis>
bool npstat::HistoND< Numeric, Axis >::isUniformlyBinned ( ) const

This method returns "true" if the method isUniform() of each histogram axis returns "true"

◆ lowerAxisLimits()

template<typename Numeric , class Axis = HistoAxis>
std::vector<double> npstat::HistoND< Numeric, Axis >::lowerAxisLimits ( ) const

A convenience function

◆ nBins()

template<typename Numeric , class Axis = HistoAxis>
unsigned long npstat::HistoND< Numeric, Axis >::nBins ( ) const
inline

Total number of bins

◆ nFillsInRange()

template<typename Numeric , class Axis = HistoAxis>
unsigned long npstat::HistoND< Numeric, Axis >::nFillsInRange ( ) const
inline

Total number of fills which fell inside the histogram range

◆ nFillsOver()

template<typename Numeric , class Axis = HistoAxis>
unsigned long npstat::HistoND< Numeric, Axis >::nFillsOver ( ) const
inline

Total number of fills which fell outside the histogram range

◆ nFillsTotal()

template<typename Numeric , class Axis = HistoAxis>
unsigned long npstat::HistoND< Numeric, Axis >::nFillsTotal ( ) const
inline

Total number of fills performed

◆ operator!=()

template<typename Numeric , class Axis = HistoAxis>
bool npstat::HistoND< Numeric, Axis >::operator!= ( const HistoND< Numeric, Axis > &  ) const

Logical negation of operator==

◆ operator*=()

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 >
HistoND& npstat::HistoND< Numeric, Axis >::operator*= ( const Num2 &  r)

In-place multiplication by a scalar (scaling)

◆ operator+=()

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 >
HistoND& npstat::HistoND< Numeric, Axis >::operator+= ( const HistoND< Num2, Axis > &  r)

Fill from another histogram. Compatibility of axis limits will not be checked, but compatibility of array shapes will be.

◆ operator-=()

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 >
HistoND& npstat::HistoND< Numeric, Axis >::operator-= ( const HistoND< Num2, Axis > &  r)

Subtract contents of another histogram. Equivalent to multiplying the contents of the other histogram by -1 and then adding them. One of the consequences of this approach is that, for histograms "a" and "b", the sequence of operations "a += b; a -= b;" does not leave histogram "a" unchanged: although its bin contents will remain the same (up to round-off errors), the fill counts will increase by twice the fill counts of "b".

◆ operator/=()

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 >
HistoND& npstat::HistoND< Numeric, Axis >::operator/= ( const Num2 &  r)

In-place division by a scalar

◆ operator=()

template<typename Numeric , class Axis = HistoAxis>
HistoND& npstat::HistoND< Numeric, Axis >::operator= ( const HistoND< Numeric, Axis > &  )

Assignment operator. Works even when the binning of the two histograms is not compatible.

◆ operator==()

template<typename Numeric , class Axis = HistoAxis>
bool npstat::HistoND< Numeric, Axis >::operator== ( const HistoND< Numeric, Axis > &  ) const

Comparison for equality

◆ overflows()

template<typename Numeric , class Axis = HistoAxis>
const ArrayND<Numeric>& npstat::HistoND< Numeric, Axis >::overflows ( ) const
inline

Retrive a reference to the array of overflows

◆ recalculateNFillsFromData()

template<typename Numeric , class Axis = HistoAxis>
void npstat::HistoND< Numeric, Axis >::recalculateNFillsFromData ( )

This member function instructs the histogram to recalculate the number of fills from data. It may be useful to call this function after "setBinContents" in case the contents are filled from another histogram.

◆ scaleBinContents()

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 >
void npstat::HistoND< Numeric, Axis >::scaleBinContents ( const Num2 *  data,
unsigned long  dataLength 
)

Multiplication by a value which is different for every bin

◆ setAccumulatedDataLabel()

template<typename Numeric , class Axis = HistoAxis>
void npstat::HistoND< Numeric, Axis >::setAccumulatedDataLabel ( const char *  newlabel)
inline

Modify the label associated with accumulated data

◆ setAxisLabel()

template<typename Numeric , class Axis = HistoAxis>
void npstat::HistoND< Numeric, Axis >::setAxisLabel ( const unsigned  axisNum,
const char *  newlabel 
)
inline

Modify the label for the histogram axis with the given number

◆ setBin()

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 >
void npstat::HistoND< Numeric, Axis >::setBin ( const unsigned *  index,
unsigned  indexLen,
const Num2 &  v 
)

Method to set contents of individual bins (no bounds checking)

◆ setBinAt()

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 >
void npstat::HistoND< Numeric, Axis >::setBinAt ( const unsigned *  index,
unsigned  indexLen,
const Num2 &  v 
)

Method to set contents of individual bins with bounds checking

◆ setBinContents()

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 >
void npstat::HistoND< Numeric, Axis >::setBinContents ( const Num2 *  data,
unsigned long  dataLength,
bool  clearOverflows = true 
)

This method sets all bin contents in one fell swoop

◆ setBinsToConst()

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 >
void npstat::HistoND< Numeric, Axis >::setBinsToConst ( const Num2 &  value)
inline

Setting bin contents to some constant value. The Num2 type should allow automatic conversion to Numeric.

◆ setNFillsTotal()

template<typename Numeric , class Axis = HistoAxis>
void npstat::HistoND< Numeric, Axis >::setNFillsTotal ( const unsigned long  i)
inline

This method is intended for data format conversion programs only, not for typical histogramming use

◆ setOverflows()

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 >
void npstat::HistoND< Numeric, Axis >::setOverflows ( const Num2 *  data,
unsigned long  dataLength 
)

This method sets all overflows in one fell swoop

◆ setOverflowsToConst()

template<typename Numeric , class Axis = HistoAxis>
template<typename Num2 >
void npstat::HistoND< Numeric, Axis >::setOverflowsToConst ( const Num2 &  value)
inline

Setting overflows to some constant value. The Num2 type should allow automatic conversion to Numeric.

◆ setTitle()

template<typename Numeric , class Axis = HistoAxis>
void npstat::HistoND< Numeric, Axis >::setTitle ( const char *  newtitle)
inline

Modify the histogram title

◆ title()

template<typename Numeric , class Axis = HistoAxis>
const std::string& npstat::HistoND< Numeric, Axis >::title ( ) const
inline

Histogram title

◆ transpose()

template<typename Numeric , class Axis = HistoAxis>
HistoND npstat::HistoND< Numeric, Axis >::transpose ( unsigned  axisNum1,
unsigned  axisNum2 
) const

Transpose the histogram axes and bin contents

◆ underflowWeight()

template<typename Numeric , class Axis = HistoAxis>
Numeric npstat::HistoND< Numeric, Axis >::underflowWeight ( unsigned  axisNumber) const
inline

Retrieve overflows for individual axes, marginalized over all other axes

◆ volume()

template<typename Numeric , class Axis = HistoAxis>
double npstat::HistoND< Numeric, Axis >::volume ( ) const

Volume of the histogram bounding box (this direct call is faster than calling boundingBox().volume() ). This function returns 1.0 for 0-dim histogram, axis interval length for 1-d histogram, etc.


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