Main Page
Namespaces
Classes
Package Documentation
CalibCalorimetry
EcalLaserSorting
src
Majority.h
Go to the documentation of this file.
1
/*
2
*/
3
4
#ifndef MAJORITY_H
5
#define MAJORITY_H
6
7
#include <map>
8
11
template
<
class
T>
12
class
Majority
{
13
//constructor(s) and destructor(s)
14
public
:
17
Majority
() :
n_
(0) {}
18
21
virtual
~Majority
() {}
22
23
void
add
(
const
T
&
value
) {
24
votes_
[
value
] += 1.;
25
n_
+= 1.;
26
}
27
28
T
result
(
double
* proba)
const
{
29
std::pair<T, double>
m
(
T
(), -1.);
30
for
(
typename
std::map<T, double>::const_iterator it =
votes_
.begin(); it !=
votes_
.end(); ++it) {
31
if
(it->second > m.second) {
32
m = *it;
33
}
34
}
35
if
(proba)
36
*proba =
n_
> 0 ? m.second /
n_
: -1;
37
return
m.first;
38
}
39
40
//method(s)
41
public
:
42
private
:
43
//attribute(s)
44
protected
:
45
private
:
46
std::map<T, double>
votes_
;
47
double
n_
;
48
};
49
50
#endif //MAJORITY_H not defined
Majority::votes_
std::map< T, double > votes_
Definition:
Majority.h:46
Majority::n_
double n_
Definition:
Majority.h:47
Majority::~Majority
virtual ~Majority()
Definition:
Majority.h:21
Majority::add
void add(const T &value)
Definition:
Majority.h:23
Majority
Definition:
Majority.h:12
value
Definition:
value.py:1
relativeConstraints.value
value
Definition:
relativeConstraints.py:53
funct::m
m
Definition:
Factorize.h:56
Majority::result
T result(double *proba) const
Definition:
Majority.h:28
T
long double T
Definition:
Basic3DVectorLD.h:66
Majority::Majority
Majority()
Definition:
Majority.h:17
Generated for CMSSW Reference Manual by
1.8.11