YODA is hosted by Hepforge, IPPP Durham

A Bin1D specialised for handling histogram-type information. More...

#include <HistoBin1D.h>

Inheritance diagram for YODA::HistoBin1D:
YODA::Bin1D< Dbn1D > YODA::Bin

Public Member Functions

HistoBin1Doperator+= (const HistoBin1D &toAdd)
 Add two bins (for use by Histo1D). More...
 
HistoBin1Doperator-= (const HistoBin1D &toSubtract)
 Subtract two bins. More...
 
Constructor giving bin low and high edges.
 HistoBin1D (double lowedge, double highedge)
 Make a new, empty bin with a pair of edges. More...
 
 HistoBin1D (const std::pair< double, double > &edges)
 Make a new, empty bin with a pair of edges. More...
 
 HistoBin1D (std::pair< double, double > edges, const Dbn1D &dbnx)
 Make a bin with all the components of a fill history. More...
 
 HistoBin1D (const HistoBin1D &hb)
 Copy constructor. More...
 
HistoBin1Doperator= (const HistoBin1D &hb)
 Copy assignment. More...
 
Modifiers
void fill (double x, double weight=1.0)
 
void fillBin (double weight=1.0)
 
Bin content info
double area () const
 
double height () const
 The height is defined as area/width. More...
 
Error info
double areaErr () const
 
double heightErr () const
 
double relErr () const
 The relative size of the error (same for either area or height errors) More...
 
- Public Member Functions inherited from YODA::Bin1D< Dbn1D >
 Bin1D (const std::pair< double, double > &edges)
 Make a new, empty bin with a pair of edges. More...
 
 Bin1D (const std::pair< double, double > &edges, const Dbn1D &dbn)
 Make a bin with all the components of a fill history. More...
 
 Bin1D (const Bin1D< Dbn1D > &b)
 Copy constructor. More...
 
Bin1Doperator= (const Bin1D< Dbn1D > &b)
 Copy assignment. More...
 
virtual void reset ()
 Reset this bin. More...
 
void scaleW (double scalefactor)
 
void scaleX (double factor)
 
std::pair< double, double > xEdges () const
 Get the {low,high} edges as an STL pair. More...
 
double xMin () const
 Lower limit of the bin (inclusive). More...
 
double xMax () const
 Upper limit of the bin (exclusive). More...
 
double xMid () const
 Geometric centre of the bin, i.e. high+low/2.0. More...
 
double midpoint () const
 
double xWidth () const
 Separation of low and high edges, i.e. high-low. More...
 
double width () const
 
double xFocus () const
 The mean position in the bin, or the midpoint if that is not available. More...
 
double xMean () const
 Mean value of x-values in the bin. More...
 
double xVariance () const
 The variance of x-values in the bin. More...
 
double xStdDev () const
 The standard deviation (spread) of x-values in the bin. More...
 
double xStdErr () const
 The standard error on the bin focus. More...
 
double xRMS () const
 The x RMS in the bin. More...
 
Dbn1Ddbn ()
 Statistical distribution in this bin (non-const) More...
 
const Dbn1Ddbn () const
 Statistical distribution in this bin (const) More...
 
unsigned long numEntries () const
 The number of entries. More...
 
double effNumEntries () const
 The effective number of entries. More...
 
double sumW () const
 The sum of weights. More...
 
double sumW2 () const
 The sum of weights squared. More...
 
double sumWX () const
 The sum of x*weight. More...
 
double sumWX2 () const
 The sum of x^2 * weight. More...
 
Bin1D< Dbn1D > & operator+= (const Bin1D< Dbn1D > &b)
 Add two bins. More...
 
Bin1D< Dbn1D > & operator-= (const Bin1D< Dbn1D > &b)
 Subtract one bin from another. More...
 
Bin1D< Dbn1D > & merge (const Bin1D< Dbn1D > &b)
 Merge two adjacent bins. More...
 
Bin1D< Dbn1D > & add (const Bin1D< Dbn1D > &b)
 
Bin1D< Dbn1D > & subtract (const Bin1D< Dbn1D > &b)
 
- Public Member Functions inherited from YODA::Bin
virtual ~Bin ()
 Virtual destructor for inheritance. More...
 

Protected Member Functions

HistoBin1Dadd (const HistoBin1D &hb)
 Add two bins (internal, explicitly named version) More...
 
HistoBin1Dsubtract (const HistoBin1D &hb)
 Subtract one bin from another (internal, explicitly named version) More...
 

Detailed Description

A Bin1D specialised for handling histogram-type information.

This is a 1D bin type, which supports all the operations defined for a generic Bin1D object, but also supplies the specific member functions for histogram-type data, as opposed to profile-type.

Definition at line 21 of file HistoBin1D.h.

Constructor & Destructor Documentation

YODA::HistoBin1D::HistoBin1D ( double  lowedge,
double  highedge 
)
inline

Make a new, empty bin with a pair of edges.

Definition at line 28 of file HistoBin1D.h.

29  : Bin1D<Dbn1D>(std::make_pair(lowedge, highedge))
30  { }
YODA::HistoBin1D::HistoBin1D ( const std::pair< double, double > &  edges)
inline

Make a new, empty bin with a pair of edges.

Definition at line 34 of file HistoBin1D.h.

35  : Bin1D<Dbn1D>(edges)
36  { }
YODA::HistoBin1D::HistoBin1D ( std::pair< double, double >  edges,
const Dbn1D dbnx 
)
inline

Make a bin with all the components of a fill history.

Mainly intended for internal persistency use.

Definition at line 42 of file HistoBin1D.h.

43  : Bin1D<Dbn1D>(edges, dbnx)
44  { }
YODA::HistoBin1D::HistoBin1D ( const HistoBin1D hb)
inline

