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 
26  VFATFrame(const VFATFrame& copy) {
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
VFATFrame::VFATFrame
VFATFrame(const word *_data=nullptr)
Definition: VFATFrame.cc:15
VFATFrame::checkCRC
virtual bool checkCRC() const
Definition: VFATFrame.cc:61
VFATFrame::checkFootprint
bool checkFootprint() const
Definition: VFATFrame.cc:48
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
VFATFrame::Print
void Print(bool binary=false) const
Definition: VFATFrame.cc:103
VFATFrame::isCRCPresent
bool isCRCPresent() const
Returns true if the CRC word is present in the frame.
Definition: VFATFrame.h:74
VFATFrame::isNumberOfClustersPresent
bool isNumberOfClustersPresent() const
Returns true if the CRC word is present in the frame.
Definition: VFATFrame.h:77
findQualityFiles.v
v
Definition: findQualityFiles.py:179
VFATFrame::getActiveChannels
virtual std::vector< unsigned char > getActiveChannels() const
Definition: VFATFrame.cc:28
VFATFrame::channelActive
virtual bool channelActive(unsigned char channel) const
Definition: VFATFrame.h:99
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
VFATFrame::getFlags
VFATFrame::word getFlags() const
Returns flags.
Definition: VFATFrame.h:53
VFATFrame::numberOfClusters
uint8_t numberOfClusters
Definition: VFATFrame.h:143
VFATFrame::getBC
VFATFrame::word getBC() const
Returns Bunch Crossing number (BC<11:0>).
Definition: VFATFrame.h:47
VFATFrame::data
word data[12]
Definition: VFATFrame.h:127
VFATFrame::getData
VFATFrame::word * getData()
Definition: VFATFrame.h:42
VFATFrame::getNumberOfClusters
uint8_t getNumberOfClusters() const
Definition: VFATFrame.h:86
VFATFrame::setNumberOfClusters
void setNumberOfClusters(uint8_t v)
Definition: VFATFrame.h:82
VFATFrame::isBCPresent
bool isBCPresent() const
Returns true if the BC word is present in the frame.
Definition: VFATFrame.h:65
funct::true
true
Definition: Factorize.h:173
VFATFrame::getChipID
VFATFrame::word getChipID() const
Returns ChipID (ChipID<11:0>).
Definition: VFATFrame.h:56
VFATFrame::getCRC
VFATFrame::word getCRC() const
Returns the CRC.
Definition: VFATFrame.h:59
VFATFrame::setPresenceFlags
void setPresenceFlags(uint8_t v)
Sets presence flags.
Definition: VFATFrame.h:62
VFATFrame::word
uint16_t word
Definition: VFATFrame.h:25
VFATFrame::isECPresent
bool isECPresent() const
Returns true if the EC word is present in the frame.
Definition: VFATFrame.h:68
VFATFrame::getEC
VFATFrame::word getEC() const
Returns Event Counter (EV<7:0>).
Definition: VFATFrame.h:50
VFATFrame::isIDPresent
bool isIDPresent() const
Returns true if the ID word is present in the frame.
Definition: VFATFrame.h:71
VFATFrame
Definition: VFATFrame.h:18
VFATFrame::calculateCRC
static word calculateCRC(word crc_in, word dato)
internaly used to check CRC
Definition: VFATFrame.cc:79
VFATFrame::setDAQErrorFlags
void setDAQErrorFlags(uint8_t v)
Sets DAQ error flags.
Definition: VFATFrame.h:80
VFATFrame::~VFATFrame
virtual ~VFATFrame()
Definition: VFATFrame.h:37
VFATFrame::daqErrorFlags
uint8_t daqErrorFlags
Error flag as given by certain versions of DAQ.
Definition: VFATFrame.h:139
VFATFrame::presenceFlags
uint8_t presenceFlags
Definition: VFATFrame.h:136
VFATFrame::setData
void setData(const word *_data)
Copies a memory block to data buffer.
Definition: VFATFrame.cc:26