ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArCnv
LArByteStream
src
LArRodBlockCalibrationV1.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/LArRodBlockCalibrationV1.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
LArRodBlockCalibrationV1::LArRodBlockCalibrationV1
(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
LArRodBlockCalibrationV1::resetPointers
();
31
}
32
33
// clear temporary block vectors
34
void
LArRodBlockCalibrationV1::clearBlocks
()
35
{
36
m_RawDataBlock
.clear();
37
}
38
39
void
LArRodBlockCalibrationV1::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
LArRodBlockCalibrationV1::getTDCPhase
()
const
52
{
53
return
(
getHeader16
(
NSamples
)>>8);
54
}
55
56
57
58
59
int
LArRodBlockCalibrationV1::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
LArRodBlockCalibrationV1::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
const
unsigned
int
ntriggers = (int)
getNTrigger
();
165
const
unsigned
int
dac = (int)
getDAC
();
166
const
unsigned
int
delay
= (int)
getDelay
();
167
unsigned
int
nStepTriggers = 1;
168
const
unsigned
int
FebConfig
= (int)
getFebConfig
();
169
LARBSDBG
(
"This FEB has "
<< nsamples <<
" samples"
);
170
LARBSDBG
(
"This FEB has "
<< ngains <<
" gains"
);
171
LARBSDBG
(
"This FEB has "
<< ntriggers <<
" ntriggers"
);
172
LARBSDBG
(
"This FEB has "
<< dac <<
" dac"
);
173
LARBSDBG
(
"This FEB has "
<<
delay
<<
" delay"
);
174
LARBSDBG
(
"This FEB has "
<< std::hex <<
FebConfig
<<
" FebConfig"
);
175
if
(ngains==0 || nsamples==0)
return
0;
176
// IWS 11.01.2006 book vectors
177
if
(!iStepTriggers)
178
{
179
samplesSum.resize(nStepTriggers);
180
samples2Sum.resize(nStepTriggers);
181
}
182
// Loop over gains to look for m_fixedGain
183
int
offset;
184
uint32_t
x
,x2;
185
if
(
m_fixedGain
!=
CaloGain::LARNGAIN
) {
//Fixed gain: Search for gain
186
if
(
FebConfig
==0)
// free gain - dontknow what to do
187
{
188
LARBSDBG
(
"free gain - dont know what to do Accumulated Calib Digit - return 0"
);
189
return
0;
190
}
191
else
if
(
FebConfig
<4 )
// one fixed gain
192
{
193
febgain=
FebConfig
;
194
}
195
else
if
((
FebConfig
>3) && (
FebConfig
<10))
// two gains - not yet ready
196
{
197
LARBSDBG
(
"two gains - dont know what to do yet in Accumulated Calib Digit - return 0"
);
198
return
0;
199
}
200
else
if
(
FebConfig
>9)
// three gains - not yet ready
201
{
202
LARBSDBG
(
"three gains - dont know what to do yet in Accumulated Calib Digit - return 0"
);
203
return
0;
204
}
205
}
206
else
207
{
208
febgain=
FebConfig
&0x3;
// to be done better when this is better understood
209
}
210
211
// nsamples*2 for Sum + Sum2
212
// 11 is the size of the calibration header
213
offset=block + 11 + (channelNumber&0x7F)*(nsamples*2);
// needs to be updated for loop on gains
214
uint32_t
index
=offset;
215
216
for
(
unsigned
int
i=0;i<nsamples;i++)
217
{
218
x
=
m_FebBlock
[
index
];
219
x2=
m_FebBlock
[
index
+1];
220
221
samplesSum[iStepTriggers].push_back(
x
);
222
samples2Sum[iStepTriggers].push_back(x2);
223
index
+=2;
224
}
225
226
gain=
RawToOfflineGain
(febgain);
227
228
++
m_Result1Counter
;
229
return
1;
230
}
231
232
233
uint32_t
LArRodBlockCalibrationV1::getNumberOfSamples
()
const
234
{
235
return
getHeader16
(
NSamples
);
236
}
237
238
uint32_t
LArRodBlockCalibrationV1::getNumberOfGains
()
const
239
{
240
return
getHeader16
(
NGains
);
241
}
242
243
uint16_t
LArRodBlockCalibrationV1::getNTrigger
()
const
244
{
245
246
int
index
=
getHeader16
(
ResultsOff1
);
247
uint32_t
x
=
m_FebBlock
[
index
+
NTrigger
/2];
248
return
(uint16_t)
x
;
249
}
250
251
uint16_t
LArRodBlockCalibrationV1::getDAC
()
const
252
{
253
int
index
=
getHeader16
(
ResultsOff1
);
254
uint32_t
x
=
m_FebBlock
[
index
+
Dac
/2];
255
return
(uint16_t)
x
;
256
}
257
258
uint16_t
LArRodBlockCalibrationV1::getDelay
()
const
259
{
260
int
index
=
getHeader16
(
ResultsOff1
);
261
uint32_t
x
=
m_FebBlock
[
index
+
Delay
/2];
262
return
(uint32_t)
x
;
263
}
264
265
uint32_t
LArRodBlockCalibrationV1::getRadd
(uint32_t adc, uint32_t sample)
const
266
{
267
int
ngain=
getHeader16
(
NGains
);
268
int
index
=
getHeader16
(
RawDataBlkOff
);
269
if
(
index
<=0)
return
0;
270
index
+=(8+64*ngain)*sample+adc/2;
271
uint32_t
x
=
m_FebBlock
[
index
];
272
if
(adc&0x1)
return
x
>>16;
273
return
x
&0xffff;
274
}
275
276
uint16_t
LArRodBlockCalibrationV1::getCtrl1
(uint32_t adc)
const
277
{
278
int
index
=
getHeader16
(
RawDataBlkOff
)-16+adc/2;
279
uint32_t
x
=
m_FebBlock
[
index
];
280
if
(adc&0x1)
x
=
x
>>16;
281
else
x
=
x
&0xffff;
282
uint16_t ctrl=
x
;
283
return
ctrl;
284
}
285
286
uint16_t
LArRodBlockCalibrationV1::getCtrl2
(uint32_t adc)
const
287
{
288
int
index
=
getHeader16
(
RawDataBlkOff
)-8+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
LArRodBlockCalibrationV1::getCtrl3
(uint32_t adc)
const
297
{
298
int
nsamples=
getHeader16
(
NSamples
);
299
int
ngains=
getHeader16
(
NGains
);
300
int
offset=nsamples*(8+64*ngains)+adc/2;
301
int
index
=
getHeader16
(
RawDataBlkOff
)+offset;
302
uint32_t
x
=
m_FebBlock
[
index
];
303
if
(adc&0x1)
x
=
x
>>16;
304
else
x
=
x
&0xffff;
305
uint16_t ctrl=
x
;
306
return
ctrl;
307
}
308
309
uint32_t
LArRodBlockCalibrationV1::getStatus
()
const
310
{
311
// Get Rod status word
312
int
nsamples =
getHeader16
(
NSamples
);
313
int
ngains =
getHeader16
(
NGains
);
314
int
offset = nsamples*(8+64*ngains)+8;
315
int
index
=
getHeader16
(
RawDataBlkOff
)+offset;
316
uint32_t
x
=
m_FebBlock
[
index
];
317
return
x
;
318
319
}
320
321
322
#ifdef LARBSDBGOUTPUT
323
#undef LARBSDBGOUTPUT
324
#endif
325
#undef LARBSDBG
delay
double delay(std::size_t d)
Definition
JetTrigTimerTest.cxx:11
LArRodBlockCalibrationV1.h
LARBSDBG
#define LARBSDBG(text)
This class provides decoding/encoding from/to ROD format.
Definition
LArRodBlockPhysicsV0.h:43
x
#define x
LArRodBlockCalibrationV1::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
LArRodBlockCalibrationV1.cxx:135
LArRodBlockCalibrationV1::m_Result1Index
int m_Result1Index
Definition
LArRodBlockCalibrationV1.h:111
LArRodBlockCalibrationV1::resetPointers
virtual void resetPointers()
Definition
LArRodBlockCalibrationV1.cxx:39
LArRodBlockCalibrationV1::m_RawDataBlock
std::vector< uint32_t > m_RawDataBlock
Definition
LArRodBlockCalibrationV1.h:108
LArRodBlockCalibrationV1::endtag
@ endtag
Definition
LArRodBlockCalibrationV1.h:70
LArRodBlockCalibrationV1::NTrigger
@ NTrigger
Definition
LArRodBlockCalibrationV1.h:48
LArRodBlockCalibrationV1::Delay
@ Delay
Definition
LArRodBlockCalibrationV1.h:52
LArRodBlockCalibrationV1::Dac
@ Dac
Definition
LArRodBlockCalibrationV1.h:50
LArRodBlockCalibrationV1::getDelay
uint16_t getDelay() const
Definition
LArRodBlockCalibrationV1.cxx:258
LArRodBlockCalibrationV1::m_Result1Counter
int m_Result1Counter
Definition
LArRodBlockCalibrationV1.h:110
LArRodBlockCalibrationV1::getCtrl3
virtual uint16_t getCtrl3(uint32_t adc) const
Definition
LArRodBlockCalibrationV1.cxx:296
LArRodBlockCalibrationV1::m_fixedGain
int m_fixedGain
Definition
LArRodBlockCalibrationV1.h:117
LArRodBlockCalibrationV1::getRadd
virtual uint32_t getRadd(uint32_t adc, uint32_t sample) const
Definition
LArRodBlockCalibrationV1.cxx:265
LArRodBlockCalibrationV1::getNumberOfGains
virtual uint32_t getNumberOfGains() const
Definition
LArRodBlockCalibrationV1.cxx:238
LArRodBlockCalibrationV1::getNextRawData
virtual int getNextRawData(int &channelNumber, std::vector< short > &samples, uint32_t &gain)
Definition
LArRodBlockCalibrationV1.cxx:59
LArRodBlockCalibrationV1::getTDCPhase
virtual uint8_t getTDCPhase() const
Definition
LArRodBlockCalibrationV1.cxx:51
LArRodBlockCalibrationV1::getDAC
uint16_t getDAC() const
Definition
LArRodBlockCalibrationV1.cxx:251
LArRodBlockCalibrationV1::getStatus
virtual uint32_t getStatus() const
Definition
LArRodBlockCalibrationV1.cxx:309
LArRodBlockCalibrationV1::getFebConfig
uint32_t getFebConfig() const
Definition
LArRodBlockCalibrationV1.h:130
LArRodBlockCalibrationV1::m_Result2Counter
int m_Result2Counter
Definition
LArRodBlockCalibrationV1.h:112
LArRodBlockCalibrationV1::getCtrl2
virtual uint16_t getCtrl2(uint32_t adc) const
Definition
LArRodBlockCalibrationV1.cxx:286
LArRodBlockCalibrationV1::clearBlocks
void clearBlocks()
Definition
LArRodBlockCalibrationV1.cxx:34
LArRodBlockCalibrationV1::m_Result2Index
int m_Result2Index
Definition
LArRodBlockCalibrationV1.h:113
LArRodBlockCalibrationV1::BlockType
static std::string BlockType()
Definition
LArRodBlockCalibrationV1.h:76
LArRodBlockCalibrationV1::getNumberOfSamples
virtual uint32_t getNumberOfSamples() const
Definition
LArRodBlockCalibrationV1.cxx:233
LArRodBlockCalibrationV1::FebConfig
@ FebConfig
Definition
LArRodBlockCalibrationV1.h:42
LArRodBlockCalibrationV1::ResultsOff1
@ ResultsOff1
Definition
LArRodBlockCalibrationV1.h:32
LArRodBlockCalibrationV1::FEBID
@ FEBID
Definition
LArRodBlockCalibrationV1.h:28
LArRodBlockCalibrationV1::NSamples
@ NSamples
Definition
LArRodBlockCalibrationV1.h:41
LArRodBlockCalibrationV1::RawDataBlkOff
@ RawDataBlkOff
Definition
LArRodBlockCalibrationV1.h:36
LArRodBlockCalibrationV1::NGains
@ NGains
Definition
LArRodBlockCalibrationV1.h:40
LArRodBlockCalibrationV1::m_RawDataCounter
int m_RawDataCounter
Definition
LArRodBlockCalibrationV1.h:114
LArRodBlockCalibrationV1::m_RawDataIndex
int m_RawDataIndex
Definition
LArRodBlockCalibrationV1.h:115
LArRodBlockCalibrationV1::getCtrl1
virtual uint16_t getCtrl1(uint32_t adc) const
Definition
LArRodBlockCalibrationV1.cxx:276
LArRodBlockCalibrationV1::LArRodBlockCalibrationV1
LArRodBlockCalibrationV1(IMessageSvc *msgSvc)
Definition
LArRodBlockCalibrationV1.cxx:25
LArRodBlockCalibrationV1::getNTrigger
uint16_t getNTrigger() const
Definition
LArRodBlockCalibrationV1.cxx:243
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