14#include <fmt/format.h>
15#include <fairlogger/Logger.h>
40 mIsInitialized =
false;
46 int index = payloadwords.size();
50 auto word = payloadwords[--
index];
51 if ((word >> 30) != 3) {
54 mFirmwareVersion = (word >> 16) & 0xFF;
56 mRCUId = (int)((word >> 7) & 0x1FF);
57 int trailerSize = (word & 0x7F);
59 if (trailerSize < 2 || trailerSize >
index + 1) {
62 mTrailerSize = trailerSize;
65 for (; trailerSize > 0; trailerSize--) {
66 word = payloadwords[--
index];
67 if ((word >> 30) != 2) {
68 LOG(
error) <<
"Missing RCU trailer identifier pattern!";
71 int parCode = (word >> 26) & 0xF;
72 int parData = word & 0x3FFFFFF;
76 mFECERRA = ((parData >> 13) & 0x1FFF) << 7;
77 mFECERRB = ((parData & 0x1FFF)) << 7;
81 mERRREG2 = parData & 0x1FF;
85 mERRREG3 = parData & 0x1FFFFFF;
89 mActiveFECsA = parData & 0xFFFF;
93 mActiveFECsB = parData & 0xFFFF;
97 mAltroCFG1 = parData & 0xFFFFF;
101 mAltroCFG2 = parData & 0x1FFFFFF;
104 LOG(
error) <<
"Undefined parameter code " << parCode <<
", ignore it !";
108 mPayloadSize = payloadwords[--
index] & 0x3FFFFFF;
109 mIsInitialized =
true;
114 unsigned char fq = (mAltroCFG2 >> 5) & 0xF;
133 return tSample * o2::constants::lhc::LHCBunchSpacingNS * 1.e-9;
139 if (std::abs(timesample - 50) < DBL_EPSILON) {
141 }
else if (std::abs(timesample - 100) < DBL_EPSILON) {
143 }
else if (std::abs(timesample - 200) < DBL_EPSILON) {
148 mAltroCFG2 = (mAltroCFG2 & 0x1F) | fq << 5;
154 phase = ((double)(mAltroCFG2 & 0x1F)) * o2::constants::lhc::LHCBunchSpacingNS * 1.e-9;
155 if (
phase >= tSample) {
163 int phase = l1phase / 25.;
164 mAltroCFG2 = (mAltroCFG2 & 0x1E0) |
phase;
169 std::vector<uint32_t> encoded;
170 encoded.emplace_back(mPayloadSize | 2 << 30);
171 encoded.emplace_back(mAltroCFG2 | 7 << 26 | 2 << 30);
172 encoded.emplace_back(mAltroCFG1 | 6 << 26 | 2 << 30);
173 encoded.emplace_back(mActiveFECsB | 5 << 26 | 2 << 30);
174 encoded.emplace_back(mActiveFECsA | 4 << 26 | 2 << 30);
175 encoded.emplace_back(mERRREG3 | 3 << 26 | 2 << 30);
176 encoded.emplace_back(mERRREG2 | 2 << 26 | 2 << 30);
177 encoded.emplace_back(mFECERRB >> 7 | (mFECERRA >> 7) << 13 | 1 << 26 | 2 << 30);
179 uint32_t lasttrailerword = 3 << 30 | mFirmwareVersion << 16 | mRCUId << 7 | (encoded.size() + 1);
180 encoded.emplace_back(lasttrailerword);
187 std::vector<std::string> errors;
188 double timesample = -1., l1phase = -1.;
192 errors.push_back(
e.what());
197 errors.push_back(
e.what());
200 stream <<
"RCU trailer (Format version 2):\n"
201 <<
"==================================================\n"
202 <<
"RCU ID: " << mRCUId <<
"\n"
203 <<
"Firmware version: " << int(mFirmwareVersion) <<
"\n"
204 <<
"Trailer size: " << mTrailerSize <<
"\n"
205 <<
"Payload size: " << mPayloadSize <<
"\n"
206 <<
"FECERRA: 0x" << std::hex << mFECERRA <<
"\n"
207 <<
"FECERRB: 0x" << std::hex << mFECERRB <<
"\n"
208 <<
"ERRREG2: 0x" << std::hex << mERRREG2 <<
"\n"
211 <<
"Active FECs (branch A): 0x" << std::hex << mActiveFECsA <<
"\n"
212 <<
"Active FECs (branch B): 0x" << std::hex << mActiveFECsB <<
"\n"
224 <<
"AltroCFG1: 0x" << std::hex << mAltroCFG1 <<
"\n"
225 <<
"AltroCFG2: 0x" << std::hex << mAltroCFG2 <<
"\n"
226 <<
"Sampling time: " << std::scientific << timesample <<
" s\n"
227 <<
"L1 Phase: " << std::scientific << l1phase <<
" s\n"
228 << std::dec << std::fixed;
231 <<
"-------------------------------------------------\n";
232 for (
const auto&
e : errors) {
236 stream <<
"==================================================\n";
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char e
char error[CURL_ERROR_SIZE]
Header to collect LHC related constants.
@ SIZE_INVALID
Invalid trailer size.
@ SAMPLINGFREQ_INVALID
Invalid sampling frequency.
@ DECODING_INVALID
Invalid words during decoding.
@ L1PHASE_INVALID
Invalid L1 phase.
Information stored in the RCU trailer.
void reset()
Reset the RCU trailer.
RCUTrailer()=default
Constructor.
bool getNumberOfAltroBuffers() const
unsigned char getGlitchFilter() const
static RCUTrailer constructFromPayloadWords(const gsl::span< const uint32_t > payloadwords)
unsigned short getNumberOfChannelAddressMismatch() const
void printStream(std::ostream &stream) const
Prints the contents of the RCU trailer data.
void setTimeSample(double timesample)
set time sample
bool isSparseReadout() const
unsigned char getNumberOfNonZeroSuppressedPostsamples() const
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
bool hasSecondBaselineCorr() const
double getTimeSample() const
Access to the sampling time.
unsigned short getNumberOfSamplesPerChannel() const
std::vector< uint32_t > encode() const
void setL1Phase(double l1phase)
Set the L1 phase.
double getL1Phase() const
Access to the L1 phase.
unsigned char getNumberOfPostsamples() const
unsigned short getNumberOfChannelLengthMismatch() const
unsigned char getNumberOfPretriggerSamples() const
unsigned char getBaselineCorrection() const
unsigned char getNumberOfNonZeroSuppressedPresamples() const
std::ostream & operator<<(std::ostream &in, const BadChannelsMap &bcm)
Printing bad channel map on the stream.
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"