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