ATLAS Offline Software
LArCalorimeter
LArCalibUtils
LArCalibUtils
LArCalibUtils/LArCalibUtils/LArAutoCorr.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef LARAUTOCORR_H
6
#define LARAUTOCORR_H
7
/********************************************************************
8
9
NAME: LArAutoCorr.h
10
PACKAGE: offline/LArCalorimeter/LArCalibUtils
11
12
AUTHORS: M. AHARROUCHE
13
CREATED: Dec. 16, 2003
14
15
PURPOSE: Intermediate object used to handle data
16
to be used for calculation of autocorrelation
17
elements.
18
19
********************************************************************/
20
// Include files
21
#include <string>
22
#include <vector>
23
#include <math.h>
24
25
26
class
LArAutoCorr
27
{
28
private
:
29
30
// Lower bound of window
31
short
m_min
;
32
33
// Upper bound of window
34
short
m_max
;
35
36
// Sum of components
37
std::vector<double>
m_sum
;
38
39
// Sum of squares
40
std::vector<double>
m_matrix
;
41
42
// Autocorrelation matrix
43
std::vector<double>
m_cov
;
44
std::vector<double>
m_cov_temp
;
45
46
// Counter of events
47
int
m_nped
;
48
49
public
:
50
51
// Constructor
52
LArAutoCorr
()
53
{
54
m_min
= -1;
55
m_max
= -1;
56
m_nped
= 0;
57
}
58
59
// Destructor
60
~LArAutoCorr
(){}
61
62
// Reset m_sum, m_matrix and m_nped
63
void
correl_zero
();
64
65
// Set lower value
66
void
set_min
(
const
short
min
);
67
68
// Set upper value
69
void
set_max
(
const
short
max
);
70
71
// Get number of entries
72
int
get_nentries
()
const
;
73
74
// Get mean value
75
double
get_mean
()
const
;
76
77
// Get rms value
78
double
get_rms
()
const
;
79
80
// Get lower value
81
const
short
&
get_min
()
const
;
82
83
// Get uper value
84
const
short
&
get_max
()
const
;
85
86
// Fill the m_sum and m_matrix vector
87
void
add
(
const
std::vector<short>&
samples
,
size_t
maxnsamples);
88
89
// Compute the autocorrelation elements
90
//MGV implement switch m_normalize to normalize
91
const
std::vector<double> &
get_cov
(
int
m_normalize,
int
m_phys) ;
92
93
94
};
95
96
//----------------------------------------------------------------------------
97
void
LArAutoCorr::set_min
(
const
short
min
)
98
//----------------------------------------------------------------------------
99
{
100
m_min
=
min
;
101
}
102
103
//----------------------------------------------------------------------------
104
void
LArAutoCorr::set_max
(
const
short
max
)
105
//----------------------------------------------------------------------------
106
{
107
m_max
=
max
;
108
}
109
110
//----------------------------------------------------------------------------
111
int
LArAutoCorr::get_nentries
()
const
112
//----------------------------------------------------------------------------
113
{
114
return
m_nped
;
115
}
116
117
118
//----------------------------------------------------------------------------
119
const
short
&
LArAutoCorr::get_min
()
const
120
//----------------------------------------------------------------------------
121
{
122
return
m_min
;
123
}
124
125
//----------------------------------------------------------------------------
126
const
short
&
LArAutoCorr::get_max
()
const
127
//----------------------------------------------------------------------------
128
{
129
return
m_max
;
130
}
131
132
133
//----------------------------------------------------------------------------
134
double
LArAutoCorr::get_mean
()
const
135
//----------------------------------------------------------------------------
136
{
137
double
mean
= 0;
138
139
int
nsamples
=
m_sum
.size();
140
for
(
int
i
=0;
i
<
nsamples
;
i
++)
141
mean
+=
m_sum
[
i
];
142
mean
/= ((
double
)(
nsamples
*
m_nped
));
143
144
return
mean
;
145
}
146
147
148
//----------------------------------------------------------------------------
149
const
std::vector<double> &
LArAutoCorr::get_cov
(
int
m_normalize,
int
m_phys)
150
//----------------------------------------------------------------------------
151
{
152
int
nsamples
=
m_sum
.size();
153
int
k
=0;
154
if
(
m_nped
==0)
return
m_cov
;
155
for
(
int
i
=0;
i
<
nsamples
;
i
++){
156
for
(
int
j=
i
;j<
nsamples
;j++,
k
++)
157
m_cov_temp
[
k
]= (
double
)((
m_matrix
[
k
]/(
m_nped
)) - ((
m_sum
[
i
]*
m_sum
[j])/(
m_nped
*
m_nped
)));
158
}
159
160
//MGV normalize covariance elements if required
161
if
(m_normalize == 1 && m_phys == 0 ){
162
k
=0;
163
int
si,sj;
164
si=0;
165
for
(
int
i
=0;
i
<
nsamples
;
i
++){
166
sj=si;
167
for
(
int
j=
i
;j<
nsamples
;j++,
k
++) {
168
if
(
m_sum
[
i
]!=.0 &&
m_sum
[j]!=.0)
169
m_cov_temp
[
k
]=
m_cov_temp
[
k
]/(
double
)sqrt((
m_matrix
[si]/(
m_nped
)-(
m_sum
[
i
]*
m_sum
[
i
])/(
m_nped
*
m_nped
))*(
m_matrix
[sj]/(
m_nped
)-(
m_sum
[j]*
m_sum
[j])/(
m_nped
*
m_nped
)));
170
sj+=
nsamples
-j;
171
}
172
si+=
nsamples
-
i
;
173
}
174
}
175
//MGV
176
177
if
(m_phys==0) {
178
double
sum
;
179
int
s
;
180
for
(
int
diag =1;diag<
nsamples
;diag++)
181
{
182
sum
=0;
183
s
= 0;
184
for
(
int
i
=0;
i
<
nsamples
-diag;
i
++)
185
{
186
sum
+=
m_cov_temp
[
s
+ diag];
187
s
+=
nsamples
-
i
;
188
}
189
sum
=
sum
/(
nsamples
-diag);
190
m_cov
[diag-1]=
sum
;
191
}
192
return
m_cov
;
193
}
194
else
195
return
m_cov_temp
;
196
}
197
198
//----------------------------------------------------------------------------
199
double
LArAutoCorr::get_rms
()
const
200
//----------------------------------------------------------------------------
201
{
202
double
x
=0,
y
=0;
203
int
k
= 0;
204
int
nsamples
=
m_sum
.size();
205
206
for
(
int
i
=0;
i
<
nsamples
;
i
++)
207
{
208
x
+=
m_sum
[
i
];
209
y
+=
m_matrix
[
k
];
210
k
+=
nsamples
-
i
;
// Index of diagonal element
211
}
212
213
x
/= (
double
) (
nsamples
*
m_nped
);
214
y
/=(
double
) (
nsamples
*
m_nped
);
215
216
double
noise
= sqrt(
y
-
x
*
x
);
217
218
return
noise
;
219
}
220
221
//----------------------------------------------------------------------------
222
void
LArAutoCorr::add
(
const
std::vector<short>&
samples
,
size_t
maxnsamples)
223
//----------------------------------------------------------------------------
224
{
225
unsigned
int
nsamples
=
std::min
(
samples
.size(),maxnsamples);
226
int
k
=0;
227
228
if
(
m_sum
.size()<
nsamples
)
229
{
230
231
m_cov
.resize(
nsamples
- 1);
232
m_cov_temp
.resize((
nsamples
*(
nsamples
+1))/2);
233
m_sum
.resize(
nsamples
);
234
m_matrix
.resize((
nsamples
*(
nsamples
+1))/2);
235
}
236
237
for
(
unsigned
int
i
=0;
i
<
nsamples
;
i
++)
238
{
239
for
(
unsigned
int
j=
i
; j<
nsamples
; j++,
k
++)
240
m_matrix
[
k
] += ((
double
)(
samples
[j]*
samples
[
i
]));
241
242
m_sum
[
i
] += ((
double
)
samples
[
i
]);
243
}
244
m_nped
++;
245
}
246
247
//----------------------------------------------------------------------------
248
void
LArAutoCorr::correl_zero
()
249
//----------------------------------------------------------------------------
250
{
251
int
j =0;
252
int
nsamples
=
m_sum
.size();
253
for
(
int
l
=0;
l
<
nsamples
;
l
++)
254
{
255
for
(
int
k
=
l
;
k
<
nsamples
;
k
++,j++)
256
m_matrix
[j] = 0;
257
m_sum
[
l
]=0;
258
}
259
m_nped
=0;
260
}
261
262
#endif
263
python.SystemOfUnits.s
int s
Definition:
SystemOfUnits.py:131
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
max
#define max(a, b)
Definition:
cfImp.cxx:41
LArAutoCorr::correl_zero
void correl_zero()
Definition:
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:248
UploadAMITag.l
list l
Definition:
UploadAMITag.larcaf.py:158
LArAutoCorr::m_cov_temp
std::vector< double > m_cov_temp
Definition:
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:56
const
bool const RAWDATA *ch2 const
Definition:
LArRodBlockPhysicsV0.cxx:562
LArAutoCorr::get_max
const short & get_max() const
Definition:
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:126
x
#define x
LArAutoCorr::m_sum
std::vector< double > m_sum
Definition:
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:49
LArAutoCorr::get_cov
const std::vector< double > & get_cov(int m_normalize, int m_phys)
Definition:
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:149
LArAutoCorr::~LArAutoCorr
~LArAutoCorr()
Definition:
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:72
LArAutoCorr::set_max
void set_max(const short max)
Definition:
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:104
LArAutoCorr::m_cov
std::vector< double > m_cov
Definition:
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:55
convertTimingResiduals.sum
sum
Definition:
convertTimingResiduals.py:55
lumiFormat.i
int i
Definition:
lumiFormat.py:92
01SubmitToGrid.samples
samples
Definition:
01SubmitToGrid.py:58
LArAutoCorr::set_min
void set_min(const short min)
Definition:
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:97
LArAutoCorr::add
void add(const std::vector< short > &samples, size_t maxnsamples)
Definition:
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:222
xAOD::double
double
Definition:
CompositeParticle_v1.cxx:159
LArAutoCorr::get_nentries
int get_nentries() const
Definition:
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:111
LArAutoCorr::get_mean
double get_mean() const
Definition:
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:134
min
#define min(a, b)
Definition:
cfImp.cxx:40
LArAutoCorr::m_max
short m_max
Definition:
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:46
LArAutoCorr::get_min
const short & get_min() const
Definition:
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:119
ReadOfcFromCool.nsamples
nsamples
Definition:
ReadOfcFromCool.py:115
LArAutoCorr::m_matrix
std::vector< double > m_matrix
Definition:
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:52
y
#define y
LArAutoCorr
Definition:
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:27
LArAutoCorr::m_min
short m_min
Definition:
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:43
LArAutoCorr::get_rms
double get_rms() const
Definition:
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:199
LArAutoCorr::LArAutoCorr
LArAutoCorr()
Definition:
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:64
LArAutoCorr::m_nped
int m_nped
Definition:
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:59
WriteCellNoiseToCool.noise
noise
Definition:
WriteCellNoiseToCool.py:380
fitman.k
k
Definition:
fitman.py:528
Generated on Thu Jul 4 2024 21:19:53 for ATLAS Offline Software by
1.8.18