Project
Loading...
Searching...
No Matches
RCUTrailer.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11#ifndef ALICEO2_PHOS_RCUTRAILER_H
12#define ALICEO2_PHOS_RCUTRAILER_H
13
14#include <exception>
15#include <iosfwd>
16#include <string>
17#include <cstdint>
18#include <gsl/span>
19#include "Rtypes.h"
20
21namespace o2
22{
23
24namespace phos
25{
26
28 uint32_t mDataWord;
29 struct {
30 uint32_t mHardwareAddress : 16;
31 uint32_t mPayloadSize : 10;
32 uint32_t mZero1 : 3;
33 uint32_t mBadChannel : 1;
34 uint32_t mMark : 1;
35 };
36};
37
39 uint32_t mDataWord;
40 struct {
41 uint32_t mWord2 : 10;
42 uint32_t mWord1 : 10;
43 uint32_t mWord0 : 10;
44 uint32_t mZero : 2;
45 };
46};
47
56{
57 public:
60 class Error : public std::exception
61 {
62 public:
71
78 Error(ErrorType_t errtype, const char* message) : mErrorType(errtype), mErrorMessage(message) {}
79
81 ~Error() noexcept override = default;
82
85 const char* what() const noexcept override { return mErrorMessage.data(); }
86
89 ErrorType_t getErrorType() const noexcept { return mErrorType; }
90
91 private:
92 ErrorType_t mErrorType;
93 std::string mErrorMessage;
94 };
95
97 RCUTrailer() = default;
98
99 RCUTrailer(const gsl::span<const uint32_t> payloadwords);
100
102 ~RCUTrailer() = default;
103
107 void reset();
108
111 void printStream(std::ostream& stream) const;
112
118 void constructFromRawPayload(const gsl::span<const uint32_t> payloadwords);
119
120 unsigned int getFECErrorsA() const { return mFECERRA; }
121 unsigned int getFECErrorsB() const { return mFECERRB; }
122 unsigned short getErrorsG2() const { return mERRREG2; }
123 unsigned int getErrorsG3() const { return mERRREG3; }
124 unsigned short getActiveFECsA() const { return mActiveFECsA; }
125 unsigned short getActiveFECsB() const { return mActiveFECsB; }
126 unsigned int getAltroCFGReg1() const { return mAltroCFG1; }
127 unsigned int getAltroCFGReg2() const { return mAltroCFG2; }
128 int getRCUID() const { return mRCUId; }
129 unsigned int getTrailerSize() const { return mTrailerSize; }
130 unsigned int getPayloadSize() const { return mPayloadSize; }
131 unsigned char getFirmwareVersion() const { return mFirmwareVersion; }
132
133 unsigned short getNumberOfChannelAddressMismatch() const { return (mERRREG3 & 0xFFF); }
134 unsigned short getNumberOfChannelLengthMismatch() const { return ((mERRREG3 >> 12) & 0x1FFF); }
135 unsigned char getBaselineCorrection() const { return mAltroCFG1 & 0xF; }
136 bool getPolarity() const { return (mAltroCFG1 >> 4) & 0x1; }
137 unsigned char getNumberOfPresamples() const { return (mAltroCFG1 >> 5) & 0x3; }
138 unsigned char getNumberOfPostsamples() const { return (mAltroCFG1 >> 7) & 0xF; }
139 bool hasSecondBaselineCorr() const { return (mAltroCFG1 >> 11) & 0x1; }
140 unsigned char getGlitchFilter() const { return (mAltroCFG1 >> 12) & 0x3; }
141 unsigned char getNumberOfNonZeroSuppressedPostsamples() const { return (mAltroCFG1 >> 14) & 0x7; }
142 unsigned char getNumberOfNonZeroSuppressedPresamples() const { return (mAltroCFG1 >> 17) & 0x3; }
143 bool hasZeroSuppression() const { return (mAltroCFG1 >> 19) & 0x1; }
144 bool getNumberOfAltroBuffers() const { return (mAltroCFG2 >> 24) & 0x1; }
145 unsigned char getNumberOfPretriggerSamples() const { return (mAltroCFG2 >> 20) & 0xF; }
146 unsigned short getNumberOfSamplesPerChannel() const { return (mAltroCFG2 >> 10) & 0x3FF; }
147 bool isSparseReadout() const { return (mAltroCFG2 >> 9) & 0x1; }
148
152 double getTimeSample() const;
153
156 void setTimeSample(double timesample);
157
160 double getL1Phase() const;
161
164 void setL1Phase(double l1phase);
165
166 void setFECErrorsA(unsigned int value) { mFECERRA = value; }
167 void setFECErrorsB(unsigned int value) { mFECERRB = value; }
168 void setErrorsG2(unsigned short value) { mERRREG2 = value; }
169 void setErrorsG3(unsigned int value) { mERRREG3 = value; }
170 void setActiveFECsA(unsigned short value) { mActiveFECsA = value; }
171 void setActiveFECsB(unsigned short value) { mActiveFECsB = value; }
172 void setAltroCFGReg1(unsigned int value) { mAltroCFG1 = value; }
173 void setAltroCFGReg2(unsigned int value) { mAltroCFG2 = value; }
174 void setFirmwareVersion(unsigned char version) { mFirmwareVersion = version; }
175 void setPayloadSize(unsigned int size) { mPayloadSize = size; }
176
179 bool isInitialized() const { return mIsInitialized; }
180
181 std::vector<uint32_t> encode() const;
182
183 static RCUTrailer constructFromPayloadWords(const gsl::span<const uint32_t> payloadwords);
184
185 private:
186 int mRCUId = -1;
187 unsigned char mFirmwareVersion = 0;
188 unsigned int mTrailerSize = 0;
189 unsigned int mPayloadSize = 0;
190 unsigned int mFECERRA = 0;
191 unsigned int mFECERRB = 0;
192 unsigned short mERRREG2 = 0;
193 unsigned int mERRREG3 = 0;
194 unsigned short mActiveFECsA = 0;
195 unsigned short mActiveFECsB = 0;
196 unsigned int mAltroCFG1 = 0;
197 unsigned int mAltroCFG2 = 0;
198 bool mIsInitialized = false;
199
200 ClassDefNV(RCUTrailer, 1);
201};
202
203std::ostream& operator<<(std::ostream& stream, const RCUTrailer& trailer);
204
205} // namespace phos
206
207} // namespace o2
208
209#endif
uint32_t version
Definition RawData.h:8
Error handling of the.
Definition RCUTrailer.h:61
ErrorType_t
Error codes for different error types.
Definition RCUTrailer.h:65
@ SAMPLINGFREQ_INVALID
Invalid sampling frequency.
@ DECODING_INVALID
Invalid words during decoding.
ErrorType_t getErrorType() const noexcept
Access to error code.
Definition RCUTrailer.h:89
const char * what() const noexcept override
Access to the error message.
Definition RCUTrailer.h:85
Error(ErrorType_t errtype, const char *message)
Constructor.
Definition RCUTrailer.h:78
~Error() noexcept override=default
Destructor.
Information stored in the RCU trailer.
Definition RCUTrailer.h:56
void reset()
Reset the RCU trailer.
void setAltroCFGReg2(unsigned int value)
Definition RCUTrailer.h:173
unsigned short getActiveFECsB() const
Definition RCUTrailer.h:125
int getRCUID() const
Definition RCUTrailer.h:128
void setAltroCFGReg1(unsigned int value)
Definition RCUTrailer.h:172
RCUTrailer()=default
Constructor.
bool getNumberOfAltroBuffers() const
Definition RCUTrailer.h:144
unsigned char getGlitchFilter() const
Definition RCUTrailer.h:140
static RCUTrailer constructFromPayloadWords(const gsl::span< const uint32_t > payloadwords)
unsigned short getNumberOfChannelAddressMismatch() const
Definition RCUTrailer.h:133
void printStream(std::ostream &stream) const
Prints the contents of the RCU trailer data.
unsigned char getFirmwareVersion() const
Definition RCUTrailer.h:131
unsigned int getAltroCFGReg2() const
Definition RCUTrailer.h:127
bool isInitialized() const
checlks whether the RCU trailer is initialzied
Definition RCUTrailer.h:179
void setTimeSample(double timesample)
set time sample
void setFECErrorsA(unsigned int value)
Definition RCUTrailer.h:166
bool isSparseReadout() const
Definition RCUTrailer.h:147
void setActiveFECsA(unsigned short value)
Definition RCUTrailer.h:170
void setActiveFECsB(unsigned short value)
Definition RCUTrailer.h:171
void setFirmwareVersion(unsigned char version)
Definition RCUTrailer.h:174
unsigned int getFECErrorsA() const
Definition RCUTrailer.h:120
void setPayloadSize(unsigned int size)
Definition RCUTrailer.h:175
unsigned char getNumberOfNonZeroSuppressedPostsamples() const
Definition RCUTrailer.h:141
unsigned short getErrorsG2() const
Definition RCUTrailer.h:122
void setErrorsG2(unsigned short value)
Definition RCUTrailer.h:168
void constructFromRawPayload(const gsl::span< const uint32_t > payloadwords)
Decode RCU trailer from the 32-bit words in the raw buffer.
unsigned char getNumberOfPresamples() const
Definition RCUTrailer.h:137
unsigned int getPayloadSize() const
Definition RCUTrailer.h:130
bool hasSecondBaselineCorr() const
Definition RCUTrailer.h:139
double getTimeSample() const
Access to the sampling time.
unsigned short getNumberOfSamplesPerChannel() const
Definition RCUTrailer.h:146
unsigned short getActiveFECsA() const
Definition RCUTrailer.h:124
unsigned int getTrailerSize() const
Definition RCUTrailer.h:129
void setErrorsG3(unsigned int value)
Definition RCUTrailer.h:169
~RCUTrailer()=default
destructor
std::vector< uint32_t > encode() const
void setL1Phase(double l1phase)
Set the L1 phase.
bool getPolarity() const
Definition RCUTrailer.h:136
unsigned int getAltroCFGReg1() const
Definition RCUTrailer.h:126
double getL1Phase() const
Access to the L1 phase.
unsigned char getNumberOfPostsamples() const
Definition RCUTrailer.h:138
unsigned short getNumberOfChannelLengthMismatch() const
Definition RCUTrailer.h:134
unsigned int getErrorsG3() const
Definition RCUTrailer.h:123
bool hasZeroSuppression() const
Definition RCUTrailer.h:143
void setFECErrorsB(unsigned int value)
Definition RCUTrailer.h:167
unsigned int getFECErrorsB() const
Definition RCUTrailer.h:121
unsigned char getNumberOfPretriggerSamples() const
Definition RCUTrailer.h:145
unsigned char getBaselineCorrection() const
Definition RCUTrailer.h:135
unsigned char getNumberOfNonZeroSuppressedPresamples() const
Definition RCUTrailer.h:142
GLsizeiptr size
Definition glcorearb.h:659
GLsizei const GLfloat * value
Definition glcorearb.h:819
GLuint GLsizei const GLchar * message
Definition glcorearb.h:2517
GLuint GLuint stream
Definition glcorearb.h:1806
std::ostream & operator<<(std::ostream &in, const BadChannelsMap &bcm)
Printing bad channel map on the stream.
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
uint32_t mWord1
Bits 10 - 19 : Word 1.
Definition RCUTrailer.h:42
uint32_t mWord2
Bits 0 - 9 : Word 2.
Definition RCUTrailer.h:41
uint32_t mWord0
Bits 20 - 29 : Word 0.
Definition RCUTrailer.h:43
uint32_t mZero
Bits 30 - 31 : zeroed.
Definition RCUTrailer.h:44
uint32_t mMark
Bits 30 - 30: Mark header.
Definition RCUTrailer.h:34
uint32_t mZero1
Bits 26 - 28: zeroed.
Definition RCUTrailer.h:32
uint32_t mHardwareAddress
Bits 0 - 15: Hardware address.
Definition RCUTrailer.h:30
uint32_t mBadChannel
Bit 29: Bad channel status.
Definition RCUTrailer.h:33
uint32_t mPayloadSize
Bits 16 - 25: Payload size.
Definition RCUTrailer.h:31