File indexing completed on 2023-05-11 02:22:05
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef EventFilter_CTPPSRawToDigi_VFATFrame
0010 #define EventFilter_CTPPSRawToDigi_VFATFrame
0011
0012 #include <vector>
0013 #include <cstddef>
0014 #include <cstdint>
0015
0016
0017
0018
0019 class VFATFrame {
0020 public:
0021 typedef uint16_t word;
0022
0023 public:
0024 VFATFrame(const word* _data = nullptr);
0025
0026 VFATFrame(const VFATFrame& copy) {
0027 setData(copy.data);
0028 presenceFlags = copy.presenceFlags;
0029 daqErrorFlags = copy.daqErrorFlags;
0030 numberOfClusters = copy.numberOfClusters;
0031 }
0032
0033 virtual ~VFATFrame() {}
0034
0035
0036 void setData(const word* _data);
0037
0038 VFATFrame::word* getData() { return data; }
0039
0040 const VFATFrame::word* getData() const { return data; }
0041
0042
0043 VFATFrame::word getBC() const { return data[11] & 0x0FFF; }
0044
0045
0046 VFATFrame::word getEC() const { return (data[10] & 0x0FF0) >> 4; }
0047
0048
0049 VFATFrame::word getFlags() const { return data[10] & 0x000F; }
0050
0051
0052 VFATFrame::word getChipID() const { return data[9] & 0x0FFF; }
0053
0054
0055 VFATFrame::word getCRC() const { return data[0]; }
0056
0057
0058 void setPresenceFlags(uint8_t v) { presenceFlags = v; }
0059
0060
0061 bool isBCPresent() const { return presenceFlags & 0x1; }
0062
0063
0064 bool isECPresent() const { return presenceFlags & 0x2; }
0065
0066
0067 bool isIDPresent() const { return presenceFlags & 0x4; }
0068
0069
0070 bool isCRCPresent() const { return presenceFlags & 0x8; }
0071
0072
0073 bool isNumberOfClustersPresent() const { return presenceFlags & 0x10; }
0074
0075
0076 void setDAQErrorFlags(uint8_t v) { daqErrorFlags = v; }
0077
0078 void setNumberOfClusters(uint8_t v) { numberOfClusters = v; }
0079
0080
0081
0082 uint8_t getNumberOfClusters() const { return numberOfClusters; }
0083
0084
0085
0086 bool checkFootprint() const;
0087
0088
0089
0090
0091 virtual bool checkCRC() const;
0092
0093
0094
0095 virtual bool channelActive(unsigned char channel) const {
0096 return (data[1 + (channel / 16)] & (1 << (channel % 16))) ? true : false;
0097 }
0098
0099
0100
0101 virtual std::vector<unsigned char> getActiveChannels() const;
0102
0103
0104
0105 void Print(bool binary = false) const;
0106
0107
0108 void PrintT2(bool binary = false) const;
0109
0110
0111 static word calculateCRC(word crc_in, word dato);
0112
0113 protected:
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126 word data[12];
0127
0128 private:
0129
0130
0131
0132
0133
0134
0135 uint8_t presenceFlags;
0136
0137
0138 uint8_t daqErrorFlags;
0139
0140
0141
0142 uint8_t numberOfClusters;
0143 };
0144
0145 #endif