CMS 3D CMS Logo

VFATFrame.h
Go to the documentation of this file.
1 /**********************************************************
2 *
3 * This is a part of the TOTEM offline software.
4 * Authors:
5 * Jan Kaspar (jan.kaspar@gmail.com)
6 *
7 **********************************************************/
8 
9 #ifndef EventFilter_CTPPSRawToDigi_VFATFrame
10 #define EventFilter_CTPPSRawToDigi_VFATFrame
11 
12 #include <vector>
13 #include <cstddef>
14 #include <cstdint>
15 
19 class VFATFrame {
20 public:
21  typedef uint16_t word;
22 
23 public:
24  VFATFrame(const word* _data = nullptr);
25 
27  setData(copy.data);
28  presenceFlags = copy.presenceFlags;
29  daqErrorFlags = copy.daqErrorFlags;
30  numberOfClusters = copy.numberOfClusters;
31  }
32 
33  virtual ~VFATFrame() {}
34 
36  void setData(const word* _data);
37 
38  VFATFrame::word* getData() { return data; }
39 
40  const VFATFrame::word* getData() const { return data; }
41 
43  VFATFrame::word getBC() const { return data[11] & 0x0FFF; }
44 
46  VFATFrame::word getEC() const { return (data[10] & 0x0FF0) >> 4; }
47 
49  VFATFrame::word getFlags() const { return data[10] & 0x000F; }
50 
52  VFATFrame::word getChipID() const { return data[9] & 0x0FFF; }
53 
55  VFATFrame::word getCRC() const { return data[0]; }
56 
58  VFATFrame::word getCRCT2() const { return data[11]; }
59 
61  void setPresenceFlags(uint8_t v) { presenceFlags = v; }
62 
64  bool isBCPresent() const { return presenceFlags & 0x1; }
65 
67  bool isECPresent() const { return presenceFlags & 0x2; }
68 
70  bool isIDPresent() const { return presenceFlags & 0x4; }
71 
73  bool isCRCPresent() const { return presenceFlags & 0x8; }
74 
76  bool isNumberOfClustersPresent() const { return presenceFlags & 0x10; }
77 
79  void setDAQErrorFlags(uint8_t v) { daqErrorFlags = v; }
80 
81  void setNumberOfClusters(uint8_t v) { numberOfClusters = v; }
82 
85  uint8_t getNumberOfClusters() const { return numberOfClusters; }
86 
89  bool checkFootprint() const;
90 
93  bool checkFootprintT2() const;
94 
98  virtual bool checkCRC() const;
99 
102  virtual bool checkCRCT2() const;
103 
106  virtual bool channelActive(unsigned char channel) const {
107  return (data[1 + (channel / 16)] & (1 << (channel % 16))) ? true : false;
108  }
109 
112  virtual std::vector<unsigned char> getActiveChannels() const;
113 
116  void Print(bool binary = false) const;
117 
118  //Follow the VFAT2 manual format, not reversed
119  void PrintT2(bool binary = false) const;
120 
122  static word calculateCRC(word crc_in, word dato);
123 
124 protected:
137  word data[12];
138 
139 private:
146  uint8_t presenceFlags;
147 
149  uint8_t daqErrorFlags;
150 
154 };
155 
156 #endif
virtual bool checkCRC() const
Definition: VFATFrame.cc:75
word data[12]
Definition: VFATFrame.h:137
const VFATFrame::word * getData() const
Definition: VFATFrame.h:40
VFATFrame::word * getData()
Definition: VFATFrame.h:38
void Print(bool binary=false) const
Definition: VFATFrame.cc:131
VFATFrame::word getEC() const
Returns Event Counter (EV<7:0>).
Definition: VFATFrame.h:46
bool checkFootprint() const
Definition: VFATFrame.cc:49
VFATFrame::word getCRC() const
Returns the CRC.
Definition: VFATFrame.h:55
uint16_t word
Definition: VFATFrame.h:21
VFATFrame::word getFlags() const
Returns flags.
Definition: VFATFrame.h:49
bool isNumberOfClustersPresent() const
Returns true if the CRC word is present in the frame.
Definition: VFATFrame.h:76
virtual std::vector< unsigned char > getActiveChannels() const
Definition: VFATFrame.cc:29
uint64_t word
bool isBCPresent() const
Returns true if the BC word is present in the frame.
Definition: VFATFrame.h:64
uint8_t daqErrorFlags
Error flag as given by certain versions of DAQ.
Definition: VFATFrame.h:149
uint8_t presenceFlags
Definition: VFATFrame.h:146
virtual bool checkCRCT2() const
Definition: VFATFrame.cc:93
VFATFrame::word getChipID() const
Returns ChipID (ChipID<11:0>).
Definition: VFATFrame.h:52
VFATFrame::word getCRCT2() const
Returns the CRC, for non-reversed TOTEM T2.
Definition: VFATFrame.h:58
void PrintT2(bool binary=false) const
Definition: VFATFrame.cc:177
void setPresenceFlags(uint8_t v)
Sets presence flags.
Definition: VFATFrame.h:61
bool checkFootprintT2() const
Definition: VFATFrame.cc:62
virtual bool channelActive(unsigned char channel) const
Definition: VFATFrame.h:106
bool isCRCPresent() const
Returns true if the CRC word is present in the frame.
Definition: VFATFrame.h:73
static word calculateCRC(word crc_in, word dato)
internaly used to check CRC
Definition: VFATFrame.cc:107
void setDAQErrorFlags(uint8_t v)
Sets DAQ error flags.
Definition: VFATFrame.h:79
bool isECPresent() const
Returns true if the EC word is present in the frame.
Definition: VFATFrame.h:67
virtual ~VFATFrame()
Definition: VFATFrame.h:33
bool isIDPresent() const
Returns true if the ID word is present in the frame.
Definition: VFATFrame.h:70
uint8_t numberOfClusters
Definition: VFATFrame.h:153
VFATFrame::word getBC() const
Returns Bunch Crossing number (BC<11:0>).
Definition: VFATFrame.h:43
void setData(const word *_data)
Copies a memory block to data buffer.
Definition: VFATFrame.cc:27
VFATFrame(const word *_data=nullptr)
Definition: VFATFrame.cc:16
uint8_t getNumberOfClusters() const
Definition: VFATFrame.h:85
void setNumberOfClusters(uint8_t v)
Definition: VFATFrame.h:81
VFATFrame(const VFATFrame &copy)
Definition: VFATFrame.h:26