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
pseudoRunningMean.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file pseudoRunningMean.cc
1
#include "
pseudoRunningMean.h
"
2
3
pseudoRunningMean::pseudoRunningMean
(
const
int
n
,
const
int
d)
4
{
5
int
i
;
6
depth
= d;
7
NumberofChannels
=
n
;
8
current_depth
=0;
9
array
=
new
double
[
NumberofChannels
];
10
for
(i=0; i<
NumberofChannels
; i++)
array
[i] = 0.;
11
}
12
13
pseudoRunningMean::~pseudoRunningMean
()
14
{
15
delete
[]
array
;
16
}
17
18
19
int
pseudoRunningMean::Add
(
const
int
iarr[])
20
{
21
int
i
;
22
23
for
(i = 0; i<
NumberofChannels
; i++)
addChannel
(i, iarr[i]);
24
if
(
current_depth
<
depth
)
current_depth
++;
25
return
0;
26
27
}
28
int
pseudoRunningMean::Add
(
const
float
farr[])
29
{
30
int
i
;
31
32
for
(i = 0; i<
NumberofChannels
; i++)
addChannel
(i, farr[i]);
33
if
(
current_depth
<
depth
)
current_depth
++;
34
return
0;
35
36
}
37
int
pseudoRunningMean::Add
(
const
double
darr[])
38
{
39
int
i
;
40
41
for
(i = 0; i<
NumberofChannels
; i++)
addChannel
(i, darr[i]);
42
if
(
current_depth
<
depth
)
current_depth
++;
43
return
0;
44
}
45
46
47
int
pseudoRunningMean::Reset
()
48
{
49
int
i
;
50
for
(i=0; i<
NumberofChannels
; i++)
array
[i] = 0.;
51
current_depth
= 0;
// Reset current_depth to 0
52
return
0;
53
}
54
55
double
pseudoRunningMean::getMean
(
const
int
ich)
const
56
{
57
if
(
current_depth
==0)
return
0;
58
return
array
[ich] /
double
(
current_depth
);
59
}
60
61
62
int
pseudoRunningMean::addChannel
(
const
int
channel
,
const
double
k
)
63
{
64
65
if
(
current_depth
<
depth
)
66
{
67
array
[
channel
] +=
k
;
68
}
69
else
70
{
71
double
x
,
y
,ratio;
72
x =
current_depth
-1;
73
y =
current_depth
;
74
ratio = x/
y
;
75
array
[
channel
] =
array
[
channel
] * ratio +
k
;
76
}
77
return
0;
78
}
79
OnlMon
blob
main
onlmonutils
pseudoRunningMean.cc
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:28
using
1.8.2 with
sPHENIX GitHub integration