ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArRawEvent
src
LArAutoCorr.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: LArAutoCorr.cxx
8
PACKAGE: offline/LArCalorimeter/LArRawEvent
9
10
AUTHORS: F.Tarrade
11
CREATED: Jan. 22th 2009
12
13
PURPOSE: Intermediate object used to handle data
14
to be used for calculation of autocorrelation
15
elements.
16
17
********************************************************************/
18
// Include files
19
#include "
LArRawEvent/LArAutoCorr.h
"
20
21
//----------------------------------------------------------------------------
22
void
LArAutoCorr::set_min
(
const
short
min
)
23
//----------------------------------------------------------------------------
24
{
25
m_min
=
min
;
26
}
27
28
//----------------------------------------------------------------------------
29
void
LArAutoCorr::set_max
(
const
short
max
)
30
//----------------------------------------------------------------------------
31
{
32
m_max
=
max
;
33
}
34
35
//----------------------------------------------------------------------------
36
int
LArAutoCorr::get_nentries
()
const
37
//----------------------------------------------------------------------------
38
{
39
return
m_nped
;
40
}
41
42
43
//----------------------------------------------------------------------------
44
const
short
&
LArAutoCorr::get_min
()
const
45
//----------------------------------------------------------------------------
46
{
47
return
m_min
;
48
}
49
50
//----------------------------------------------------------------------------
51
const
short
&
LArAutoCorr::get_max
()
const
52
//----------------------------------------------------------------------------
53
{
54
return
m_max
;
55
}
56
57
58
//----------------------------------------------------------------------------
59
double
LArAutoCorr::get_mean
()
const
60
//----------------------------------------------------------------------------
61
{
62
double
mean
= 0;
63
64
int
nsamples
=
m_sum
.size();
65
for
(
int
i=0;
i
<
nsamples
;
i
++)
66
mean
+=
m_sum
[i];
67
mean
/= ((
double
)(
nsamples
*
m_nped
));
68
69
return
mean
;
70
}
71
72
73
//----------------------------------------------------------------------------
74
const
std::vector<double> &
LArAutoCorr::get_cov
(
int
normalize
,
int
phys)
75
//----------------------------------------------------------------------------
76
{
77
int
nsamples
=
m_sum
.size();
78
int
k
=0;
79
if
(
m_nped
==0)
return
m_cov
;
80
for
(
int
i=0;
i
<
nsamples
;
i
++){
81
for
(
int
j=i;
j
<
nsamples
;
j
++,
k
++)
82
m_cov_temp
[k]= (
double
)((
m_matrix
[
k
]/(
m_nped
)) - ((
m_sum
[
i
]*
m_sum
[
j
])/(
m_nped
*
m_nped
)));
83
}
84
85
//MGV normalize covariance elements if required
86
if
(
normalize
== 1 && phys == 0 ){
87
k
=0;
88
int
si,sj;
89
si=0;
90
for
(
int
i=0;
i
<
nsamples
;
i
++){
91
sj=si;
92
for
(
int
j=i;
j
<
nsamples
;
j
++,
k
++) {
93
if
(
m_sum
[i]!=.0 &&
m_sum
[j]!=.0)
94
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
)));
95
sj+=
nsamples
-
j
;
96
}
97
si+=
nsamples
-
i
;
98
}
99
}
100
//MGV
101
102
if
(phys==0) {
103
double
sum
;
104
int
s
;
105
for
(
int
diag =1;diag<
nsamples
;diag++)
106
{
107
sum
=0;
108
s
= 0;
109
for
(
int
i=0;
i
<
nsamples
-diag;
i
++)
110
{
111
sum
+=
m_cov_temp
[
s
+ diag];
112
s
+=
nsamples
-
i
;
113
}
114
sum
=
sum
/(
nsamples
-diag);
115
m_cov
[diag-1]=
sum
;
116
}
117
return
m_cov
;
118
}
119
else
120
return
m_cov_temp
;
121
}
122
123
//----------------------------------------------------------------------------
124
double
LArAutoCorr::get_rms
()
const
125
//----------------------------------------------------------------------------
126
{
127
double
x
=0,
y
=0;
128
int
k
= 0;
129
int
nsamples
=
m_sum
.size();
130
131
for
(
int
i=0;
i
<
nsamples
;
i
++)
132
{
133
x
+=
m_sum
[
i
];
134
y
+=
m_matrix
[
k
];
135
k
+=
nsamples
-
i
;
// Index of diagonal element
136
}
137
138
x
/= (
double
) (nsamples*
m_nped
);
139
y
/=(
double
) (nsamples*
m_nped
);
140
141
double
noise
= sqrt(
y
-
x
*
x
);
142
143
return
noise
;
144
}
145
146
//----------------------------------------------------------------------------
147
void
LArAutoCorr::add
(
const
std::vector<short>& samples,
size_t
maxnsamples)
148
//----------------------------------------------------------------------------
149
{
150
unsigned
int
nsamples
= std::min(samples.size(),maxnsamples);
151
int
k
=0;
152
153
if
(
m_sum
.size()<nsamples)
154
{
155
156
m_cov
.resize(nsamples - 1);
157
m_cov_temp
.resize((nsamples*(nsamples+1))/2);
158
m_sum
.resize(nsamples);
159
m_matrix
.resize((nsamples*(nsamples+1))/2);
160
}
161
162
for
(
unsigned
int
i=0;
i
<
nsamples
;
i
++)
163
{
164
for
(
unsigned
int
j=i;
j
<
nsamples
;
j
++,
k
++)
165
m_matrix
[k] += ((
double
)(samples[j]*samples[i]));
166
167
m_sum
[
i
] += ((
double
) samples[
i
]);
168
}
169
m_nped
++;
170
}
171
172
//----------------------------------------------------------------------------
173
void
LArAutoCorr::correl_zero
()
174
//----------------------------------------------------------------------------
175
{
176
int
j
=0;
177
int
nsamples
=
m_sum
.size();
178
for
(
int
l=0;
l
<
nsamples
;
l
++)
179
{
180
for
(
int
k=l;
k
<
nsamples
;
k
++,
j
++)
181
m_matrix
[j] = 0;
182
m_sum
[
l
]=0;
183
}
184
m_nped
=0;
185
}
normalize
Double_t normalize(TF1 *func, Double_t *rampl=NULL, Double_t from=0., Double_t to=0., Double_t step=1.)
Definition
LArPhysWaveHECTool.cxx:825
LArAutoCorr.h
y
#define y
x
#define x
min
#define min(a, b)
Definition
cfImp.cxx:40
max
#define max(a, b)
Definition
cfImp.cxx:41
LArAutoCorr::get_max
const short & get_max() const
Definition
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:126
LArAutoCorr::set_max
void set_max(const short max)
Definition
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:104
LArAutoCorr::get_nentries
int get_nentries() const
Definition
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:111
LArAutoCorr::get_cov
const std::vector< double > & get_cov(int m_normalize, int m_phys)
Definition
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:149
LArAutoCorr::m_nped
int m_nped
Definition
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:47
LArAutoCorr::m_sum
std::vector< double > m_sum
Definition
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:37
LArAutoCorr::get_mean
double get_mean() const
Definition
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:134
LArAutoCorr::get_rms
double get_rms() const
Definition
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:199
LArAutoCorr::m_min
short m_min
Definition
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:31
LArAutoCorr::get_min
const short & get_min() const
Definition
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:119
LArAutoCorr::set_min
void set_min(const short min)
Definition
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:97
LArAutoCorr::m_cov_temp
std::vector< double > m_cov_temp
Definition
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:44
LArAutoCorr::m_max
short m_max
Definition
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:34
LArAutoCorr::m_cov
std::vector< double > m_cov
Definition
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:43
LArAutoCorr::m_matrix
std::vector< double > m_matrix
Definition
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:40
LArAutoCorr::correl_zero
void correl_zero()
Definition
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:248
LArAutoCorr::add
void add(const std::vector< short > &samples, size_t maxnsamples)
Definition
LArCalibUtils/LArCalibUtils/LArAutoCorr.h:222
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
PrintTrkAnaSummary.l
l
Printing final latex table to .tex output file.
Definition
PrintTrkAnaSummary.py:370
ReadOfcFromCrest.nsamples
nsamples
Definition
ReadOfcFromCrest.py:129
TauHitVars::j
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
Definition
ConstituentLoaderTauHit.cxx:102
WriteCellNoiseToCrest.noise
noise
Definition
WriteCellNoiseToCrest.py:405
convertTimingResiduals.sum
int sum
Definition
convertTimingResiduals.py:55
fitman.k
k
Definition
fitman.py:528
lumiFormat.i
int i
Definition
lumiFormat.py:85
python.SystemOfUnits.s
float s
Definition
SystemOfUnits.py:147
xAOD::double
double
Definition
CompositeParticle_v1.cxx:159
Generated on
for ATLAS Offline Software by
1.17.0