ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TileCalorimeter
TileConditions
src
TileCondToolOfc.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// Tile includes
6
#include "
TileConditions/TileCondToolOfc.h
"
7
#include "
TileConditions/TileCablingService.h
"
8
#include "
TileConditions/TileCablingSvc.h
"
9
10
// Athena includes
11
#include "
AthenaKernel/errorcheck.h
"
12
13
14
//
15
//____________________________________________________________________
16
TileCondToolOfc::TileCondToolOfc
(
const
std::string&
type
,
const
std::string& name,
17
const
IInterface* parent)
18
: base_class(
type
, name, parent)
19
,
m_tileInfo
(nullptr)
20
{
21
declareProperty(
"nSamples"
,
m_nSamples
= 7,
"number of samples used in the run"
);
22
declareProperty(
"OptFilterDeltaCorrelation"
,
m_deltaCorrelation
=
false
23
,
"true=> use delta correlation; false=>use calculation obtained from data"
);
24
25
m_t0Sample
= (
m_nSamples
- 1) / 2;
26
}
27
28
//
29
//____________________________________________________________________
30
TileCondToolOfc::~TileCondToolOfc
() {
31
32
}
33
34
//
35
//____________________________________________________________________
36
StatusCode
TileCondToolOfc::initialize
() {
37
38
ATH_MSG_INFO
(
"In initialize()"
);
39
40
//=== Get TileCondToolPulseShape
41
ATH_CHECK
(
m_tileToolPulseShape
.retrieve() );
42
43
if
(!
m_deltaCorrelation
) {
44
ATH_CHECK
(
m_tileToolAutoCr
.retrieve());
45
}
else
{
46
m_tileToolAutoCr
.disable();
47
}
48
49
//==== TileInfo
50
ATH_CHECK
( detStore()->retrieve(
m_tileInfo
,
"TileInfo"
) );
51
52
if
(
m_nSamples
!=
m_tileInfo
->NdigitSamples()) {
53
ATH_MSG_WARNING
(
"Changing number of samples from "
<<
m_nSamples
54
<<
" to "
<<
m_tileInfo
->NdigitSamples() );
55
56
m_nSamples
=
m_tileInfo
->NdigitSamples();
57
}
else
{
58
ATH_MSG_INFO
(
"Number of samples is "
<<
m_nSamples
);
59
}
60
61
m_t0Sample
= (
m_nSamples
- 1) / 2;
62
if
(
m_t0Sample
!=
m_tileInfo
->ItrigSample()) {
63
ATH_MSG_WARNING
(
"Changing T0 sample from "
<<
m_t0Sample
64
<<
" to "
<<
m_tileInfo
->ItrigSample() );
65
66
m_t0Sample
=
m_tileInfo
->ItrigSample();
67
}
else
{
68
ATH_MSG_INFO
(
"T0 sample is "
<<
m_t0Sample
);
69
}
70
71
//=== Initialize max values
72
ServiceHandle<TileCablingSvc>
cablingSvc(
"TileCablingSvc"
, name());
73
ATH_CHECK
( cablingSvc.retrieve());
74
75
const
TileCablingService
* cabling = cablingSvc->cablingService();
76
if
(!cabling) {
77
ATH_MSG_ERROR
(
"Unable to retrieve TileCablingService"
);
78
return
StatusCode::FAILURE;
79
}
80
81
82
//--------------------------------------------------------
83
ATH_MSG_INFO
(
"TileCondToolOfc initialization completed. "
);
84
85
return
StatusCode::SUCCESS;
86
}
87
88
//
89
//____________________________________________________________________
90
StatusCode
TileCondToolOfc::finalize
() {
91
ATH_MSG_DEBUG
(
"TileCondToolOfc finalize called"
);
92
93
return
StatusCode::SUCCESS;
94
}
95
96
//
97
//____________________________________________________________________
98
100
StatusCode
TileCondToolOfc::getOfcWeights
(
unsigned
int
drawerIdx
101
,
unsigned
int
channel
102
,
unsigned
int
gain
103
,
float
& phase
104
,
bool
of2
105
,
TileOfcWeightsStruct
&
weights
106
,
const
EventContext& ctx)
const
107
{
108
ATH_MSG_DEBUG
(
"TileCondToolOfc weights, drawerIdx:"
<< drawerIdx
109
<<
" channel: "
<< channel
110
<<
" gain: "
<< gain
111
<<
" phase: "
<< phase );
112
113
std::fill (std::begin(
weights
.g), std::end(
weights
.g), 0);
114
std::fill (std::begin(
weights
.dg), std::end(
weights
.dg), 0);
115
std::fill (std::begin(
weights
.w_a), std::end(
weights
.w_a), 0);
116
std::fill (std::begin(
weights
.w_b), std::end(
weights
.w_b), 0);
117
std::fill (std::begin(
weights
.w_c), std::end(
weights
.w_c), 0);
118
119
120
CLHEP::HepMatrix Correlation(
m_nSamples
,
m_nSamples
, 1);
121
//aa , Inverse(m_nSamples,m_nSamples,0), Zero(m_nSamples,m_nSamples,0);
122
CLHEP::HepMatrix PulseShape(
m_nSamples
, 1, 0), DPulseShape(
m_nSamples
, 1, 0);
123
CLHEP::HepMatrix
a
(
m_nSamples
, 1, 0), b(
m_nSamples
, 1, 0);
124
125
126
//int ierr=0;
127
128
if
(msgLvl(MSG::DEBUG)) {
129
msg
(MSG::DEBUG) <<
" Calculating "
<< (of2 ?
"OF2"
:
"OF1"
) <<
" weights "
;
130
131
if
(
m_deltaCorrelation
)
132
msg
(MSG::DEBUG) <<
"with Delta correlation matrix "
<<
endmsg
;
133
else
134
msg
(MSG::DEBUG) <<
"with correlation matrix obtained from DB "
<<
endmsg
;
135
136
msg
(MSG::DEBUG) <<
"for drawerIdx= "
<< drawerIdx
137
<<
" channel="
<< channel
138
<<
" gain="
<< gain
139
<<
" phase "
<< phase <<
endmsg
;
140
}
141
142
int
npr = 2;
143
if
(of2) npr = 3;
144
weights
.n_samples =
m_nSamples
;
145
weights
.of2 = of2;
146
147
if
(!
m_deltaCorrelation
) {
//=== Retrieve autocorrelations from COOL DB
148
std::vector<float> vecAutoCr;
149
m_tileToolAutoCr
->getAutoCorr(drawerIdx, channel, gain, vecAutoCr);
150
151
ATH_MSG_DEBUG
(
" vecAutoCr size: "
<< vecAutoCr.size() );
152
ATH_MSG_VERBOSE
(
" vecAutoCr "
<< vecAutoCr );
153
if
(vecAutoCr[0] > -1233.){
154
if
(vecAutoCr.size() == 28){
155
int
AutoCrPosition = 0;
156
for
(
int
i = 0; i <
m_nSamples
; ++i)
157
for
(
int
j = i; j <
m_nSamples
; ++j){
158
Correlation[i][j] = vecAutoCr[AutoCrPosition];
159
Correlation[j][i] = vecAutoCr[AutoCrPosition];
160
++AutoCrPosition;
161
}
162
}
else
{
163
for
(
int
i = 0; i <
m_nSamples
; i++)
164
Correlation[i][i] = 1.;
165
for
(
int
i = 0; i <
m_nSamples
- 1; i++) {
// Fill non-diag. elements
166
for
(
int
j = 0; j <
m_nSamples
- i - 1; j++) {
167
Correlation[i][j + i + 1] = vecAutoCr[j];
168
Correlation[j + i + 1][i] = vecAutoCr[j];
169
}
170
}
171
}
172
}
173
}
174
175
ATH_MSG_VERBOSE
(
" Correlation: "
<< Correlation );
176
177
float
py = 0.;
178
float
pdy = 0.;
179
//if (ierr==0)
180
181
{
182
for
(
int
i = 0; i <
m_nSamples
; i++) {
183
m_tileToolPulseShape
->getPulseShapeYDY(drawerIdx, channel, gain
184
, phase + 25 * (i -
m_t0Sample
), py, pdy, ctx);
185
186
// If overflow/underflow using boundary value of y and dy=0, OF affected when the number of samples is high. Set y=0 and dy=0 for OF weights computation
187
if
( (phase + 25 * (i -
m_t0Sample
) < -150) || (phase + 25 * (i -
m_t0Sample
) > 150) ){
188
py=0;
189
pdy=0;
190
}
191
192
193
PulseShape[i][0] = py;
194
DPulseShape[i][0] = pdy;
195
weights
.g[i] = PulseShape[i][0];
196
weights
.dg[i] = DPulseShape[i][0];
197
198
ATH_MSG_VERBOSE
(
" Pulse shape: isamp "
<< i
199
<<
" phase "
<< phase
200
<<
" py "
<< py
201
<<
" pdy "
<< pdy );
202
203
}
204
205
// Build System Matrix with Correlations and pulse function points
206
207
CLHEP::HepMatrix SystemMatrix(
m_nSamples
+ npr,
m_nSamples
+ npr, 0);
208
CLHEP::HepVector
Result
(
m_nSamples
+ npr, 0);
209
CLHEP::HepVector IndependTermsAmp(
m_nSamples
+ npr, 0);
210
CLHEP::HepVector IndependTermsTime(
m_nSamples
+ npr, 0);
211
CLHEP::HepVector IndependTermsPed(
m_nSamples
+ npr, 0);
212
213
for
(
int
i = 0; i <
m_nSamples
; i++) {
214
for
(
int
j = 0; j <
m_nSamples
; j++) {
215
SystemMatrix[i][j] = Correlation[i][j];
216
}
217
218
SystemMatrix[
m_nSamples
][i] = PulseShape[i][0];
219
SystemMatrix[i][
m_nSamples
] = PulseShape[i][0];
220
221
SystemMatrix[
m_nSamples
+ 1][i] = DPulseShape[i][0];
222
SystemMatrix[i][
m_nSamples
+ 1] = DPulseShape[i][0];
223
224
if
(of2) {
225
SystemMatrix[
m_nSamples
+ 2][i] = 1.;
226
SystemMatrix[i][
m_nSamples
+ 2] = 1.;
227
}
228
}
229
230
IndependTermsAmp[
m_nSamples
] = 1.;
231
IndependTermsTime[
m_nSamples
+ 1] = -1.;
232
233
if
(of2) IndependTermsPed[
m_nSamples
+ 2] = 1.;
234
235
Result
= solve(SystemMatrix, IndependTermsAmp);
236
237
for
(
int
ismp = 0; ismp <
m_nSamples
; ismp++) {
238
weights
.w_a[ismp] = (double)
Result
[ismp];
239
// ATH_MSG_DEBUG( "w_a " << weights.w_a[ismp] << " ismp " << ismp );
240
241
}
242
243
Result
= solve(SystemMatrix, IndependTermsTime);
244
245
for
(
int
ismp = 0; ismp <
m_nSamples
; ismp++) {
246
weights
.w_b[ismp] = (double)
Result
[ismp];
247
// ATH_MSG_DEBUG( "w_b " << weights.w_b[ismp] << " ismp " << ismp );
248
}
249
250
if
(of2) {
// OF2
251
Result
= solve(SystemMatrix, IndependTermsPed);
252
253
for
(
int
ismp = 0; ismp <
m_nSamples
; ismp++) {
254
weights
.w_c[ismp] = (double)
Result
[ismp];
255
// ATH_MSG_DEBUG( "w_c " << weights.w_c[ismp] << " ismp " << ismp );
256
}
257
}
258
259
}
260
261
#if 0
262
else
{
263
for
(
int
ismp=0; ismp<
m_nSamples
; ismp++) {
264
weights
.w_a[ismp] = 0.;
265
weights
.w_b[ismp] = 0.;
266
weights
.w_c[ismp] = 0.;
267
weights
.g[ismp] = 0.;
268
weights
.dg[ismp] = 0.;
269
}
270
}
271
#endif
272
273
ATH_MSG_DEBUG
(
"...OFC weights fixed-phase calculated"
);
274
275
return
StatusCode::SUCCESS;
276
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
Result
ICscStripFitter::Result Result
Definition
CalibCscStripFitter.cxx:13
errorcheck.h
Helpers for checking error return status codes and reporting errors.
a
static Double_t a
Definition
LArPhysWaveHECTool.cxx:38
TileCablingService.h
TileCablingSvc.h
TileCondToolOfc.h
ServiceHandle
Definition
ClusterMakerTool.h:36
TileCablingService
Definition
TileCablingService.h:23
TileCondToolOfc::initialize
virtual StatusCode initialize() override
Definition
TileCondToolOfc.cxx:36
TileCondToolOfc::~TileCondToolOfc
virtual ~TileCondToolOfc()
Definition
TileCondToolOfc.cxx:30
TileCondToolOfc::TileCondToolOfc
TileCondToolOfc(const std::string &type, const std::string &name, const IInterface *parent)
Definition
TileCondToolOfc.cxx:16
TileCondToolOfc::m_deltaCorrelation
bool m_deltaCorrelation
Definition
TileCondToolOfc.h:74
TileCondToolOfc::m_nSamples
int m_nSamples
Definition
TileCondToolOfc.h:72
TileCondToolOfc::finalize
virtual StatusCode finalize() override
Definition
TileCondToolOfc.cxx:90
TileCondToolOfc::m_tileToolAutoCr
ToolHandle< TileCondToolAutoCr > m_tileToolAutoCr
Definition
TileCondToolOfc.h:66
TileCondToolOfc::m_t0Sample
int m_t0Sample
Definition
TileCondToolOfc.h:73
TileCondToolOfc::m_tileToolPulseShape
ToolHandle< TileCondToolPulseShape > m_tileToolPulseShape
Definition
TileCondToolOfc.h:63
TileCondToolOfc::m_tileInfo
const TileInfo * m_tileInfo
Definition
TileCondToolOfc.h:69
TileCondToolOfc::getOfcWeights
virtual StatusCode getOfcWeights(unsigned int drawerIdx, unsigned int channel, unsigned int adc, float &phase, bool of2, TileOfcWeightsStruct &weights, const EventContext &ctx) const override
Definition
TileCondToolOfc.cxx:100
type
Result
Definition
fbtTestBasics.cxx:50
TileOfcWeightsStruct
Definition
ITileCondToolOfc.h:13
weights
Definition
herwig7_interface.h:38
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0