CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
Majority< T > Class Template Reference

#include <Majority.h>

Public Member Functions

void add (const T &value)
 
void add (const T &value)
 
 Majority ()
 
 Majority ()
 
T result (double *proba) const
 
T result (double *proba) const
 
virtual ~Majority ()
 
virtual ~Majority ()
 

Private Attributes

double n_
 
std::map< T, double > votes_
 

Detailed Description

template<class T>
class Majority< T >

Utility class to take a decision on majority based. Used by MatacqProducer.

Definition at line 12 of file Majority.h.

Constructor & Destructor Documentation

template<class T>
Majority< T >::Majority ( )
inline

Constructs a Majority

Definition at line 17 of file Majority.h.

17 : n_(0){}
double n_
Definition: Majority.h:50
template<class T>
virtual Majority< T >::~Majority ( )
inlinevirtual

Destructor

Definition at line 21 of file Majority.h.

21 {}
template<class T>
Majority< T >::Majority ( )
inline

Constructs a Majority

Definition at line 18 of file Majority.h.

18 : n_(0){}
double n_
Definition: Majority.h:50
template<class T>
virtual Majority< T >::~Majority ( )
inlinevirtual

Destructor

Definition at line 22 of file Majority.h.

22 {}

Member Function Documentation

template<class T>
void Majority< T >::add ( const T value)
inline

Definition at line 24 of file Majority.h.

References Majority< T >::n_, relativeConstraints::value, and Majority< T >::votes_.

Referenced by MatacqProducer::getCalibTriggerType(), LaserSorter::getDetailedTriggerType(), and counter.Counter::register().

24  {
25  votes_[value] += 1.;
26  n_ += 1.;
27  }
std::map< T, double > votes_
Definition: Majority.h:49
double n_
Definition: Majority.h:50
template<class T>
void Majority< T >::add ( const T value)
inline

Collects event

Parameters
valueevent

Definition at line 28 of file Majority.h.

References Majority< T >::n_, relativeConstraints::value, and Majority< T >::votes_.

Referenced by counter.Counter::register().

28  {
29  votes_[value] += 1.;
30  n_ += 1.;
31  }
std::map< T, double > votes_
Definition: Majority.h:49
double n_
Definition: Majority.h:50
template<class T>
T Majority< T >::result ( double *  proba) const
inline

Definition at line 29 of file Majority.h.

References contentValuesFiles::m, Majority< T >::n_, and Majority< T >::votes_.

Referenced by MatacqProducer::getCalibTriggerType(), and LaserSorter::getDetailedTriggerType().

29  {
30  std::pair<T, double> m(T(), -1.);
31  for(typename std::map<T, double>::const_iterator it = votes_.begin();
32  it != votes_.end();
33  ++it){
34  if(it->second > m.second){
35  m = *it;
36  }
37  }
38  if(proba) *proba = n_>0?m.second/n_:-1;
39  return m.first;
40  }
std::map< T, double > votes_
Definition: Majority.h:49
double n_
Definition: Majority.h:50
long double T
template<class T>
T Majority< T >::result ( double *  proba) const
inline

Result of majority decision

Parameters
proba.If not null, filled with the frequency of the selected value.
Returns
selected value, that is the most frequent one.

Definition at line 38 of file Majority.h.

References contentValuesFiles::m, Majority< T >::n_, and Majority< T >::votes_.

38  {
39  std::pair<T, double> m(T(), -1.);
40  for(typename std::map<T, double>::const_iterator it = votes_.begin();
41  it != votes_.end();
42  ++it){
43  if(it->second > m.second){
44  m = *it;
45  }
46  }
47  if(proba) *proba = n_>0?m.second/n_:-1;
48  return m.first;
49  }
std::map< T, double > votes_
Definition: Majority.h:49
double n_
Definition: Majority.h:50
long double T

Member Data Documentation

template<class T>
double Majority< T >::n_
private

Definition at line 50 of file Majority.h.

Referenced by Majority< T >::add(), and Majority< T >::result().

template<class T>
std::map< T, double > Majority< T >::votes_
private

Definition at line 49 of file Majority.h.

Referenced by Majority< T >::add(), and Majority< T >::result().