cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches

1D histogram container More...

#include <CepGen/Utils/Histogram.h>

+ Inheritance diagram for Hist1D:
+ Collaboration diagram for Hist1D:

Public Types

enum  BinMode { low = 0 , high , both }
 
typedef std::map< coord_t, Valueaxis_t
 Metadata for an axis (coordinates and bins value)
 
typedef std::map< coord_t, axis_tdualaxis_t
 Metadata for a two-dimensional axis definition (coordinates and bins values)
 

Public Member Functions

 Hist1D (const ParametersList &)
 Build a histogram from user-steeed parameters.
 
 Hist1D (size_t num_bins_x, const Limits &, const std::string &name="", const std::string &title="")
 Build a histogram from uniform-width bins.
 
 Hist1D (const std::vector< double > &bins, const std::string &name="", const std::string &title="")
 Build a histogram from variable-width bins.
 
 Hist1D (const Hist1D &)
 Copy constructor.
 
void clear () override
 Reset the histogram.
 
void fill (double x, double weight=1.)
 Increment the histogram with one value.
 
void add (Hist1D, double scaling=1.)
 Bin-to-bin addition of another histogram to this one.
 
void scale (double) override
 Rescale all histogram bins by a constant factor.
 
double sample (RandomGenerator &) const
 Sample individual "events" from a distribution.
 
double chi2test (const Hist1D &, size_t &ndf) const
 Perform a chi^2 test between two histograms.
 
std::vector< Valuevalues () const
 Retrieve the value + uncertainty for all bins.
 
Value value (size_t bin) const
 Retrieve the value + uncertainty for one bin.
 
void setValue (size_t bin, Value value)
 Set the value + uncertainty for one bin.
 
axis_t axis () const
 Axis content.
 
size_t nbins () const
 Number of histogram bins.
 
Limits range () const
 Axis range.
 
Limits binRange (size_t bin) const
 Range for a single bin.
 
std::vector< double > bins (BinMode) const
 List of bins limits (nbins + 1 values if min-max, nbins values otherwise)
 
size_t bin (double x) const
 Retrieve the bin index for a x value.
 
double mean () const
 Compute the mean histogram value over full range.
 
double rms () const
 Compute the root-mean-square value over full range.
 
double minimum () const override
 Retrieve the maximum bin value.
 
double maximum () const override
 Retrieve the minimum bin value.
 
double integral (bool=false) const override
 Compute the histogram integral.
 
size_t underflow () const
 
size_t overflow () const
 
bool isHist1D () const override final
 Is this drawable a one-dimensional histogram?
 
void normalise (double integ=1.)
 Normalise the histogram to a given constant.
 
const std::string & name () const
 Drawable name.
 
void setName (const std::string &name)
 Set the drawable name.
 
const std::string & title () const
 Drawable name.
 
void setTitle (const std::string &title)
 Set the drawable title.
 
AxisInfoxAxis ()
 
const AxisInfoxAxis () const
 
AxisInfoyAxis ()
 
const AxisInfoyAxis () const
 
AxisInfozAxis ()
 
const AxisInfozAxis () const
 
virtual bool isHist2D () const
 Is this drawable a two-dimensional histogram?
 
virtual bool isGraph1D () const
 Is this drawable a one-dimensional graph?
 
virtual bool isGraph2D () const
 Is this drawable a two-dimensional graph?
 

Protected Member Functions

std::set< double > extractBins (BinMode mode, size_t num_bins, const std::function< Limits(size_t)> &bins_extractor) const
 Extract the list of bin limits.
 

Protected Attributes

std::string name_
 Computer-readable name.
 
std::string title_
 Human-readable title.
 
AxisInfo xaxis_
 x-axis metadata
 
AxisInfo yaxis_
 y-axis metadata
 
AxisInfo zaxis_
 z-axis metadata
 

Detailed Description

Definition at line 72 of file Histogram.h.

Member Typedef Documentation

◆ axis_t

typedef std::map<coord_t, Value> axis_t
inherited

Definition at line 95 of file Drawable.h.

◆ dualaxis_t

typedef std::map<coord_t, axis_t> dualaxis_t
inherited

Definition at line 103 of file Drawable.h.

Member Enumeration Documentation

◆ BinMode

enum BinMode
inherited
Enumerator
low 
high 
both 

Definition at line 46 of file Histogram.h.

Constructor & Destructor Documentation

◆ Hist1D() [1/4]

Hist1D ( const ParametersList params)
explicit

Definition at line 31 of file Hist1D.cpp.

◆ Hist1D() [2/4]

Hist1D ( size_t  num_bins_x,
const Limits xrange,
const std::string &  name = "",
const std::string &  title = "" 
)
explicit

Definition at line 41 of file Hist1D.cpp.

◆ Hist1D() [3/4]

Hist1D ( const std::vector< double > &  bins,
const std::string &  name = "",
const std::string &  title = "" 
)
explicit

Definition at line 48 of file Hist1D.cpp.

◆ Hist1D() [4/4]

Hist1D ( const Hist1D oth)

Definition at line 55 of file Hist1D.cpp.

Member Function Documentation

◆ add()

void add ( Hist1D  oth,
double  scaling = 1. 
)

Definition at line 117 of file Hist1D.cpp.

◆ axis()

Drawable::axis_t axis ( ) const

Definition at line 145 of file Hist1D.cpp.

◆ bin()

