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 {
21  public:
22  typedef uint16_t word;
23  public:
24  VFATFrame(const word* _data = nullptr);
25 
27  {
28  setData(copy.data);
32 
33  }
34 
35  virtual ~VFATFrame() {}
36 
38  void setData(const word *_data);
39 
41  {
42  return data;
43  }
44 
45  const VFATFrame::word* getData() const
46  {
47  return data;
48  }
49 
52  {
53  return data[11] & 0x0FFF;
54  }
55 
58  {
59  return (data[10] & 0x0FF0) >> 4;
60  }
61 
64  {
65  return data[10] & 0x000F;
66  }
67 
70  {
71  return data[9] & 0x0FFF;
72  }
73 
76  {
77  return data[0];
78  }
79 
80 
82  void setPresenceFlags(uint8_t v)
83  {
84  presenceFlags = v;
85  }
86 
88  bool isBCPresent() const
89  {
90  return presenceFlags & 0x1;
91  }
92 
94  bool isECPresent() const
95  {
96  return presenceFlags & 0x2;
97  }
98 
100  bool isIDPresent() const
101  {
102  return presenceFlags & 0x4;
103  }
104 
106  bool isCRCPresent() const
107  {
108  return presenceFlags & 0x8;
109  }
110 
113  {
114  return presenceFlags & 0x10;
115  }
116 
118  void setDAQErrorFlags(uint8_t v)
119  {
120  daqErrorFlags = v;
121  }
122 
123  void setNumberOfClusters(uint8_t v)
124  {
126  }
127 
130  uint8_t getNumberOfClusters() const
131  {
132  return numberOfClusters;
133  }
134 
137  bool checkFootprint() const;
138 
139 
143  virtual bool checkCRC() const;
144 
147  virtual bool channelActive(unsigned char channel) const
148  {
149  return ( data[1 + (channel / 16)] & (1 << (channel % 16)) ) ? true : false;
150  }
151 
154  virtual std::vector<unsigned char> getActiveChannels() const;
155 
158  void Print(bool binary = false) const;
159 
160  protected:
173  word data[12];
174  private:
181  uint8_t presenceFlags;
182 
184  uint8_t daqErrorFlags;
185 
189 
191  static word calculateCRC(word crc_in, word dato);
192 };
193 
194 #endif
const VFATFrame::word * getData() const
Definition: VFATFrame.h:45
word data[12]
Definition: VFATFrame.h:173
VFATFrame::word getFlags() const
Returns flags.
Definition: VFATFrame.h:63
VFATFrame::word * getData()
Definition: VFATFrame.h:40
def copy(args, dbName)
VFATFrame::word getBC() const
Returns Bunch Crossing number (BC<11:0>).
Definition: VFATFrame.h:51
uint16_t word
Definition: VFATFrame.h:22
bool checkFootprint() const
Definition: VFATFrame.cc:63
virtual bool checkCRC() const
Definition: VFATFrame.cc:79
uint8_t getNumberOfClusters() const
Definition: VFATFrame.h:130
bool isECPresent() const
Returns true if the EC word is present in the frame.
Definition: VFATFrame.h:94
bool isNumberOfClustersPresent() const
Returns true if the CRC word is present in the frame.
Definition: VFATFrame.h:112
uint8_t daqErrorFlags
Error flag as given by certain versions of DAQ.
Definition: VFATFrame.h:184
void Print(bool binary=false) const
Definition: VFATFrame.cc:128
uint8_t presenceFlags
Definition: VFATFrame.h:181
VFATFrame::word getCRC() const
Returns the CRC.
Definition: VFATFrame.h:75
void setPresenceFlags(uint8_t v)
Sets presence flags.
Definition: VFATFrame.h:82
VFATFrame::word getEC() const
Returns Event Counter (EV<7:0>).
Definition: VFATFrame.h:57
bool isBCPresent() const
Returns true if the BC word is present in the frame.
Definition: VFATFrame.h:88
static word calculateCRC(word crc_in, word dato)
internaly used to check CRC
Definition: VFATFrame.cc:100
void setDAQErrorFlags(uint8_t v)
Sets DAQ error flags.
Definition: VFATFrame.h:118
virtual ~VFATFrame()
Definition: VFATFrame.h:35
bool isIDPresent() const
Returns true if the ID word is present in the frame.
Definition: VFATFrame.h:100
uint8_t numberOfClusters
Definition: VFATFrame.h:188
VFATFrame::word getChipID() const
Returns ChipID (ChipID<11:0>).
Definition: VFATFrame.h:69
virtual std::vector< unsigned char > getActiveChannels() const
Definition: VFATFrame.cc:38
void setData(const word *_data)
Copies a memory block to data buffer.
Definition: VFATFrame.cc:31
VFATFrame(const word *_data=nullptr)
Definition: VFATFrame.cc:18
bool isCRCPresent() const
Returns true if the CRC word is present in the frame.
Definition: VFATFrame.h:106
void setNumberOfClusters(uint8_t v)
Definition: VFATFrame.h:123
virtual bool channelActive(unsigned char channel) const
Definition: VFATFrame.h:147
VFATFrame(const VFATFrame &copy)
Definition: VFATFrame.h:26