CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TSinglePedEntry.cc
Go to the documentation of this file.
1 
3 #include <iostream>
4 #include <cmath>
5 
7  m_pedestalSqSum (0),
8  m_pedestalSum (0),
9  m_entries (0)
10 {
11 // std::cout << "[TSinglePedEntry][ctor]" << std::endl ;
12 }
13 
14 
16 {}
17 
18 
20 {
23  m_entries = orig.m_entries ;
24 }
25 
26 
27 void TSinglePedEntry::insert (const int & pedestal)
28 {
29  m_pedestalSqSum += pedestal * pedestal ;
31  ++m_entries ;
32 }
33 
34 
35 double TSinglePedEntry::average () const
36 {
37  if (!m_entries) return -1;
38  return static_cast<double>(m_pedestalSum) / m_entries ;
39 }
40 
41 
42 double TSinglePedEntry::RMS () const
43 {
44  if (!m_entries) return -1;
45  return sqrt (RMSSq ()) ;
46 }
47 
48 double TSinglePedEntry::RMSSq () const
49 {
50 /*
51  std::cout << "[TSinglePedEntry][minchia] " << m_pedestalSum
52  << "\t" << m_pedestalSum
53  << "\t" << m_entries << std::endl ; // FIXME
54 */
55  if (!m_entries) return -1;
56  double num = 1./static_cast<double>(m_entries) ;
57  double output = m_pedestalSqSum * num - m_pedestalSum * num * m_pedestalSum * num ;
58  return output ;
59 }
60 
61 
int m_pedestalSqSum
squared sum of entries
double RMS() const
get the RMS of the inserted values
T sqrt(T t)
Definition: SSEVec.h:48
double average() const
get the average of the inserted values
Transient container for a single entry in pedestal offset studies.
int m_entries
number of entries
double RMSSq() const
get the squared RMS of the inserted values
int m_pedestalSum
sum of entries
void insert(const int &pedestal)
add a single value