22#include <fairlogger/Logger.h>
34 "Row Marker Word with 0 words",
"Duplicated Pad Word !",
"Row Marker Wrong/Lost -> to EoE",
35 "Row Marker Wrong/Lost -> to EoE",
"Row Marker reports an ERROR !",
"Lost EoE Marker !",
"Double EoE marker",
36 "Wrong size definition in EoE Marker",
"Double Mark Word",
"Wrong Size in Segment Marker",
"Lost EoS Marker !",
37 "HMPID Header Errors"};
42 "L1 is received without L0",
43 "L1A signal arrived before the L1 Latency",
"L1A signal arrived after the L1 Latency",
44 "L1A is missing or L1 timeout",
"L1A Message is missing or L1 Message"};
54 int EqIds[] = {0, 1, 2, 3, 4, 5, 8, 9, 6, 7, 10, 11, 12, 13};
55 int CruIds[] = {0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3};
56 int LinkIds[] = {0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 0, 1, 2};
186 if ((wp & 0x0000ffff) == 0x000036A8 || (wp & 0x0000ffff) == 0x000032A8 || (wp & 0x0000ffff) == 0x000030A0 || (wp & 0x0800ffff) == 0x080010A0) {
187 *
p2 = (wp & 0x03ff0000) >> 16;
188 *
p1 = wp & 0x0000ffff;
191 if ((wp & 0xfff00000) >> 20 == 0xAB0) {
192 *
p2 = (wp & 0x000fff00) >> 8;
193 *
p1 = (wp & 0xfff00000) >> 20;
194 *p3 = wp & 0x0000000F;
195 if (*p3 < 4 && *p3 > 0) {
200 if ((wp & 0x0803FF80) == 0x08000080) {
201 *
p1 = (wp & 0x07c00000) >> 22;
202 *
p2 = (wp & 0x003C0000) >> 18;
203 *p3 = (wp & 0x0000007F);
204 if (*
p1 < 25 && *
p2 < 11) {
208 if ((wp & 0x08000000) == 0) {
210 *
p1 = (wp & 0x07c00000) >> 22;
211 *
p2 = (wp & 0x003C0000) >> 18;
212 *p3 = (wp & 0x0003F000) >> 12;
213 *p4 = (wp & 0x00000FFF);
214 if (*
p1 > 0 && *p1 < 25 && *p2 > 0 && *
p2 < 11 && *p3 < 48) {
231 if ((wp & 0x0000ffff) == 0x36A8 || (wp & 0x0000ffff) == 0x32A8 || (wp & 0x0000ffff) == 0x30A0 || (wp & 0x0800ffff) == 0x080010A0) {
232 *rowSize = (wp & 0x03ff0000) >> 16;
233 *mark = wp & 0x0000ffff;
252 if ((wp & 0xfff00000) >> 20 == 0xAB0) {
253 *segSize = (wp & 0x000fff00) >> 8;
254 *mark = (wp & 0xfff00000) >> 20;
255 *Seg = wp & 0x0000000F;
256 if (*Seg > 3 || *Seg < 1) {
257 LOG(info) <<
" Wrong segment Marker Word, bad Number of segment" << *Seg <<
"!";
279 if ((wp & 0x08000000) != 0) {
282 *Col = (wp & 0x07c00000) >> 22;
283 *Dilogic = (wp & 0x003C0000) >> 18;
284 *Channel = (wp & 0x0003F000) >> 12;
285 *Charge = (wp & 0x00000FFF);
287 if ((wp & 0x0ffff) == 0x036A8 || (wp & 0x0ffff) == 0x032A8 || (wp & 0x0ffff) == 0x030A0 || (wp & 0x0ffff) == 0x010A0) {
288 if (*Dilogic > 10 || *Channel > 47 || *Dilogic < 1 || *Col > 24 || *Col < 1) {
292 if (*Dilogic > 10 || *Channel > 47 || *Dilogic < 1 || *Col > 24 || *Col < 1) {
312 if ((wp & 0x0803FF80) == 0x08000080) {
313 *Col = (wp & 0x07c00000) >> 22;
314 *Dilogic = (wp & 0x003C0000) >> 18;
315 *Eoesize = (wp & 0x0000007F);
316 if (*Col > 24 || *Dilogic > 10) {
317 LOG(info) <<
" EoE size wrong definition. Col=" << *Col <<
" Dilogic=" << *Dilogic;
337 if ((ErrorField & (0x01 <<
i)) != 0) {
360 uint32_t*
buffer = streamPtrAdr;
420 if (*EquipIndex == -1) {
421 LOG(error) <<
"ERROR ! Bad equipment Number: " <<
mEquipment;
492 LOG(
debug) <<
"End main decoding loop !";
498 LOG(error) <<
"Failed to decode the Header !";
514 if (newOne ==
true) {
537 LOG(info) <<
"Event" << eq->
mEventNumber <<
" >" << std::hex << wp << std::dec <<
"<" <<
type;
607 if (isIt ==
true && error ==
false) {
620 LOG(info) <<
"Event" << eq->
mEventNumber <<
" >" <<
p1 - 1 <<
"," <<
p2 - 1 <<
"," << p3 <<
"," << p4;
638 if (isIt ==
true && error ==
false) {
691 int typb, p1b, p2b, p3b, p4b;
692 typb =
checkType((wp | 0x08000000), &p1b, &p2b, &p3b, &p4b);
713 }
else if (
type == 2) {
756 int equipmentIndex = -1;
767 LOG(
debug) <<
"End main buffer decoding loop !";
793 LOG(info) <<
"End Fast Page decoding loop !";
799 LOG(info) <<
"Failed to decode the Header !";
806 int Column, Dilogic, Channel, Charge;
817 if (
isPadWord(wp, &pwer, &Column, &Dilogic, &Channel, &Charge) ==
true) {
819 setPad(eq, Column - 1, Dilogic - 1, Channel, Charge);
845 LOG(info) <<
"Enter FAST decoding !";
852 LOG(info) <<
" End Buffer Fast Decoding !";
928 return (
mTheEquipments[EqInd]->mPadSamples[Column][Dilogic][Channel]);
943 return (
mTheEquipments[EqInd]->mPadSum[Column][Dilogic][Channel]);
958 return (
mTheEquipments[EqInd]->mPadSquares[Column][Dilogic][Channel]);
997 std::cout <<
"Dump Errors for the Equipment = " << EquipmId << std::endl;
1001 std::cout <<
" -------- " << std::endl;
1015 int Module = EquipmId / 2;
1016 int StartRow = (EquipmId % 2 == 1) ? 80 : 0;
1017 int EndRow = (EquipmId % 2 == 1) ? 160 : 80;
1018 std::cout <<
"Dump Pads for the Equipment = " << EquipmId << std::endl;
1019 for (
int c = 0;
c < 144;
c++) {
1020 for (
int r = StartRow;
r < EndRow;
r++) {
1033 std::cout << std::endl;
1035 std::cout <<
" -------- " << std::endl;
1045 LOG(error) <<
"HMPID Error field = " << ErrorField <<
" : " << printbuf;
1056 FILE* fs = fopen(summaryFileName,
"w");
1057 if (fs ==
nullptr) {
1058 printf(
"Error opening the file %s !\n", summaryFileName);
1062 fprintf(fs,
"HMPID Readout Raw Data Decoding Summary File\n");
1063 fprintf(fs,
"Equipment Id\t");
1069 fprintf(fs,
"Number of events\t");
1075 fprintf(fs,
"Average Event Size\t");
1081 fprintf(fs,
"Total pads\t");
1087 fprintf(fs,
"Average pads per event\t");
1093 fprintf(fs,
"Busy Time average\t");
1099 fprintf(fs,
"Event rate\t");
1105 fprintf(fs,
"Number of Empty Events\t");
1111 fprintf(fs,
"-------------Errors--------------------\n");
1112 fprintf(fs,
"Wrong events\t");
1126 fprintf(fs,
"Total errors\t");
constexpr int p1()
constexpr to accelerate the coordinates changing
Base Class to decode HMPID Raw Data stream.
#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
double getChannelSum(int Equipment, int Column, int Dilogic, int Channel)
uint32_t * mStartStreamPtr
uint16_t getPadSamples(int Module, int Row, int Column)
bool isRowMarker(uint32_t wp, int *Err, int *rowSize, int *mark)
int checkType(uint32_t wp, int *p1, int *p2, int *p3, int *p4)
int decodeHeader(uint32_t *streamPtrAdr, int *EquipIndex)
void decodePage(uint32_t **streamBuffer)
uint16_t getChannelSamples(int Equipment, int Column, int Dilogic, int Channel)
static char sErrorDescription[MAXERRORS][MAXDESCRIPTIONLENGHT]
Decoding Error Messages Definitions.
virtual bool getHeaderFromStream(uint32_t **streamPtr)=0
bool decodeHmpidError(int ErrorField, char *outbuf)
void updateStatistics(HmpidEquipment *eq)
void dumpHmpidError(int ErrorField)
double getPadSquares(int Module, int Row, int Column)
int getEquipmentIndex(int EquipmentId)
bool isPadWord(uint32_t wp, int *Err, int *Col, int *Dilogic, int *Channel, int *Charge)
void decodePageFast(uint32_t **streamBuf)
virtual bool getWordFromStream(uint32_t *word)=0
virtual void setPad(HmpidEquipment *eq, int col, int dil, int ch, uint16_t charge)=0
~HmpidDecoder()
Destructor : remove the Equipments instances.
bool isEoEmarker(uint32_t wp, int *Err, int *Col, int *Dilogic, int *Eoesize)
double getChannelSquare(int Equipment, int Column, int Dilogic, int Channel)
HmpidDecoder(int *EqIds, int *CruIds, int *LinkIds, int numOfEquipments)
HmpidEquipment * evaluateHeaderContents(int EquipmentIndex)
o2::InteractionRecord mIntReco
void writeSummaryFile(char *summaryFileName)
HmpidEquipment * mTheEquipments[Geo::MAXEQUIPMENTS]
uint32_t * mActualStreamPtr
float getAverageBusyTime(int Equipment)
void init()
Init all the members variables.
double getPadSum(int Module, int Row, int Column)
static char sHmpidErrorDescription[MAXHMPIDERRORS][MAXDESCRIPTIONLENGHT]
HMPID Firmware Error Messages Definitions.
float getAverageEventSize(int Equipment)
void dumpErrors(int Equipment)
void dumpPads(int Equipment, int type=0)
int getEquipmentID(int CruId, int LinkId)
bool isSegmentMarker(uint32_t wp, int *Err, int *segSize, int *Seg, int *mark)
int mWordsPerDilogicCounter
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
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 ERR_ROWMARKEMPTY
const uint64_t OUTRANGEEVENTNUMBER
const int ERR_LOSTEOSMARK
const int ERR_ROWMARKWRONG
const int ERR_ROWMARKERROR
const int ERR_ROWMARKLOST
const int ERR_WRONGSIZEINEOE
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"