00001 00002 #include "CalibCalorimetry/EcalPedestalOffsets/interface/TSinglePedEntry.h" 00003 #include <iostream> 00004 #include <cmath> 00005 00006 TSinglePedEntry::TSinglePedEntry () : 00007 m_pedestalSqSum (0), 00008 m_pedestalSum (0), 00009 m_entries (0) 00010 { 00011 // std::cout << "[TSinglePedEntry][ctor]" << std::endl ; 00012 } 00013 00014 00015 TSinglePedEntry::~TSinglePedEntry () 00016 {} 00017 00018 00019 TSinglePedEntry::TSinglePedEntry (const TSinglePedEntry & orig) 00020 { 00021 m_pedestalSqSum = orig.m_pedestalSqSum ; 00022 m_pedestalSum = orig.m_pedestalSum ; 00023 m_entries = orig.m_entries ; 00024 } 00025 00026 00027 void TSinglePedEntry::insert (const int & pedestal) 00028 { 00029 m_pedestalSqSum += pedestal * pedestal ; 00030 m_pedestalSum += pedestal ; 00031 ++m_entries ; 00032 } 00033 00034 00035 double TSinglePedEntry::average () const 00036 { 00037 if (!m_entries) return -1; 00038 return static_cast<double>(m_pedestalSum) / m_entries ; 00039 } 00040 00041 00042 double TSinglePedEntry::RMS () const 00043 { 00044 if (!m_entries) return -1; 00045 return sqrt (RMSSq ()) ; 00046 } 00047 00048 double TSinglePedEntry::RMSSq () const 00049 { 00050 /* 00051 std::cout << "[TSinglePedEntry][minchia] " << m_pedestalSum 00052 << "\t" << m_pedestalSum 00053 << "\t" << m_entries << std::endl ; // FIXME 00054 */ 00055 if (!m_entries) return -1; 00056 double num = 1./static_cast<double>(m_entries) ; 00057 double output = m_pedestalSqSum * num - m_pedestalSum * num * m_pedestalSum * num ; 00058 return output ; 00059 } 00060 00061