Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
CalibCalorimetry
EcalLaserSorting
src
Majority.h
Go to the documentation of this file.
1
/*
2
* $Id: Majority.h,v 1.1 2009/02/25 17:34:05 pgras Exp $
3
*/
4
5
#ifndef MAJORITY_H
6
#define MAJORITY_H
7
8
#include <map>
9
12
template
<
class
T>
13
class
Majority
{
14
//constructor(s) and destructor(s)
15
public
:
18
Majority
():
n_
(0){}
19
22
virtual
~Majority
(){}
23
24
void
25
add
(
const
T
&
value
){
26
votes_
[
value
] += 1.;
27
n_
+= 1.;
28
}
29
30
T
result
(
double
* proba)
const
{
31
std::pair<T, double>
m
(
T
(), -1.);
32
for
(
typename
std::map<T, double>::const_iterator it =
votes_
.begin();
33
it !=
votes_
.end();
34
++it){
35
if
(it->second > m.second){
36
m = *it;
37
}
38
}
39
if
(proba) *proba =
n_
>0?m.second/
n_
:-1;
40
return
m.first;
41
}
42
43
//method(s)
44
public
:
45
private
:
46
47
//attribute(s)
48
protected
:
49
private
:
50
std::map<T, double>
votes_
;
51
double
n_
;
52
};
53
54
#endif //MAJORITY_H not defined
Majority::votes_
std::map< T, double > votes_
Definition:
Majority.h:50
relativeConstraints.value
tuple value
Definition:
relativeConstraints.py:54
Majority::n_
double n_
Definition:
Majority.h:51
Majority::~Majority
virtual ~Majority()
Definition:
Majority.h:22
Majority::add
void add(const T &value)
Definition:
Majority.h:25
Majority
Definition:
Majority.h:13
m
int m
Definition:
DTDataIntegrityTask.cc:33
Majority::result
T result(double *proba) const
Definition:
Majority.h:30
T
long double T
Definition:
Basic3DVectorLD.h:59
Majority::Majority
Majority()
Definition:
Majority.h:18
Generated for CMSSW Reference Manual by
1.8.5