BornAgain  1.18.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 scattering at grazing incidence
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 #ifndef BORNAGAIN_CORE_INTENSITY_CUMULATIVEVALUE_H
16 #define BORNAGAIN_CORE_INTENSITY_CUMULATIVEVALUE_H
17 
18 //! The cumulative value with average and rms on-the-flight calculations.
19 //! @ingroup tools
20 
22 {
23 public:
25 
26  void clear();
27  void setContent(double value) { m_sum = value; }
28  void add(double value, double weight = 1.0);
29 
30  int getNumberOfEntries() const { return m_n_entries; }
31  double getContent() const { return m_sum; }
32  double getAverage() const { return m_average; }
33  double getRMS() const;
34 
35 private:
37  double m_sum;
38  double m_average;
39  double m_rms2; // sum[ (x-x_aver)^2]/nentries
41 };
42 
43 bool operator<(const CumulativeValue& lhs, const CumulativeValue& rhs);
44 bool operator>(const CumulativeValue& lhs, const CumulativeValue& rhs);
45 
46 #endif // BORNAGAIN_CORE_INTENSITY_CUMULATIVEVALUE_H
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)