ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArCnv
LArByteStream
src
LArRodBlockCalibrationV3.cxx
Go to the documentation of this file.
1
//Dear emacs, this is -*- c++ -*-
2
3
/*
4
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
5
*/
6
7
// Implementation of a LArRODBlockStructure class
8
// This version contains LArDigits in fixed gain.
9
// See .h file for more details.
10
11
#include "GaudiKernel/MsgStream.h"
12
#include "
AthenaKernel/getMessageSvc.h
"
13
#include "
LArByteStream/LArRodBlockCalibrationV3.h
"
14
#include <iostream>
15
16
#ifdef LARBSDBGOUTPUT
17
#define LARBSDBG(text) logstr<<MSG::DEBUG<<text<<endmsg
18
#else
19
#define LARBSDBG(text)
20
#endif
21
22
23
LArRodBlockCalibrationV3::LArRodBlockCalibrationV3
(IMessageSvc* msgSvc)
24
:
LArRodBlockStructure
(msgSvc,
BlockType
())
25
{
26
m_iHeadBlockSize
=
endtag
/2;
// The implicit cast rounds down to the right size
27
m_fixedGain
=
CaloGain::LARNGAIN
;
28
LArRodBlockCalibrationV3::resetPointers
();
29
}
30
31
// clear temporary block vectors
32
void
LArRodBlockCalibrationV3::clearBlocks
()
33
{
34
m_RawDataBlock
.clear();
35
}
36
37
void
LArRodBlockCalibrationV3::resetPointers
()
38
{
39
m_Result1Counter
=0;
40
m_Result1Index
=0;
41
m_Result2Counter
=0;
42
m_Result2Index
=0;
43
m_RawDataCounter
=0;
44
m_RawDataIndex
=0;
45
46
}
47
48
49
uint8_t
LArRodBlockCalibrationV3::getTDCPhase
()
const
50
{
51
return
(
getHeader16
(
NSamples
)>>8);
52
}
53
54
55
56
57
int
LArRodBlockCalibrationV3::getNextRawData
(
int
& channelNumber, std::vector<short>& samples, uint32_t& gain)
58
{
59
#ifdef LARBSDBGOUTPUT
60
MsgStream logstr(
Athena::getMessageSvc
(),
BlockType
());
61
#endif
62
if
(
m_RawDataCounter
>=
m_channelsPerFEB
) {
//Already beyond maximal number of channels
63
LARBSDBG
(
"Maximum number of channels reached"
);
64
return
0;
65
}
66
const
uint16_t block =
getHeader16
(
RawDataBlkOff
);
67
if
(!block) {
//Block does not exist
68
LARBSDBG
(
"No Raw Data Block in this FEB"
);
69
return
0;
70
}
71
//The m_RawDataChannel keeps track of the last read channel
72
73
// Get next channel
74
channelNumber=
m_RawDataCounter
;
75
uint32_t febgain;
76
const
unsigned
int
nsamples =
getHeader16
(
NSamples
) & 0xff;
77
const
unsigned
int
ngains =
getHeader16
(
NGains
);
78
if
(ngains==0 || nsamples==0)
return
0;
79
// Loop over gains to look for m_fixedGain
80
unsigned
int
this_gain=0;
81
int
offset;
82
LARBSDBG
(
" ===> fixedGain= "
<<
m_fixedGain
<<
" CaloGain = "
<<
CaloGain::LARNGAIN
);
83
if
(
m_fixedGain
!=
CaloGain::LARNGAIN
) {
//Fixed gain: Search for gain
84
offset=block + 8 + ((channelNumber&0x3F)>>3) + ((channelNumber & 0x7)<<3);
85
for
(this_gain=0;this_gain<ngains;this_gain++) {
86
int
index
= offset + 64*this_gain;
87
uint32_t
x
=
m_FebBlock
[
index
];
88
if
(channelNumber>=64)
89
x
= (
x
& 0x3000) >> 12;
90
else
91
x
= (
x
& 0x30000000) >> 28;
92
unsigned
data_gain =
RawToOfflineGain
(
x
);
93
if
(data_gain==
m_fixedGain
)
break
;
94
}
95
}
96
if
(this_gain<ngains) {
//Gain found in this fragment
97
int
s_size = 8 + 64 * ngains;
// Size of one sample block 16 RADD of 16 bit + 128 channels (16 bit data)
98
offset = block + 8 + ((channelNumber&0x3F)>>3) + ((channelNumber & 0x7)<<3) + 64*this_gain;
99
int
index
= offset;
100
uint32_t
x
=
m_FebBlock
[
index
];
101
if
(channelNumber>=64) {
//low channels on lower bits
102
// First decode gain
103
febgain = (
x
& 0x3000) >> 12;
// gain on bits 12 and 13
104
// Than samples
105
for
(
unsigned
int
s=0;s<nsamples;s++) {
106
index
= offset + s*s_size;
107
x
=
m_FebBlock
[
index
];
108
samples.push_back((
short
) (
x
& 0x0fff));
// sample on bits 0 to 11
109
}
110
}
else
{
//high channels on higher bits
111
// First decode gain
112
febgain = (
x
& 0x30000000) >> 28;
// gain on bits 12 and 13
113
// Than samples
114
for
(
unsigned
int
s=0;s<nsamples;s++) {
115
index
= offset + s*s_size;
116
x
= (
m_FebBlock
[
index
]) >> 16;
117
samples.push_back((
short
) (
x
& 0x0fff));
// sample on bits 0 to 11
118
}
119
}
120
gain=
RawToOfflineGain
(febgain);
121
}
122
++
m_RawDataCounter
;
123
unsigned
rearrangeFirstSample=0;
124
if
(
m_rearrangeFirstSample
)
125
rearrangeFirstSample=
m_rearrangeFirstSample
;
//Overwrite by jobOptions
126
else
127
rearrangeFirstSample=
getFirstSampleIndex
();
128
if
(rearrangeFirstSample && rearrangeFirstSample<samples.size())
//FIXME: Very ugly hack! See explanation in LArRodDecoder.h file
129
{
//Change e.g. 3 0 1 2 4 to 0 1 2 3 4
130
short
movedSample=samples[0];
131
for
(
unsigned
i=1;i<=rearrangeFirstSample;i++)
132
samples[i-1]=samples[i];
133
samples[rearrangeFirstSample]=movedSample;
134
}
135
LARBSDBG
(
"GetNextRawData for FEB finished 0x"
<< MSG::hex << (uint32_t)
getHeader32
(
FEBID
) << MSG::dec);
136
return
1;
137
}
138
139
140
141
int
LArRodBlockCalibrationV3::getNextAccumulatedCalibDigit
(
int
& channelNumber, std::vector < uint64_t >& samplesSum , std::vector < uint64_t >& samples2Sum, uint32_t&
/*idummy*/
, uint32_t& gain )
142
{
143
#ifdef LARBSDBGOUTPUT
144
MsgStream logstr(
Athena::getMessageSvc
(),
BlockType
());
145
#endif
146
//Debug output
147
LARBSDBG
(
"m_Result1Counter"
<<
m_Result1Counter
<<
" m_Result1Index="
<<
m_Result1Index
148
<<
" m_channelsPerFEB="
<<
m_channelsPerFEB
);
149
LARBSDBG
(
"requested gain= "
<<
m_fixedGain
);
150
if
(
m_Result1Counter
>=
m_channelsPerFEB
) {
//Already beyond maximal number of channels
151
LARBSDBG
(
"Maximum number of channels reached"
);
152
return
0;
153
}
154
const
uint16_t block =
getHeader16
(
ResultsOff1
);
//Position of the AccumulatedCalibDigits FEB data block
155
if
(!block) {
//Block does not exist
156
LARBSDBG
(
"No Accumulated Calib Digit Block in this FEB"
);
157
return
0;
158
}
159
//The m_Result1Channel keeps track of the last read channel
160
161
// Get next channel
162
channelNumber=
m_Result1Counter
;
163
// This is just for fun; these data are not stored here but in RodBlockDecoder.cxx
164
// IWS 08.08.2005 This part is useless in fact - just for debugging
165
const
unsigned
int
nsamples =
getHeader16
(
NSamples
);
166
const
unsigned
int
ngains =
getHeader16
(
NGains
);
167
168
const
unsigned
int
FebConfig
= (int)
getFebConfig
();
169
if
(ngains==0 || nsamples==0)
return
0;
170
// Loop over gains to look for m_fixedGain
171
int
offset;
172
uint32_t
x
,x2;
173
uint32_t febgain;
174
175
if
(
FebConfig
==0 ||
FebConfig
>3) {
176
// to be done better when this is understood
177
febgain=1;
178
gain=
RawToOfflineGain
(febgain);
179
if
(
m_fixedGain
!=
CaloGain::LARNGAIN
&& gain!=
m_fixedGain
)
180
gain=
m_fixedGain
;
181
182
}
else
{
183
febgain=
FebConfig
&0x3;
184
gain=
RawToOfflineGain
(febgain);
185
}
186
187
if
(
m_fixedGain
!=
CaloGain::LARNGAIN
&& gain!=
m_fixedGain
) {
188
LARBSDBG
(
"Requested gain: "
<<
m_fixedGain
<<
" got "
<< gain <<
" data ingored."
);
189
return
0;
190
}
191
192
// nsamples*2 for Sum + Sum2
193
// 12 is the size of the calibration header
194
offset=block + 12 + (channelNumber&0x7F)*(nsamples*2);
// needs to be updated for loop on gains
195
uint32_t
index
=offset;
196
197
samplesSum.resize(nsamples);
198
samples2Sum.resize(nsamples);
199
200
for
(
size_t
i=0;i<nsamples;++i) {
201
x
=
m_FebBlock
[
index
];
202
x2=
m_FebBlock
[
index
+1];
203
204
samplesSum[i]=
x
;
205
samples2Sum[i]=x2;
206
index
+=2;
207
}
208
209
++
m_Result1Counter
;
210
return
1;
211
}
212
213
214
uint32_t
LArRodBlockCalibrationV3::getNumberOfSamples
()
const
215
{
216
return
getHeader16
(
NSamples
);
217
}
218
219
uint32_t
LArRodBlockCalibrationV3::getNumberOfGains
()
const
220
{
221
return
getHeader16
(
NGains
);
222
}
223
224
uint16_t
LArRodBlockCalibrationV3::getNTrigger
()
const
225
{
226
227
int
index
=
getHeader16
(
ResultsOff1
);
228
uint32_t
x
=
m_FebBlock
[
index
+
NTrigger
/2];
229
return
(uint16_t)
x
;
230
}
231
232
uint16_t
LArRodBlockCalibrationV3::getDAC
()
const
233
{
234
int
index
=
getHeader16
(
ResultsOff1
);
235
uint32_t
x
=
m_FebBlock
[
index
+
Dac
/2];
236
return
(uint16_t)
x
;
237
}
238
239
uint16_t
LArRodBlockCalibrationV3::getDelay
()
const
240
{
241
int
index
=
getHeader16
(
ResultsOff1
);
242
uint32_t
x
=
m_FebBlock
[
index
+
Delay
/2];
243
return
(uint32_t)
x
;
244
}
245
246
uint16_t
LArRodBlockCalibrationV3::getStepIndex
()
const
247
{
248
int
index
=
getHeader16
(
ResultsOff1
);
249
uint32_t
x
=
m_FebBlock
[
index
+
StepIndex
/2]&0xffff;
250
return
(uint16_t)
x
;
251
}
252
253
uint16_t
LArRodBlockCalibrationV3::getResults1Size
()
const
254
{
255
return
getHeader16
(
ResultsDim1
);
256
}
257
258
uint16_t
LArRodBlockCalibrationV3::getResults2Size
()
const
259
{
260
return
getHeader16
(
ResultsDim2
);
261
}
262
263
uint16_t
LArRodBlockCalibrationV3::getRawDataSize
()
const
264
{
265
return
getHeader16
(
RawDataBlkDim
);
266
}
267
268
uint16_t
LArRodBlockCalibrationV3::getNStep
()
const
269
{
270
int
index
=
getHeader16
(
ResultsOff1
);
271
uint32_t
x
=
m_FebBlock
[
index
+
StepIndex
/2]>>16;
272
return
(uint16_t)
x
;
273
}
274
275
uint32_t
LArRodBlockCalibrationV3::getRadd
(uint32_t adc, uint32_t sample)
const
276
{
277
int
ngain=
getHeader16
(
NGains
);
278
int
index
=
getHeader16
(
RawDataBlkOff
);
279
if
(
index
<=0)
return
0;
280
index
+=(8+64*ngain)*sample+adc/2;
281
uint32_t
x
=
m_FebBlock
[
index
];
282
if
(adc&0x1)
return
x
>>16;
283
return
x
&0xffff;
284
}
285
286
uint16_t
LArRodBlockCalibrationV3::getCtrl1
(uint32_t adc)
const
287
{
288
int
index
=
getHeader16
(
RawDataBlkOff
)-16+adc/2;
289
uint32_t
x
=
m_FebBlock
[
index
];
290
if
(adc&0x1)
x
=
x
>>16;
291
else
x
=
x
&0xffff;
292
uint16_t ctrl=
x
;
293
return
ctrl;
294
}
295
296
uint16_t
LArRodBlockCalibrationV3::getCtrl2
(uint32_t adc)
const
297
{
298
int
index
=
getHeader16
(
RawDataBlkOff
)-8+adc/2;
299
uint32_t
x
=
m_FebBlock
[
index
];
300
if
(adc&0x1)
x
=
x
>>16;
301
else
x
=
x
&0xffff;
302
uint16_t ctrl=
x
;
303
return
ctrl;
304
}
305
306
uint16_t
LArRodBlockCalibrationV3::getCtrl3
(uint32_t adc)
const
307
{
308
int
nsamples=
getHeader16
(
NSamples
);
309
int
ngains=
getHeader16
(
NGains
);
310
int
offset=nsamples*(8+64*ngains)+adc/2;
311
int
index
=
getHeader16
(
RawDataBlkOff
)+offset;
312
uint32_t
x
=
m_FebBlock
[
index
];
313
if
(adc&0x1)
x
=
x
>>16;
314
else
x
=
x
&0xffff;
315
uint16_t ctrl=
x
;
316
return
ctrl;
317
}
318
319
uint32_t
LArRodBlockCalibrationV3::getStatus
()
const
320
{
321
// Get Dsp status word
322
if
(
getNumberOfWords
()<
EventStatus
/2)
return
0;
323
uint32_t
x
=
getHeader32
(
EventStatus
);
324
return
x
;
325
}
326
327
328
#ifdef LARBSDBGOUTPUT
329
#undef LARBSDBGOUTPUT
330
#endif
331
#undef LARBSDBG
LArRodBlockCalibrationV3.h
LARBSDBG
#define LARBSDBG(text)
This class provides decoding/encoding from/to ROD format.
Definition
LArRodBlockPhysicsV0.h:43
x
#define x
LArRodBlockCalibrationV3::m_fixedGain
unsigned m_fixedGain
Definition
LArRodBlockCalibrationV3.h:123
LArRodBlockCalibrationV3::getTDCPhase
virtual uint8_t getTDCPhase() const
Definition
LArRodBlockCalibrationV3.cxx:49
LArRodBlockCalibrationV3::resetPointers
virtual void resetPointers()
Definition
LArRodBlockCalibrationV3.cxx:37
LArRodBlockCalibrationV3::getStepIndex
uint16_t getStepIndex() const
Definition
LArRodBlockCalibrationV3.cxx:246
LArRodBlockCalibrationV3::m_Result2Counter
int m_Result2Counter
Definition
LArRodBlockCalibrationV3.h:118
LArRodBlockCalibrationV3::getFirstSampleIndex
uint16_t getFirstSampleIndex() const
Definition
LArRodBlockCalibrationV3.h:153
LArRodBlockCalibrationV3::LArRodBlockCalibrationV3
LArRodBlockCalibrationV3(IMessageSvc *msgSvc)
Definition
LArRodBlockCalibrationV3.cxx:23
LArRodBlockCalibrationV3::m_Result2Index
int m_Result2Index
Definition
LArRodBlockCalibrationV3.h:119
LArRodBlockCalibrationV3::FebConfig
@ FebConfig
Definition
LArRodBlockCalibrationV3.h:45
LArRodBlockCalibrationV3::NSamples
@ NSamples
Definition
LArRodBlockCalibrationV3.h:43
LArRodBlockCalibrationV3::FEBID
@ FEBID
Definition
LArRodBlockCalibrationV3.h:30
LArRodBlockCalibrationV3::RawDataBlkDim
@ RawDataBlkDim
Definition
LArRodBlockCalibrationV3.h:39
LArRodBlockCalibrationV3::NGains
@ NGains
Definition
LArRodBlockCalibrationV3.h:42
LArRodBlockCalibrationV3::ResultsDim1
@ ResultsDim1
Definition
LArRodBlockCalibrationV3.h:35
LArRodBlockCalibrationV3::RawDataBlkOff
@ RawDataBlkOff
Definition
LArRodBlockCalibrationV3.h:38
LArRodBlockCalibrationV3::ResultsOff1
@ ResultsOff1
Definition
LArRodBlockCalibrationV3.h:34
LArRodBlockCalibrationV3::ResultsDim2
@ ResultsDim2
Definition
LArRodBlockCalibrationV3.h:37
LArRodBlockCalibrationV3::EventStatus
@ EventStatus
Definition
LArRodBlockCalibrationV3.h:40
LArRodBlockCalibrationV3::endtag
@ endtag
Definition
LArRodBlockCalibrationV3.h:48
LArRodBlockCalibrationV3::m_Result1Counter
int m_Result1Counter
Definition
LArRodBlockCalibrationV3.h:116
LArRodBlockCalibrationV3::getRadd
virtual uint32_t getRadd(uint32_t adc, uint32_t sample) const
Definition
LArRodBlockCalibrationV3.cxx:275
LArRodBlockCalibrationV3::getDelay
uint16_t getDelay() const
Definition
LArRodBlockCalibrationV3.cxx:239
LArRodBlockCalibrationV3::m_RawDataCounter
int m_RawDataCounter
Definition
LArRodBlockCalibrationV3.h:120
LArRodBlockCalibrationV3::getResults1Size
virtual uint16_t getResults1Size() const
Definition
LArRodBlockCalibrationV3.cxx:253
LArRodBlockCalibrationV3::m_Result1Index
int m_Result1Index
Definition
LArRodBlockCalibrationV3.h:117
LArRodBlockCalibrationV3::getFebConfig
uint16_t getFebConfig() const
Definition
LArRodBlockCalibrationV3.h:148
LArRodBlockCalibrationV3::getRawDataSize
virtual uint16_t getRawDataSize() const
Definition
LArRodBlockCalibrationV3.cxx:263
LArRodBlockCalibrationV3::getNextAccumulatedCalibDigit
virtual int getNextAccumulatedCalibDigit(int &channelNumber, std::vector< uint64_t > &samplesSum, std::vector< uint64_t > &samples2Sum, uint32_t &iStepTrigger, uint32_t &gain)
Definition
LArRodBlockCalibrationV3.cxx:141
LArRodBlockCalibrationV3::getStatus
virtual uint32_t getStatus() const
Definition
LArRodBlockCalibrationV3.cxx:319
LArRodBlockCalibrationV3::getNumberOfSamples
virtual uint32_t getNumberOfSamples() const
Definition
LArRodBlockCalibrationV3.cxx:214
LArRodBlockCalibrationV3::BlockType
static std::string BlockType()
Definition
LArRodBlockCalibrationV3.h:80
LArRodBlockCalibrationV3::clearBlocks
void clearBlocks()
Definition
LArRodBlockCalibrationV3.cxx:32
LArRodBlockCalibrationV3::m_RawDataIndex
int m_RawDataIndex
Definition
LArRodBlockCalibrationV3.h:121
LArRodBlockCalibrationV3::getNTrigger
uint16_t getNTrigger() const
Definition
LArRodBlockCalibrationV3.cxx:224
LArRodBlockCalibrationV3::getCtrl1
virtual uint16_t getCtrl1(uint32_t adc) const
Definition
LArRodBlockCalibrationV3.cxx:286
LArRodBlockCalibrationV3::getNextRawData
virtual int getNextRawData(int &channelNumber, std::vector< short > &samples, uint32_t &gain)
Definition
LArRodBlockCalibrationV3.cxx:57
LArRodBlockCalibrationV3::getNumberOfGains
virtual uint32_t getNumberOfGains() const
Definition
LArRodBlockCalibrationV3.cxx:219
LArRodBlockCalibrationV3::getCtrl2
virtual uint16_t getCtrl2(uint32_t adc) const
Definition
LArRodBlockCalibrationV3.cxx:296
LArRodBlockCalibrationV3::getResults2Size
virtual uint16_t getResults2Size() const
Definition
LArRodBlockCalibrationV3.cxx:258
LArRodBlockCalibrationV3::m_RawDataBlock
std::vector< uint32_t > m_RawDataBlock
Definition
LArRodBlockCalibrationV3.h:114
LArRodBlockCalibrationV3::getCtrl3
virtual uint16_t getCtrl3(uint32_t adc) const
Definition
LArRodBlockCalibrationV3.cxx:306
LArRodBlockCalibrationV3::getDAC
uint16_t getDAC() const
Definition
LArRodBlockCalibrationV3.cxx:232
LArRodBlockCalibrationV3::Dac
@ Dac
Definition
LArRodBlockCalibrationV3.h:53
LArRodBlockCalibrationV3::StepIndex
@ StepIndex
Definition
LArRodBlockCalibrationV3.h:65
LArRodBlockCalibrationV3::Delay
@ Delay
Definition
LArRodBlockCalibrationV3.h:55
LArRodBlockCalibrationV3::NTrigger
@ NTrigger
Definition
LArRodBlockCalibrationV3.h:51
LArRodBlockCalibrationV3::getNStep
uint16_t getNStep() const
Definition
LArRodBlockCalibrationV3.cxx:268
LArRodBlockStructure::m_rearrangeFirstSample
unsigned int m_rearrangeFirstSample
Definition
LArRodBlockStructure.h:235
LArRodBlockStructure::m_channelsPerFEB
int m_channelsPerFEB
Definition
LArRodBlockStructure.h:219
LArRodBlockStructure::getHeader16
uint16_t getHeader16(const unsigned n) const
Definition
LArRodBlockStructure.h:345
LArRodBlockStructure::getHeader32
uint32_t getHeader32(const unsigned n) const
Definition
LArRodBlockStructure.h:353
LArRodBlockStructure::m_FebBlock
const uint32_t * m_FebBlock
Definition
LArRodBlockStructure.h:221
LArRodBlockStructure::m_iHeadBlockSize
unsigned short m_iHeadBlockSize
Definition
LArRodBlockStructure.h:217
LArRodBlockStructure::LArRodBlockStructure
LArRodBlockStructure(IMessageSvc *msgSvc, const std::string &blockType)
Definition
LArRodBlockStructure.cxx:18
LArRodBlockStructure::RawToOfflineGain
uint32_t RawToOfflineGain(const uint32_t gain) const
Definition
LArRodBlockStructure.h:339
LArRodBlockStructure::getNumberOfWords
uint32_t getNumberOfWords() const
Definition
LArRodBlockStructure.h:417
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition
getMessageSvc.cxx:20
CaloGain::LARNGAIN
@ LARNGAIN
Definition
CaloGain.h:19
index
Definition
index.py:1
Generated on
for ATLAS Offline Software by
1.17.0