QualityControl  1.5.1
O2 Data Quality Control Framework
HmpidDecoder.h
Go to the documentation of this file.
1 // Copyright CERN and copyright holders of ALICE O2. This software is
2 // distributed under the terms of the GNU General Public License v3 (GPL
3 // Version 3), copied verbatim in the file "COPYING".
4 //
5 // See http://alice-o2.web.cern.ch/license for full licensing information.
6 //
7 // In applying this license CERN does not waive the privileges and immunities
8 // granted to it by virtue of its status as an Intergovernmental Organization
9 // or submit itself to any jurisdiction.
10 
16 
17 #ifndef COMMON_HMPIDDECODER_H_
18 #define COMMON_HMPIDDECODER_H_
19 
20 #include <cstdio>
21 #include <stdint.h>
22 #include <iostream>
23 #include <cstring>
24 
26 
27 #include "HMPID/HmpidEquipment.h"
28 
29 #define MAXDESCRIPTIONLENGHT 50
30 
31 // ---- RDH 6 standard dimension -------
32 #define RAWBLOCKDIMENSION_W 2048
33 #define HEADERDIMENSION_W 16
34 #define PAYLOADDIMENSION_W 2032
35 
36 // ---- Defines for the decoding
37 #define WTYPE_ROW 1
38 #define WTYPE_EOS 2
39 #define WTYPE_PAD 3
40 #define WTYPE_EOE 4
41 #define WTYPE_NONE 0
42 
43 // Hmpid Equipment class
45 {
46 
48 {
49 
50  // Members
51  public:
52  int mVerbose;
53  HmpidEquipment* mTheEquipments[MAXEQUIPMENTS];
54  int mNumberOfEquipments;
55 
56  static char sErrorDescription[MAXERRORS][MAXDESCRIPTIONLENGHT];
57  static char sHmpidErrorDescription[MAXHMPIDERRORS][MAXDESCRIPTIONLENGHT];
58 
59  public:
60  int mHeEvent;
61  int mHeBusy;
62  int mNumberWordToRead;
63  int mPayloadTail;
64 
65  int mHeFEEID;
66  int mHeSize;
67  int mHeVer;
68  int mHePrior;
69  int mHeStop;
70  int mHePages;
71  int mEquipment;
72 
73  int mHeOffsetNewPack;
74  int mHeMemorySize;
75 
76  int mHeDetectorID;
77  int mHeDW;
78  int mHeCruID;
79  int mHePackNum;
80  int mHePAR;
81 
82  int mHePageNum;
83  int mHeLinkNum;
84  int mHeFirmwareVersion;
85  int mHeHmpidError;
86  int mHeBCDI;
87  int mHeORBIT;
88  int mHeTType;
89 
90  int32_t* mActualStreamPtr;
91  int32_t* mEndStreamPtr;
92  int32_t* mStartStreamPtr;
93 
94  // Methods
95  public:
96  HmpidDecoder(int* EqIds, int* CruIds, int* LinkIds, int numOfEquipments);
97  HmpidDecoder(int numOfEquipments);
98  ~HmpidDecoder();
99 
100  void init();
101  virtual bool setUpStream(void* Buffer, long BufferLen) = 0;
102  void setVerbosity(int Level)
103  {
104  mVerbose = Level;
105  };
106  int getVerbosity()
107  {
108  return (mVerbose);
109  };
110 
111  int getNumberOfEquipments()
112  {
113  return (mNumberOfEquipments);
114  };
115  int getEquipmentIndex(int EquipmentId);
116  int getEquipmentIndex(int CruID, int LinkId);
117  int getEquipmentID(int CruId, int LinkId);
118 
119  bool decodeBuffer();
120 
121  uint16_t getChannelSamples(int Equipment, int Column, int Dilogic, int Channel);
122  double getChannelSum(int Equipment, int Column, int Dilogic, int Channel);
123  double getChannelSquare(int Equipment, int Column, int Dilogic, int Channel);
124  uint16_t getPadSamples(int Module, int Column, int Row);
125  double getPadSum(int Module, int Column, int Row);
126  double getPadSquares(int Module, int Column, int Row);
127 
128  void dumpErrors(int Equipment);
129  void dumpPads(int Equipment, int type = 0);
130  void writeSummaryFile(char* summaryFileName);
131 
132  float getAverageEventSize(int Equipment);
133  float getAverageBusyTime(int Equipment);
134 
135  protected:
136  int checkType(int32_t wp, int* p1, int* p2, int* p3, int* p4);
137  bool isRowMarker(int32_t wp, int* Err, int* rowSize, int* mark);
138  bool isSegmentMarker(int32_t wp, int* Err, int* segSize, int* Seg, int* mark);
139  bool isPadWord(int32_t wp, int* Err, int* Col, int* Dilogic, int* Channel, int* Charge);
140  bool isEoEmarker(int32_t wp, int* Err, int* Col, int* Dilogic, int* Eoesize);
141  int decodeHeader(int32_t* streamPtrAdr, int* EquipIndex);
142  bool decodeHmpidError(int ErrorField, char* outbuf);
143  void dumpHmpidError(int ErrorField);
144  HmpidEquipment* evaluateHeaderContents(int EquipmentIndex);
146 
147  virtual void setPad(HmpidEquipment* eq, int col, int dil, int ch, int charge) = 0;
148 
149  virtual bool getBlockFromStream(int32_t** streamPtr, uint32_t Size) = 0;
150  virtual bool getHeaderFromStream(int32_t** streamPtr) = 0;
151  virtual bool getWordFromStream(int32_t* word) = 0;
152  int32_t* getActualStreamPtr()
153  {
154  return (mActualStreamPtr);
155  };
156 };
157 } // namespace o2::quality_control_modules::hmpid
158 #endif /* COMMON_HMPIDDECODER_H_ */
bool isRowMarker(int32_t wp, int *Err, int *rowSize, int *mark)
Definition: HmpidDecoder.cxx:219
void updateStatistics(HmpidEquipment *eq)
Definition: HmpidDecoder.cxx:390
HmpidDecoder(int *EqIds, int *CruIds, int *LinkIds, int numOfEquipments)
Definition: HmpidDecoder.cxx:69
int getEquipmentID(int CruId, int LinkId)
Definition: HmpidDecoder.cxx:156
void dumpHmpidError(int ErrorField)
Definition: HmpidDecoder.cxx:918
double getPadSquares(int Module, int Column, int Row)
Definition: HmpidDecoder.cxx:788
Definition: HmpidDecoder.h:44
float getAverageBusyTime(int Equipment)
Definition: HmpidDecoder.cxx:854
void writeSummaryFile(char *summaryFileName)
Definition: HmpidDecoder.cxx:931
HmpidEquipment * evaluateHeaderContents(int EquipmentIndex)
Definition: HmpidDecoder.cxx:408
void dumpErrors(int Equipment)
Definition: HmpidDecoder.cxx:868
int getEquipmentIndex(int EquipmentId)
Definition: HmpidDecoder.cxx:142
int decodeHeader(int32_t *streamPtrAdr, int *EquipIndex)
Definition: HmpidDecoder.cxx:341
uint16_t getPadSamples(int Module, int Column, int Row)
Definition: HmpidDecoder.cxx:758
~HmpidDecoder()
Destructor : remove the Equipments instances.
Definition: HmpidDecoder.cxx:78
static char sHmpidErrorDescription[MAXHMPIDERRORS][MAXDESCRIPTIONLENGHT]
HMPID Firmware Error Messages Definitions.
Definition: HmpidDecoder.h:57
bool decodeBuffer()
Definition: HmpidDecoder.cxx:435
static char sErrorDescription[MAXERRORS][MAXDESCRIPTIONLENGHT]
Decoding Error Messages Definitions.
Definition: HmpidDecoder.h:56
bool isSegmentMarker(int32_t wp, int *Err, int *segSize, int *Seg, int *mark)
Definition: HmpidDecoder.cxx:239
double getChannelSum(int Equipment, int Column, int Dilogic, int Channel)
Definition: HmpidDecoder.cxx:818
uint16_t getChannelSamples(int Equipment, int Column, int Dilogic, int Channel)
Definition: HmpidDecoder.cxx:804
void dumpPads(int Equipment, int type=0)
Definition: HmpidDecoder.cxx:886
int checkType(int32_t wp, int *p1, int *p2, int *p3, int *p4)
Definition: HmpidDecoder.cxx:174
void init()
Resets to 0 all the class members.
Definition: HmpidDecoder.cxx:86
bool decodeHmpidError(int ErrorField, char *outbuf)
Definition: HmpidDecoder.cxx:315
float getAverageEventSize(int Equipment)
Definition: HmpidDecoder.cxx:843
bool isEoEmarker(int32_t wp, int *Err, int *Col, int *Dilogic, int *Eoesize)
Definition: HmpidDecoder.cxx:291
bool isPadWord(int32_t wp, int *Err, int *Col, int *Dilogic, int *Channel, int *Charge)
Definition: HmpidDecoder.cxx:266
double getChannelSquare(int Equipment, int Column, int Dilogic, int Channel)
Definition: HmpidDecoder.cxx:832
double getPadSum(int Module, int Column, int Row)
Definition: HmpidDecoder.cxx:773