CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Attributes
sistrip::MeanAndStdDev Class Reference

#include <Utility.h>

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.

79  : s_(0.),
80  x_(0.),
81  xx_(0.),
82  vec_()
83 {;}
std::vector< float > vec_
Definition: Utility.h:85
sistrip::MeanAndStdDev::~MeanAndStdDev ( )
inline

Definition at line 61 of file Utility.h.

61 {;}

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.

88  {
89  if ( e > 0. ) {
90  float wt = 1. / sqrt(e);
91  s_ += wt;
92  x_ += x*wt;
93  xx_ += x*x*wt;
94  } else {
95  s_++;
96  x_ += x;
97  xx_ += x*x;
98  }
99  vec_.push_back(x);
100 }
T sqrt(T t)
Definition: SSEVec.h:48
Definition: DDAxes.h:10
std::vector< float > vec_
Definition: Utility.h:85
void sistrip::MeanAndStdDev::fit ( Params fit_params)

Definition at line 104 of file Utility.cc.

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

104  {
105  if ( s_ > 0. ) {
106  float m = x_/s_;
107  float t = xx_/s_ - m*m;
108  if ( t > 0. ) { t = sqrt(t); }
109  else { t = 0.; }
110  params.mean_ = m;
111  params.rms_ = t;
112  }
113  if ( !vec_.empty() ) {
114  sort( vec_.begin(), vec_.end() );
115  uint16_t index = vec_.size()%2 ? vec_.size()/2 : vec_.size()/2-1;
116  params.median_ = vec_[index];
117  }
118 }
T sqrt(T t)
Definition: SSEVec.h:48
std::vector< float > vec_
Definition: Utility.h:85

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.