ATLAS Offline Software
LArCalorimeter
LArRawEvent
src
LArRawEvent/src/LArPedestal.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
/********************************************************************
6
7
NAME: LArPedestal.cxx
8
PACKAGE: offline/LArCalorimeter/LArRawEvent
9
10
AUTHORS: M. AHARROUCHE
11
CREATED: Jan. 12, 2004
12
UPDATED: Mar. 09, 2004 Remi Lafaye
13
14
PURPOSE: Interchanges the data with LArPedestalMaker for
15
calculation of pedestal and rms.
16
17
********************************************************************/
18
#include "
CaloIdentifier/CaloGain.h
"
19
#include "
LArRawEvent/LArPedestal.h
"
20
#include <iostream>
21
22
//----------------------------------------------------------------------------
23
LArPedestal::LArPedestal
()
24
//----------------------------------------------------------------------------
25
{
26
m_min
= -1;
27
m_max
= -1;
28
m_nped
= 0;
29
}
30
31
//----------------------------------------------------------------------------
32
LArPedestal::~LArPedestal
()
33
//----------------------------------------------------------------------------
34
=
default
;
35
36
//----------------------------------------------------------------------------
37
void
LArPedestal::set_min
(
const
short
min
)
38
//----------------------------------------------------------------------------
39
{
40
m_min
=
min
;
41
}
42
43
//----------------------------------------------------------------------------
44
void
LArPedestal::set_max
(
const
short
max
)
45
//----------------------------------------------------------------------------
46
{
47
m_max
=
max
;
48
}
49
50
//----------------------------------------------------------------------------
51
double
LArPedestal::get_sum
(
const
unsigned
isample)
const
52
//----------------------------------------------------------------------------
53
{
54
if
(isample>=m_sum.size())
55
return
0;
56
57
return
m_sum[isample];
58
}
59
60
//----------------------------------------------------------------------------
61
double
LArPedestal::get_sum
()
const
62
//----------------------------------------------------------------------------
63
{
64
double
sum
= 0;
65
int
nsamples
=
m_sum
.size();
66
for
(
int
i
=0;
i
<
nsamples
;
i
++)
67
sum
+=
m_sum
[
i
];
68
69
return
sum
;
70
}
71
72
//----------------------------------------------------------------------------
73
double
LArPedestal::get_mean
(
const
unsigned
isample_min,
const
unsigned
isample_max)
const
74
//----------------------------------------------------------------------------
75
{
76
unsigned
imin=0;
77
unsigned
imax
=m_sum.size()-1;
78
79
if
(isample_min > 0 && isample_min < m_sum.size()) imin=isample_min;
80
if
(isample_max > 0 && isample_max < m_sum.size())
imax
=isample_max;
81
double
mean
= 0;
82
for
(
unsigned
i
=0;
i
<=
imax
; ++
i
)
mean
+= m_sum[
i
];
83
mean
/= ((
imax
-imin+1)*(
double
) m_nped);
84
85
return
mean
;
86
}
87
//----------------------------------------------------------------------------
88
double
LArPedestal::get_mean
(
const
unsigned
isample)
const
89
//----------------------------------------------------------------------------
90
{
91
if
(isample>=m_sum.size() || m_nped==0)
92
return
0;
93
double
mean
= 0;
94
mean
= m_sum[isample];
95
mean
/= ((
double
) m_nped);
96
97
return
mean
;
98
}
99
100
//----------------------------------------------------------------------------
101
double
LArPedestal::get_mean
()
const
102
//----------------------------------------------------------------------------
103
{
104
const
int
nsamples
=
m_sum
.size();
105
if
(
nsamples
==0 ||
m_nped
==0)
return
0;
106
uint32_t
imean = 0;
107
for
(
int
i
=0;
i
<
nsamples
;
i
++)
108
imean +=
m_sum
[
i
];
109
110
return
double
(imean)/(
nsamples
*
m_nped
);
111
112
113
}
114
115
//----------------------------------------------------------------------------
116
double
LArPedestal::get_rms
(
const
unsigned
isample_min,
const
unsigned
isample_max)
const
117
//----------------------------------------------------------------------------
118
{
119
unsigned
imin=0;
120
unsigned
imax
=m_sum.size()-1;
121
122
if
(isample_min > 0 && isample_min < m_sum.size()) imin=isample_min;
123
if
(isample_max > 0 && isample_max < m_sum.size())
imax
=isample_max;
124
//const int nsamples = m_sum.size();
125
uint64_t
x
=0,
y
=0;
126
for
(
unsigned
i
=imin;
i
<=
imax
;
i
++) {
127
x
+=m_sum[
i
];
128
y
+=m_sumSquares[
i
];
129
}
130
131
const
double
mean
=
double
(
x
)/((
imax
-imin+1)*m_nped);
132
const
double
ss
=
double
(
y
)/((
imax
-imin+1)*m_nped);
133
return
sqrt(
ss
-
mean
*
mean
);
134
}
135
136
137
//----------------------------------------------------------------------------
138
double
LArPedestal::get_rms
(
const
unsigned
isample)
const
139
//----------------------------------------------------------------------------
140
{
141
if
(isample>=m_sum.size() || m_nped==0)
142
return
0;
143
//const int nsamples = m_sum.size();
144
const
double
x
= m_sum[isample]/
double
(m_nped);
145
const
double
y
= m_sumSquares[isample]/
double
(m_nped);
146
return
sqrt(
y
-
x
*
x
);
147
}
148
149
//----------------------------------------------------------------------------
150
double
LArPedestal::get_rms
()
const
151
//----------------------------------------------------------------------------
152
{
153
const
int
nsamples
=
m_sum
.size();
154
if
(
nsamples
==0 ||
m_nped
==0)
return
0;
155
uint64_t
x
=0,
y
=0;
156
for
(
int
i
=0;
i
<
nsamples
;
i
++) {
157
x
+=
m_sum
[
i
];
158
y
+=
m_sumSquares
[
i
];
159
}
160
161
const
double
mean
=
double
(
x
)/(
nsamples
*
m_nped
);
162
const
double
ss
=
double
(
y
)/(
nsamples
*
m_nped
);
163
return
sqrt(
ss
-
mean
*
mean
);
164
//double noise=y-x*x
165
//return sqrt(noise/(m_nped*m_nped*nsamples*nsamples));
166
}
167
168
//----------------------------------------------------------------------------
169
void
LArPedestal::add
(
const
std::vector<short>& samples)
170
//----------------------------------------------------------------------------
171
{
172
const
size_t
nsamples
= samples.size();
173
174
if
(
m_sum
.size()<
nsamples
) {
175
m_sum
.resize(
nsamples
);
176
m_sumSquares
.resize(
nsamples
);
177
}
178
179
for
(
size_t
i
=0;
i
<
nsamples
;
i
++) {
180
m_sum
[
i
] += samples[
i
];
181
m_sumSquares
[
i
] += (samples[
i
]*samples[
i
]);
182
}
183
m_nped
++;
184
}
185
186
//----------------------------------------------------------------------------
187
void
LArPedestal::zero
()
188
//----------------------------------------------------------------------------
189
{
190
const
int
nsamples
=
m_sum
.size();
191
for
(
int
l
=0;
l
<
nsamples
;
l
++) {
192
m_sumSquares
[
l
] = 0;
193
m_sum
[
l
]=0;
194
}
195
m_nped
=0;
196
}
197
198
LArPedestal::m_min
short m_min
Definition:
LArCalibUtils/LArCalibUtils/LArPedestal.h:43
LArPedestal::get_rms
double get_rms() const
Definition:
LArCalibUtils/src/LArPedestal.cxx:151
mean
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
Definition:
dependence.cxx:254
PowhegControl_ttHplus_NLO.ss
ss
Definition:
PowhegControl_ttHplus_NLO.py:83
LArPedestal::get_mean
double get_mean() const
Definition:
LArCalibUtils/src/LArPedestal.cxx:102
xAOD::uint32_t
setEventNumber uint32_t
Definition:
EventInfo_v1.cxx:127
LArPedestal::~LArPedestal
~LArPedestal()
max
constexpr double max()
Definition:
ap_fixedTest.cxx:33
min
constexpr double min()
Definition:
ap_fixedTest.cxx:26
LArPedestal::m_sum
std::vector< uint32_t > m_sum
Definition:
LArCalibUtils/LArCalibUtils/LArPedestal.h:47
UploadAMITag.l
list l
Definition:
UploadAMITag.larcaf.py:158
LArPedestal.h
LArPedestal::add
void add(const std::vector< short > &samples)
Definition:
LArCalibUtils/src/LArPedestal.cxx:170
const
bool const RAWDATA *ch2 const
Definition:
LArRodBlockPhysicsV0.cxx:560
x
#define x
LArPedestal::m_nped
uint32_t m_nped
Definition:
LArCalibUtils/LArCalibUtils/LArPedestal.h:51
LArPedestal::set_min
void set_min(const short min)
Definition:
LArCalibUtils/src/LArPedestal.cxx:37
convertTimingResiduals.sum
sum
Definition:
convertTimingResiduals.py:55
lumiFormat.i
int i
Definition:
lumiFormat.py:85
xAOD::uint64_t
uint64_t
Definition:
EventInfo_v1.cxx:123
xAOD::double
double
Definition:
CompositeParticle_v1.cxx:159
LArPedestal::set_max
void set_max(const short max)
Definition:
LArCalibUtils/src/LArPedestal.cxx:44
imax
int imax(int i, int j)
Definition:
TileLaserTimingTool.cxx:33
LArPedestal::m_sumSquares
std::vector< uint64_t > m_sumSquares
Definition:
LArCalibUtils/LArCalibUtils/LArPedestal.h:49
LArPedestal::get_sum
double get_sum() const
Definition:
LArCalibUtils/src/LArPedestal.cxx:61
ReadOfcFromCool.nsamples
nsamples
Definition:
ReadOfcFromCool.py:115
y
#define y
LArPedestal::zero
void zero()
Definition:
LArCalibUtils/src/LArPedestal.cxx:188
LArPedestal::LArPedestal
LArPedestal()
Definition:
LArCalibUtils/src/LArPedestal.cxx:23
LArPedestal::m_max
short m_max
Definition:
LArCalibUtils/LArCalibUtils/LArPedestal.h:45
CaloGain.h
Generated on Fri Jan 10 2025 21:13:22 for ATLAS Offline Software by
1.8.18