75 {
return {
"dn_dV",
"dn_dlogV",
"dn_dlnV",
"N_V",
"n_V"}; }
84 {
return castFromValue<HistogramType>(histogramTypeIndex); }
101 inline std::vector<HistogramType>
HistogramTypeCast (
const std::vector<int> histogramTypeIndeces)
102 {
return castFromValues<HistogramType>(histogramTypeIndeces); }
110 inline std::vector<HistogramType>
HistogramTypeCast (
const std::vector<std::string> histogramTypeNames)
159 { (void)var;
return ErrorCBL(
"",
"digitize",
"Histogram.h"); }
168 virtual std::vector<int>
digitize (
const std::vector<double> var)
169 { (void)var;
ErrorCBL(
"",
"digitize",
"Histogram.h"); std::vector<int> vv;
return vv; }
178 virtual void put (
const double var,
const double weight)
179 { (void)var; (void)weight;
ErrorCBL(
"",
"put",
"Histogram.h"); }
188 virtual void put (
const std::vector<double> var,
const std::vector<double> weight)
189 { (void)var; (void)weight;
ErrorCBL(
"",
"put",
"Histogram.h"); }
200 virtual void put (
const int bin,
const double weight,
const double var)
201 { (void)
bin; (void)weight; (void)var;
ErrorCBL(
"",
"put",
"Histogram.h"); }
212 virtual void put (
const std::vector<int>
bins,
const std::vector<double> weight,
const std::vector<double> var)
213 { (void)
bins; (void)weight; (void)var;
ErrorCBL(
"",
"put",
"Histogram.h"); }
233 virtual 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={})
244 virtual std::vector<int>
digitize (
const double var1,
const double var2)
245 { (void)var1; (void)var2;
ErrorCBL(
"",
"digitize",
"Histogram.h"); std::vector<int> vv;
return vv; }
255 virtual std::vector<std::vector<int>>
digitize (
const std::vector<double> var1,
const std::vector<double> var2)
256 { (void)var1; (void)var2;
ErrorCBL(
"",
"digitize",
"Histogram.h"); std::vector<std::vector<int>> vv;
return vv; }
267 virtual void put (
const double var1,
const double var2,
const double weight)
268 { (void)var1; (void)var2; (void)weight;
ErrorCBL(
"",
"put",
"Histogram.h"); }
279 virtual void put (
const std::vector<double> var1,
const std::vector<double> var2,
const std::vector<double> weight)
280 { (void)var1; (void)var2; (void)weight;
ErrorCBL(
"",
"put",
"Histogram.h"); }
295 virtual void put (
const int bin1,
const int bin2,
const double weight,
const double var1,
const double var2)
296 { (void)
bin1; (void)
bin2; (void)weight; (void)var1; (void)var2;
ErrorCBL(
"",
"put",
"Histogram.h"); }
309 virtual void put (
const std::vector<std::vector<int>>
bins,
const std::vector<double> weight,
const std::vector<double> var1,
const std::vector<double> var2)
310 { (void)
bins; (void)weight; (void)var1; (void)var2;
ErrorCBL(
"",
"put",
"Histogram.h"); }
326 {
ErrorCBL(
"",
"nbins",
"Histogram.h");
return 1; }
334 {
ErrorCBL(
"",
"binSize",
"Histogram.h");
return 0.; }
343 {
ErrorCBL(
"",
"minVar",
"Histogram.h");
return 0.; }
352 {
ErrorCBL(
"",
"maxVar",
"Histogram.h");
return 0.; }
360 {
ErrorCBL(
"",
"shift",
"Histogram.h");
return 0.; }
377 virtual double bin (
const size_t i)
const
378 {(void)i;
ErrorCBL(
"",
"bin",
"Histogram.h");
return 0.; }
385 virtual std::vector<double>
bins ()
const
386 {
ErrorCBL(
"",
"bins",
"Histogram.h"); std::vector<double> vv;
return vv; }
394 {
ErrorCBL(
"",
"averaged_bins",
"Histogram.h"); std::vector<double> vv;
return vv; }
402 {
ErrorCBL(
"",
"error_bins",
"Histogram.h"); std::vector<double> vv;
return vv; }
411 virtual double edge (
const size_t i)
const
412 { (void)i;
ErrorCBL(
"",
"edge",
"Histogram.h");
return 0.; }
419 virtual std::vector<double>
edges ()
const
420 {
ErrorCBL(
"",
"edges",
"Histogram.h"); std::vector<double> vv;
return vv; }
429 {
ErrorCBL(
"",
"nbins1",
"Histogram.h");
return 1; }
437 {
ErrorCBL(
"",
"binSize1",
"Histogram.h");
return 1.; }
447 {
ErrorCBL(
"",
"minVar1",
"Histogram.h");
return 1.; }
457 {
ErrorCBL(
"",
"maxVar1",
"Histogram.h");
return 1.; }
466 {
ErrorCBL(
"",
"shift1",
"Histogram.h");
return 1.; }
484 {
ErrorCBL(
"",
"bins2",
"Histogram.h");
return 1; }
492 {
ErrorCBL(
"",
"binSize2",
"Histogram.h");
return 1.; }
502 {
ErrorCBL(
"",
"minVar2",
"Histogram.h");
return 1.; }
512 {
ErrorCBL(
"",
"maxVar2",
"Histogram.h");
return 1.; }
521 {
ErrorCBL(
"",
"shift2",
"Histogram.h");
return 1.; }
539 virtual double bin1 (
const size_t i)
const
540 { (void)i;
ErrorCBL(
"",
"bin1",
"Histogram.h");
return 0.; }
547 virtual std::vector<double>
bins1 ()
const
548 {
ErrorCBL(
"",
"bins1",
"Histogram.h"); std::vector<double> vv;
return vv; }
556 {
ErrorCBL(
"",
"averaged_bins1",
"Histogram.h"); std::vector<std::vector<double>> vv;
return vv; }
564 {
ErrorCBL(
"",
"error_bins1",
"Histogram.h"); std::vector<std::vector<double>> vv;
return vv; }
573 virtual double edge1 (
const size_t i)
const
574 { (void)i;
ErrorCBL(
"",
"edge1",
"Histogram.h");
return 0.; }
581 virtual std::vector<double>
edges1 ()
const
582 {
ErrorCBL(
"",
"edges1",
"Histogram.h"); std::vector<double> vv;
return vv; }
591 virtual double bin2 (
const size_t i)
const
592 { (void)i;
ErrorCBL(
"",
"bin2",
"Histogram.h");
return 0.; }
599 virtual std::vector<double>
bins2 ()
const
600 {
ErrorCBL(
"",
"bins2",
"Histogram.h"); std::vector<double> vv;
return vv; }
608 {
ErrorCBL(
"",
"averaged_bins2",
"Histogram.h"); std::vector<std::vector<double>> vv;
return vv; }
616 {
ErrorCBL(
"",
"error_bins2",
"Histogram.h"); std::vector<std::vector<double>> vv;
return vv; }
625 virtual double edge2 (
const size_t i)
const
626 { (void)i;
ErrorCBL(
"",
"edge2",
"Histogram.h");
return 0.; }
633 virtual std::vector<double>
edges2 ()
const
634 {
ErrorCBL(
"",
"edges2",
"Histogram.h"); std::vector<double> vv;
return vv; }
649 { (void)i; (void)hist_type; (void)fact;
ErrorCBL(
"",
"operator ()",
"Histogram.h");
return 0.; }
666 { (void)i; (void)j; (void)hist_type; (void)fact;
ErrorCBL(
"",
"operator()",
"Histogram.h");
return 0.; }
680 { (void)hist_type; (void)fact;
ErrorCBL(
"",
"operator ()",
"Histogram.h"); std::vector<double> vv;
return vv; }
695 { (void)i; (void)hist_type; (void)fact;
ErrorCBL(
"",
"normalization",
"Histogram.h");
return 0.; }
712 { (void)i; (void)j; (void)hist_type; (void)fact;
ErrorCBL(
"",
"normalization",
"Histogram.h");
return 0.; }
722 { (void)i;
ErrorCBL(
"",
"counts",
"Histogram.h");
return 0; }
730 {
ErrorCBL(
"",
"weights",
"Histogram.h"); std::vector<int> vv;
return vv; }
742 { (void)i; (void)j;
ErrorCBL(
"",
"weight",
"Histogram.h");
return 0.; }
758 { (void)i; (void)hist_type; (void)fact;
ErrorCBL(
"",
"error",
"Histogram.h");
return 0.; }
775 virtual double error (
const int i,
const int j,
const HistogramType hist_type,
const double fact=1.)
const
776 { (void)i; (void)j; (void)hist_type; (void)fact;
ErrorCBL(
"",
"error",
"Histogram.h");
return 0.; }
791 { (void)hist_type; (void)fact;
ErrorCBL(
"",
"error",
"Histogram.h"); std::vector<double> vv;
return vv; }
812 virtual void write (
const std::string dir,
const std::string file,
const HistogramType hist_type,
const double fact=1.)
const
813 { (void)dir; (void)file; (void)hist_type; (void)fact;
ErrorCBL(
"",
"write",
"Histogram.h"); }
826 class Histogram1D :
public Histogram
832 std::shared_ptr<gsl_histogram> m_histo;
835 std::shared_ptr<gsl_histogram> m_histo_error;
838 std::vector<int> m_counts;
841 std::vector<double> m_var;
844 std::vector<double> m_var_err;
847 std::vector<double> m_bins;
850 std::vector<double> m_edges;
880 Histogram1D () =
default;
905 ~Histogram1D () =
default;
935 int digitize (
const double var)
override;
944 std::vector<int> digitize (
const std::vector<double> var)
override;
955 void put (
const double var,
const double weight)
override;
966 void put (
const std::vector<double> var,
const std::vector<double> weight)
override;
979 void put (
const int bin,
const double weight,
const double var)
override;
992 void put (
const std::vector<int> bin,
const std::vector<double> weight,
const std::vector<double> var)
override;
1007 size_t nbins ()
const override {
return m_nbins; }
1014 double binSize ()
const override {
return m_binSize; }
1022 double minVar()
const override {
return m_minVar; }
1030 double maxVar()
const override {
return m_maxVar; }
1037 double shift()
const override {
return m_shift; }
1044 BinType bin_type()
const override {
return m_binType; }
1053 double bin (
const size_t i)
const override {
return m_bins[i]; }
1060 std::vector<double> bins ()
const override {
return m_bins; }
1067 std::vector<double> averaged_bins ()
const {
return m_var;}
1074 std::vector<double> error_bins ()
const;
1083 double edge (
const size_t i)
const override {
return m_edges[i]; }
1090 std::vector<double> edges ()
const override {
return m_edges; }
1134 double operator() (
const int i,
const HistogramType hist_type,
const double fact=1.)
const override;
1146 std::vector<double> operator() (
const HistogramType hist_type,
const double fact=1.)
const override;
1160 double error (
const int i,
const HistogramType hist_type,
const double fact=1.)
const override;
1173 std::vector<double>
error (
const HistogramType hist_type,
const double fact=1.)
const override;
1196 void write (
const std::string dir,
const std::string file,
const HistogramType hist_type,
const double fact=1.)
const override;
1323 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_);
1366 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;
1376 std::vector<int>
digitize (
const double var1,
const double var2)
override;
1386 std::vector<std::vector<int>>
digitize (
const std::vector<double> var1,
const std::vector<double> var2)
override;
1399 void put (
const double var1,
const double var2,
const double weight)
override;
1412 void put (
const std::vector<double> var1,
const std::vector<double> var2,
const std::vector<double> weight)
override;
1429 void put (
const int bin1,
const int bin2,
const double weight,
const double var1,
const double var2)
override;
1445 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;
1589 std::vector<std::vector<double>>
error_bins1 ()
const;
1596 std::vector<std::vector<double>>
error_bins2 ()
const;
1687 double operator() (
const int i,
const int j,
const HistogramType hist_type,
const double fact=1.)
const override;
1704 double error (
const int i,
const int j,
const HistogramType hist_type,
const double fact=1.)
const override;
1727 void write (
const std::string dir,
const std::string file,
const HistogramType hist_type,
const double fact=1.)
const override;
Useful generic functions.
double bin1(const size_t i) const override
return the i-th bin of the first variable
double m_minVar1
minimum first variable value
double normalization(const int i, const int j, const HistogramType hist_type, const double fact=1.) const override
return the bin normalization
std::vector< std::vector< double > > m_var1
bin-weighted first variable
BinType m_binType1
first variable bin type
double shift2() const override
return the bin shift for the second variable
std::vector< std::vector< double > > averaged_bins2() const
return the averaged bins
std::vector< double > m_edges1
first variable edges
std::vector< std::vector< int > > m_counts
histogram weights
Histogram2D()=default
default constructor
double m_binSize1
the binSize for the first variable
BinType m_binType2
second variable bin type
std::shared_ptr< gsl_histogram2d > m_histo_error
GSL histogram error.
std::vector< std::vector< double > > m_var1_err
bin-weighted first variable error
double shift1() const override
return the bin shift for the first variable
double m_shift2
the bin shift for the second variable
double maxVar2() const override
return the upper limit of the histogram for the second variable
std::vector< std::vector< double > > m_var2
bin-weighted second variable
double minVar2() const override
return the lower limit of the histogram for the second variable
~Histogram2D()=default
default destructor
std::shared_ptr< gsl_histogram2d > m_histo
GSL histogram.
std::vector< std::vector< double > > m_var2_err
bin-weighted second variable error
double m_binSize2
the binSize for the second variable
std::vector< double > edges2() const override
return the histogram edges of the second variable
size_t m_nbins2
the number of bins
size_t nbins2() const override
return the number of bins for the second variable
std::vector< std::vector< double > > error_bins1() const
return the averaged bins
std::vector< int > digitize(const double var1, const double var2) override
get the histogram index
std::vector< double > m_edges2
variable edges
std::vector< double > edges1() const override
return the histogram edges of the first variable
double m_maxVar2
maximum second variable value
std::vector< double > bins1() const override
return the first variable bins
std::vector< std::vector< double > > error_bins2() const
return the averaged bins
void write(const std::string dir, const std::string file, const HistogramType hist_type, const double fact=1.) const override
write the histogram
std::vector< double > m_bins1
first variable bins
double m_minVar2
minimum second variable value
double binSize2() const override
return the bin size for the second variable
int unweighted_counts(const int i, const int j) const override
return the bin unweighted counts
double edge2(const size_t i) const override
return the i-th edge of the second variable
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
double m_maxVar1
maximum first variable value
std::vector< std::vector< double > > averaged_bins1() const
return the averaged bins
void put(const double var1, const double var2, const double weight) override
bin the data
double bin2(const size_t i) const override
return the i-th bin of the second variable
double minVar1() const override
return the lower limit of the histogram for the first variable
BinType bin_type1() const override
return the bin type for the first variable
double maxVar1() const override
return the upper limit of the histogram for the first variable
size_t m_nbins1
the number of bins for the first variable
BinType bin_type2() const override
return the bin type for the second variable
std::vector< double > bins2() const override
return the second variable bins
double m_shift1
the bin shift for the first variable
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)
std::vector< double > m_bins2
variable bins
size_t nbins1() const override
return the number of bins for the first variable
double edge1(const size_t i) const override
return the i-th edge of the first variable
double operator()(const int i, const int j, const HistogramType hist_type, const double fact=1.) const override
return the histogram at (i,j)
double binSize1() const override
return the bin size for the first variable
virtual double normalization(const int i, const int j, const HistogramType hist_type, const double fact=1.) const
return the bin normalization
virtual void put(const std::vector< double > var, const std::vector< double > weight)
bin the data
virtual std::vector< std::vector< double > > averaged_bins2() const
return the second variable averaged bins
virtual void put(const std::vector< double > var1, const std::vector< double > var2, const std::vector< double > weight)
bin the data
virtual BinType bin_type2() const
return the bin type for the second variable
virtual double edge(const size_t i) const
return the i-th edge
virtual int unweighted_counts(const int i, const int j) const
return the unweighted bin counts
virtual double shift2() const
return the bin shift for the second variable
virtual size_t nbins2() const
return the number of bins for the second variable
virtual void put(const std::vector< std::vector< int >> bins, const std::vector< double > weight, const std::vector< double > var1, const std::vector< double > var2)
bin the data
virtual double minVar() const
return the lower limit of the histogram
virtual double maxVar() const
return the upper limit of the histogram
virtual int digitize(const double var)
get the histogram index
virtual size_t nbins1() const
return the number of bins for the first variable
virtual std::vector< double > averaged_bins() const
return the averaged bins
virtual double maxVar2() const
return the upper limit of the histogram for the second variable
virtual void write(const std::string dir, const std::string file, const HistogramType hist_type, const double fact=1.) const
write the histogram
~Histogram()=default
default destructor
virtual double bin1(const size_t i) const
return the i-th bin of the first variable
virtual double operator()(const int i, const HistogramType hist_type, const double fact=1.) const
return the histogram
virtual double binSize2() const
return the second variable bin size
virtual double error(const int i, const int j, const HistogramType hist_type, const double fact=1.) const
return the error of the histogram at (i,j)
virtual std::vector< double > bins2() const
return the second variable bins
virtual std::vector< int > unweighted_counts() const
return the weights
virtual double shift() const
return the bin shift
virtual double normalization(const int i, const HistogramType hist_type, const double fact=1.) const
return the bin normalization
virtual std::vector< double > error(const HistogramType hist_type, const double fact=1.) const
return the error of the histogram
virtual double minVar1() const
return the lower limit of the histogram for the first variable
virtual std::vector< std::vector< int > > digitize(const std::vector< double > var1, const std::vector< double > var2)
get the histogram indeces
virtual void put(const int bin, const double weight, const double var)
bin the data
virtual double binSize1() const
return the first variable bin size
virtual void put(const double var1, const double var2, const double weight)
bin the data
virtual std::vector< double > bins1() const
return the first variable bins
virtual std::vector< double > error_bins() const
return the bin errors
virtual int unweighted_counts(const int i) const
return the unweighted bin counts
virtual std::vector< double > edges() const
return the histogram edges
virtual std::vector< std::vector< double > > averaged_bins1() const
return the first variable averaged bins
virtual void put(const double var, const double weight)
bin the data
virtual std::vector< int > digitize(const double var1, const double var2)
get the histogram index
virtual double edge1(const size_t i) const
return the i-th edge of the first variable
Histogram()=default
default constructor
virtual double bin(const size_t i) const
return the i-th bin
virtual std::vector< double > bins() const
return the bins
virtual double binSize() const
return the bin size
virtual void put(const int bin1, const int bin2, const double weight, const double var1, const double var2)
bin the data
virtual double error(const int i, const HistogramType hist_type, const double fact=1.) const
return the poisson error of the histogram
virtual std::vector< std::vector< double > > error_bins1() const
return the first variable averaged bin errors
virtual double minVar2() const
return the lower limit of the histogram for the second variable
virtual std::vector< int > digitize(const std::vector< double > var)
get the histogram indeces
virtual std::vector< double > edges2() const
return the histogram edges of the second variable
virtual BinType bin_type() const
return the bin type
virtual double bin2(const size_t i) const
return the i-th bin of the second variable
virtual void put(const std::vector< int > bins, const std::vector< double > weight, const std::vector< double > var)
bin the data
virtual double shift1() const
return the bin shift for the first variable
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
virtual std::vector< std::vector< double > > error_bins2() const
return the second variable averaged bin errors
virtual double maxVar1() const
return the upper limit of the histogram for the first variable
virtual 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={})
set the histogram variables
virtual std::vector< double > edges1() const
return the histogram edges of the first variable
virtual double edge2(const size_t i) const
return the i-th edge of the second variable
virtual size_t nbins() const
return the number of bins
virtual BinType bin_type1() const
return the bin type for the first variable
static const double defaultDouble
default double value
HistogramType HistogramTypeCast(const int histogramTypeIndex)
cast an enum of type HistogramType from its index
HistogramType
the histogram type
@ _n_V_
the normalised binned counts, i.e. , where the factor is a number provided in input
@ _N_V_
the binned counts,
@ _dn_dV_
, where are the bin limits
@ _dn_dlogV_
, where are the bin limits
@ _dn_dlnV_
, where are the bin limits
std::vector< std::string > HistogramTypeNames()
return a vector containing the HistogramType names
The global namespace of the CosmoBolognaLib
int ErrorCBL(const std::string msg, const std::string functionCBL, const std::string fileCBL, const cbl::glob::ExitCode exitCode=cbl::glob::ExitCode::_error_)
throw an exception: it is used for handling exceptions inside the CosmoBolognaLib