ATLAS Offline Software
MeanRMS.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "cmath"
6 
7 namespace MuonCalib {
8 
9  class MeanRMS {
10  public:
11  inline MeanRMS() : m_sum_x(0.), m_sum_x_sq(0.), m_n_ent(0) {}
12  inline void Insert(double x) {
13  m_sum_x += x;
14  m_sum_x_sq += x * x;
15  m_n_ent++;
16  }
17  inline double GetMean() const {
18  if (m_n_ent == 0) return 0;
19  return m_sum_x / static_cast<double>(m_n_ent);
20  }
21  inline double GetRMS() const {
22  if (m_n_ent == 0) return 0;
23  double mean = GetMean();
24  return std::sqrt(m_sum_x_sq / static_cast<double>(m_n_ent) - mean * mean);
25  }
26  inline int GetN() const { return m_n_ent; }
27 
28  private:
29  double m_sum_x;
30  double m_sum_x_sq;
31  int m_n_ent;
32  };
33 } // namespace MuonCalib
MuonCalib::MeanRMS
Definition: MeanRMS.h:9
mean
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
Definition: dependence.cxx:254
MuonCalib::MeanRMS::Insert
void Insert(double x)
Definition: MeanRMS.h:12
MuonCalib::MeanRMS::GetMean
double GetMean() const
Definition: MeanRMS.h:17
MuonCalib::MeanRMS::GetN
int GetN() const
Definition: MeanRMS.h:26
x
#define x
MuonCalib
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
Definition: CscCalcPed.cxx:22
MuonCalib::MeanRMS::GetRMS
double GetRMS() const
Definition: MeanRMS.h:21
MuonCalib::MeanRMS::m_n_ent
int m_n_ent
Definition: MeanRMS.h:31
MuonCalib::MeanRMS::m_sum_x_sq
double m_sum_x_sq
Definition: MeanRMS.h:30
MuonCalib::MeanRMS::m_sum_x
double m_sum_x
Definition: MeanRMS.h:29
MuonCalib::MeanRMS::MeanRMS
MeanRMS()
Definition: MeanRMS.h:11