thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.2.1
LWH::Histogram2D Class Reference

User level interface to 1D Histogram. More...

#include <Histogram2D.h>

Inheritance diagram for LWH::Histogram2D:

Public Member Functions

 Histogram2D (int nx, double lox, double upx, int ny, double loy, double upy)
 Standard constructor.
 
 Histogram2D (const std::vector< double > &xedges, const std::vector< double > &yedges)
 Standard constructor for variable bin width.
 
 Histogram2D (const Histogram2D &h)
 Copy constructor.
 
virtual ~Histogram2D ()
 Destructor.
 
std::string title () const
 Get the Histogram's title. More...
 
std::string name () const
 Get the Histogram's name. More...
 
bool setTitle (const std::string &title)
 Set the histogram title. More...
 
IAnnotation & annotation ()
 Not implemented in LWH. More...
 
const IAnnotation & annotation () const
 Not implemented in LWH. More...
 
int dimension () const
 Get the Histogram's dimension. More...
 
bool reset ()
 Reset the Histogram; as if just created. More...
 
int entries () const
 Get the number of in-range entries in the Histogram. More...
 
int allEntries () const
 Sum of the entries in all the IHistogram's bins, i.e in-range bins, UNDERFLOW and OVERFLOW. More...
 
int extraEntries () const
 Number of entries in the UNDERFLOW and OVERFLOW bins. More...
 
double equivalentBinEntries () const
 Number of equivalent entries, i.e. More...
 
double sumBinHeights () const
 Sum of in-range bin heights in the IHistogram, UNDERFLOW and OVERFLOW bins are excluded. More...
 
double sumAllBinHeights () const
 Sum of the heights of all the IHistogram's bins, i.e in-range bins, UNDERFLOW and OVERFLOW. More...
 
double sumExtraBinHeights () const
 Sum of heights in the UNDERFLOW and OVERFLOW bins. More...
 
double minBinHeight () const
 Minimum height of the in-range bins, i.e. More...
 
double maxBinHeight () const
 Maximum height of the in-range bins, i.e. More...
 
bool fill (double x, double y, double weight=1.)
 Fill the IHistogram1D with a value and the corresponding weight. More...
 
double binMeanX (int xindex, int yindex) const
 The weighted mean along the x-axis of a bin. More...
 
double binMeanY (int xindex, int yindex) const
 The weighted mean along the y-axis of a bin. More...
 
double binRmsX (int xindex, int yindex) const
 The weighted x-RMS of a bin. More...
 
double binRmsY (int xindex, int yindex) const
 The weighted y-RMS of a bin. More...
 
int binEntries (int xindex, int yindex) const
 Number of entries in the corresponding bin (ie the number of times fill was called for this bin). More...
 
virtual int binEntriesX (int index) const
 Sum of all the entries of the bins along a given x bin. More...
 
virtual int binEntriesY (int index) const
 Sum of all the entries of the bins along a given y bin. More...
 
double binHeight (int xindex, int yindex) const
 Total height of the corresponding bin (ie the sum of the weights in this bin). More...
 
virtual double binHeightX (int index) const
 Sum of all the heights of the bins along a given x bin. More...
 
virtual double binHeightY (int index) const
 Sum of all the heights of the bins along a given y bin. More...
 
double binError (int xindex, int yindex) const
 The error of a given bin. More...
 
double meanX () const
 The mean of the IHistogram2D along the x axis. More...
 
double meanY () const
 The mean of the IHistogram2D along the y axis. More...
 
double rmsX () const
 The RMS of the IHistogram2D along the x axis. More...
 
double rmsY () const
 The RMS of the IHistogram2D along the x axis. More...
 
double getSumW (int xindex, int yindex) const
 The weights. More...
 
double getSumW2 (int xindex, int yindex) const
 The squared weights. More...
 
double getSumXW (int xindex, int yindex) const
 The weighted x-values. More...
 
double getSumX2W (int xindex, int yindex) const
 The weighted x-square-values. More...
 
double getSumYW (int xindex, int yindex) const
 The weighted x-values. More...
 
