BornAgain  1.19.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 reflection and scattering
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_DEVICE_HISTO_HISTOGRAM1D_H
16 #define BORNAGAIN_DEVICE_HISTO_HISTOGRAM1D_H
17 
19 
20 //! One dimensional histogram.
21 //! @ingroup tools
22 
23 class Histogram1D : public IHistogram {
24 public:
25  //! Constructor for fix bin size histograms.
26  //! @param nbinsx number of bins
27  //! @param xlow low edge of the first bin
28  //! @param xup upper edge of the last bin
29  Histogram1D(int nbinsx, double xlow, double xup);
30 
31  //! Constructor for variable bin size histograms.
32  //! @param nbinsx number of bins
33  //! @param xbins Array of size nbins+1 containing low-edges for each
34  //! bin and upper edge of last bin.
35  Histogram1D(int nbinsx, const std::vector<double>& xbins);
36 
37  //! Constructor for 1D histogram with custom axis
38  Histogram1D(const IAxis& axis);
39 
40  //! Constructor for 1D histograms from basic OutputData object
41  Histogram1D(const OutputData<double>& data);
42 
43  //! Returns clone of other histogram
44  Histogram1D* clone() const;
45 
46  //! Returns the number of histogram dimensions
47  size_t rank() const { return 1; }
48 
49  //! Increment bin with abscissa x with a weight.
50  int fill(double x, double weight = 1.0);
51 
52  //! returns vector of histogram bin centers
53  std::vector<double> binCenters() const;
54 
55  //! returns vector of bin content (the value accumulated by bins)
56  std::vector<double> binValues() const;
57 
58  //! returns vector of bin errors
59  std::vector<double> binErrors() const;
60 
61 #ifdef BORNAGAIN_PYTHON
62  PyObject* binCentersNumpy() const;
63  PyObject* binValuesNumpy() const;
64  PyObject* binErrorsNumpy() const;
65 #endif
66 
67  //! Creates new histogram by applying crop on axis.
68  Histogram1D* crop(double xmin, double xmax);
69 };
70 
71 #endif // BORNAGAIN_DEVICE_HISTO_HISTOGRAM1D_H
Defines interface IHistogram.
_object PyObject
Definition: PyObject.h:25
One dimensional histogram.
Definition: Histogram1D.h:23
std::vector< double > binValues() const
returns vector of bin content (the value accumulated by bins)
Definition: Histogram1D.cpp:57
int fill(double x, double weight=1.0)
Increment bin with abscissa x with a weight.
Definition: Histogram1D.cpp:42
std::vector< double > binCenters() const
returns vector of histogram bin centers
Definition: Histogram1D.cpp:52
PyObject * binErrorsNumpy() const
Definition: Histogram1D.cpp:79
PyObject * binValuesNumpy() const
Definition: Histogram1D.cpp:74
std::vector< double > binErrors() 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
size_t rank() const
Returns the number of histogram dimensions.
Definition: Histogram1D.h:47
Histogram1D(int nbinsx, double xlow, double xup)
Constructor for fix bin size histograms.
Definition: Histogram1D.cpp:20
PyObject * binCentersNumpy() const
Definition: Histogram1D.cpp:69
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