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
runningMean.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file runningMean.cc
1
#include "
runningMean.h
"
2
3
runningMean::runningMean
()
4
{
5
refArray
=
nullptr
;
6
}
7
8
runningMean::~runningMean
()
9
{
10
if
(
refArray
)
delete
[]
refArray
;
11
}
12
13
int
runningMean::setRefArray
(
const
double
darr[])
14
{
15
int
i
;
16
if
(
refArray
==
nullptr
)
17
{
18
refArray
=
new
double
[
getNumberofChannels
()];
19
}
20
21
for
(i=0; i<
getNumberofChannels
(); i++)
refArray
[i] = darr[i];
22
23
return
0;
24
}
25
26
int
runningMean::setRefChannel
(
const
int
channel
,
const
double
refvalue)
27
{
28
int
i
;
29
if
(
refArray
==
nullptr
)
30
{
31
refArray
=
new
double
[
getNumberofChannels
()];
32
for
(i=0; i<
getNumberofChannels
(); i++)
refArray
[i] = 0;
33
}
34
35
if
(channel < 0 || channel >=
getNumberofChannels
() )
return
-1;
36
refArray
[
channel
] = refvalue;
37
38
return
0;
39
}
40
41
int
runningMean::setAsReference
()
42
{
43
int
i
;
44
if
(
refArray
==
nullptr
)
45
{
46
refArray
=
new
double
[
getNumberofChannels
()];
47
}
48
for
(i=0; i<
getNumberofChannels
(); i++)
refArray
[i] =
getMean
(i);
49
return
0;
50
}
51
52
double
runningMean::getReference
(
const
int
channel
)
const
53
{
54
if
(
refArray
==
nullptr
)
return
0;
55
56
if
(channel < 0 || channel >=
getNumberofChannels
() )
return
0;
57
return
refArray
[
channel
];
58
}
59
60
double
runningMean::getPercentDeviation
(
const
int
channel
)
const
61
{
62
if
(
refArray
==
nullptr
)
return
0;
63
64
if
(channel < 0 || channel >=
getNumberofChannels
() )
return
0;
65
66
if
(
getReference
(channel) == 0.)
return
0.;
67
return
( 100.* (
getMean
(channel) -
getReference
(channel) ) /
getReference
(channel) );
68
}
69
OnlMon
blob
main
onlmonutils
runningMean.cc
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:28
using
1.8.2 with
sPHENIX GitHub integration