double getSumY2W (int xindex, int yindex) const
 The weighted x-square-values. More...
 
const IAxis & xAxis () const
 Get the x axis of the IHistogram2D. More...
 
const IAxis & yAxis () const
 Get the y axis of the IHistogram2D. More...
 
int coordToIndexX (double coord) const
 Get the bin number corresponding to a given coordinate along the x axis. More...
 
int coordToIndexY (double coord) const
 Get the bin number corresponding to a given coordinate along the y axis. More...
 
bool add (const Histogram2D &h)
 Add to this Histogram2D the contents of another IHistogram2D. More...
 
bool add (const IHistogram2D &hist)
 Add to this IHistogram1D the contents of another IHistogram1D. More...
 
bool scale (double s)
 Scale the contents of this histogram with the given factor. More...
 
void normalize (double intg)
 Scale the given histogram so that the integral over all bins (including overflow) gives intg. More...
 
void * cast (const std::string &) const
 Return the integral over the histogram bins assuming it has been normalize()d. More...
 
bool writeXML (std::ostream &os, std::string path, std::string name)
 Write out the histogram in the AIDA xml format.
 
bool writeFLAT (std::ostream &os, std::string path, std::string name)
 Write out the histogram in a flat text file suitable for eg. More...
 
- Public Member Functions inherited from LWH::ManagedObject
virtual ~ManagedObject ()
 Destructor.
 

Private Attributes

std::string theTitle
 The title.
 
IAxis * xax
 The axis. More...
 
Axisxfax
 Pointer (possibly null) to a axis with fixed bin width. More...
 
VariAxisxvax
 Pointer (possibly null) to a axis with fixed bin width. More...
 
IAxis * yax
 The axis. More...
 
Axisyfax
 Pointer (possibly null) to a axis with fixed bin width. More...
 
VariAxisyvax
 Pointer (possibly null) to a axis with fixed bin width. More...
 
std::vector< std::vector< int > > sum
 The counts. More...
 
std::vector< std::vector< double > > sumw
 The weights. More...
 
std::vector< std::vector< double > > sumw2
 The squared weights. More...
 
std::vector< std::vector< double > > sumxw
 The weighted x-values. More...
 
std::vector< std::vector< double > > sumx2w
 The weighted x-square-values. More...
 
std::vector< std::vector< double > > sumyw
 The weighted y-values. More...
 
std::vector< std::vector< double > > sumy2w
 The weighted y-square-values. More...
 
IAnnotation * anno
 dummy pointer to non-existen annotation. More...
 

Friends

class HistogramFactory
 HistFactory is a friend. More...
 

Detailed Description

User level interface to 1D Histogram.

Definition at line 25 of file Histogram2D.h.

Member Function Documentation

◆ add() [1/2]

bool LWH::Histogram2D::add ( const Histogram2D h)
inline

Add to this Histogram2D the contents of another IHistogram2D.

Parameters
hThe Histogram2D to be added to this IHistogram2D.
Returns
false If the IHistogram1Ds binnings are incompatible.

Definition at line 577 of file Histogram2D.h.

References sum, sumw, sumw2, sumx2w, sumxw, sumy2w, sumyw, xax, and yax.

Referenced by LWH::HistogramFactory::add().

◆ add() [2/2]

bool LWH::Histogram2D::add ( const IHistogram2D &  hist)
inline

Add to this IHistogram1D the contents of another IHistogram1D.

Parameters
histThe IHistogram1D to be added to this IHistogram1D.
Returns
false If the IHistogram1Ds binnings are incompatible.

Definition at line 602 of file Histogram2D.h.

◆ allEntries()

int LWH::Histogram2D::allEntries ( ) const
inline

Sum of the entries in all the IHistogram's bins, i.e in-range bins, UNDERFLOW and OVERFLOW.

This is equivalent to the number of times the method fill was invoked.

Returns
The sum of all the entries.

Definition at line 178 of file Histogram2D.h.

◆ annotation() [1/2]

IAnnotation& LWH::Histogram2D::annotation ( )
inline

