BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
FixedBinAxis.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Base/Axis/FixedBinAxis.h
6 //! @brief Defines class FixedBinAxis.
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_BASE_AXIS_FIXEDBINAXIS_H
16 #define BORNAGAIN_BASE_AXIS_FIXEDBINAXIS_H
17 
18 #include "Base/Axis/IAxis.h"
19 
20 //! Axis with fixed bin size.
21 //! @ingroup tools
22 
23 class FixedBinAxis : public IAxis {
24 public:
25  //! FixedBinAxis constructor.
26  //! @param name Axis name
27  //! @param nbins number of bins
28  //! @param start low edge of first bin
29  //! @param end upper edge of last bin
30  FixedBinAxis(const std::string& name, size_t nbins, double start, double end);
31  virtual ~FixedBinAxis() {}
32 
33  FixedBinAxis* clone() const;
34 
35  size_t size() const { return m_nbins; }
36 
37  double operator[](size_t index) const;
38 
39  Bin1D bin(size_t index) const;
40 
41  double lowerBound() const { return m_start; }
42  double upperBound() const { return m_end; }
43 
44  double binCenter(size_t index) const { return (*this)[index]; }
45 
46  size_t findClosestIndex(double value) const;
47 
48  std::vector<double> binCenters() const;
49 
50  std::vector<double> binBoundaries() const;
51 
52  FixedBinAxis* createClippedAxis(double left, double right) const;
53 
54 protected:
55  void print(std::ostream& ostr) const;
56  virtual bool equals(const IAxis& other) const;
57 
58 private:
59  size_t m_nbins;
60  double m_start;
61  double m_end;
62 };
63 
64 #endif // BORNAGAIN_BASE_AXIS_FIXEDBINAXIS_H
Defines interface IAxis.
Axis with fixed bin size.
Definition: FixedBinAxis.h:23
double binCenter(size_t index) const
Definition: FixedBinAxis.h:44
double m_start
Definition: FixedBinAxis.h:60
FixedBinAxis * createClippedAxis(double left, double right) const
Creates a new clipped axis.
virtual bool equals(const IAxis &other) const
double operator[](size_t index) const
indexed accessor retrieves a sample
size_t findClosestIndex(double value) const
find bin index which is best match for given value
void print(std::ostream &ostr) const
std::vector< double > binBoundaries() const
Bin1D bin(size_t index) const
retrieve a 1d bin for the given index
FixedBinAxis * clone() const
clone function
double lowerBound() const
Returns value of first point of axis.
Definition: FixedBinAxis.h:41
double m_end
Definition: FixedBinAxis.h:61
double upperBound() const
Returns value of last point of axis.
Definition: FixedBinAxis.h:42
std::vector< double > binCenters() const
size_t m_nbins
Definition: FixedBinAxis.h:59
FixedBinAxis(const std::string &name, size_t nbins, double start, double end)
FixedBinAxis constructor.
size_t size() const
retrieve the number of bins
Definition: FixedBinAxis.h:35
virtual ~FixedBinAxis()
Definition: FixedBinAxis.h:31
Interface for one-dimensional axes.
Definition: IAxis.h:25
QString const & name(EShape k)
Definition: particles.cpp:21
Definition: Bin.h:20