test
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 
)
void Averages::add ( const float &  value)
void Averages::add ( const uint32_t &  value,
const uint32_t &  weight 
)
void Averages::add ( const uint32_t &  value)
void Averages::calc ( Params params)

Definition at line 60 of file Averages.cc.

References cmsHarvester::index, visualization-live-secondInstance_cfg::m, bookConverter::max, Averages::Params::max_, Averages::Params::mean_, Averages::Params::median_, Averages::Params::min_, Averages::Params::mode_, Averages::Params::num_, Averages::Params::rms_, mathSSE::sqrt(), lumiQTWidget::t, and Averages::Params::weight_.

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
T sqrt(T t)
Definition: SSEVec.h:18
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.

std::map<uint32_t,uint32_t> Averages::mode_
private

Definition at line 56 of file Averages.h.

uint32_t Averages::n_
private

Definition at line 51 of file Averages.h.

float Averages::s_
private

Definition at line 52 of file Averages.h.

float Averages::x_
private

Definition at line 53 of file Averages.h.

float Averages::xx_
private

Definition at line 54 of file Averages.h.