Not implemented in LWH.

will throw an exception.

Definition at line 121 of file Histogram2D.h.

◆ annotation() [2/2]

const IAnnotation& LWH::Histogram2D::annotation ( ) const
inline

Not implemented in LWH.

will throw an exception.

Definition at line 129 of file Histogram2D.h.

◆ binEntries()

int LWH::Histogram2D::binEntries ( int  xindex,
int  yindex 
) const
inline

Number of entries in the corresponding bin (ie the number of times fill was called for this bin).

Parameters
indexThe bin number (0...N-1) or OVERFLOW or UNDERFLOW.
Returns
The number of entries in the corresponding bin.

Definition at line 352 of file Histogram2D.h.

◆ binEntriesX()

virtual int LWH::Histogram2D::binEntriesX ( int  index) const
inlinevirtual

Sum of all the entries of the bins along a given x bin.

This is equivalent to projectionX().binEntries(index).

Parameters
indexThe x bin number (0...N-1) or OVERFLOW or UNDERFLOW.
Returns
The number of entries in the corresponding set of bins.

Definition at line 363 of file Histogram2D.h.

◆ binEntriesY()

virtual int LWH::Histogram2D::binEntriesY ( int  index) const
inlinevirtual

Sum of all the entries of the bins along a given y bin.

This is equivalent to projectionY().binEntries(index).

Parameters
indexThe y bin number (0...N-1) or OVERFLOW or UNDERFLOW.
Returns
The number of entries in the corresponding set of bins.

Definition at line 377 of file Histogram2D.h.

◆ binError()

double LWH::Histogram2D::binError ( int  xindex,
int  yindex 
) const
inline

The error of a given bin.

Parameters
indexThe bin number (0...N-1) or OVERFLOW or UNDERFLOW.
Returns
The error on the corresponding bin.

Definition at line 430 of file Histogram2D.h.

◆ binHeight()

double LWH::Histogram2D::binHeight ( int  xindex,
int  yindex 
) const
inline

Total height of the corresponding bin (ie the sum of the weights in this bin).

Parameters
indexThe bin number (0...N-1) or OVERFLOW or UNDERFLOW.
Returns
The height of the corresponding bin.
Todo:
While this is compatible with the reference AIDA implementation, it is not the bin height!

Definition at line 390 of file Histogram2D.h.

◆ binHeightX()

virtual double LWH::Histogram2D::binHeightX ( int  index) const
inlinevirtual

Sum of all the heights of the bins along a given x bin.

This is equivalent to projectionX().binHeight(index).

Parameters
indexThe x bin number (0...N-1) or OVERFLOW or UNDERFLOW.
Returns
The sum of the heights in the corresponding set of bins.

Definition at line 403 of file Histogram2D.h.

◆ binHeightY()

virtual double LWH::Histogram2D::binHeightY ( int  index) const
inlinevirtual

Sum of all the heights of the bins along a given y bin.

This is equivalent to projectionY().binHeight(index).

Parameters
indexThe y bin number (0...N-1) or OVERFLOW or UNDERFLOW.
Returns
The sum of the heights in the corresponding set of bins.

Definition at line 417 of file Histogram2D.h.

◆ binMeanX()

double LWH::Histogram2D::binMeanX ( int  xindex,
int  yindex 
) const
inline

The weighted mean along the x-axis of a bin.

Parameters
xindexThe bin number (0...N-1) or OVERFLOW or UNDERFLOW.
yindexThe bin number (0...N-1) or OVERFLOW or UNDERFLOW.
Returns
The mean of the corresponding bin.

Definition at line 298 of file Histogram2D.h.

◆ binMeanY()

double LWH::Histogram2D::binMeanY ( int  xindex,
int  yindex 
) const
inline

The weighted mean along the y-axis of a bin.

Parameters
xindexThe bin number (0...N-1) or OVERFLOW or UNDERFLOW.
yindexThe bin number (0...N-1) or OVERFLOW or UNDERFLOW.
Returns
The mean of the corresponding bin.

Definition at line 311 of file Histogram2D.h.

