![]() |
CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
|
The class Histogram2D. More...
#include "Headers/Histogram.h"


Public Member Functions | |
Constructors/destructors | |
| Histogram2D ()=default | |
| default constructor | |
| Histogram2D (const std::vector< double > var1, const std::vector< double > var2, const std::vector< double > weight, const size_t nbins1, const size_t nbins2, const double minVar1=par::defaultDouble, const double maxVar1=par::defaultDouble, const double minVar2=par::defaultDouble, const double maxVar2=par::defaultDouble, const double shift1=0.5, const double shift2=0.5, const BinType bin_type1=BinType::_linear_, const BinType bin_type2=BinType::_linear_) | |
| constructor More... | |
| ~Histogram2D ()=default | |
| default destructor | |
Functions to set the private members of the class | |
| void | set (const size_t nbins1, const size_t nbins2, const double minVar1=par::defaultDouble, const double maxVar1=par::defaultDouble, const double minVar2=par::defaultDouble, const double maxVar2=par::defaultDouble, const double shift1=0.5, const double shift2=0.5, const BinType bin_type1=BinType::_linear_, const BinType bin_type2=BinType::_linear_, const std::vector< double > vec_edges1={}, const std::vector< double > vec_edges2={}) override |
| set the histogram variables More... | |
| std::vector< int > | digitize (const double var1, const double var2) override |
| get the histogram index More... | |
| std::vector< std::vector< int > > | digitize (const std::vector< double > var1, const std::vector< double > var2) override |
| get the histogram indeces More... | |
| void | put (const double var1, const double var2, const double weight) override |
| bin the data More... | |
| void | put (const std::vector< double > var1, const std::vector< double > var2, const std::vector< double > weight) override |
| bin the data More... | |
| void | put (const int bin1, const int bin2, const double weight, const double var1, const double var2) override |
| bin the data More... | |
| void | put (const std::vector< std::vector< int >> bins, const std::vector< double > weight, const std::vector< double > var1, const std::vector< double > var2) override |
| bin the data More... | |
Functions to get the private members of the class | |
| size_t | nbins1 () const override |
| return the number of bins for the first variable More... | |
| double | binSize1 () const override |
| return the bin size for the first variable More... | |
| double | minVar1 () const override |
| return the lower limit of the histogram for the first variable More... | |
| double | maxVar1 () const override |
| return the upper limit of the histogram for the first variable More... | |
| double | shift1 () const override |
| return the bin shift for the first variable More... | |
| BinType | bin_type1 () const override |
| return the bin type for the first variable More... | |
| size_t | nbins2 () const override |
| return the number of bins for the second variable More... | |
| double | binSize2 () const override |
| return the bin size for the second variable More... | |
| double | minVar2 () const override |
| return the lower limit of the histogram for the second variable More... | |
| double | maxVar2 () const override |
| return the upper limit of the histogram for the second variable More... | |
| double | shift2 () const override |
| return the bin shift for the second variable More... | |
| BinType | bin_type2 () const override |
| return the bin type for the second variable More... | |
| double | bin1 (const size_t i) const override |
| return the i-th bin of the first variable More... | |
| std::vector< double > | bins1 () const override |
| return the first variable bins More... | |
| std::vector< std::vector< double > > | averaged_bins1 () const |
| return the averaged bins More... | |
| std::vector< std::vector< double > > | averaged_bins2 () const |
| return the averaged bins More... | |
| std::vector< std::vector< double > > | error_bins1 () const |
| return the averaged bins More... | |
| std::vector< std::vector< double > > | error_bins2 () const |
| return the averaged bins More... | |
| double | edge1 (const size_t i) const override |
| return the i-th edge of the first variable More... | |
| std::vector< double > | edges1 () const override |
| return the histogram edges of the first variable More... | |
| double | bin2 (const size_t i) const override |
| return the i-th bin of the second variable More... | |
| std::vector< double > | bins2 () const override |
| return the second variable bins More... | |
| double | edge2 (const size_t i) const override |
| return the i-th edge of the second variable More... | |
| std::vector< double > | edges2 () const override |
| return the histogram edges of the second variable More... | |
| double | normalization (const int i, const int j, const HistogramType hist_type, const double fact=1.) const override |
| return the bin normalization More... | |
| int | unweighted_counts (const int i, const int j) const override |
| return the bin unweighted counts More... | |
| double | operator() (const int i, const int j, const HistogramType hist_type, const double fact=1.) const override |
| return the histogram at (i,j) More... | |
| double | error (const int i, const int j, const HistogramType hist_type, const double fact=1.) const override |
| return the poisson error of the histogram at (i,j) More... | |
input/output member functions (customized in all the derived classes) | |
| void | write (const std::string dir, const std::string file, const HistogramType hist_type, const double fact=1.) const override |
| write the histogram More... | |
Public Member Functions inherited from cbl::glob::Histogram | |
| Histogram ()=default | |
| default constructor | |
| ~Histogram ()=default | |
| default destructor | |
| virtual void | set (const size_t nbins, const double minVar=par::defaultDouble, const double maxVar=par::defaultDouble, const double shift=0.5, const BinType bin_type=BinType::_linear_, const std::vector< double > vec_edges={}) |
| set the histogram variables More... | |
| virtual int | digitize (const double var) |
| get the histogram index More... | |
| virtual std::vector< int > | digitize (const std::vector< double > var) |
| get the histogram indeces More... | |
| virtual void | put (const double var, const double weight) |
| bin the data More... | |
| virtual void | put (const std::vector< double > var, const std::vector< double > weight) |
| bin the data More... | |
| virtual void | put (const int bin, const double weight, const double var) |
| bin the data More... | |
| virtual void | put (const std::vector< int > bins, const std::vector< double > weight, const std::vector< double > var) |
| bin the data More... | |
| virtual size_t | nbins () const |
| return the number of bins More... | |
| virtual double | binSize () const |
| return the bin size More... | |
| virtual double | minVar () const |
| return the lower limit of the histogram More... | |
| virtual double | maxVar () const |
| return the upper limit of the histogram More... | |
| virtual double | shift () const |
| return the bin shift More... | |
| virtual BinType | bin_type () const |
| return the bin type More... | |
| virtual double | bin (const size_t i) const |
| return the i-th bin More... | |
| virtual std::vector< double > | bins () const |
| return the bins More... | |
| virtual std::vector< double > | averaged_bins () const |
| return the averaged bins More... | |
| virtual std::vector< double > | error_bins () const |
| return the bin errors More... | |
| virtual double | edge (const size_t i) const |
| return the i-th edge More... | |
| virtual std::vector< double > | edges () const |
| return the histogram edges More... | |
| virtual double | operator() (const int i, const HistogramType hist_type, const double fact=1.) const |
| return the histogram More... | |
| virtual std::vector< double > | operator() (const HistogramType hist_type, const double fact=1.) const |
| return the histogram More... | |
| virtual double | normalization (const int i, const HistogramType hist_type, const double fact=1.) const |
| return the bin normalization More... | |
| virtual int | unweighted_counts (const int i) const |
| return the unweighted bin counts More... | |
| virtual std::vector< int > | unweighted_counts () const |
| return the weights More... | |
| virtual double | error (const int i, const HistogramType hist_type, const double fact=1.) const |
| return the poisson error of the histogram More... | |
| virtual std::vector< double > | error (const HistogramType hist_type, const double fact=1.) const |
| return the error of the histogram More... | |
Private Attributes | |
| std::shared_ptr< gsl_histogram2d > | m_histo |
| GSL histogram. | |
| std::shared_ptr< gsl_histogram2d > | m_histo_error |
| GSL histogram error. | |
| std::vector< std::vector< int > > | m_counts |
| histogram weights | |
| std::vector< std::vector< double > > | m_var1 |
| bin-weighted first variable | |
| std::vector< std::vector< double > > | m_var1_err |
| bin-weighted first variable error | |
| std::vector< std::vector< double > > | m_var2 |
| bin-weighted second variable | |
| std::vector< std::vector< double > > | m_var2_err |
| bin-weighted second variable error | |
| std::vector< double > | m_bins1 |
| first variable bins | |
| std::vector< double > | m_edges1 |
| first variable edges | |
| size_t | m_nbins1 |
| the number of bins for the first variable | |
| double | m_binSize1 |
| the binSize for the first variable | |
| double | m_shift1 |
| the bin shift for the first variable | |
| double | m_minVar1 |
| minimum first variable value | |
| double | m_maxVar1 |
| maximum first variable value | |
| BinType | m_binType1 |
| first variable bin type | |
| std::vector< double > | m_bins2 |
| variable bins | |
| std::vector< double > | m_edges2 |
| variable edges | |
| size_t | m_nbins2 |
| the number of bins | |
| double | m_binSize2 |
| the binSize for the second variable | |
| double | m_shift2 |
| the bin shift for the second variable | |
| double | m_minVar2 |
| minimum second variable value | |
| double | m_maxVar2 |
| maximum second variable value | |
| BinType | m_binType2 |
| second variable bin type | |
The class Histogram2D.
This class is used to bin 2D variables.
Definition at line 1209 of file Histogram.h.
| cbl::glob::Histogram2D::Histogram2D | ( | const std::vector< double > | var1, |
| const std::vector< double > | var2, | ||
| const std::vector< double > | weight, | ||
| const size_t | nbins1, | ||
| const size_t | nbins2, | ||
| const double | minVar1 = par::defaultDouble, |
||
| const double | maxVar1 = par::defaultDouble, |
||
| const double | minVar2 = par::defaultDouble, |
||
| const double | maxVar2 = par::defaultDouble, |
||
| const double | shift1 = 0.5, |
||
| const double | shift2 = 0.5, |
||
| const BinType | bin_type1 = BinType::_linear_, |
||
| const BinType | bin_type2 = BinType::_linear_ |
||
| ) |
constructor
| var1 | values of the first var |
| var2 | values of the second var |
| weight | weights of the var |
| nbins1 | the number of bins for the first variable |
| nbins2 | the number of bins for the second variable |
| minVar1 | minimum range for the first variable |
| maxVar1 | maximmum range for the first variable |
| minVar2 | minimum range for the second variable |
| maxVar2 | maximmum range for the second variable |
| shift1 | bin shift for the first variable |
| shift2 | bin shift for the second variable |
| bin_type1 | the binning type for the first variable |
| bin_type2 | the binning type for the second variable |
Definition at line 321 of file Histogram.cpp.
|
inlinevirtual |
return the averaged bins
Reimplemented from cbl::glob::Histogram.
Definition at line 1575 of file Histogram.h.
|
inlinevirtual |
return the averaged bins
Reimplemented from cbl::glob::Histogram.
Definition at line 1582 of file Histogram.h.
|
inlineoverridevirtual |
return the i-th bin of the first variable
| i | the i-th index |
Reimplemented from cbl::glob::Histogram.
Definition at line 1561 of file Histogram.h.
|
inlineoverridevirtual |
return the i-th bin of the second variable
| i | the i-th index |
Reimplemented from cbl::glob::Histogram.
Definition at line 1621 of file Histogram.h.
|
inlineoverridevirtual |
return the bin type for the first variable
Reimplemented from cbl::glob::Histogram.
Definition at line 1502 of file Histogram.h.
|
inlineoverridevirtual |
return the bin type for the second variable
Reimplemented from cbl::glob::Histogram.
Definition at line 1552 of file Histogram.h.
|
inlineoverridevirtual |
return the first variable bins
Reimplemented from cbl::glob::Histogram.
Definition at line 1568 of file Histogram.h.
|
inlineoverridevirtual |
return the second variable bins
Reimplemented from cbl::glob::Histogram.
Definition at line 1628 of file Histogram.h.
|
inlineoverridevirtual |
return the bin size for the first variable
Reimplemented from cbl::glob::Histogram.
Definition at line 1468 of file Histogram.h.
|
inlineoverridevirtual |
return the bin size for the second variable
Reimplemented from cbl::glob::Histogram.
Definition at line 1518 of file Histogram.h.
|
overridevirtual |
get the histogram index
| var1 | value of the first var |
| var2 | value of the second var |
Reimplemented from cbl::glob::Histogram.
Definition at line 460 of file Histogram.cpp.
|
overridevirtual |
get the histogram indeces
| var1 | values of the first var |
| var2 | values of the second var |
Reimplemented from cbl::glob::Histogram.
Definition at line 474 of file Histogram.cpp.
|
inlineoverridevirtual |
return the i-th edge of the first variable
| i | the i-th index |
Reimplemented from cbl::glob::Histogram.
Definition at line 1605 of file Histogram.h.
|
inlineoverridevirtual |
return the i-th edge of the second variable
| i | the i-th index |
Reimplemented from cbl::glob::Histogram.
Definition at line 1637 of file Histogram.h.
|
inlineoverridevirtual |
return the histogram edges of the first variable
Reimplemented from cbl::glob::Histogram.
Definition at line 1612 of file Histogram.h.
|
inlineoverridevirtual |
return the histogram edges of the second variable
Reimplemented from cbl::glob::Histogram.
Definition at line 1644 of file Histogram.h.
|
overridevirtual |
return the poisson error of the histogram at (i,j)
| i | the i-th first variable bin |
| j | the j-th second variable bin |
| hist_type | the type of histogram |
| fact | the factor used to normalized the histogram |
Reimplemented from cbl::glob::Histogram.
Definition at line 616 of file Histogram.cpp.
|
virtual |
return the averaged bins
Reimplemented from cbl::glob::Histogram.
Definition at line 590 of file Histogram.cpp.
|
virtual |
return the averaged bins
Reimplemented from cbl::glob::Histogram.
Definition at line 603 of file Histogram.cpp.
|
inlineoverridevirtual |
return the upper limit of the histogram for the first variable
Reimplemented from cbl::glob::Histogram.
Definition at line 1486 of file Histogram.h.
|
inlineoverridevirtual |
return the upper limit of the histogram for the second variable
Reimplemented from cbl::glob::Histogram.
Definition at line 1536 of file Histogram.h.
|
inlineoverridevirtual |
return the lower limit of the histogram for the first variable
Reimplemented from cbl::glob::Histogram.
Definition at line 1477 of file Histogram.h.
|
inlineoverridevirtual |
return the lower limit of the histogram for the second variable
Reimplemented from cbl::glob::Histogram.
Definition at line 1527 of file Histogram.h.
|
inlineoverridevirtual |
return the number of bins for the first variable
Reimplemented from cbl::glob::Histogram.
Definition at line 1460 of file Histogram.h.
|
inlineoverridevirtual |
return the number of bins for the second variable
Reimplemented from cbl::glob::Histogram.
Definition at line 1510 of file Histogram.h.
|
overridevirtual |
return the bin normalization
| i | i-th bin |
| j | j-th bin |
| hist_type | the type of histogram |
| fact | the factor used to normalized the histogram |
Reimplemented from cbl::glob::Histogram.
Definition at line 544 of file Histogram.cpp.
|
overridevirtual |
return the histogram at (i,j)
| i | the i-th first variable bin |
| j | the j-th second variable bin |
| hist_type | the type of histogram |
| fact | the factor used to normalized the histogram |
Reimplemented from cbl::glob::Histogram.
Definition at line 581 of file Histogram.cpp.
|
overridevirtual |
bin the data
| var1 | value of the first var |
| var2 | value of the second var |
| weight | weight of the var |
Reimplemented from cbl::glob::Histogram.
Definition at line 488 of file Histogram.cpp.
|
overridevirtual |
bin the data
| bin1 | value of the first bin |
| bin2 | value of the second bin |
| weight | weight of the var |
| var1 | value of the first var |
| var2 | value of the second var |
Reimplemented from cbl::glob::Histogram.
Definition at line 510 of file Histogram.cpp.
|
overridevirtual |
bin the data
| var1 | values of the first var |
| var2 | values of the second var |
| weight | weights of the var |
Reimplemented from cbl::glob::Histogram.
Definition at line 500 of file Histogram.cpp.
|
overridevirtual |
bin the data
| bins | std::vector containing the values of the bins |
| weight | weights of the var |
| var1 | value of the first var |
| var2 | value of the second var |
Reimplemented from cbl::glob::Histogram.
Definition at line 534 of file Histogram.cpp.
|
overridevirtual |
set the histogram variables
| nbins1 | the number of bins for the first variable |
| nbins2 | the number of bins for the second variable |
| minVar1 | minimum range for the first variable |
| maxVar1 | maximmum range for the first variable |
| minVar2 | minimum range for the second variable |
| maxVar2 | maximmum range for the second variable |
| shift1 | bin shift for the first variable |
| shift2 | bin shift for the second variable |
| bin_type1 | the binning type for the first variable |
| bin_type2 | the binning type for the second variable |
| vec_edges1 | the first variable bin edges, used only if bin_type is custom |
| vec_edges2 | the second variable bin edges, used only if bin_type is custom |
Reimplemented from cbl::glob::Histogram.
Definition at line 337 of file Histogram.cpp.
|
inlineoverridevirtual |
return the bin shift for the first variable
Reimplemented from cbl::glob::Histogram.
Definition at line 1494 of file Histogram.h.
|
inlineoverridevirtual |
return the bin shift for the second variable
Reimplemented from cbl::glob::Histogram.
Definition at line 1544 of file Histogram.h.
|
inlineoverridevirtual |
return the bin unweighted counts
| i | i-th bin |
| j | j-th bin |
Reimplemented from cbl::glob::Histogram.
Definition at line 1671 of file Histogram.h.
|
overridevirtual |
write the histogram
| dir | output directory |
| file | output file |
| hist_type | the type of histogram |
| fact | the factor used to normalized the histogram |
Reimplemented from cbl::glob::Histogram.
Definition at line 625 of file Histogram.cpp.