Main Page
Namespaces
Classes
Package Documentation
DQM
SiStripCommissioningSources
src
Averages.cc
Go to the documentation of this file.
1
#include "
DQM/SiStripCommissioningSources/interface/Averages.h
"
2
#include <iostream>
3
#include <cmath>
4
#include <algorithm>
5
6
using namespace
std
;
7
8
// ----------------------------------------------------------------------------
9
//
10
Averages::Averages
()
11
: n_(0),
12
s_(0.),
13
x_(0.),
14
xx_(0.),
15
median_(),
16
mode_()
17
{;}
18
19
// ----------------------------------------------------------------------------
20
//
21
void
Averages::add
(
const
uint32_t&
x
,
22
const
uint32_t&
e
) {
23
mode_
[
x
]++;
24
add
( static_cast<float>(
x
),
25
static_cast<float>(e) );
26
}
27
// ----------------------------------------------------------------------------
28
//
29
void
Averages::add
(
const
uint32_t&
x
) {
30
mode_
[
x
]++;
31
add
( static_cast<float>(x), -1. );
32
}
33
34
// ----------------------------------------------------------------------------
35
//
36
void
Averages::add
(
const
float
&
x
,
37
const
float
&
e
) {
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
}
51
52
// ----------------------------------------------------------------------------
53
//
54
void
Averages::add
(
const
float
&
x
) {
55
add
( x, -1. );
56
}
57
58
// ----------------------------------------------------------------------------
59
//
60
void
Averages::calc
(
Params
& params ) {
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
}
Averages::mode_
std::map< uint32_t, uint32_t > mode_
Definition:
Averages.h:56
jetUpdater_cfi.sort
sort
Definition:
jetUpdater_cfi.py:29
Averages::x_
float x_
Definition:
Averages.h:53
Averages::Params
Definition:
Averages.h:17
Averages::Params::min_
float min_
Definition:
Averages.h:25
std
Definition:
JetResolutionObject.h:80
MillePedeFileConverter_cfg.e
e
Definition:
MillePedeFileConverter_cfg.py:37
Averages::Params::rms_
float rms_
Definition:
Averages.h:22
Averages::Params::mean_
float mean_
Definition:
Averages.h:19
Averages::Params::mode_
float mode_
Definition:
Averages.h:21
AlignmentPI::index
index
Definition:
AlignmentPayloadInspectorHelper.h:36
Averages.h
protons_cff.t
t
Definition:
protons_cff.py:34
mathSSE::sqrt
T sqrt(T t)
Definition:
SSEVec.h:18
Averages::add
void add(const float &value, const float &weight)
Averages::n_
uint32_t n_
Definition:
Averages.h:51
Averages::calc
void calc(Params &)
Definition:
Averages.cc:60
Averages::median_
std::vector< float > median_
Definition:
Averages.h:55
SiStripPI::max
Definition:
SiStripPayloadInspectorHelper.h:178
Averages::s_
float s_
Definition:
Averages.h:52
Averages::Params::median_
float median_
Definition:
Averages.h:20
Averages::Params::max_
float max_
Definition:
Averages.h:24
funct::m
m
Definition:
Factorize.h:56
Averages::Params::num_
uint32_t num_
Definition:
Averages.h:26
Averages::Averages
Averages()
Definition:
Averages.cc:10
Averages::xx_
float xx_
Definition:
Averages.h:54
DDAxes::x
Averages::Params::weight_
float weight_
Definition:
Averages.h:23
Generated for CMSSW Reference Manual by
1.8.11