◆ binRmsX()

double LWH::Histogram2D::binRmsX ( int  xindex,
int  yindex 
) const
inline

The weighted x-RMS of a bin.

Parameters
xindexThe bin number (0...N-1) or OVERFLOW or UNDERFLOW.
yindexThe bin number (0...N-1) or OVERFLOW or UNDERFLOW.
Returns
The RMS of the corresponding bin.

Definition at line 324 of file Histogram2D.h.

◆ binRmsY()

double LWH::Histogram2D::binRmsY ( int  xindex,
int  yindex 
) const
inline

The weighted y-RMS of a bin.

Parameters
xindexThe bin number (0...N-1) or OVERFLOW or UNDERFLOW.
yindexThe bin number (0...N-1) or OVERFLOW or UNDERFLOW.
Returns
The RMS of the corresponding bin.

Definition at line 338 of file Histogram2D.h.

◆ cast()

void* LWH::Histogram2D::cast ( const std::string &  ) const
inline

Return the integral over the histogram bins assuming it has been normalize()d.

Not implemented in LWH.

Returns
null pointer always.

Definition at line 666 of file Histogram2D.h.

◆ coordToIndexX()

int LWH::Histogram2D::coordToIndexX ( double  coord) const
inline

Get the bin number corresponding to a given coordinate along the x axis.

This is a convenience method, equivalent to axis().coordToIndex(coord).

Parameters
coordThe coordinalte along the x axis.
Returns
The corresponding bin number.

Definition at line 557 of file Histogram2D.h.

◆ coordToIndexY()

int LWH::Histogram2D::coordToIndexY ( double  coord) const
inline

Get the bin number corresponding to a given coordinate along the y axis.

This is a convenience method, equivalent to axis().coordToIndex(coord).

Parameters
coordThe coordinalte along the y axis.
Returns
The corresponding bin number.

Definition at line 568 of file Histogram2D.h.

◆ dimension()

int LWH::Histogram2D::dimension ( ) const
inline

Get the Histogram's dimension.

Returns
The Histogram's dimension.

Definition at line 138 of file Histogram2D.h.

◆ entries()

int LWH::Histogram2D::entries ( ) const
inline

Get the number of in-range entries in the Histogram.

Returns
The number of in-range entries.

Definition at line 164 of file Histogram2D.h.

◆ equivalentBinEntries()

double LWH::Histogram2D::equivalentBinEntries ( ) const
inline

Number of equivalent entries, i.e.

SUM[ weight ] ^ 2 / SUM[ weight^2 ]

Returns
The number of equivalent entries.

Definition at line 200 of file Histogram2D.h.

◆ extraEntries()

int LWH::Histogram2D::extraEntries ( ) const
inline

Number of entries in the UNDERFLOW and OVERFLOW bins.

Returns
The number of entries outside the range of the IHistogram.

Definition at line 186 of file Histogram2D.h.

◆ fill()

bool LWH::Histogram2D::fill ( double  x,
double  y,
double  weight = 1. 
)
inline

Fill the IHistogram1D with a value and the corresponding weight.

Parameters
xThe value to be filled in.
weightThe corresponding weight (by default 1).
Returns
false If the weight is <0 or >1 (?).

Definition at line 279 of file Histogram2D.h.

◆ getSumW()

double LWH::Histogram2D::getSumW ( int  xindex,
int  yindex 
) const
inline

The weights.

Definition at line 505 of file Histogram2D.h.

◆ getSumW2()

double LWH::Histogram2D::getSumW2 ( int  xindex,
int  yindex 
) const
inline

The squared weights.

Definition at line 510 of file Histogram2D.h.

◆ getSumX2W()

double LWH::Histogram2D::getSumX2W ( int  xindex,
int  yindex 
) const
inline

The weighted x-square-values.

Definition at line 520 of file Histogram2D.h.

◆ getSumXW()

double LWH::Histogram2D::getSumXW ( int  xindex,
int  yindex 
) const
inline

The weighted x-values.

Definition at line 515 of file Histogram2D.h.

◆ getSumY2W()

