BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
Histogram1D.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Device/Histo/Histogram1D.h
6 //! @brief Defines class Histogram1D.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************** //
14 
15 #ifndef BORNAGAIN_CORE_INTENSITY_HISTOGRAM1D_H
16 #define BORNAGAIN_CORE_INTENSITY_HISTOGRAM1D_H
17 
19 
20 //! One dimensional histogram.
21 //! @ingroup tools
22 
23 class Histogram1D : public IHistogram
24 {
25 public:
26  //! Constructor for fix bin size histograms.
27  //! @param nbinsx number of bins
28  //! @param xlow low edge of the first bin
29  //! @param xup upper edge of the last bin
30  Histogram1D(int nbinsx, double xlow, double xup);
31 
32  //! Constructor for variable bin size histograms.
33  //! @param nbinsx number of bins
34  //! @param xbins Array of size nbins+1 containing low-edges for each
35  //! bin and upper edge of last bin.
36  Histogram1D(int nbinsx, const std::vector<double>& xbins);
37 
38  //! Constructor for 1D histogram with custom axis
39  Histogram1D(const IAxis& axis);
40 
41  //! Constructor for 1D histograms from basic OutputData object
42  Histogram1D(const OutputData<double>& data);
43 
44  //! Returns clone of other histogram
45  Histogram1D* clone() const;
46 
47  //! Returns the number of histogram dimensions
48  size_t getRank() const { return 1; }
49 
50  //! Increment bin with abscissa x with a weight.
51  int fill(double x, double weight = 1.0);
52 
53  //! returns vector of histogram bin centers
54  std::vector<double> getBinCenters() const;
55 
56  //! returns vector of bin content (the value accumulated by bins)
57  std::vector<double> getBinValues() const;
58 
59  //! returns vector of bin errors
60  std::vector<double> getBinErrors() const;
61 
62 #ifdef BORNAGAIN_PYTHON
64  PyObject* getBinValuesNumpy() const;
65  PyObject* getBinErrorsNumpy() const;
66 #endif
67 
68  //! Creates new histogram by applying crop on axis.
69  Histogram1D* crop(double xmin, double xmax);
70 };
71 
72 #endif // BORNAGAIN_CORE_INTENSITY_HISTOGRAM1D_H
Defines class IHistogram.
_object PyObject
Definition: PyObject.h:20
One dimensional histogram.
Definition: Histogram1D.h:24
std::vector< double > getBinCenters() const
returns vector of histogram bin centers
Definition: Histogram1D.cpp:52
size_t getRank() const
Returns the number of histogram dimensions.
Definition: Histogram1D.h:48
int fill(double x, double weight=1.0)
Increment bin with abscissa x with a weight.
Definition: Histogram1D.cpp:42
std::vector< double > getBinErrors() const
returns vector of bin errors
Definition: Histogram1D.cpp:62
Histogram1D * crop(double xmin, double xmax)
Creates new histogram by applying crop on axis.
Definition: Histogram1D.cpp:86
PyObject * getBinCentersNumpy() const
Definition: Histogram1D.cpp:69
std::vector< double > getBinValues() const
returns vector of bin content (the value accumulated by bins)
Definition: Histogram1D.cpp:57
Histogram1D(int nbinsx, double xlow, double xup)
Constructor for fix bin size histograms.
Definition: Histogram1D.cpp:20
PyObject * getBinErrorsNumpy() const
Definition: Histogram1D.cpp:79
PyObject * getBinValuesNumpy() const
Definition: Histogram1D.cpp:74
Histogram1D * clone() const
Returns clone of other histogram.
Definition: Histogram1D.cpp:37
Interface for one-dimensional axes.
Definition: IAxis.h:25
Base class for 1D and 2D histograms holding values of double type.
Definition: IHistogram.h:27