CMS 3D CMS Logo

Classes | Public Member Functions | Private Attributes

sistrip::MeanAndStdDev Class Reference

#include <Utility.h>

List of all members.

Classes

class  Params

Public Member Functions

void add (const float &value, const float &error)
void fit (Params &fit_params)
 MeanAndStdDev ()
 ~MeanAndStdDev ()

Private Attributes

float s_
std::vector< float > vec_
float x_
float xx_

Detailed Description

Definition at line 55 of file Utility.h.


Constructor & Destructor Documentation

sistrip::MeanAndStdDev::MeanAndStdDev ( )

Definition at line 78 of file Utility.cc.

  : s_(0.),
    x_(0.),
    xx_(0.),
    vec_()
{;}
sistrip::MeanAndStdDev::~MeanAndStdDev ( ) [inline]

Definition at line 61 of file Utility.h.

{;}

Member Function Documentation

void sistrip::MeanAndStdDev::add ( const float &  value,
const float &  error 
)

Definition at line 87 of file Utility.cc.

References mathSSE::sqrt(), and x.

                                          {
  if ( e > 0. ) { 
    float wt = 1. / sqrt(e); 
    s_ += wt;
    x_ += x*wt;
    xx_ += x*x*wt;
  } else {
    s_++;
    x_ += x;
    xx_ += x*x;
  }
  vec_.push_back(x);
}
void sistrip::MeanAndStdDev::fit ( Params fit_params)

Definition at line 104 of file Utility.cc.

References getHLTprescales::index, m, sistrip::MeanAndStdDev::Params::mean_, sistrip::MeanAndStdDev::Params::median_, sistrip::MeanAndStdDev::Params::rms_, python::multivaluedict::sort(), mathSSE::sqrt(), and lumiQTWidget::t.

                                               {
  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;
  }
  if ( !vec_.empty() ) {
    sort( vec_.begin(), vec_.end() );
    uint16_t index = vec_.size()%2 ? vec_.size()/2 : vec_.size()/2-1;
    params.median_ = vec_[index];
  }      
}

Member Data Documentation

float sistrip::MeanAndStdDev::s_ [private]

Definition at line 82 of file Utility.h.

std::vector<float> sistrip::MeanAndStdDev::vec_ [private]

Definition at line 85 of file Utility.h.

float sistrip::MeanAndStdDev::x_ [private]

Definition at line 83 of file Utility.h.

float sistrip::MeanAndStdDev::xx_ [private]

Definition at line 84 of file Utility.h.