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
Averages Class Reference

#include <Averages.h>

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.

11  : n_(0),
12  s_(0.),
13  x_(0.),
14  xx_(0.),
15  median_(),
16  mode_()
17 {;}
std::map< uint32_t, uint32_t > mode_
Definition: Averages.h:56
float x_
Definition: Averages.h:53
uint32_t n_
Definition: Averages.h:51
std::vector< float > median_
Definition: Averages.h:55
float s_
Definition: Averages.h:52
float xx_
Definition: Averages.h:54
Averages::~Averages ( )
inline

Definition at line 15 of file Averages.h.

15 {;}

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

37  {
38  n_++;
39  if ( e > 0. ) {
40  float wt = 1. / sqrt(e);
41  s_ += wt;
42  x_ += x*wt;
43  xx_ += x*x*wt;
44  } else {
45  s_++;
46  x_ += x;
47  xx_ += x*x;
48  }
49  median_.push_back(x);
50 }
float x_
Definition: Averages.h:53
T sqrt(T t)
Definition: SSEVec.h:48
uint32_t n_
Definition: Averages.h:51
std::vector< float > median_
Definition: Averages.h:55
float s_
Definition: Averages.h:52
Definition: DDAxes.h:10
float xx_
Definition: Averages.h:54
void Averages::add ( const float &  value)

Definition at line 54 of file Averages.cc.

References add().

54  {
55  add( x, -1. );
56 }
void add(const float &value, const float &weight)
Definition: Averages.cc:36
Definition: DDAxes.h:10
void Averages::add ( const uint32_t &  value,
const uint32_t &  weight 
)

Definition at line 21 of file Averages.cc.

References add(), mode_, and x.

22  {
23  mode_[x]++;
24  add( static_cast<float>(x),
25  static_cast<float>(e) );
26 }
std::map< uint32_t, uint32_t > mode_
Definition: Averages.h:56
void add(const float &value, const float &weight)
Definition: Averages.cc:36
Definition: DDAxes.h:10
void Averages::add ( const uint32_t &  value)

Definition at line 29 of file Averages.cc.

References add(), mode_, and x.

29  {
30  mode_[x]++;
31  add( static_cast<float>(x), -1. );
32 }
std::map< uint32_t, uint32_t > mode_
Definition: Averages.h:56
void add(const float &value, const float &weight)
Definition: Averages.cc:36
Definition: DDAxes.h:10
void Averages::calc ( Params params)

Definition at line 60 of file Averages.cc.

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

Referenced by SiStripCommissioningSource::fillCablingHistos().

60  {
61  params.num_ = n_;
62  if ( s_ > 0. ) {
63  float m = x_/s_;
64  float t = xx_/s_ - m*m;
65  if ( t > 0. ) { t = sqrt(t); }
66  else { t = 0.; }
67  params.mean_ = m;
68  params.rms_ = t;
69  params.weight_ = s_;
70  }
71  if ( !median_.empty() ) {
72  sort( median_.begin(), median_.end() );
73  uint16_t index = median_.size()%2 ? median_.size()/2 : median_.size()/2-1;
74  params.median_ = median_[index];
75  params.max_ = median_.back();
76  params.min_ = median_.front();
77  }
78  if ( !mode_.empty() ) {
79  uint32_t max = 0;
80  std::map<uint32_t,uint32_t>::const_iterator imap = mode_.begin();
81  for ( ; imap != mode_.end(); imap++ ) {
82  if ( imap->second > max ) {
83  max = imap->second;
84  params.mode_ = imap->first;
85  }
86  }
87  }
88 
89 }
std::map< uint32_t, uint32_t > mode_
Definition: Averages.h:56
float x_
Definition: Averages.h:53
const T & max(const T &a, const T &b)
T sqrt(T t)
Definition: SSEVec.h:48
uint32_t n_
Definition: Averages.h:51
std::vector< float > median_
Definition: Averages.h:55
float s_
Definition: Averages.h:52
float xx_
Definition: Averages.h:54

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