Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:47:02

0001 
0002 #include "CalibCalorimetry/EcalPedestalOffsets/interface/TSinglePedEntry.h"
0003 #include <cmath>
0004 #include <iostream>
0005 
0006 TSinglePedEntry::TSinglePedEntry() : m_pedestalSqSum(0), m_pedestalSum(0), m_entries(0) {
0007   //  std::cout << "[TSinglePedEntry][ctor]" << std::endl ;
0008 }
0009 
0010 TSinglePedEntry::~TSinglePedEntry() {}
0011 
0012 TSinglePedEntry::TSinglePedEntry(const TSinglePedEntry &orig) {
0013   m_pedestalSqSum = orig.m_pedestalSqSum;
0014   m_pedestalSum = orig.m_pedestalSum;
0015   m_entries = orig.m_entries;
0016 }
0017 
0018 void TSinglePedEntry::insert(const int &pedestal) {
0019   m_pedestalSqSum += pedestal * pedestal;
0020   m_pedestalSum += pedestal;
0021   ++m_entries;
0022 }
0023 
0024 double TSinglePedEntry::average() const {
0025   if (!m_entries)
0026     return -1;
0027   return static_cast<double>(m_pedestalSum) / m_entries;
0028 }
0029 
0030 double TSinglePedEntry::RMS() const {
0031   if (!m_entries)
0032     return -1;
0033   return sqrt(RMSSq());
0034 }
0035 
0036 double TSinglePedEntry::RMSSq() const {
0037   /*
0038     std::cout << "[TSinglePedEntry][minchia] " << m_pedestalSum
0039               << "\t" << m_pedestalSum
0040               << "\t" << m_entries << std::endl ;   // FIXME
0041   */
0042   if (!m_entries)
0043     return -1;
0044   double num = 1. / static_cast<double>(m_entries);
0045   double output = m_pedestalSqSum * num - m_pedestalSum * num * m_pedestalSum * num;
0046   return output;
0047 }