CMS 3D CMS Logo

sistrip::MeanAndStdDev Class Reference

#include <DQM/SiStripCommissioningAnalysis/src/Utility.h>

List of all members.

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_

Classes

class  Params


Detailed Description

Definition at line 55 of file Utility.h.


Constructor & Destructor Documentation

sistrip::MeanAndStdDev::MeanAndStdDev (  ) 

Definition at line 77 of file Utility.cc.

00078   : s_(0.),
00079     x_(0.),
00080     xx_(0.),
00081     vec_()
00082 {;}

sistrip::MeanAndStdDev::~MeanAndStdDev (  )  [inline]

Definition at line 61 of file Utility.h.

00061 {;}


Member Function Documentation

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

Definition at line 86 of file Utility.cc.

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

00087                                           {
00088   if ( e > 0. ) { 
00089     float wt = 1. / sqrt(e); 
00090     s_ += wt;
00091     x_ += x*wt;
00092     xx_ += x*x*wt;
00093   } else {
00094     s_++;
00095     x_ += x;
00096     xx_ += x*x;
00097   }
00098   vec_.push_back(x);
00099 }

void sistrip::MeanAndStdDev::fit ( Params fit_params  ) 

Definition at line 103 of file Utility.cc.

References index, m, sistrip::MeanAndStdDev::Params::mean_, sistrip::MeanAndStdDev::Params::median_, sistrip::MeanAndStdDev::Params::rms_, s_, python::multivaluedict::sort(), funct::sqrt(), t, vec_, x_, and xx_.

00103                                                {
00104   if ( s_ > 0. ) { 
00105     float m = x_/s_;
00106     float t = xx_/s_ - m*m;
00107     if ( t > 0. ) { t = sqrt(t); } 
00108     else { t = 0.; }
00109     params.mean_ = m;
00110     params.rms_  = t;
00111   }
00112   if ( !vec_.empty() ) {
00113     sort( vec_.begin(), vec_.end() );
00114     uint16_t index = vec_.size()%2 ? vec_.size()/2 : vec_.size()/2-1;
00115     params.median_ = vec_[index];
00116   }      
00117 }


Member Data Documentation

float sistrip::MeanAndStdDev::s_ [private]

Definition at line 82 of file Utility.h.

Referenced by add(), and fit().

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

Definition at line 85 of file Utility.h.

Referenced by add(), and fit().

float sistrip::MeanAndStdDev::x_ [private]

Definition at line 83 of file Utility.h.

Referenced by add(), and fit().

float sistrip::MeanAndStdDev::xx_ [private]

Definition at line 84 of file Utility.h.

Referenced by add(), and fit().


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