ATLAS Offline Software
Loading...
Searching...
No Matches
LArCalorimeter
LArCalibUtils
src
LArCalibUtils/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/LArCalibUtils
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 "
LArCalibUtils/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
int
i=0; i<=
imax
; ++i)
mean
+=
m_sum
[i];
83
mean
/= ((
imax
-imin+1)*(double)
m_nped
);
84
85
return
mean
;
86
}
87
88
//----------------------------------------------------------------------------
89
double
LArPedestal::get_mean
(
const
unsigned
isample)
const
90
//----------------------------------------------------------------------------
91
{
92
if
(isample>=
m_sum
.size() ||
m_nped
==0)
93
return
0;
94
double
mean
= 0;
95
mean
=
m_sum
[isample];
96
mean
/= ((double)
m_nped
);
97
98
return
mean
;
99
}
100
101
//----------------------------------------------------------------------------
102
double
LArPedestal::get_mean
()
const
103
//----------------------------------------------------------------------------
104
{
105
const
int
nsamples =
m_sum
.size();
106
if
(nsamples==0 ||
m_nped
==0)
return
0;
107
uint32_t imean = 0;
108
for
(
int
i=0; i<nsamples; i++)
109
imean +=
m_sum
[i];
110
111
return
double(imean)/(nsamples*
m_nped
);
112
113
114
}
115
116
//----------------------------------------------------------------------------
117
double
LArPedestal::get_rms
(
const
unsigned
isample_min,
const
unsigned
isample_max)
const
118
//----------------------------------------------------------------------------
119
{
120
unsigned
imin=0;
121
unsigned
imax
=
m_sum
.size()-1;
122
123
if
(isample_min > 0 && isample_min <
m_sum
.size()) imin=isample_min;
124
if
(isample_max > 0 && isample_max <
m_sum
.size())
imax
=isample_max;
125
//const int nsamples = m_sum.size();
126
uint64_t
x
=0,
y
=0;
127
for
(
unsigned
int
i=imin; i<=
imax
; i++) {
128
x
+=
m_sum
[i];
129
y
+=
m_sumSquares
[i];
130
}
131
132
const
double
mean
=double(
x
)/((
imax
-imin+1)*
m_nped
);
133
const
double
ss
=double(
y
)/((
imax
-imin+1)*
m_nped
);
134
return
sqrt(
ss
-
mean
*
mean
);
135
}
136
137
138
//----------------------------------------------------------------------------
139
double
LArPedestal::get_rms
(
const
unsigned
isample)
const
140
//----------------------------------------------------------------------------
141
{
142
if
(isample>=
m_sum
.size() ||
m_nped
==0)
143
return
0;
144
//const int nsamples = m_sum.size();
145
const
double
x
=
m_sum
[isample]/double(
m_nped
);
146
const
double
y
=
m_sumSquares
[isample]/double(
m_nped
);
147
return
sqrt(
y
-
x
*
x
);
148
}
149
150
//----------------------------------------------------------------------------
151
double
LArPedestal::get_rms
()
const
152
//----------------------------------------------------------------------------
153
{
154
const
int
nsamples =
m_sum
.size();
155
if
(nsamples==0 ||
m_nped
==0)
return
0;
156
uint64_t
x
=0,
y
=0;
157
for
(
int
i=0; i<nsamples; i++) {
158
x
+=
m_sum
[i];
159
y
+=
m_sumSquares
[i];
160
}
161
162
const
double
mean
=double(
x
)/(nsamples*
m_nped
);
163
const
double
ss
=double(
y
)/(nsamples*
m_nped
);
164
return
sqrt(
ss
-
mean
*
mean
);
165
//double noise=y-x*x
166
//return sqrt(noise/(m_nped*m_nped*nsamples*nsamples));
167
}
168
169
//----------------------------------------------------------------------------
170
void
LArPedestal::add
(
const
std::vector<short>& samples)
171
//----------------------------------------------------------------------------
172
{
173
const
size_t
nsamples = samples.size();
174
175
if
(
m_sum
.size()<nsamples) {
176
m_sum
.resize(nsamples);
177
m_sumSquares
.resize(nsamples);
178
}
179
180
for
(
size_t
i=0; i<nsamples; i++) {
181
m_sum
[i] += samples[i];
182
m_sumSquares
[i] += (samples[i]*samples[i]);
183
}
184
m_nped
++;
185
}
186
187
//----------------------------------------------------------------------------
188
void
LArPedestal::zero
()
189
//----------------------------------------------------------------------------
190
{
191
const
int
nsamples =
m_sum
.size();
192
for
(
int
l=0; l<nsamples; l++) {
193
m_sumSquares
[l] = 0;
194
m_sum
[l]=0;
195
}
196
m_nped
=0;
197
}
198
199
CaloGain.h
LArPedestal.h
ss
static Double_t ss
Definition
LArPhysWaveHECTool.cxx:37
imax
int imax(int i, int j)
Definition
TileLaserTimingTool.cxx:33
y
#define y
x
#define x
min
#define min(a, b)
Definition
cfImp.cxx:40
max
#define max(a, b)
Definition
cfImp.cxx:41
LArPedestal::m_sum
std::vector< uint32_t > m_sum
Definition
LArCalibUtils/LArCalibUtils/LArPedestal.h:35
LArPedestal::~LArPedestal
~LArPedestal()
LArPedestal::add
void add(const std::vector< short > &samples)
Definition
LArCalibUtils/src/LArPedestal.cxx:170
LArPedestal::get_sum
double get_sum() const
Definition
LArCalibUtils/src/LArPedestal.cxx:61
LArPedestal::m_sumSquares
std::vector< uint64_t > m_sumSquares
Definition
LArCalibUtils/LArCalibUtils/LArPedestal.h:37
LArPedestal::m_max
short m_max
Definition
LArCalibUtils/LArCalibUtils/LArPedestal.h:33
LArPedestal::set_max
void set_max(const short max)
Definition
LArCalibUtils/src/LArPedestal.cxx:44
LArPedestal::get_rms
double get_rms() const
Definition
LArCalibUtils/src/LArPedestal.cxx:151
LArPedestal::m_nped
uint32_t m_nped
Definition
LArCalibUtils/LArCalibUtils/LArPedestal.h:39
LArPedestal::LArPedestal
LArPedestal()
Definition
LArCalibUtils/src/LArPedestal.cxx:23
LArPedestal::m_min
short m_min
Definition
LArCalibUtils/LArCalibUtils/LArPedestal.h:31
LArPedestal::get_mean
double get_mean() const
Definition
LArCalibUtils/src/LArPedestal.cxx:102
LArPedestal::zero
void zero()
Definition
LArCalibUtils/src/LArPedestal.cxx:188
LArPedestal::set_min
void set_min(const short min)
Definition
LArCalibUtils/src/LArPedestal.cxx:37
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
const
Generated on
for ATLAS Offline Software by
1.14.0