Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
fullRunningMean.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file fullRunningMean.cc
1
#include "
fullRunningMean.h
"
2
3
fullRunningMean::fullRunningMean
(
const
int
n
,
const
int
d)
4
{
5
int
i
,
j
;
6
depth
= d;
7
NumberofChannels
=
n
;
8
current_depth
=0;
9
array
=
new
double
*[
NumberofChannels
];
10
for
(i=0; i<
NumberofChannels
; i++)
11
{
12
array
[
i
] =
new
double
[
depth
];
13
for
(j=0; j<
depth
; j++)
array
[i][j] = 0.;
14
}
15
}
16
17
fullRunningMean::~fullRunningMean
()
18
{
19
int
i
;
20
for
(i=0; i<
NumberofChannels
; i++)
21
{
22
delete
[]
array
[
i
];
23
}
24
delete
[]
array
;
25
}
26
27
int
fullRunningMean::Add
(
const
int
iarr[])
28
{
29
int
i
;
30
31
for
(i = 0; i<
NumberofChannels
; i++)
addChannel
(i,
double
(iarr[i]) );
32
if
(
current_depth
<
depth
)
current_depth
++;
33
return
0;
34
35
}
36
int
fullRunningMean::Add
(
const
float
farr[])
37
{
38
int
i
;
39
40
for
(i = 0; i<
NumberofChannels
; i++)
addChannel
(i, farr[i]);
41
if
(
current_depth
<
depth
)
current_depth
++;
42
return
0;
43
44
}
45
int
fullRunningMean::Add
(
const
double
darr[])
46
{
47
int
i
;
48
49
for
(i = 0; i<
NumberofChannels
; i++)
addChannel
(i, darr[i]);
50
if
(
current_depth
<
depth
)
current_depth
++;
51
return
0;
52
}
53
54
55
int
fullRunningMean::Reset
()
56
{
57
int
i
,
j
;
58
for
(i=0; i<
NumberofChannels
; i++)
59
{
60
for
(j=0; j<
depth
; j++)
array
[i][j] = 0.;
61
}
62
return
0;
63
}
64
65
double
fullRunningMean::getMean
(
const
int
ich)
const
66
{
67
int
j
;
68
double
x
= 0.;
69
70
if
(
current_depth
== 0)
return
0.;
71
72
for
(j=0; j<
current_depth
; j++) x +=
array
[ich][j];
73
return
x /
double
(current_depth);
74
}
75
76
77
int
fullRunningMean::addChannel
(
const
int
channel
,
const
double
k
)
78
{
79
int
j
;
80
if
(
current_depth
<
depth
)
81
{
82
array
[
channel
][
current_depth
] =
k
;
83
}
84
else
85
{
86
for
(j=1; j<
depth
; j++)
array
[channel][j-1] =
array
[channel][j];
87
array
[
channel
][depth-1] =
k
;
88
}
89
return
0;
90
}
91
OnlMon
blob
main
onlmonutils
fullRunningMean.cc
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:28
using
1.8.2 with
sPHENIX GitHub integration