CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 <stdint.h>
15 
19 class VFATFrame
20 {
21  public:
22  typedef uint16_t word;
23  public:
24  VFATFrame(const word* _data = NULL);
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 
47  {
48  return data[11] & 0x0FFF;
49  }
50 
53  {
54  return (data[10] & 0x0FF0) >> 4;
55  }
56 
59  {
60  return data[10] & 0x000F;
61  }
62 
65  {
66  return data[9] & 0x0FFF;
67  }
68 
71  {
72  return data[0];
73  }
74 
75 
77  void setPresenceFlags(uint8_t v)
78  {
79  presenceFlags = v;
80  }
81 
83  bool isBCPresent() const
84  {
85  return presenceFlags & 0x1;
86  }
87 
89  bool isECPresent() const
90  {
91  return presenceFlags & 0x2;
92  }
93 
95  bool isIDPresent() const
96  {
97  return presenceFlags & 0x4;
98  }
99 
101  bool isCRCPresent() const
102  {
103  return presenceFlags & 0x8;
104  }
105 
108  {
109  return presenceFlags & 0x10;
110  }
111 
113  void setDAQErrorFlags(uint8_t v)
114  {
115  daqErrorFlags = v;
116  }
117 
118  void setNumberOfClusters(uint8_t v)
119  {
121  }
122 
125  uint8_t getNumberOfClusters() const
126  {
127  return numberOfClusters;
128  }
129 
132  bool checkFootprint() const;
133 
134 
138  virtual bool checkCRC() const;
139 
142  virtual bool channelActive(unsigned char channel) const
143  {
144  return ( data[1 + (channel / 16)] & (1 << (channel % 16)) ) ? 1 : 0;
145  }
146 
149  virtual std::vector<unsigned char> getActiveChannels() const;
150 
153  void Print(bool binary = false) const;
154 
155  protected:
168  word data[12];
169  private:
176  uint8_t presenceFlags;
177 
179  uint8_t daqErrorFlags;
180 
184 
186  static word calculateCRC(word crc_in, word dato);
187 };
188 
189 #endif
word data[12]
Definition: VFATFrame.h:168
VFATFrame::word getFlags() const
Returns flags.
Definition: VFATFrame.h:58
VFATFrame::word * getData()
Definition: VFATFrame.h:40
VFATFrame::word getBC() const
Returns Bunch Crossing number (BC&lt;11:0&gt;).
Definition: VFATFrame.h:46
uint16_t word
Definition: VFATFrame.h:22
#define NULL
Definition: scimark2.h:8
bool checkFootprint() const
Definition: VFATFrame.cc:63
virtual bool checkCRC() const
Definition: VFATFrame.cc:79
uint8_t getNumberOfClusters() const
Definition: VFATFrame.h:125
bool isECPresent() const
Returns true if the EC word is present in the frame.
Definition: VFATFrame.h:89
bool isNumberOfClustersPresent() const
Returns true if the CRC word is present in the frame.
Definition: VFATFrame.h:107
uint8_t daqErrorFlags
Error flag as given by certain versions of DAQ.
Definition: VFATFrame.h:179
void Print(bool binary=false) const
Definition: VFATFrame.cc:128
uint8_t presenceFlags
Definition: VFATFrame.h:176
VFATFrame::word getCRC() const
Returns the CRC.
Definition: VFATFrame.h:70
void setPresenceFlags(uint8_t v)
Sets presence flags.
Definition: VFATFrame.h:77
VFATFrame::word getEC() const
Returns Event Counter (EV&lt;7:0&gt;).
Definition: VFATFrame.h:52
bool isBCPresent() const
Returns true if the BC word is present in the frame.
Definition: VFATFrame.h:83
VFATFrame(const word *_data=NULL)
Definition: VFATFrame.cc:18
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:113
virtual ~VFATFrame()
Definition: VFATFrame.h:35
bool isIDPresent() const
Returns true if the ID word is present in the frame.
Definition: VFATFrame.h:95
uint8_t numberOfClusters
Definition: VFATFrame.h:183
VFATFrame::word getChipID() const
Returns ChipID (ChipID&lt;11:0&gt;).
Definition: VFATFrame.h:64
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
bool isCRCPresent() const
Returns true if the CRC word is present in the frame.
Definition: VFATFrame.h:101
void setNumberOfClusters(uint8_t v)
Definition: VFATFrame.h:118
virtual bool channelActive(unsigned char channel) const
Definition: VFATFrame.h:142
VFATFrame(const VFATFrame &copy)
Definition: VFATFrame.h:26