double LWH::Histogram2D::getSumY2W ( int  xindex,
int  yindex 
) const
inline

The weighted x-square-values.

Definition at line 530 of file Histogram2D.h.

◆ getSumYW()

double LWH::Histogram2D::getSumYW ( int  xindex,
int  yindex 
) const
inline

The weighted x-values.

Definition at line 525 of file Histogram2D.h.

◆ maxBinHeight()

double LWH::Histogram2D::maxBinHeight ( ) const
inline

Maximum height of the in-range bins, i.e.

not considering the UNDERFLOW and OVERFLOW bins.

Returns
The maximum height among the in-range bins.

Definition at line 264 of file Histogram2D.h.

◆ meanX()

double LWH::Histogram2D::meanX ( ) const
inline

The mean of the IHistogram2D along the x axis.

Returns
The mean of the IHistogram2D along the x axis.

Definition at line 439 of file Histogram2D.h.

◆ meanY()

double LWH::Histogram2D::meanY ( ) const
inline

The mean of the IHistogram2D along the y axis.

Returns
The mean of the IHistogram2D along the y axis.

Definition at line 455 of file Histogram2D.h.

◆ minBinHeight()

double LWH::Histogram2D::minBinHeight ( ) const
inline

Minimum height of the in-range bins, i.e.

not considering the UNDERFLOW and OVERFLOW bins.

Returns
The minimum height among the in-range bins.

Definition at line 251 of file Histogram2D.h.

◆ name()

std::string LWH::Histogram2D::name ( ) const
inline

Get the Histogram's name.

Returns
The Histogram's name

Definition at line 104 of file Histogram2D.h.

◆ normalize()

void LWH::Histogram2D::normalize ( double  intg)
inline

Scale the given histogram so that the integral over all bins (including overflow) gives intg.

This function also corrects for the bin-widths, which means that it should only be run once for each histogram. Further rescaling must be done with the scale(double) function.

Definition at line 630 of file Histogram2D.h.

◆ reset()

bool LWH::Histogram2D::reset ( )
inline

Reset the Histogram; as if just created.

Returns
false If something goes wrong.

Definition at line 146 of file Histogram2D.h.

◆ rmsX()

double LWH::Histogram2D::rmsX ( ) const
inline

The RMS of the IHistogram2D along the x axis.

Returns
The RMS if the IHistogram2D along the x axis.

Definition at line 471 of file Histogram2D.h.

◆ rmsY()

double LWH::Histogram2D::rmsY ( ) const
inline

The RMS of the IHistogram2D along the x axis.

Returns
The RMS if the IHistogram2D along the x axis.

Definition at line 490 of file Histogram2D.h.

◆ scale()

bool LWH::Histogram2D::scale ( double  s)
inline

Scale the contents of this histogram with the given factor.

Parameters
sthe scaling factor to use.

Definition at line 610 of file Histogram2D.h.

◆ setTitle()

bool LWH::Histogram2D::setTitle ( const std::string &  title)
inline

Set the histogram title.

Parameters
titleThe title.
Returns
false If title cannot be changed.

Definition at line 113 of file Histogram2D.h.

Referenced by LWH::HistogramFactory::add(), LWH::HistogramFactory::createCopy(), LWH::HistogramFactory::createHistogram2D(), LWH::HistogramFactory::divide(), LWH::HistogramFactory::multiply(), and LWH::HistogramFactory::subtract().

◆ sumAllBinHeights()

double LWH::Histogram2D::sumAllBinHeights ( ) const
inline

Sum of the heights of all the IHistogram's bins, i.e in-range bins, UNDERFLOW and OVERFLOW.

Returns
The sum of all the bins heights.

Definition at line 229 of file Histogram2D.h.

◆ sumBinHeights()

double LWH::Histogram2D::sumBinHeights ( ) const
inline

Sum of in-range bin heights in the IHistogram, UNDERFLOW and OVERFLOW bins are excluded.

Returns
The sum of the in-range bins heights.

Definition at line 217 of file Histogram2D.h.

◆ sumExtraBinHeights()

