23#include <fairlogger/Logger.h>
36 "Row Marker Word with 0 words",
37 "Duplicated Pad Word !",
38 "Row Marker Wrong/Lost -> to EoE",
39 "Row Marker Wrong/Lost -> to EoE",
40 "Row Marker reports an ERROR !",
43 "Wrong size definition in EoE Marker",
44 "Double Mark Word",
"Wrong Size in Segment Marker",
46 "HMPID Header Errors"};
50 "L1-Trigger received without L0",
51 "L1-Trigger received before the L1-Latency",
52 "L1-Trigger received after the L1-Time-Latency-Window",
53 "L1-Trigger after L1-Message or after timeout (12.8us)",
54 "L1-Message before L1-Trigger or after timeout (12.8us)"};
196 if ((wp & 0x0000ffff) == 0x000036A8 || (wp & 0x0000ffff) == 0x000032A8 || (wp & 0x0000ffff) == 0x000030A0 || (wp & 0x0800ffff) == 0x080010A0) {
197 *
p2 = (wp & 0x03ff0000) >> 16;
198 *
p1 = wp & 0x0000ffff;
201 if ((wp & 0xfff00000) >> 20 == 0xAB0) {
202 *
p2 = (wp & 0x000fff00) >> 8;
203 *
p1 = (wp & 0xfff00000) >> 20;
204 *p3 = wp & 0x0000000F;
205 if (*p3 < 4 && *p3 > 0) {
210 if ((wp & 0x0803FF80) == 0x08000080) {
211 *
p1 = (wp & 0x07c00000) >> 22;
212 *
p2 = (wp & 0x003C0000) >> 18;
213 *p3 = (wp & 0x0000007F);
214 if (*
p1 < 25 && *
p2 < 11) {
218 if ((wp & 0x08000000) == 0) {
220 *
p1 = (wp & 0x07c00000) >> 22;
221 *
p2 = (wp & 0x003C0000) >> 18;
222 *p3 = (wp & 0x0003F000) >> 12;
223 *p4 = (wp & 0x00000FFF);
224 if (*
p1 > 0 && *p1 < 25 && *p2 > 0 && *
p2 < 11 && *p3 < 48) {
241 if ((wp & 0x0000ffff) == 0x36A8 || (wp & 0x0000ffff) == 0x32A8 || (wp & 0x0000ffff) == 0x30A0 || (wp & 0x0800ffff) == 0x080010A0) {
242 *rowSize = (wp & 0x03ff0000) >> 16;
243 *mark = wp & 0x0000ffff;
262 if ((wp & 0xfff00000) >> 20 == 0xAB0) {
263 *segSize = (wp & 0x000fff00) >> 8;
264 *mark = (wp & 0xfff00000) >> 20;
265 *Seg = wp & 0x0000000F;
266 if (*Seg > 3 || *Seg < 1) {
268 std::cout <<
"HMPID Decoder2 : [INFO] "
269 <<
" Wrong segment Marker Word, bad Number of segment" << *Seg <<
"!" << std::endl;
292 if ((wp & 0x08000000) != 0) {
295 *Col = (wp & 0x07c00000) >> 22;
296 *Dilogic = (wp & 0x003C0000) >> 18;
297 *Channel = (wp & 0x0003F000) >> 12;
298 *Charge = (wp & 0x00000FFF);
301 row = (wp & 0x03ff0000) >> 16;
303 if (mark == 0x036A8 || mark == 0x032A8 || mark == 0x030A0 || mark == 0x010A0) {
304 if (*Dilogic > 10 || *Channel > 47 || *Dilogic < 1 || *Col > 24 || *Col < 1 || row <= 490 || row > 10) {
308 if (*Dilogic > 10 || *Channel > 47 || *Dilogic < 1 || *Col > 24 || *Col < 1) {
328 if ((wp & 0x0803FF80) == 0x08000080) {
329 *Col = (wp & 0x07c00000) >> 22;
330 *Dilogic = (wp & 0x003C0000) >> 18;
331 *Eoesize = (wp & 0x0000007F);
332 if (*Col > 24 || *Dilogic > 10) {
334 std::cout <<
"HMPID Decoder2 : [DEBUG] "
335 <<
" EoE size wrong definition. Col=" << *Col <<
" Dilogic=" << *Dilogic << std::endl;
356 if ((ErrorField & (0x01 <<
i)) != 0) {
379 uint32_t*
buffer = streamPtrAdr;
411 std::cout <<
"HMPID Decoder2 : [INFO] "
417 if (*EquipIndex == -1) {
419 std::cout <<
"HMPID Decoder2 : [ERROR] "
420 <<
"ERROR ! Bad equipment Number: " <<
mEquipment << std::endl;
426 std::cout <<
"HMPID Decoder2 : [ERROR] "
427 <<
"ERROR ! Bad Detector Id Number: " <<
mHeDetectorID << std::endl;
460 if (EquipmentIndex < 0 || EquipmentIndex > 13) {
462 std::cout <<
"HMPID Decoder2 : [ERROR] "
463 <<
"Bad Equipment number !" << EquipmentIndex << std::endl;
482 std::cout <<
"HMPID Header reports an error : " <<
mHeHmpidError << std::endl;
503 std::cout <<
"HMPID Decoder2 : [DEBUG] "
504 <<
"End main decoding loop !" << std::endl;
512 std::cout <<
"HMPID Decoder2 : [ERROR] "
513 <<
"Failed to decode the Header !" << std::endl;
534 if (newOne ==
true) {
555 std::cout <<
"HMPID Decoder2 : [INFO] "
557 << eq->
mEventNumber <<
" >" << std::hex << wp << std::dec <<
"<" <<
type << std::endl;
576 std::cout <<
"HMPID Decoder2 : [INFO] "
625 if (isIt ==
true && error ==
false) {
637 std::cout <<
"HMPID Decoder2 : [INFO] "
638 <<
"Event" << eq->
mEventNumber <<
" >" <<
p1 - 1 <<
"," <<
p2 - 1 <<
"," << p3 <<
"," << p4 << std::endl;
657 if (isIt ==
true && error ==
false) {
704 int typb, p1b, p2b, p3b, p4b;
705 typb =
checkType((wp | 0x08000000), &p1b, &p2b, &p3b, &p4b);
724 }
else if (
type == 2) {
767 std::cout <<
"HMPID Decoder2 : [DEBUG] "
768 <<
"Enter decoding !" << std::endl;
777 std::cout <<
"HMPID Decoder2 : [DEBUG] "
778 <<
"End main buffer decoding loop !" << std::endl;
824 std::cout <<
"HMPID Decoder2 : [INFO] "
825 <<
"End Fast Page decoding loop ! (" << e <<
")" << std::endl;
833 std::cout <<
"HMPID Decoder2 : [INFO] "
834 <<
"Failed to decode the Header ! (" << e <<
")" << std::endl;
843 std::cout <<
"HMPID Decoder2 : [INFO] "
844 <<
"Failed to evaluate the Header ! (" << e <<
")" << std::endl;
851 int Column, Dilogic, Channel, Charge;
859 std::cout <<
"HMPID Decoder2 : [DEBUG] "
863 if (
isPadWord(wp, &pwer, &Column, &Dilogic, &Channel, &Charge) ==
true) {
865 if (!((equipmentIndex == 6 && Column == 16 && Dilogic == 10) || (equipmentIndex == 13 && Column == 18 && Dilogic == 2))) {
866 setPad(eq, Column - 1, Dilogic - 1, Channel, Charge);
888 bool isNotEmpty =
true;
896 std::cout <<
"HMPID Decoder2 : [INFO] "
897 <<
"Enter FAST decoding !" << std::endl;
905 std::cout <<
"HMPID Decoder2 : [ERROR] "
906 <<
"End Buffer Fast Decoding! Exit code error = " << e << std::endl;
983 return (
mTheEquipments[EqInd]->mPadSamples[Column][Dilogic][Channel]);
998 return (
mTheEquipments[EqInd]->mPadSum[Column][Dilogic][Channel]);
1013 return (
mTheEquipments[EqInd]->mPadSquares[Column][Dilogic][Channel]);
1052 std::cout <<
"Dump Errors for the Equipment = " << EquipmId << std::endl;
1056 std::cout <<
" -------- " << std::endl;
1070 int Module = EquipmId / 2;
1071 int StartRow = (EquipmId % 2 == 1) ? 80 : 0;
1072 int EndRow = (EquipmId % 2 == 1) ? 160 : 80;
1073 std::cout <<
"Dump Pads for the Equipment = " << EquipmId << std::endl;
1074 for (
int c = 0;
c < 144;
c++) {
1075 for (
int r = StartRow;
r < EndRow;
r++) {
1088 std::cout << std::endl;
1090 std::cout <<
" -------- " << std::endl;
1101 std::cout <<
"HMPID Decoder2 : [ERROR] "
1102 <<
"HMPID Error field = " << ErrorField <<
" : " << printbuf << std::endl;
1104 LOG(warn) <<
"HMPID Header Error Field =" << ErrorField <<
" [" << printbuf <<
"]"
1116 const unsigned char*
data =
static_cast<const unsigned char*
>(MemoryStartPtr);
1117 for (std::size_t
i = 0;
i < Dimension;
i += 16) {
1118 std::cout << std::hex << std::setw(4) << std::setfill(
'0') <<
i <<
" : ";
1120 for (std::size_t
j = 0;
j < 16; ++
j) {
1121 if (
i +
j < Dimension) {
1122 std::cout << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(
data[
i +
j]) <<
" ";
1129 for (std::size_t
j = 0;
j < 16 &&
i +
j < Dimension; ++
j) {
1130 char ch = (
data[
i +
j] >= 32 &&
data[
i +
j] <= 126) ?
static_cast<char>(
data[
i +
j]) :
'.';
1133 std::cout << std::endl;
1144 FILE* fs = fopen(summaryFileName,
"w");
1145 if (fs ==
nullptr) {
1146 printf(
"Error opening the file %s !\n", summaryFileName);
1150 fprintf(fs,
"HMPID Readout Raw Data Decoding Summary File\n");
1151 fprintf(fs,
"Equipment Id\t");
1157 fprintf(fs,
"Number of events\t");
1163 fprintf(fs,
"Average Event Size\t");
1169 fprintf(fs,
"Total pads\t");
1175 fprintf(fs,
"Average pads per event\t");
1181 fprintf(fs,
"Busy Time average\t");
1187 fprintf(fs,
"Event rate\t");
1193 fprintf(fs,
"Number of Empty Events\t");
1199 fprintf(fs,
"-------------Errors--------------------\n");
1200 fprintf(fs,
"Wrong events\t");
1214 fprintf(fs,
"Total errors\t");
1279 long wordsBufferLen = BufferLen / (
sizeof(int32_t) /
sizeof(
char));
1280 if (Buffer ==
nullptr) {
1282 std::cout <<
"HMPID Decoder2 : [ERROR] "
1283 <<
"Raw data buffer null Pointer ! " << std::endl;
1287 if (wordsBufferLen == 0) {
1289 std::cout <<
"HMPID Decoder2 : [ERROR] "
1290 <<
"Raw data buffer Empty ! " << std::endl;
1294 if (wordsBufferLen < 16) {
1296 std::cout <<
"HMPID Decoder2 : [ERROR] "
1297 <<
"Raw data buffer less then the Header Dimension = " << wordsBufferLen << std::endl;
1307 std::cout <<
"HMPID Decoder2 : setUpStream() "
1309 <<
" BufferLen = " << std::dec << BufferLen << std::endl;
1310 if (BufferLen < 256) {
constexpr int p1()
constexpr to accelerate the coordinates changing
#define MAXDESCRIPTIONLENGHT
Class for time synchronization of RawReader instances.
static void absolute2Equipment(int Module, int x, int y, int *Equi, int *Colu, int *Dilo, int *Chan)
static constexpr int MAXEQUIPMENTS
float getAverageEventSize(int Equipment)
HmpidDecoder2(int *EqIds, int *CruIds, int *LinkIds, int numOfEquipments)
static char sHmpidErrorDescription[MAXHMPIDERRORS][MAXDESCRIPTIONLENGHT]
HMPID Firmware Error Messages Definitions.
void dumpPads(int Equipment, int type=0)
bool isPadWord(uint32_t wp, int *Err, int *Col, int *Dilogic, int *Channel, int *Charge)
void setPad(HmpidEquipment *eq, int col, int dil, int ch, uint16_t charge)
int checkType(uint32_t wp, int *p1, int *p2, int *p3, int *p4)
bool isEoEmarker(uint32_t wp, int *Err, int *Col, int *Dilogic, int *Eoesize)
void decodePageFast(uint32_t **streamBuf)
void init()
Init all the members variables.
std::vector< o2::hmpid::Digit > mDigits
uint32_t readWordFromStream()
bool decodeHmpidError(int ErrorField, char *outbuf)
void dumpMemory(const void *MemoryStartPtr, std::size_t Dimension)
uint32_t * mActualStreamPtr
double getChannelSquare(int Equipment, int Column, int Dilogic, int Channel)
static char sErrorDescription[MAXERRORS][MAXDESCRIPTIONLENGHT]
Decoding Error Messages Definitions.
HmpidEquipment * evaluateHeaderContents(int EquipmentIndex)
void decodePage(uint32_t **streamBuffer)
uint16_t getChannelSamples(int Equipment, int Column, int Dilogic, int Channel)
~HmpidDecoder2()
Destructor : remove the Equipments instances.
bool isRowMarker(uint32_t wp, int *Err, int *rowSize, int *mark)
o2::InteractionRecord mIntReco
bool setUpStream(void *Buffer, long BufferLen)
int decodeHeader(uint32_t *streamPtrAdr, int *EquipIndex)
void writeSummaryFile(char *summaryFileName)
void dumpErrors(int Equipment)
int getEquipmentIndex(int EquipmentId)
double getPadSum(int Module, int Row, int Column)
bool isSegmentMarker(uint32_t wp, int *Err, int *segSize, int *Seg, int *mark)
HmpidEquipment * mTheEquipments[Geo::MAXEQUIPMENTS]
uint16_t getPadSamples(int Module, int Row, int Column)
bool getHeaderFromStream(uint32_t **streamPtr)
uint32_t * mStartStreamPtr
void updateStatistics(HmpidEquipment *eq)
void dumpHmpidError(HmpidEquipment *eq, int ErrorField, int mHeBCDI, int mHeORBIT)
float getAverageBusyTime(int Equipment)
bool getBlockFromStream(uint32_t **streamPtr, uint32_t Size)
double getPadSquares(int Module, int Row, int Column)
double getChannelSum(int Equipment, int Column, int Dilogic, int Channel)
int getEquipmentID(int CruId, int LinkId)
int mWordsPerDilogicCounter
void setPad(int col, int dil, int cha, uint16_t charge)
void setError(int ErrType)
void init()
Inits the members for the decoding.
void resetPadMap()
Resets the matrix that contains the results of the decoding.
void resetErrors()
Resets the decoding errors statistics.
float mPadsPerEventAverage
static int FeeId(unsigned int idx)
static int CruId(unsigned int idx)
static int LnkId(unsigned int idx)
GLint GLint GLsizei GLint GLenum GLenum type
const int ERR_DOUBLEEOEMARK
const int TH_WRONGEQUIPINDEX
const int ERR_DOUBLEMARKWORD
const int ERR_DUPLICATEPAD
const int ERR_LOSTEOEMARK
const int ERR_WRONGSIZESEGMENTMARK
const int TH_NULLBUFFERPOINTER
const int ERR_ROWMARKEMPTY
const int TH_BUFFERPOINTERTOEND
const uint64_t OUTRANGEEVENTNUMBER
const int ERR_LOSTEOSMARK
const int ERR_ROWMARKWRONG
const int ERR_ROWMARKERROR
const int ERR_ROWMARKLOST
const int TH_WRONGBUFFERDIM
const int ERR_WRONGSIZEINEOE
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"