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  void setPresenceFlags(uint8_t v) { presenceFlags = v; }
59 
61  bool isBCPresent() const { return presenceFlags & 0x1; }
62 
64  bool isECPresent() const { return presenceFlags & 0x2; }
65 
67  bool isIDPresent() const { return presenceFlags & 0x4; }
68 
70  bool isCRCPresent() const { return presenceFlags & 0x8; }
71 
73  bool isNumberOfClustersPresent() const { return presenceFlags & 0x10; }
74 
76  void setDAQErrorFlags(uint8_t v) { daqErrorFlags = v; }
77 
78  void setNumberOfClusters(uint8_t v) { numberOfClusters = v; }
79 
82  uint8_t getNumberOfClusters() const { return numberOfClusters; }
83 
86  bool checkFootprint() const;
87 
91  virtual bool checkCRC() const;
92 
95  virtual bool channelActive(unsigned char channel) const {
96  return (data[1 + (channel / 16)] & (1 << (channel % 16))) ? true : false;
97  }
98 
101  virtual std::vector<unsigned char> getActiveChannels() const;
102 
105  void Print(bool binary = false) const;
106 
108  static word calculateCRC(word crc_in, word dato);
109 
110 protected:
123  word data[12];
124 
125 private:
132  uint8_t presenceFlags;
133 
135  uint8_t daqErrorFlags;
136 
140 };
141 
142 #endif
virtual bool checkCRC() const
Definition: VFATFrame.cc:62
word data[12]
Definition: VFATFrame.h:123
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:104
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:73
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:61
uint8_t daqErrorFlags
Error flag as given by certain versions of DAQ.
Definition: VFATFrame.h:135
uint8_t presenceFlags
Definition: VFATFrame.h:132
VFATFrame::word getChipID() const
Returns ChipID (ChipID<11:0>).
Definition: VFATFrame.h:52
void setPresenceFlags(uint8_t v)
Sets presence flags.
Definition: VFATFrame.h:58
virtual bool channelActive(unsigned char channel) const
Definition: VFATFrame.h:95
bool isCRCPresent() const
Returns true if the CRC word is present in the frame.
Definition: VFATFrame.h:70
static word calculateCRC(word crc_in, word dato)
internaly used to check CRC
Definition: VFATFrame.cc:80
void setDAQErrorFlags(uint8_t v)
Sets DAQ error flags.
Definition: VFATFrame.h:76
bool isECPresent() const
Returns true if the EC word is present in the frame.
Definition: VFATFrame.h:64
virtual ~VFATFrame()
Definition: VFATFrame.h:33
bool isIDPresent() const
Returns true if the ID word is present in the frame.
Definition: VFATFrame.h:67
uint8_t numberOfClusters
Definition: VFATFrame.h:139
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:82
void setNumberOfClusters(uint8_t v)
Definition: VFATFrame.h:78
VFATFrame(const VFATFrame &copy)
Definition: VFATFrame.h:26