CMS 3D CMS Logo

Averages Class Reference

#include <DQM/SiStripCommissioningSources/interface/Averages.h>

List of all members.

Public Member Functions

void add (const uint32_t &value)
void add (const uint32_t &value, const uint32_t &weight)
void add (const float &value)
void add (const float &value, const float &weight)
 Averages ()
void calc (Params &)
 ~Averages ()

Private Attributes

std::vector< float > median_
std::map< uint32_t, uint32_t > mode_
uint32_t n_
float s_
float x_
float xx_

Classes

class  Params


Detailed Description

Definition at line 10 of file Averages.h.


Constructor & Destructor Documentation

Averages::Averages (  ) 

Definition at line 9 of file Averages.cc.

00010   : n_(0),
00011     s_(0.),
00012     x_(0.),
00013     xx_(0.),
00014     median_(),
00015     mode_()
00016 {;}

Averages::~Averages (  )  [inline]

Definition at line 15 of file Averages.h.

00015 {;}


Member Function Documentation

void Averages::add ( const uint32_t &  value  ) 

Definition at line 28 of file Averages.cc.

References mode_.

00028                                       {
00029   mode_[x]++;
00030   add( static_cast<float>(x), -1. );
00031 }

void Averages::add ( const uint32_t &  value,
const uint32_t &  weight 
)

Definition at line 20 of file Averages.cc.

References mode_.

00021                                         {
00022   mode_[x]++;
00023   add( static_cast<float>(x),
00024        static_cast<float>(e) );
00025 }

void Averages::add ( const float &  value  ) 

Definition at line 53 of file Averages.cc.

00053                                    { 
00054   add( x, -1. );
00055 }

void Averages::add ( const float &  value,
const float &  weight 
)

Definition at line 35 of file Averages.cc.

References median_, n_, s_, funct::sqrt(), x_, and xx_.

Referenced by SiStripCommissioningSource::fillCablingHistos().

00036                                      {
00037   n_++;
00038   if ( e > 0. ) { 
00039     float wt = 1. / sqrt(e); 
00040     s_ += wt;
00041     x_ += x*wt;
00042     xx_ += x*x*wt;
00043   } else {
00044     s_++;
00045     x_ += x;
00046     xx_ += x*x;
00047   }
00048   median_.push_back(x);
00049 }

void Averages::calc ( Params params  ) 

Definition at line 59 of file Averages.cc.

References index, m, max, Averages::Params::max_, Averages::Params::mean_, median_, Averages::Params::median_, Averages::Params::min_, mode_, Averages::Params::mode_, n_, Averages::Params::num_, Averages::Params::rms_, s_, python::multivaluedict::sort(), funct::sqrt(), t, Averages::Params::weight_, x_, and xx_.

Referenced by SiStripCommissioningSource::fillCablingHistos().

00059                                     {
00060   params.num_ = n_;
00061   if ( s_ > 0. ) { 
00062     float m = x_/s_;
00063     float t = xx_/s_ - m*m;
00064     if ( t > 0. ) { t = sqrt(t); } 
00065     else { t = 0.; }
00066     params.mean_ = m;
00067     params.rms_ = t;
00068     params.weight_ = s_;
00069   }
00070   if ( !median_.empty() ) {
00071     sort( median_.begin(), median_.end() );
00072     uint16_t index = median_.size()%2 ? median_.size()/2 : median_.size()/2-1;
00073     params.median_ = median_[index];
00074     params.max_ = median_.back();
00075     params.min_ = median_.front();
00076   }
00077   if ( !mode_.empty() ) {
00078     uint32_t max = 0;
00079     std::map<uint32_t,uint32_t>::const_iterator imap = mode_.begin();
00080     for ( ; imap != mode_.end(); imap++ ) {
00081       if ( imap->second > max ) { 
00082         max = imap->second;
00083         params.mode_ = imap->first;
00084       }
00085     }    
00086   }
00087   
00088 }


Member Data Documentation

std::vector<float> Averages::median_ [private]

Definition at line 55 of file Averages.h.

Referenced by add(), and calc().

std::map<uint32_t,uint32_t> Averages::mode_ [private]

Definition at line 56 of file Averages.h.

Referenced by add(), and calc().

uint32_t Averages::n_ [private]

Definition at line 51 of file Averages.h.

Referenced by add(), and calc().

float Averages::s_ [private]

Definition at line 52 of file Averages.h.

Referenced by add(), and calc().

float Averages::x_ [private]

Definition at line 53 of file Averages.h.

Referenced by add(), and calc().

float Averages::xx_ [private]

Definition at line 54 of file Averages.h.

Referenced by add(), and calc().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:14:50 2009 for CMSSW by  doxygen 1.5.4