BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
CumulativeValue.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Device/Data/CumulativeValue.h
6 //! @brief Defines class CumulativeValue.
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 #ifdef SWIG
16 #error no need to expose this header to Swig
17 #endif
18 
19 #ifndef USER_API
20 #ifndef BORNAGAIN_DEVICE_DATA_CUMULATIVEVALUE_H
21 #define BORNAGAIN_DEVICE_DATA_CUMULATIVEVALUE_H
22 
23 //! The cumulative value with average and rms on-the-flight calculations.
24 //! @ingroup tools
25 
27 public:
29 
30  void clear();
31  void setContent(double value) { m_sum = value; }
32  void add(double value, double weight = 1.0);
33 
34  int getNumberOfEntries() const { return m_n_entries; }
35  double getContent() const { return m_sum; }
36  double getAverage() const { return m_average; }
37  double getRMS() const;
38 
39 private:
41  double m_sum;
42  double m_average;
43  double m_rms2; // sum[ (x-x_aver)^2]/nentries
45 };
46 
47 bool operator<(const CumulativeValue& lhs, const CumulativeValue& rhs);
48 bool operator>(const CumulativeValue& lhs, const CumulativeValue& rhs);
49 
50 #endif // BORNAGAIN_DEVICE_DATA_CUMULATIVEVALUE_H
51 #endif // USER_API
bool operator<(const CumulativeValue &lhs, const CumulativeValue &rhs)
bool operator>(const CumulativeValue &lhs, const CumulativeValue &rhs)
The cumulative value with average and rms on-the-flight calculations.
void setContent(double value)
double getContent() const
double getRMS() const
int getNumberOfEntries() const
double getAverage() const
void add(double value, double weight=1.0)