CMS 3D CMS Logo

GEMVFAT.h
Go to the documentation of this file.
1 #ifndef DataFormats_GEMDigi_GEMVFAT_h
2 #define DataFormats_GEMDigi_GEMVFAT_h
3 #include <cstdint>
4 
5 class GEMVFAT {
6 public:
8  union VFATfirst {
10  // v3 dataformat
11  struct {
13  uint64_t bc : 16;
14  uint64_t ec : 8;
16  // is half-full, so it's like a warning
17  uint64_t vc : 1;
18  uint64_t : 7; // unused
19  uint64_t pos : 5; // VFAT position on chamber, 5 used in GE11 but more is needed for phase2
20  uint64_t : 3; // unused
21  };
22  // v2 dataformat
23  struct {
27  uint64_t flag : 4;
28  uint64_t ecV2 : 8;
30  uint64_t bcV2 : 12;
32  };
33  };
34  union VFATsecond {
36  struct {
39  };
40  };
41  union VFATthird {
43  struct {
44  uint64_t crc : 16;
46  };
47  };
48 
49  GEMVFAT();
50  // this constructor only used for packing sim digis
51  GEMVFAT(const int vfatVer,
52  const uint16_t BC,
53  const uint32_t EC,
54  const uint16_t chipID,
55  const uint64_t lsDatas,
56  const uint64_t msDatas);
57  ~GEMVFAT() {}
58 
60  void read_fw(uint64_t word) { fw_ = word; }
61  uint64_t get_fw() const { return fw_; }
62 
64  void read_sw(uint64_t word) { sw_ = word; }
65  uint64_t get_sw() const { return sw_; }
66 
68  void read_tw(uint64_t word) { tw_ = word; }
69  uint64_t get_tw() const { return tw_; }
70 
71  // local phi in chamber
72  void setPhi(int i) { phiPos_ = i; }
73  int phi() const { return phiPos_; }
74 
75  uint64_t lsData() const { return uint64_t(VFATsecond{sw_}.lsData1) << 48 | VFATthird{tw_}.lsData2; }
76  uint64_t msData() const { return uint64_t(VFATfirst{fw_}.msData1) << 48 | VFATsecond{sw_}.msData2; }
77 
78  uint16_t bc() const {
79  if (ver_ == 2)
80  return VFATfirst{fw_}.bcV2;
81  return VFATfirst{fw_}.bc;
82  }
83  uint8_t ec() const {
84  if (ver_ == 2)
85  return VFATfirst{fw_}.ecV2;
86  return VFATfirst{fw_}.ec;
87  }
88  uint16_t vfatId() const {
89  if (ver_ == 2)
90  return VFATfirst{fw_}.chipID;
91  return VFATfirst{fw_}.pos;
92  }
93 
94  void setVersion(int i) { ver_ = i; }
95  int version() const { return ver_; }
96 
98  uint8_t quality();
99 
101  uint8_t header() const { return VFATfirst{fw_}.header; }
102  bool vc() const { return VFATfirst{fw_}.vc; }
103  uint8_t position() const { return VFATfirst{fw_}.pos; }
104  uint8_t crcCheck() const { return VFATfirst{fw_}.vc; } // to be removed
105 
107  uint8_t b1010() const { return VFATfirst{fw_}.b1010; }
108  uint8_t b1100() const { return VFATfirst{fw_}.b1100; }
109  uint8_t b1110() const { return VFATfirst{fw_}.b1110; }
110  uint8_t flag() const { return VFATfirst{fw_}.flag; }
111  uint16_t chipID() const { return VFATfirst{fw_}.chipID; }
112  uint16_t crc() const { return VFATthird{tw_}.crc; }
113 
114  uint16_t crc_cal(uint16_t crc_in, uint16_t dato);
115  uint16_t checkCRC();
116 
117  static const int nChannels = 128;
118  static const int sizeChipID = 12;
119 
120 private:
121  int ver_;
122  int phiPos_;
123 
124  uint64_t fw_; // VFAT first word
125  uint64_t sw_; // VFAT second word
126  uint64_t tw_; // VFAT third word
127 };
128 
129 #endif
uint8_t position() const
Definition: GEMVFAT.h:103
uint64_t flag
Control Flags: 4 bits, Hamming Error/AFULL/SEUlogic/SUEI2C.
Definition: GEMVFAT.h:27
uint64_t word
Definition: GEMVFAT.h:35
uint64_t fw_
phi position of vfat in chamber
Definition: GEMVFAT.h:124
uint8_t b1100() const
Definition: GEMVFAT.h:108
uint64_t lsData2
channels from 1to64
Definition: GEMVFAT.h:45
uint64_t ecV2
Event Counter, 8 bits.
Definition: GEMVFAT.h:28
uint64_t crc
Check Sum value, 16 bits.
Definition: GEMVFAT.h:44
uint16_t crc_cal(uint16_t crc_in, uint16_t dato)
Definition: GEMVFAT.cc:65
uint64_t b1010
1010:4 Control bits, shoud be 1010
Definition: GEMVFAT.h:31
uint8_t header() const
v3
Definition: GEMVFAT.h:101
uint64_t b1110
1110:4 Control bits, shoud be 1110
Definition: GEMVFAT.h:26
void setPhi(int i)
Definition: GEMVFAT.h:72
uint64_t ec
Event Counter, 8 bits.
Definition: GEMVFAT.h:14
uint64_t msData2
channels from 65to128
Definition: GEMVFAT.h:38
void read_sw(uint64_t word)
Read second word from the block.
Definition: GEMVFAT.h:64
uint8_t flag() const
Definition: GEMVFAT.h:110
uint8_t quality()
quality flag - bit: 0 good, 1 crc fail, 2 b1010 fail, 3 b1100 fail, 4 b1110
Definition: GEMVFAT.cc:49
uint64_t bcV2
Bunch Crossing number, 12 bits.
Definition: GEMVFAT.h:30
uint64_t chipID
Chip ID, 12 bits.
Definition: GEMVFAT.h:25
uint64_t get_tw() const
Definition: GEMVFAT.h:69
uint64_t pos
Definition: GEMVFAT.h:19
static const int nChannels
Definition: GEMVFAT.h:117
GEMVFAT()
Definition: GEMVFAT.cc:4
uint64_t msData1
channels from 65to128
Definition: GEMVFAT.h:12
void setVersion(int i)
Definition: GEMVFAT.h:94
uint64_t word
Definition: GEMVFAT.h:5
uint16_t bc() const
Definition: GEMVFAT.h:78
uint8_t ec() const
Definition: GEMVFAT.h:83
uint64_t bc
Bunch Crossing number, 16 bits.
Definition: GEMVFAT.h:13
uint8_t b1010() const
v2
Definition: GEMVFAT.h:107
uint64_t get_sw() const
Definition: GEMVFAT.h:65
uint64_t sw_
Definition: GEMVFAT.h:125
int ver_
Definition: GEMVFAT.h:121
uint64_t lsData1
channels from 1to64
Definition: GEMVFAT.h:37
uint16_t vfatId() const
Definition: GEMVFAT.h:88
uint8_t b1110() const
Definition: GEMVFAT.h:109
uint16_t crc() const
Definition: GEMVFAT.h:112
uint64_t b1100
1100:4, Control bits, shoud be 1100
Definition: GEMVFAT.h:29
int phiPos_
vfat version
Definition: GEMVFAT.h:122
uint64_t lsData() const
Definition: GEMVFAT.h:75
uint64_t header
normally 0x1E. 0x5E indicates that the VFAT3 internal buffer
Definition: GEMVFAT.h:15
unsigned long long uint64_t
Definition: Time.h:13
uint16_t chipID() const
Definition: GEMVFAT.h:111
~GEMVFAT()
Definition: GEMVFAT.h:57
void read_tw(uint64_t word)
Read third word from the block.
Definition: GEMVFAT.h:68
static const int sizeChipID
Definition: GEMVFAT.h:118
uint64_t vc
Definition: GEMVFAT.h:17
int version() const
Definition: GEMVFAT.h:95
uint16_t checkCRC()
Definition: GEMVFAT.cc:85
uint64_t msData1v2
channels from 65to128 - placeholder since msData1 reads same info
Definition: GEMVFAT.h:24
uint64_t tw_
Definition: GEMVFAT.h:126
bool vc() const
Definition: GEMVFAT.h:102
uint64_t get_fw() const
Definition: GEMVFAT.h:61
uint64_t msData() const
Definition: GEMVFAT.h:76
uint64_t word
Definition: GEMVFAT.h:9
void read_fw(uint64_t word)
Read first word from the block.
Definition: GEMVFAT.h:60
uint8_t crcCheck() const
Definition: GEMVFAT.h:104
uint64_t word
Definition: GEMVFAT.h:42
VFAT data structure - 3 words of 64 bits each.
Definition: GEMVFAT.h:8
int phi() const
Definition: GEMVFAT.h:73