ATLAS Offline Software
LArCalorimeter
LArCalibUtils
src
LArCalibTriggerAccumulator.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
LArCalibTriggerAccumulator.h
"
6
#include <cmath>
7
8
LArCalibTriggerAccumulator::LArCalibTriggerAccumulator
() : m_nTrigger(0) {}
9
10
LArCalibTriggerAccumulator::LArCalibTriggerAccumulator
(
const
std::vector<uint64_t>& sampleSum,
11
const
std::vector<uint64_t>& sample2Sum,
12
uint32_t
nTrigger) :
13
m_sampleSum(sampleSum), m_sample2Sum(sample2Sum), m_nTrigger(nTrigger) {}
14
15
16
17
LArCalibTriggerAccumulator::ERRTYPE
LArCalibTriggerAccumulator::add
(
const
std::vector<short>& digits) {
18
const
size_t
nS=digits.size();
19
if
(nS==0)
return
WrongNSamples
;
20
21
if
(
m_sampleSum
.empty() &&
m_sample2Sum
.empty()) {
22
m_sampleSum
.resize(nS);
23
m_sample2Sum
.resize(nS);
24
}
25
else
if
(
m_sampleSum
.size()!=nS ||
m_sample2Sum
.size()!=nS)
26
return
WrongNSamples
;
//Inconsistent number of samples
27
28
for
(
size_t
i
=0;
i
<nS;++
i
) {
29
const
uint32_t
&
dg
=digits[
i
];
30
if
(
m_sample2Sum
[
i
]>=
std::numeric_limits<uint64_t>::max
()-
dg
) {
31
//ERROR: Numeric overflow
32
//Roll back changes:
33
for
(
size_t
j=0;j<
i
;++j) {
34
m_sampleSum
[j]-=digits[j];
35
m_sample2Sum
[j]-=digits[j]*digits[j];
36
}
37
return
NumericOverflow
;
38
}
39
40
m_sampleSum
[
i
]+=
dg
;
41
m_sample2Sum
[
i
]+=
dg
*
dg
;
42
}
43
++
m_nTrigger
;
44
return
NoError
;
45
}
46
47
48
49
double
LArCalibTriggerAccumulator::mean
(
const
size_t
i
)
const
{
50
51
if
(
i
<
m_sampleSum
.size() &&
i
<
m_sample2Sum
.size() &&
m_nTrigger
>0)
52
return
((
double
)
m_sampleSum
[
i
])/((
double
)
m_nTrigger
);
53
else
54
return
0.0;
55
}
56
57
double
LArCalibTriggerAccumulator::RMS
(
const
size_t
i
)
const
{
58
59
if
(
i
<
m_sampleSum
.size() &&
i
<
m_sample2Sum
.size() &&
m_nTrigger
>0) {
60
const
double
mean
=((
double
)
m_sampleSum
[
i
])/((
double
)
m_nTrigger
);
61
return
sqrt(((
double
)
m_sample2Sum
[
i
])/((
double
)
m_nTrigger
)-
mean
*
mean
);
62
}
63
else
64
return
0.0;
65
}
66
67
68
std::vector<float>
LArCalibTriggerAccumulator::mean
()
const
{
69
70
const
size_t
nS=
m_sampleSum
.size();
71
std::vector<float>
mean
;
72
if
(
m_nTrigger
==0)
73
return
mean
;
74
else
{
75
mean
.resize(nS,0.0);
76
for
(
size_t
i
=0;
i
<nS;++
i
)
77
mean
[
i
]=((
double
)
m_sampleSum
[
i
])/((
double
)
m_nTrigger
);
78
return
mean
;
79
}
80
}
81
82
std::vector<float>
LArCalibTriggerAccumulator::RMS
()
const
{
83
std::vector<float>
rms
;
84
const
size_t
nS=
m_sampleSum
.size();
85
if
(
m_sample2Sum
.size()!=nS ||
m_nTrigger
==0)
86
return
rms
;
// ERROR, return emtpy vector
87
88
double
mean
;
89
rms
.resize(nS,0.0);
90
91
for
(
size_t
i
=0;
i
<nS;++
i
) {
92
mean
=((
double
)
m_sampleSum
[
i
])/((
double
)
m_nTrigger
);
93
rms
[
i
]=sqrt(((
double
)
m_sample2Sum
[
i
])/((
double
)
m_nTrigger
)-
mean
*
mean
);
94
}
95
return
rms
;
96
}
checkCoolLatestUpdate.dg
dg
Definition:
checkCoolLatestUpdate.py:9
xAOD::uint32_t
setEventNumber uint32_t
Definition:
EventInfo_v1.cxx:127
LArCalibTriggerAccumulator::add
ERRTYPE add(const std::vector< short > &digits)
accumulated individual set of digits.
Definition:
LArCalibTriggerAccumulator.cxx:17
LArCalibTriggerAccumulator::LArCalibTriggerAccumulator
LArCalibTriggerAccumulator()
Definition:
LArCalibTriggerAccumulator.cxx:8
max
constexpr double max()
Definition:
ap_fixedTest.cxx:33
lumiFormat.i
int i
Definition:
lumiFormat.py:85
xAOD::double
double
Definition:
CompositeParticle_v1.cxx:159
LArCalibTriggerAccumulator::m_sample2Sum
std::vector< uint64_t > m_sample2Sum
sum of squares of samples
Definition:
LArCalibTriggerAccumulator.h:38
LArCalibTriggerAccumulator::NumericOverflow
@ NumericOverflow
Definition:
LArCalibTriggerAccumulator.h:49
LArCalibTriggerAccumulator::mean
std::vector< float > mean() const
Calculates and returns the Mean value of each ADC sample.
Definition:
LArCalibTriggerAccumulator.cxx:68
LArCalibTriggerAccumulator::m_sampleSum
std::vector< uint64_t > m_sampleSum
sum of samples
Definition:
LArCalibTriggerAccumulator.h:35
LArCalibTriggerAccumulator::m_nTrigger
uint32_t m_nTrigger
number of triggers
Definition:
LArCalibTriggerAccumulator.h:41
LArCalibTriggerAccumulator::NoError
@ NoError
Definition:
LArCalibTriggerAccumulator.h:47
LArCalibTriggerAccumulator.h
beamspotnt.rms
rms
Definition:
bin/beamspotnt.py:1266
LArCalibTriggerAccumulator::ERRTYPE
ERRTYPE
Definition:
LArCalibTriggerAccumulator.h:46
LArCalibTriggerAccumulator::WrongNSamples
@ WrongNSamples
Definition:
LArCalibTriggerAccumulator.h:48
LArCalibTriggerAccumulator::RMS
std::vector< float > RMS() const
Calculates and returns the RMS value of each ADC sample.
Definition:
LArCalibTriggerAccumulator.cxx:82
Generated on Mon Dec 23 2024 21:13:21 for ATLAS Offline Software by
1.8.18