size_t bin ( double  x) const

Definition at line 178 of file Hist1D.cpp.

◆ binRange()

Limits binRange ( size_t  bin) const

Definition at line 165 of file Hist1D.cpp.

◆ bins()

std::vector< double > bins ( BinMode  mode) const

Definition at line 173 of file Hist1D.cpp.

◆ chi2test()

double chi2test ( const Hist1D oth,
size_t &  ndf 
) const
Parameters
[out]ndfnumber of degrees of freedom (non-empty bins)
Returns
chi^2-value of the equivalence test

Definition at line 244 of file Hist1D.cpp.

◆ clear()

void clear ( )
overridevirtual

Implements Histogram.

Definition at line 91 of file Hist1D.cpp.

◆ extractBins()

std::set< double > extractBins ( BinMode  mode,
size_t  num_bins,
const std::function< Limits(size_t)> &  bins_extractor 
) const
protectedinherited
Parameters
[in]modetype of extraction (low/high/low-high)
[in]num_binstotal number of bins
[in]bins_extractormethod used to extract range of one single bin

Definition at line 26 of file Histogram.cpp.

◆ fill()

void fill ( double  x,
double  weight = 1. 
)

Definition at line 98 of file Hist1D.cpp.

◆ integral()

double integral ( bool  include_out_of_range = false) const
overridevirtual

Implements Histogram.

Definition at line 227 of file Hist1D.cpp.

◆ isGraph1D()

virtual bool isGraph1D ( ) const
virtualinherited

Reimplemented in Graph1D.

Definition at line 107 of file Drawable.h.

◆ isGraph2D()

virtual bool isGraph2D ( ) const
virtualinherited

Reimplemented in Graph2D.

Definition at line 108 of file Drawable.h.

◆ isHist1D()

bool isHist1D ( ) const
finaloverridevirtual

Reimplemented from Drawable.

Definition at line 126 of file Histogram.h.

◆ isHist2D()

virtual bool isHist2D ( ) const
virtualinherited

Reimplemented in Hist2D.

Definition at line 106 of file Drawable.h.

◆ maximum()

double maximum ( ) const
overridevirtual

Implements Histogram.

Definition at line 222 of file Hist1D.cpp.

◆ mean()

double mean ( ) const

Definition at line 207 of file Hist1D.cpp.

◆ minimum()

double minimum ( ) const
overridevirtual

Implements Histogram.

Definition at line 217 of file Hist1D.cpp.

◆ name()

const std::string & name ( ) const
inherited

Definition at line 37 of file Drawable.h.

◆ nbins()

size_t nbins ( ) const

Definition at line 155 of file Hist1D.cpp.

◆ normalise()

void normalise ( double  integ = 1.)
inherited

Definition at line 24 of file Histogram.cpp.

◆ overflow()

size_t overflow ( ) const

Definition at line 124 of file Histogram.h.

◆ range()

Limits range ( ) const

Definition at line 160 of file Hist1D.cpp.

◆ rms()

double rms ( ) const

Definition at line 212 of file Hist1D.cpp.

◆ sample()

double sample ( RandomGenerator rng) const

Definition at line 235 of file Hist1D.cpp.

◆ scale()

void scale ( double  )
overridevirtual

Implements Histogram.

Definition at line 136 of file Hist1D.cpp.

◆ setName()

void setName ( const std::string &  name)
inherited

Definition at line 39 of file Drawable.h.

◆ setTitle()

void setTitle ( const std::string &  title)
inherited

Definition at line 44 of file Drawable.h.

◆ setValue()

void setValue ( size_t  bin,
Value  value 
)

Definition at line 198 of file Hist1D.cpp.

◆ title()

const std::string & title ( ) const
inherited

Definition at line 42 of file Drawable.h.

◆ underflow()

size_t underflow ( ) const

Definition at line 123 of file Histogram.h.

◆ value()

Value value ( size_t  bin) const

Definition at line 192 of file Hist1D.cpp.

◆ values()

std::vector< Value > values ( ) const

Definition at line 185 of file Hist1D.cpp.

◆ xAxis() [1/2]

AxisInfo & xAxis ( )
inherited

Definition at line 79 of file Drawable.h.

◆ xAxis() [2/2]

const AxisInfo & xAxis ( ) const
inherited

Definition at line 80 of file Drawable.h.

◆ yAxis() [1/2]

AxisInfo & yAxis ( )
inherited

Definition at line 81 of file Drawable.h.

◆ yAxis() [2/2]

const AxisInfo & yAxis ( ) const
inherited

Definition at line 82 of file Drawable.h.

◆ zAxis() [1/2]

AxisInfo & zAxis ( )
inherited

Definition at line 83 of file Drawable.h.

◆ zAxis() [2/2]

const AxisInfo & zAxis ( ) const
inherited

Definition at line 84 of file Drawable.h.

Member Data Documentation

◆ name_

std::string name_
protectedinherited

Definition at line 111 of file Drawable.h.

◆ title_

std::string title_
protectedinherited

Definition at line 112 of file Drawable.h.

◆ xaxis_

AxisInfo xaxis_
protectedinherited

Definition at line 113 of file Drawable.h.

◆ yaxis_

AxisInfo yaxis_
protectedinherited

Definition at line 114 of file Drawable.h.

◆ zaxis_

AxisInfo zaxis_
protectedinherited

Definition at line 115 of file Drawable.h.