ATLAS Offline Software
Loading...
Searching...
No Matches
ZdcPpmSubBlock.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5/*
6 *
7 */
8
9#ifndef ZDCPPMSUBBLOCK_H
10#define ZDCPPMSUBBLOCK_H
11
12#include <stdint.h>
13#include <vector>
14
15
16#include "ZdcSubBlock.h"
17
18
19
29
31
32 public:
35
37 // cppcheck-suppress duplInheritedMember
38 void clear();
39
41 void setPpmHeader(int version, int format, int seqno, int crate,
42 int module, int slicesFadc, int slicesLut);
44 void setPpmErrorHeader(int version, int format, int crate,
45 int module, int slicesFadc, int slicesLut);
46
47 // Return PPM-specific header data
48 int slicesFadc() const;
49 int slicesLut() const;
50
52 void fillPpmData(int chan, const std::vector<int>& lut,
53 const std::vector<int>& fadc,
54 const std::vector<int>& bcidLut,
55 const std::vector<int>& bcidFadc);
56
57 void ppmData(int chan, std::vector<int>& lut,
58 std::vector<int>& fadc,
59 std::vector<int>& bcidLut,
60 std::vector<int>& bcidFadc) const;
61
63 void fillPpmError(int chan, int errorWord);
65 void fillPpmPinError(int pin, int errorWord);
66
68 int ppmError(int chan) const;
70 int ppmPinError(int pin) const;
71
72 // Return individual error bits
73 bool glinkPinParity(int chan) const;
74 bool fpgaCorrupt(int chan) const;
75 bool bunchMismatch(int chan) const;
76 bool eventMismatch(int chan) const;
77 bool asicFull(int chan) const;
78 bool timeout(int chan) const;
79 bool mcmAbsent(int chan) const;
80 bool channelDisabled(int chan) const;
81 bool channelDisabledA(int pin) const;
82 bool channelDisabledB(int pin) const;
83 bool channelDisabledC(int pin) const;
84 bool channelDisabledD(int pin) const;
85 // Ditto ORed over all pins
86 bool glinkPinParity() const;
87 bool fpgaCorrupt() const;
88 bool bunchMismatch() const;
89 bool eventMismatch() const;
90 bool asicFull() const;
91 bool timeout() const;
92 bool mcmAbsent() const;
93 bool channelDisabledA() const;
94 bool channelDisabledB() const;
95 bool channelDisabledC() const;
96 bool channelDisabledD() const;
97
98 // Set triggered slice offsets, pedestal value
99 void setLutOffset(int offset);
100 void setFadcOffset(int offset);
101 void setPedestal(int pedval);
102 void setFadcBaseline(int baseline);
103 void setFadcThreshold(int threshold);
104 void setRunNumber(int run);
105 // Return triggered slice offsets, pedestal value
106 int lutOffset() const;
107 int fadcOffset() const;
108 int pedestal() const;
109 int fadcBaseline() const;
110 int fadcThreshold() const;
111 int runNumber() const;
112
113 // Reorder channels from Slink to PPM order
114 int getPpmChannel(const int channel) const;
115
117 bool pack();
119 bool unpack();
120
122 static int channelsPerSubBlock(int version, int format);
123 int channelsPerSubBlock() const;
124
126 static bool errorBlock(uint32_t word);
127
129 void setCompStats(const std::vector<uint32_t>& stats);
131 const std::vector<uint32_t>& compStats() const;
132
133 private:
134 // Header word data
135 static const uint32_t s_wordIdVal = 0xc;
136 static const int s_errorMarker = 63;
137 // Data word positions and masks
138 static const int s_wordLen = 16;
139 static const int s_lutBit = 0;
140 static const int s_bcidLutBit = 8;
141 static const int s_fadcBit = 1;
142 static const int s_bcidFadcBit = 0;
143 static const uint32_t s_lutMask = 0xff;
144 static const uint32_t s_bcidLutMask = 0x7;
145 static const uint32_t s_fadcMask = 0x3ff;
146 static const uint32_t s_bcidFadcMask = 0x1;
147 // For neutral format
148 static const int s_channels = 64;
149 static const int s_glinkPins = 16;
150 static const int s_asicChannels = 4;
151 static const int s_dataBits = 11;
152 static const int s_errorBits = 10;
153 static const int s_bunchCrossingBits = 12;
154 // Error word masks and bit positions
155 static const uint32_t s_errorMask = 0x7ff;
156 static const int s_glinkPinParityBit = 10;
157 static const int s_fpgaCorruptBit = 9;
158 static const int s_bunchMismatchBit = 8;
159 static const int s_eventMismatchBit = 7;
160 static const int s_asicFullBit = 6;
161 static const int s_timeoutBit = 5;
162 static const int s_mcmAbsentBit = 4;
163 static const int s_channelDisabledBit = 0;
164 static const int s_ppmChannel[];
165
166
167
169 int asic(int chan) const;
171 int pin(int chan) const;
172
174 bool errorBit(int pin, int bit) const;
176 bool errorBit(int bit) const;
177
178 // Packing/unpacking for specific formats
180 bool packNeutral();
186 bool unpackNeutral();
191
192 // Global error flags
194
195 // Triggered slice offsets, pedestal value
202
204 std::vector<uint32_t> m_compStats;
205
207 std::vector<uint32_t> m_datamap;
208
210 std::vector<uint32_t> m_errormap;
211
212};
213
214inline bool ZdcPpmSubBlock::glinkPinParity(const int chan) const
215{
216 return errorBit(pin(chan), s_glinkPinParityBit);
217}
218
219inline bool ZdcPpmSubBlock::fpgaCorrupt(const int chan) const
220{
221 return errorBit(pin(chan), s_fpgaCorruptBit);
222}
223
224inline bool ZdcPpmSubBlock::bunchMismatch(const int chan) const
225{
226 return errorBit(pin(chan), s_bunchMismatchBit);
227}
228
229inline bool ZdcPpmSubBlock::eventMismatch(const int chan) const
230{
231 return errorBit(pin(chan), s_eventMismatchBit);
232}
233
234inline bool ZdcPpmSubBlock::asicFull(const int chan) const
235{
236 return errorBit(pin(chan), s_asicFullBit);
237}
238
239inline bool ZdcPpmSubBlock::timeout(const int chan) const
240{
241 return errorBit(pin(chan), s_timeoutBit);
242}
243
244inline bool ZdcPpmSubBlock::mcmAbsent(const int chan) const
245{
246 return errorBit(pin(chan), s_mcmAbsentBit);
247}
248
249inline bool ZdcPpmSubBlock::channelDisabled(const int chan) const
250{
251 return errorBit(pin(chan), s_channelDisabledBit + asic(chan));
252}
253
254inline bool ZdcPpmSubBlock::channelDisabledA(const int pin) const
255{
257}
258
259inline bool ZdcPpmSubBlock::channelDisabledB(const int pin) const
260{
261 return errorBit(pin, s_channelDisabledBit + 1);
262}
263
264inline bool ZdcPpmSubBlock::channelDisabledC(const int pin) const
265{
266 return errorBit(pin, s_channelDisabledBit + 2);
267}
268
269inline bool ZdcPpmSubBlock::channelDisabledD(const int pin) const
270{
271 return errorBit(pin, s_channelDisabledBit + 3);
272}
273
275{
277}
278
280{
282}
283
285{
287}
288
290{
292}
293
294inline bool ZdcPpmSubBlock::asicFull() const
295{
296 return errorBit(s_asicFullBit);
297}
298
299inline bool ZdcPpmSubBlock::timeout() const
300{
301 return errorBit(s_timeoutBit);
302}
303
304inline bool ZdcPpmSubBlock::mcmAbsent() const
305{
306 return errorBit(s_mcmAbsentBit);
307}
308
310{
312}
313
315{
316 return errorBit(s_channelDisabledBit + 1);
317}
318
320{
321 return errorBit(s_channelDisabledBit + 2);
322}
323
325{
326 return errorBit(s_channelDisabledBit + 3);
327}
328
329inline void ZdcPpmSubBlock::setLutOffset(const int offset)
330{
331 m_lutOffset = offset;
332}
333
334inline void ZdcPpmSubBlock::setFadcOffset(const int offset)
335{
336 m_fadcOffset = offset;
337}
338
339inline void ZdcPpmSubBlock::setPedestal(const int pedval)
340{
341 m_pedestal = pedval;
342}
343
345{
347}
348
353
354inline void ZdcPpmSubBlock::setRunNumber(const int run)
355{
357}
358
360{
361 return (m_lutOffset < 0) ? slicesLut()/2 : m_lutOffset;
362}
363
365{
366 return (m_fadcOffset < 0) ? slicesFadc()/2 : m_fadcOffset;
367}
368
369inline int ZdcPpmSubBlock::pedestal() const
370{
371 return m_pedestal;
372}
373
375{
376 return m_fadcBaseline;
377}
378
380{
381 return m_fadcThreshold;
382}
383
385{
386 return m_runNumber;
387}
388
389inline const std::vector<uint32_t>& ZdcPpmSubBlock::compStats() const
390{
391 return m_compStats;
392}
393
394inline void ZdcPpmSubBlock::setCompStats(const std::vector<uint32_t>& stats)
395{
396 m_compStats = stats;
397}
398
399inline int ZdcPpmSubBlock::asic(const int chan) const
400{
401 return chan / s_glinkPins;
402}
403
404inline int ZdcPpmSubBlock::pin(const int chan) const
405{
406 return chan % s_glinkPins;
407}
408
409inline bool ZdcPpmSubBlock::errorBit(const int pin, const int bit) const
410{
411 return m_errormap[pin] & (0x1 << bit);
412}
413
414//This is needed to convert from SLINK channel ordering to PPM channel ordering
415inline int ZdcPpmSubBlock::getPpmChannel (const int channel) const
416{
417 return s_ppmChannel[channel];
418}
419
420#endif
@ baseline
int pin(int chan) const
Return the G-Link pin corresponding to a data channel.
bool unpackNeutral()
Unpack neutral data.
void fillPpmData(int chan, const std::vector< int > &lut, const std::vector< int > &fadc, const std::vector< int > &bcidLut, const std::vector< int > &bcidFadc)
Store PPM data for later packing.
std::vector< uint32_t > m_compStats
Vector for compression statistics.
bool asicFull() const
int channelsPerSubBlock() const
void setCompStats(const std::vector< uint32_t > &stats)
Set compression stats.
bool channelDisabledB() const
void setPedestal(int pedval)
bool glinkPinParity() const
bool channelDisabledD() const
int pedestal() const
void setLutOffset(int offset)
static const uint32_t s_bcidFadcMask
static const int s_glinkPins
int fadcOffset() const
static const int s_eventMismatchBit
int ppmPinError(int pin) const
Return the error word for a G-Link pin.
bool unpackUncompressedData()
Unpack uncompressed data.
void ppmData(int chan, std::vector< int > &lut, std::vector< int > &fadc, std::vector< int > &bcidLut, std::vector< int > &bcidFadc) const
Return unpacked data for given channel.
static const int s_ppmChannel[]
static const uint32_t s_bcidLutMask
bool eventMismatch() const
bool fpgaCorrupt() const
void setFadcThreshold(int threshold)
bool packNeutral()
Pack neutral data.
static const int s_dataBits
static const uint32_t s_fadcMask
void fillPpmPinError(int pin, int errorWord)
Store an error word corresponding to a G-Link pin.
static const int s_fpgaCorruptBit
void setFadcBaseline(int baseline)
bool channelDisabled(int chan) const
const std::vector< uint32_t > & compStats() const
Return reference to compression stats.
bool unpack()
Unpack data.
int fadcBaseline() const
static const int s_glinkPinParityBit
int asic(int chan) const
Return the ASIC channel corresponding to a data channel.
static const int s_bunchMismatchBit
bool packUncompressedErrors()
Pack uncompressed error data.
static const int s_bcidLutBit
static const int s_asicChannels
uint32_t m_globalError
static const int s_bunchCrossingBits
int slicesFadc() const
std::vector< uint32_t > m_datamap
Vector for intermediate data.
bool packUncompressedData()
Pack uncompressed data.
void setRunNumber(int run)
bool pack()
Pack data.
int ppmError(int chan) const
Return the error word for a data channel.
static const int s_asicFullBit
static bool errorBlock(uint32_t word)
Check if a header word is for an error block.
static const int s_wordLen
void fillPpmError(int chan, int errorWord)
Store an error word corresponding to a data channel.
static const uint32_t s_wordIdVal
Sub-Block class for PPM data.
void setFadcOffset(int offset)
bool timeout() const
static const int s_errorBits
int runNumber() const
int fadcThreshold() const
static const int s_errorMarker
int lutOffset() const
static const int s_timeoutBit
int getPpmChannel(const int channel) const
bool mcmAbsent() const
static const int s_channelDisabledBit
static const int s_fadcBit
bool errorBit(int pin, int bit) const
Error bit extraction.
void clear()
Clear all data.
int slicesLut() const
void setPpmErrorHeader(int version, int format, int crate, int module, int slicesFadc, int slicesLut)
Store PPM error block header.
std::vector< uint32_t > m_errormap
Vector for intermediate error data.
void setPpmHeader(int version, int format, int seqno, int crate, int module, int slicesFadc, int slicesLut)
Store PPM header.
bool unpackUncompressedErrors()
Unpack uncompressed error data.
static const int s_mcmAbsentBit
bool bunchMismatch() const
bool channelDisabledA() const
static const uint32_t s_lutMask
static const int s_channels
static const int s_bcidFadcBit
bool channelDisabledC() const
static const int s_lutBit
static const uint32_t s_errorMask
int version() const
int format() const
int crate() const
int module() const
int seqno() const
Definition run.py:1