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