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

2D histogram container More...

#include <CepGen/Utils/Histogram.h>

+ Inheritance diagram for Hist2D:
+ Collaboration diagram for Hist2D:

Classes

struct  contents_t
 

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

 Hist2D (const ParametersList &)
 Build a histogram from user-steeed parameters.
 
 Hist2D (size_t num_bins_x, const Limits &xlim, size_t num_bins_y, const Limits &ylim, const std::string &name="", const std::string &title="")
 Build a histogram from uniform-width bins.
 
 Hist2D (const std::vector< double > &xbins, const std::vector< double > &ybins, const std::string &name="", const std::string &title="")
 Build a histogram from variable-width bins.
 
 Hist2D (const Hist2D &)
 Copy constructor.
 
void clear () override
 Reset the histogram.
 
void fill (double x, double y, double weight=1.)
 Fill the histogram with one value.
 
void fill (const std::pair< double, double > &xy, double weight=1.)
 Fill the histogram with one value.
 
void add (Hist2D, double scaling=1.)
 Bin-by-bin addition of another histogram to this one.
 
void scale (double) override
 Rescale all histogram bins by a constant factor.
 
std::pair< double, double > sample (RandomGenerator &) const
 Sample individual "events" from a distribution.
 
Value value (size_t bin_x, size_t bin_y) const
 Retrieve the value + uncertainty for one bin.
 
void setValue (size_t bin_x, size_t bin_y, Value value)
 Set the value + uncertainty for one bin.
 
size_t nbinsX () const
 Number of x-axis bins.
 
Limits rangeX () const
 x-axis range
 
Limits binRangeX (size_t bin) const
 Range for a single x-axis bin.
 
std::vector< double > binsX (BinMode) const
 List of x-bins limits (nbinsX + 1 values if min-max, nbins values otherwise)
 
size_t nbinsY () const
 Number of y-axis bins.
 
Limits rangeY () const
 y-axis range
 
Limits binRangeY (size_t bin) const
 Range for a single y-axis bin.
 
std::vector< double > binsY (BinMode) const
 List of y-bins limits (nbinsY + 1 values if min-max, nbins values otherwise)
 
std::pair< size_t, size_t > bin (double x, double y) const
 Retrieve the bin indices for a (x, y) value.
 
double meanX () const
 Compute the mean histogram value over full x-axis range.
 
double rmsX () const
 Compute the root-mean-square value over full x-axis range.
 
double meanY () const
 Compute the mean histogram value over full y-axis range.
 
double rmsY () const
 Compute the root-mean-square value over full y-axis 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.
 
const contents_toutOfRange () const
 
bool isHist2D () const override final
 Is this drawable a two-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 isHist1D () const
 Is this drawable a one-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 146 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

◆ Hist2D() [1/4]

Hist2D ( const ParametersList params)
explicit

Definition at line 31 of file Hist2D.cpp.

◆ Hist2D() [2/4]

Hist2D ( size_t  num_bins_x,
const Limits xlim,
size_t  num_bins_y,
const Limits ylim,
const std::string &  name = "",
const std::string &  title = "" 
)
explicit

Definition at line 44 of file Hist2D.cpp.

◆ Hist2D() [3/4]

Hist2D ( const std::vector< double > &  xbins,
const std::vector< double > &  ybins,
const std::string &  name = "",
const std::string &  title = "" 
)
explicit

Definition at line 56 of file Hist2D.cpp.

◆ Hist2D() [4/4]

Hist2D ( const Hist2D oth)

Definition at line 66 of file Hist2D.cpp.

Member Function Documentation

◆ add()

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

Definition at line 148 of file Hist2D.cpp.

◆ bin()

std::pair< size_t, size_t > bin ( double  x,
double  y 
) const

Definition at line 219 of file Hist2D.cpp.

◆ binRangeX()

Limits binRangeX ( size_t  bin) const

Definition at line 183 of file Hist2D.cpp.

◆ binRangeY()

Limits binRangeY ( size_t  bin) const

Definition at line 206 of file Hist2D.cpp.

◆ binsX()

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

Definition at line 191 of file Hist2D.cpp.

◆ binsY()

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

Definition at line 214 of file Hist2D.cpp.

◆ clear()

void clear ( )
overridevirtual

Implements Histogram.

Definition at line 106 of file Hist2D.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() [1/2]

void fill ( const std::pair< double, double > &  xy,
double  weight = 1. 
)

Definition at line 168 of file Histogram.h.

◆ fill() [2/2]

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

Definition at line 113 of file Hist2D.cpp.

◆ integral()

double integral ( bool  include_out_of_range = false) const
overridevirtual

Implements Histogram.

Definition at line 273 of file Hist2D.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()

virtual bool isHist1D ( ) const
virtualinherited

Reimplemented in Hist1D.

Definition at line 105 of file Drawable.h.

◆ isHist2D()

bool isHist2D ( ) const
finaloverridevirtual

Reimplemented from Drawable.

Definition at line 231 of file Histogram.h.

◆ maximum()

double maximum ( ) const
overridevirtual

Implements Histogram.

Definition at line 268 of file Hist2D.cpp.

◆ meanX()

double meanX ( ) const

Definition at line 243 of file Hist2D.cpp.

◆ meanY()

double meanY ( ) const

Definition at line 253 of file Hist2D.cpp.

◆ minimum()

double minimum ( ) const
overridevirtual

Implements Histogram.

Definition at line 263 of file Hist2D.cpp.

◆ name()

const std::string & name ( ) const
inherited

Definition at line 37 of file Drawable.h.

◆ nbinsX()

size_t nbinsX ( ) const

Definition at line 173 of file Hist2D.cpp.

◆ nbinsY()

size_t nbinsY ( ) const

Definition at line 196 of file Hist2D.cpp.

◆ normalise()

void normalise ( double  integ = 1.)
inherited

Definition at line 24 of file Histogram.cpp.

◆ outOfRange()

const contents_t & outOfRange ( ) const

Definition at line 229 of file Histogram.h.

◆ rangeX()

Limits rangeX ( ) const

Definition at line 178 of file Hist2D.cpp.

◆ rangeY()

Limits rangeY ( ) const

Definition at line 201 of file Hist2D.cpp.

◆ rmsX()

double rmsX ( ) const

Definition at line 248 of file Hist2D.cpp.

◆ rmsY()

double rmsY ( ) const

Definition at line 258 of file Hist2D.cpp.

◆ sample()

std::pair< double, double > sample ( RandomGenerator rng) const

Definition at line 311 of file Hist2D.cpp.

◆ scale()

void scale ( double  )
overridevirtual

Implements Histogram.

Definition at line 166 of file Hist2D.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_x,
size_t  bin_y,
Value  value 
)

Definition at line 233 of file Hist2D.cpp.

◆ title()

const std::string & title ( ) const
inherited

Definition at line 42 of file Drawable.h.

◆ value()

Value value ( size_t  bin_x,
size_t  bin_y 
) const

Definition at line 227 of file Hist2D.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.