ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArCnv
LArByteStream
src
LArRodBlockPhysicsV4.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/LArRodBlockPhysicsV4.h
"
14
#include <iostream>
15
16
#ifdef LARBSDBGOUTPUT
17
#define MYLEVEL (MSG::FATAL)
18
#define LARBSDBG(text) logstr<<MYLEVEL<<text<<endmsg
19
#else
20
#define LARBSDBG(text)
21
#endif
22
23
LArRodBlockPhysicsV4::LArRodBlockPhysicsV4
(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
LArRodBlockPhysicsV4::resetPointers
();
29
}
30
31
void
LArRodBlockPhysicsV4::resetPointers
()
32
{
33
m_EnergyIndex
=0;
34
m_TimeQualityIndex
=0;
35
m_RawDataIndex
=0;
36
m_TowerIndex
=0;
37
38
m_EnergyPointer
=0;
39
m_TimeQualityPointer
=0;
40
m_RawDataPointer
=0;
41
m_GainPointer
=0;
42
m_MaskPointer
=0;
43
m_TowerPointer
=0;
44
m_SumPointer
=0;
45
m_HotCellsPointer
=0;
46
}
47
48
bool
LArRodBlockPhysicsV4::setPointers
()
49
{
50
m_EnergyIndex
=0;
51
m_TimeQualityIndex
=0;
52
m_RawDataIndex
=0;
53
m_TowerIndex
=0;
54
55
if
(
m_FebBlockSize
>
m_iHeadBlockSize
)
56
{
57
int
off = -8;
58
if
(
getHeader16
(
ResultsOff1
)) {
59
if
(
getHeader16
(
ResultsDim1
)>=8)
60
m_GainPointer
=
reinterpret_cast<
const
uint32_t*
>
(
m_FebBlock
+
getHeader16
(
ResultsOff1
)+off);
61
if
(
getHeader16
(
ResultsDim1
)>=12)
62
m_MaskPointer
=(
const
uint32_t*)(
m_FebBlock
+
getHeader16
(
ResultsOff1
)+8+off);
63
if
(
getHeader16
(
ResultsDim1
)>=13)
64
m_HotCellsPointer
=
reinterpret_cast<
const
uint16_t*
>
(
m_FebBlock
+
getHeader16
(
ResultsOff1
)+12+off);
65
if
(
getHeader16
(
ResultsDim1
)>13)
66
m_EnergyPointer
=
reinterpret_cast<
const
uint16_t*
>
(
m_FebBlock
+
getHeader16
(
ResultsOff1
)+13+off);
67
}
68
if
(
getHeader16
(
ResultsOff2
)) {
69
if
(
getHeader16
(
ResultsOff2
)>=4)
70
m_TowerPointer
=
reinterpret_cast<
const
uint8_t*
>
(
m_FebBlock
+
getHeader16
(
ResultsOff2
)+off);
71
if
(
getHeader16
(
ResultsOff2
)>=7)
72
m_SumPointer
=
reinterpret_cast<
const
int32_t*
>
(
m_FebBlock
+
getHeader16
(
ResultsOff2
)+4+off);
73
if
(
getHeader16
(
ResultsOff2
)>7)
74
m_TimeQualityPointer
=
reinterpret_cast<
const
uint16_t*
>
(
m_FebBlock
+
getHeader16
(
ResultsOff2
)+7+off);
75
}
76
if
(
getHeader16
(
RawDataBlkOff
))
77
m_RawDataPointer
=
reinterpret_cast<
const
uint16_t*
>
(
m_FebBlock
+
getHeader16
(
RawDataBlkOff
)+off);
78
79
#ifdef LARBSDBGOUTPUT
80
MsgStream logstr(
Athena::getMessageSvc
(),
BlockType
());
81
logstr <<
MYLEVEL
<<
"***********************************************************************"
<<
endmsg
;
82
logstr <<
MYLEVEL
<<
"Header values :"
<<
endmsg
;
83
logstr <<
MYLEVEL
<<
"************************************************************************"
<<
endmsg
;
84
logstr <<
MYLEVEL
<<
"Fragment @ = 0x"
<< MSG::hex <<
m_FebBlock
<<
endmsg
;
85
logstr <<
MYLEVEL
<<
"NWTot = "
<< MSG::dec <<
getNumberOfWords
() <<
endmsg
;
86
logstr <<
MYLEVEL
<<
"FebID = 0x"
<< MSG::hex <<
getHeader32
(
FEBID
) <<
endmsg
;
87
logstr <<
MYLEVEL
<<
"FebSN = 0x"
<< MSG::hex <<
getHeader32
(
FEB_SN
) <<
endmsg
;
88
logstr <<
MYLEVEL
<<
"ResultsOff1 = 0x"
<< MSG::hex <<
getHeader16
(
ResultsOff1
) <<
endmsg
;
89
logstr <<
MYLEVEL
<<
"ResultsDim1 = 0x"
<< MSG::hex <<
getHeader16
(
ResultsDim1
) <<
endmsg
;
90
logstr <<
MYLEVEL
<<
"ResultsOff2 = 0x"
<< MSG::hex <<
getHeader16
(
ResultsOff2
) <<
endmsg
;
91
logstr <<
MYLEVEL
<<
"ResultsDim2 = 0x"
<< MSG::hex <<
getHeader16
(
ResultsDim2
) <<
endmsg
;
92
logstr <<
MYLEVEL
<<
"RawDataBlkOff = 0x"
<< MSG::hex <<
getHeader16
(
RawDataBlkOff
) <<
endmsg
;
93
logstr <<
MYLEVEL
<<
"RawDataBlkDim = 0x"
<< MSG::hex <<
getHeader16
(
RawDataBlkDim
) <<
endmsg
;
94
logstr <<
MYLEVEL
<<
"************************************************************************"
<< MSG::dec <<
endmsg
;
95
96
int
size
=
getNumberOfWords
();
97
for
(
int
i=0;i<
size
;i++) {
98
logstr <<
MYLEVEL
<< MSG::hex << i <<
" : "
<< MSG::hex <<
m_FebBlock
+i <<
" : "
<< MSG::hex <<
m_FebBlock
[i] <<
endmsg
;
99
}
100
101
if
(
m_MaskPointer
)
size
= 4;
else
size
= 0;
102
logstr <<
MYLEVEL
<<
"Mask Block size = "
<< MSG::hex <<
size
<<
endmsg
;
103
logstr <<
MYLEVEL
<<
"Mask Block address = "
<< MSG::hex <<
m_MaskPointer
<<
endmsg
;
104
for
(
int
i=0;i<
size
;i++) {
105
logstr <<
MYLEVEL
<< i <<
" : "
<< MSG::hex <<
m_MaskPointer
[i] <<
endmsg
;
106
}
107
logstr <<
MYLEVEL
<<
"End of Mask Block"
<<
endmsg
;
108
#endif
109
}
110
111
return
true
;
112
}
113
114
int
LArRodBlockPhysicsV4::getNextRawData
(
int
& channelNumber, std::vector<short>& samples, uint32_t& gain)
115
{
116
#ifdef LARBSDBGOUTPUT
117
MsgStream logstr(
Athena::getMessageSvc
(),
BlockType
());
118
//Debug output
119
logstr <<
MYLEVEL
<<
"Let s go in getNextRawData..."
<<
endmsg
;
120
logstr <<
MYLEVEL
<<
"GetNextRawData for FEB 0x"
<< MSG::hex << (uint32_t)
getHeader32
(
FEBID
) << MSG::dec <<
endmsg
;
121
logstr <<
MYLEVEL
<<
"m_RawDataPointer="
<<
m_RawDataPointer
<<
" m_RawDataIndex="
<<
m_RawDataIndex
122
<<
" m_channelsPerFEB="
<<
m_channelsPerFEB
<<
endmsg
;
123
#endif
124
125
if
(
m_RawDataIndex
>=
m_channelsPerFEB
) {
//Already beyond maximal number of channels
126
#ifdef LARBSDBGOUTPUT
127
logstr <<
MYLEVEL
<<
"Maximum number of channels reached"
<<
endmsg
;
128
#endif
129
return
0;
130
}
131
if
(!
m_RawDataPointer
) {
//Block does not exist
132
#ifdef LARBSDBGOUTPUT
133
logstr <<
MYLEVEL
<<
"No Raw Data Block in this FEB"
<<
endmsg
;
134
#endif
135
return
0;
136
}
137
138
// Get next channel
139
unsigned
rodChannelNumber=
m_RawDataIndex
;
// Index of Channel in ROD-Block
140
channelNumber=((rodChannelNumber&0xe)<<2) + ((rodChannelNumber&0x1)<<6) + (rodChannelNumber>>4);
//channel number of the FEB
141
//channelNumber=(rodChannelNumber>>4) + ((rodChannelNumber&0xf)<<3); //channel number of the FEB
142
uint32_t febgain;
143
const
unsigned
int
nsamples =
getHeader16
(
NSamples
) & 0xff;
144
const
unsigned
int
ngains =
getHeader16
(
NGains
);
145
146
#ifdef LARBSDBGOUTPUT
147
logstr <<
MYLEVEL
<<
"This FEB has "
<< nsamples <<
" samples"
<<
endmsg
;
148
logstr <<
MYLEVEL
<<
"This FEB has "
<< ngains <<
" gains"
<<
endmsg
;
149
#endif
150
151
if
(ngains==0 || nsamples==0)
return
0;
152
int
s_size = nsamples+1;
153
int
offset = 12;
154
int
index
;
155
index
= s_size*
m_RawDataIndex
+ offset;
156
uint16_t s[2];
157
s[0] =
m_RawDataPointer
[
index
++]>>2;
158
febgain =
m_RawDataPointer
[
index
++];
159
samples.push_back(s[0]);
160
for
(
unsigned
int
i=0;i<nsamples/2;i++) {
161
s[1] =
m_RawDataPointer
[
index
++]>>2;
162
s[0] =
m_RawDataPointer
[
index
++]>>2;
163
samples.push_back(s[0]);
164
samples.push_back(s[1]);
165
}
166
gain=
RawToOfflineGain
(febgain);
167
168
#ifdef LARBSDBGOUTPUT
169
logstr <<
MYLEVEL
<<
" ===> ROD Channel = "
<<
m_RawDataIndex
<<
endmsg
;
170
logstr <<
MYLEVEL
<<
" ===> FEB Channel = "
<< channelNumber <<
endmsg
;
171
logstr <<
MYLEVEL
<<
" ===> Gain = "
<< gain <<
endmsg
;
172
for
(
int
i=0;i<nsamples;i++)
173
logstr <<
MYLEVEL
<<
" ===> sample "
<< i <<
" = "
<< samples[i] <<
endmsg
;
174
int
n =
m_RawDataIndex
;
175
int32_t e,t,q;
176
uint32_t g;
177
LArRodBlockPhysicsV4::getNextEnergy
(n,e,t,q,g);
178
#endif
179
++
m_RawDataIndex
;
180
unsigned
rearrangeFirstSample=0;
181
if
(
m_rearrangeFirstSample
)
182
rearrangeFirstSample=
m_rearrangeFirstSample
;
//Overwrite by jobOptions
183
else
184
rearrangeFirstSample=
getFirstSampleIndex
();
185
if
(rearrangeFirstSample && rearrangeFirstSample<samples.size())
//FIXME: Very ugly hack! See explanation in LArRodDecoder.h file
186
{
//Change e.g. 3 0 1 2 4 to 0 1 2 3 4
187
short
movedSample=samples[0];
188
for
(
unsigned
i=1;i<=rearrangeFirstSample;i++)
189
samples[i-1]=samples[i];
190
samples[rearrangeFirstSample]=movedSample;
191
}
192
#ifdef LARBSDBGOUTPUT
193
logstr <<
MYLEVEL
<<
"GetNextRawData for FEB finished 0x"
<< MSG::hex << (uint32_t)
getHeader32
(
FEBID
) << MSG::dec <<
endmsg
;
194
#endif
195
return
1;
196
}
197
198
uint32_t
LArRodBlockPhysicsV4::getNumberOfSamples
()
const
199
{
200
return
getHeader16
(
NSamples
);
201
}
202
203
uint32_t
LArRodBlockPhysicsV4::getNumberOfGains
()
const
204
{
205
return
getHeader16
(
NGains
);
206
}
207
208
uint16_t
LArRodBlockPhysicsV4::getResults1Size
()
const
209
{
210
return
getHeader16
(
ResultsDim1
);
211
}
212
213
uint16_t
LArRodBlockPhysicsV4::getResults2Size
()
const
214
{
215
return
getHeader16
(
ResultsDim2
);
216
}
217
218
uint16_t
LArRodBlockPhysicsV4::getRawDataSize
()
const
219
{
220
return
getHeader16
(
RawDataBlkDim
);
221
}
222
223
uint32_t
LArRodBlockPhysicsV4::getRadd
(uint32_t adc, uint32_t sample)
const
224
{
225
if
(!
m_RawDataPointer
)
return
0;
226
int
index
;
227
if
(sample==0)
index
=6;
228
else
if
(sample & 0x1)
index
=7+sample-1;
229
else
index
=7+sample+1;
230
uint32_t
x
=
m_RawDataPointer
[
index
];
231
if
(adc>=8)
return
x
>>8;
232
return
x
&0xff;
233
}
234
235
uint16_t
LArRodBlockPhysicsV4::getCtrl1
(uint32_t
/*adc*/
)
const
236
{
237
if
(!
m_RawDataPointer
)
return
0;
238
int
index
=5;
239
uint16_t
x
=
m_RawDataPointer
[
index
];
240
return
x
;
241
}
242
243
uint16_t
LArRodBlockPhysicsV4::getCtrl2
(uint32_t
/*adc*/
)
const
244
{
245
if
(!
m_RawDataPointer
)
return
0;
246
int
index
=4;
247
uint16_t
x
=
m_RawDataPointer
[
index
];
248
return
x
;
249
}
250
251
uint16_t
LArRodBlockPhysicsV4::getCtrl3
(uint32_t
/*adc*/
)
const
252
{
253
if
(!
m_RawDataPointer
)
return
0;
254
int
index
=7;
255
uint16_t
x
=
m_RawDataPointer
[
index
];
256
return
x
;
257
}
258
259
uint32_t
LArRodBlockPhysicsV4::getStatus
()
const
260
{
261
if
(
getNumberOfWords
()<
EventStatus
/2)
return
0;
262
uint32_t
x
=
getHeader32
(
EventStatus
);
263
return
x
;
264
}
265
266
uint32_t
LArRodBlockPhysicsV4::onlineCheckSum
()
const
267
{
268
int
index
=
getNumberOfWords
()-1;
269
if
(
index
<
m_iHeadBlockSize
)
return
0;
270
uint32_t sum =
m_FebBlock
[
index
];
271
return
sum;
272
}
273
274
uint32_t
LArRodBlockPhysicsV4::offlineCheckSum
()
const
275
{
276
int
end =
getNumberOfWords
()-3;
277
uint32_t sum = 0;
278
for
(
int
i=0;i<end;i++) {
279
sum +=
m_FebBlock
[i];
280
}
281
return
sum & 0x7fffffff;
282
}
283
284
#ifdef LARBSDBGOUTPUT
285
#undef LARBSDBGOUTPUT
286
#endif
287
#undef LARBSDBG
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
MYLEVEL
#define MYLEVEL
Definition
LArRodBlockPhysicsV3.h:46
LArRodBlockPhysicsV4.h
size
size_t size() const
Number of registered mappings.
x
#define x
LArRodBlockPhysicsV4::m_RawDataPointer
const uint16_t * m_RawDataPointer
Definition
LArRodBlockPhysicsV4.h:109
LArRodBlockPhysicsV4::getCtrl2
virtual uint16_t getCtrl2(uint32_t adc) const
Definition
LArRodBlockPhysicsV4.cxx:243
LArRodBlockPhysicsV4::m_TowerIndex
int m_TowerIndex
Definition
LArRodBlockPhysicsV4.h:106
LArRodBlockPhysicsV4::m_GainPointer
const uint32_t * m_GainPointer
Definition
LArRodBlockPhysicsV4.h:110
LArRodBlockPhysicsV4::getCtrl1
virtual uint16_t getCtrl1(uint32_t adc) const
Definition
LArRodBlockPhysicsV4.cxx:235
LArRodBlockPhysicsV4::FEBID
@ FEBID
Definition
LArRodBlockPhysicsV4.h:38
LArRodBlockPhysicsV4::RawDataBlkOff
@ RawDataBlkOff
Definition
LArRodBlockPhysicsV4.h:46
LArRodBlockPhysicsV4::EventStatus
@ EventStatus
Definition
LArRodBlockPhysicsV4.h:48
LArRodBlockPhysicsV4::ResultsOff2
@ ResultsOff2
Definition
LArRodBlockPhysicsV4.h:44
LArRodBlockPhysicsV4::NSamples
@ NSamples
Definition
LArRodBlockPhysicsV4.h:51
LArRodBlockPhysicsV4::endtag
@ endtag
Definition
LArRodBlockPhysicsV4.h:56
LArRodBlockPhysicsV4::ResultsDim1
@ ResultsDim1
Definition
LArRodBlockPhysicsV4.h:43
LArRodBlockPhysicsV4::NGains
@ NGains
Definition
LArRodBlockPhysicsV4.h:50
LArRodBlockPhysicsV4::ResultsDim2
@ ResultsDim2
Definition
LArRodBlockPhysicsV4.h:45
LArRodBlockPhysicsV4::RawDataBlkDim
@ RawDataBlkDim
Definition
LArRodBlockPhysicsV4.h:47
LArRodBlockPhysicsV4::FEB_SN
@ FEB_SN
Definition
LArRodBlockPhysicsV4.h:40
LArRodBlockPhysicsV4::ResultsOff1
@ ResultsOff1
Definition
LArRodBlockPhysicsV4.h:42
LArRodBlockPhysicsV4::getRadd
virtual uint32_t getRadd(uint32_t adc, uint32_t sample) const
Definition
LArRodBlockPhysicsV4.cxx:223
LArRodBlockPhysicsV4::m_TimeQualityIndex
int m_TimeQualityIndex
Definition
LArRodBlockPhysicsV4.h:105
LArRodBlockPhysicsV4::m_fixedGain
int m_fixedGain
Definition
LArRodBlockPhysicsV4.h:117
LArRodBlockPhysicsV4::getFirstSampleIndex
uint16_t getFirstSampleIndex() const
Definition
LArRodBlockPhysicsV4.h:131
LArRodBlockPhysicsV4::m_HotCellsPointer
const uint16_t * m_HotCellsPointer
Definition
LArRodBlockPhysicsV4.h:112
LArRodBlockPhysicsV4::resetPointers
virtual void resetPointers()
Definition
LArRodBlockPhysicsV4.cxx:31
LArRodBlockPhysicsV4::getNumberOfSamples
virtual uint32_t getNumberOfSamples() const
Definition
LArRodBlockPhysicsV4.cxx:198
LArRodBlockPhysicsV4::getResults2Size
virtual uint16_t getResults2Size() const
Definition
LArRodBlockPhysicsV4.cxx:213
LArRodBlockPhysicsV4::m_EnergyPointer
const uint16_t * m_EnergyPointer
Definition
LArRodBlockPhysicsV4.h:107
LArRodBlockPhysicsV4::BlockType
static std::string BlockType()
Definition
LArRodBlockPhysicsV4.h:62
LArRodBlockPhysicsV4::onlineCheckSum
virtual uint32_t onlineCheckSum() const
Definition
LArRodBlockPhysicsV4.cxx:266
LArRodBlockPhysicsV4::m_EnergyIndex
int m_EnergyIndex
Definition
LArRodBlockPhysicsV4.h:103
LArRodBlockPhysicsV4::getResults1Size
virtual uint16_t getResults1Size() const
Definition
LArRodBlockPhysicsV4.cxx:208
LArRodBlockPhysicsV4::LArRodBlockPhysicsV4
LArRodBlockPhysicsV4(IMessageSvc *msgSvc)
Definition
LArRodBlockPhysicsV4.cxx:23
LArRodBlockPhysicsV4::setPointers
virtual bool setPointers()
Definition
LArRodBlockPhysicsV4.cxx:48
LArRodBlockPhysicsV4::m_TowerPointer
const uint8_t * m_TowerPointer
Definition
LArRodBlockPhysicsV4.h:113
LArRodBlockPhysicsV4::m_SumPointer
const int32_t * m_SumPointer
Definition
LArRodBlockPhysicsV4.h:114
LArRodBlockPhysicsV4::getCtrl3
virtual uint16_t getCtrl3(uint32_t adc) const
Definition
LArRodBlockPhysicsV4.cxx:251
LArRodBlockPhysicsV4::offlineCheckSum
virtual uint32_t offlineCheckSum() const
Definition
LArRodBlockPhysicsV4.cxx:274
LArRodBlockPhysicsV4::getNextRawData
virtual int getNextRawData(int &channelNumber, std::vector< short > &samples, uint32_t &gain)
Definition
LArRodBlockPhysicsV4.cxx:114
LArRodBlockPhysicsV4::getNextEnergy
virtual int getNextEnergy(int &channelNumber, int32_t &energy, int32_t &time, int32_t &quality, uint32_t &gain)
Definition
LArRodBlockPhysicsV4.h:136
LArRodBlockPhysicsV4::getNumberOfGains
virtual uint32_t getNumberOfGains() const
Definition
LArRodBlockPhysicsV4.cxx:203
LArRodBlockPhysicsV4::m_MaskPointer
const uint32_t * m_MaskPointer
Definition
LArRodBlockPhysicsV4.h:111
LArRodBlockPhysicsV4::m_TimeQualityPointer
const uint16_t * m_TimeQualityPointer
Definition
LArRodBlockPhysicsV4.h:108
LArRodBlockPhysicsV4::getRawDataSize
virtual uint16_t getRawDataSize() const
Definition
LArRodBlockPhysicsV4.cxx:218
LArRodBlockPhysicsV4::getStatus
virtual uint32_t getStatus() const
Definition
LArRodBlockPhysicsV4.cxx:259
LArRodBlockPhysicsV4::m_RawDataIndex
int m_RawDataIndex
Definition
LArRodBlockPhysicsV4.h:104
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::m_FebBlockSize
int32_t m_FebBlockSize
Definition
LArRodBlockStructure.h:223
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