double LWH::Histogram2D::sumExtraBinHeights ( ) const
inline

Sum of heights in the UNDERFLOW and OVERFLOW bins.

Returns
The sum of the heights of the out-of-range bins.

Definition at line 237 of file Histogram2D.h.

◆ title()

std::string LWH::Histogram2D::title ( ) const
inline

Get the Histogram's title.

Returns
The Histogram's title.

Definition at line 96 of file Histogram2D.h.

◆ writeFLAT()

bool LWH::Histogram2D::writeFLAT ( std::ostream &  os,
std::string  path,
std::string  name 
)
inlinevirtual

Write out the histogram in a flat text file suitable for eg.

gnuplot to read. The coloums are layed out as 'x w w2 n'.

Implements LWH::ManagedObject.

Definition at line 738 of file Histogram2D.h.

◆ xAxis()

const IAxis& LWH::Histogram2D::xAxis ( ) const
inline

Get the x axis of the IHistogram2D.

Returns
The x coordinate IAxis.

Definition at line 538 of file Histogram2D.h.

◆ yAxis()

const IAxis& LWH::Histogram2D::yAxis ( ) const
inline

Get the y axis of the IHistogram2D.

Returns
The y coordinate IAxis.

Definition at line 546 of file Histogram2D.h.

Friends And Related Function Documentation

◆ HistogramFactory

friend class HistogramFactory
friend

HistFactory is a friend.

Definition at line 30 of file Histogram2D.h.

Member Data Documentation

◆ anno

IAnnotation* LWH::Histogram2D::anno
private

dummy pointer to non-existen annotation.

Definition at line 862 of file Histogram2D.h.

◆ sum

std::vector< std::vector<int> > LWH::Histogram2D::sum
private

◆ sumw

std::vector< std::vector<double> > LWH::Histogram2D::sumw
private

◆ sumw2

std::vector< std::vector<double> > LWH::Histogram2D::sumw2
private

◆ sumx2w

std::vector< std::vector<double> > LWH::Histogram2D::sumx2w
private

The weighted x-square-values.

Definition at line 853 of file Histogram2D.h.

Referenced by add(), LWH::HistogramFactory::sliceX(), and LWH::HistogramFactory::subtract().

◆ sumxw

std::vector< std::vector<double> > LWH::Histogram2D::sumxw
private

The weighted x-values.

Definition at line 850 of file Histogram2D.h.

Referenced by add(), LWH::HistogramFactory::sliceX(), and LWH::HistogramFactory::subtract().

◆ sumy2w

std::vector< std::vector<double> > LWH::Histogram2D::sumy2w
private

The weighted y-square-values.

Definition at line 859 of file Histogram2D.h.

Referenced by add(), LWH::HistogramFactory::sliceY(), and LWH::HistogramFactory::subtract().

◆ sumyw

std::vector< std::vector<double> > LWH::Histogram2D::sumyw
private

The weighted y-values.

Definition at line 856 of file Histogram2D.h.

Referenced by add(), LWH::HistogramFactory::sliceY(), and LWH::HistogramFactory::subtract().

◆ xax

◆ xfax

Axis* LWH::Histogram2D::xfax
private

Pointer (possibly null) to a axis with fixed bin width.

Definition at line 826 of file Histogram2D.h.

Referenced by LWH::HistogramFactory::checkBins(), and LWH::HistogramFactory::sliceX().

◆ xvax

VariAxis* LWH::Histogram2D::xvax
private

Pointer (possibly null) to a axis with fixed bin width.

Definition at line 829 of file Histogram2D.h.

◆ yax

◆ yfax

Axis* LWH::Histogram2D::yfax
private

Pointer (possibly null) to a axis with fixed bin width.

Definition at line 835 of file Histogram2D.h.

Referenced by LWH::HistogramFactory::checkBins(), and LWH::HistogramFactory::sliceY().

◆ yvax

VariAxis* LWH::Histogram2D::yvax
private

Pointer (possibly null) to a axis with fixed bin width.

Definition at line 838 of file Histogram2D.h.


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