CMS 3D CMS Logo

Classes | Public Member Functions | Private Attributes

Averages Class Reference

#include <Averages.h>

List of all members.

Classes

class  Params

Public Member Functions

void add (const float &value, const float &weight)
void add (const float &value)
void add (const uint32_t &value, const uint32_t &weight)
void add (const uint32_t &value)
 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_

Detailed Description

Definition at line 10 of file Averages.h.


Constructor & Destructor Documentation

Averages::Averages ( )

Definition at line 10 of file Averages.cc.

  : n_(0),
    s_(0.),
    x_(0.),
    xx_(0.),
    median_(),
    mode_()
{;}
Averages::~Averages ( ) [inline]

Definition at line 15 of file Averages.h.

{;}

Member Function Documentation

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

Definition at line 36 of file Averages.cc.

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

Referenced by add(), and SiStripCommissioningSource::fillCablingHistos().

                                     {
  n_++;
  if ( e > 0. ) { 
    float wt = 1. / sqrt(e); 
    s_ += wt;
    x_ += x*wt;
    xx_ += x*x*wt;
  } else {
    s_++;
    x_ += x;
    xx_ += x*x;
  }
  median_.push_back(x);
}
void Averages::add ( const float &  value)

Definition at line 54 of file Averages.cc.

References add().

                                   { 
  add( x, -1. );
}
void Averages::add ( const uint32_t &  value)

Definition at line 29 of file Averages.cc.

References add(), mode_, and x.

                                      {
  mode_[x]++;
  add( static_cast<float>(x), -1. );
}
void Averages::add ( const uint32_t &  value,
const uint32_t &  weight 
)

Definition at line 21 of file Averages.cc.

References add(), mode_, and x.

                                        {
  mode_[x]++;
  add( static_cast<float>(x),
       static_cast<float>(e) );
}
void Averages::calc ( Params params)

Definition at line 60 of file Averages.cc.

References getHLTprescales::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(), mathSSE::sqrt(), lumiQTWidget::t, Averages::Params::weight_, x_, and xx_.

Referenced by SiStripCommissioningSource::fillCablingHistos().

                                    {
  params.num_ = n_;
  if ( s_ > 0. ) { 
    float m = x_/s_;
    float t = xx_/s_ - m*m;
    if ( t > 0. ) { t = sqrt(t); } 
    else { t = 0.; }
    params.mean_ = m;
    params.rms_ = t;
    params.weight_ = s_;
  }
  if ( !median_.empty() ) {
    sort( median_.begin(), median_.end() );
    uint16_t index = median_.size()%2 ? median_.size()/2 : median_.size()/2-1;
    params.median_ = median_[index];
    params.max_ = median_.back();
    params.min_ = median_.front();
  }
  if ( !mode_.empty() ) {
    uint32_t max = 0;
    std::map<uint32_t,uint32_t>::const_iterator imap = mode_.begin();
    for ( ; imap != mode_.end(); imap++ ) {
      if ( imap->second > max ) { 
        max = imap->second;
        params.mode_ = imap->first;
      }
    }    
  }
  
}

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().