Copy constructor.

Definition at line 48 of file HistoBin1D.h.

49  : Bin1D<Dbn1D>(hb)
50  { }

Member Function Documentation

HistoBin1D& YODA::HistoBin1D::add ( const HistoBin1D hb)
inlineprotected

Add two bins (internal, explicitly named version)

Definition at line 145 of file HistoBin1D.h.

References YODA::Bin1D< DBN >::add().

Referenced by operator+=().

145  {
146  Bin1D<Dbn1D>::add(hb);
147  return *this;
148  }
Bin1D< DBN > & add(const Bin1D< DBN > &b)
Definition: Bin1D.h:275
double YODA::HistoBin1D::area ( ) const
inline

The area is the sum of weights in the bin, i.e. the width of the bin has no influence on this figure.

Definition at line 93 of file HistoBin1D.h.

References YODA::Bin1D< Dbn1D >::sumW().

Referenced by height().

93  {
94  return sumW();
95  }
double sumW() const
The sum of weights.
Definition: Bin1D.h:212
double YODA::HistoBin1D::areaErr ( ) const
inline

Error computed using binomial statistics on the sum of bin weights, i.e. err_area = sqrt{sum{weights}}

Definition at line 110 of file HistoBin1D.h.

References YODA::Bin1D< Dbn1D >::sumW2().

Referenced by heightErr().

110  {
111  return sqrt(sumW2());
112  }
double sumW2() const
The sum of weights squared.
Definition: Bin1D.h:217
void YODA::HistoBin1D::fill ( double  x,
double  weight = 1.0 
)
inline

Fill this bin with weight weight at position x.

Note
This should not be used, since it breaks histogram consistency. It will be removed in a future version.

Definition at line 72 of file HistoBin1D.h.

Referenced by fillBin().

72  {
73  _dbn.fill(x, weight);
74  }
void YODA::HistoBin1D::fillBin ( double  weight = 1.0)
inline

Fill this bin with weight weight.

Note
This should not be used, since it breaks histogram consistency. It will be removed in a future version.

Definition at line 79 of file HistoBin1D.h.

References fill(), and YODA::Bin1D< Dbn1D >::xMid().

79  {
80  fill(xMid(), weight);
81  }
void fill(double x, double weight=1.0)
Definition: HistoBin1D.h:72
double xMid() const
Geometric centre of the bin, i.e. high+low/2.0.
Definition: Bin1D.h:130
double YODA::HistoBin1D::height ( ) const
inline

The height is defined as area/width.

Definition at line 98 of file HistoBin1D.h.

References area(), and YODA::Bin1D< Dbn1D >::xWidth().

Referenced by YODA::chi2(), and YODA::mkScatter().

98  {
99  return area() / xWidth();
100  }
double xWidth() const
Separation of low and high edges, i.e. high-low.
Definition: Bin1D.h:138
double area() const
Definition: HistoBin1D.h:93
double YODA::HistoBin1D::heightErr ( ) const
inline

As for the height vs. area, the height error includes a scaling factor of the bin width, i.e. err_height = sqrt{sum{weights}} / width.

Definition at line 116 of file HistoBin1D.h.

References areaErr(), and YODA::Bin1D< Dbn1D >::xWidth().

Referenced by YODA::chi2(), and YODA::mkScatter().

116  {
117  return areaErr() / xWidth();
118  }
double xWidth() const
Separation of low and high edges, i.e. high-low.
Definition: Bin1D.h:138
double areaErr() const
Definition: HistoBin1D.h:110
HistoBin1D& YODA::HistoBin1D::operator+= ( const HistoBin1D toAdd)
inline

Add two bins (for use by Histo1D).

Definition at line 132 of file HistoBin1D.h.

References add().

132  {
133  return add(toAdd);
134  }
HistoBin1D & add(const HistoBin1D &hb)
Add two bins (internal, explicitly named version)
Definition: HistoBin1D.h:145
HistoBin1D& YODA::HistoBin1D::operator-= ( const HistoBin1D toSubtract)
inline

Subtract two bins.

Definition at line 137 of file HistoBin1D.h.

References subtract().

137  {
138  return subtract(toSubtract);
139  }
HistoBin1D & subtract(const HistoBin1D &hb)
Subtract one bin from another (internal, explicitly named version)
Definition: HistoBin1D.h:151
HistoBin1D& YODA::HistoBin1D::operator= ( const HistoBin1D hb)
inline

Copy assignment.

Definition at line 54 of file HistoBin1D.h.

References YODA::Bin1D< DBN >::operator=().

54  {
56  return *this;
57  }
Bin1D & operator=(const Bin1D< DBN > &b)
Copy assignment.
Definition: Bin1D.h:73
double YODA::HistoBin1D::relErr ( ) const
inline

The relative size of the error (same for either area or height errors)

Todo:
Throw excp if sumW2 is 0?

Definition at line 121 of file HistoBin1D.h.

References YODA::Bin1D< Dbn1D >::sumW(), and YODA::Bin1D< Dbn1D >::sumW2().

121  {
123  return sumW2() != 0 ? sqrt(sumW2()) / sumW() : 0;
124  }
double sumW() const
The sum of weights.
Definition: Bin1D.h:212
double sumW2() const
The sum of weights squared.
Definition: Bin1D.h:217
HistoBin1D& YODA::HistoBin1D::subtract ( const HistoBin1D hb)
inlineprotected

Subtract one bin from another (internal, explicitly named version)

Definition at line 151 of file HistoBin1D.h.

References YODA::Bin1D< DBN >::subtract().

Referenced by operator-=().

151  {
153  return *this;
154  }
Bin1D< DBN > & subtract(const Bin1D< DBN > &b)
Definition: Bin1D.h:289

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