CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 : 8; // VFAT position on chamber, 5 used in GE11 but more is needed for phase2
20  };
21  // v2 dataformat
22  struct {
26  uint64_t flag : 4;
27  uint64_t ecV2 : 8;
29  uint64_t bcV2 : 12;
31  };
32  };
33  union VFATsecond {
35  struct {
38  };
39  };
40  union VFATthird {
42  struct {
43  uint64_t crc : 16;
45  };
46  };
47 
48  GEMVFAT();
49  // this constructor only used for packing sim digis
50  GEMVFAT(const int vfatVer,
51  const uint16_t BC,
52  const uint32_t EC,
53  const uint16_t chipID,
54  const uint64_t lsDatas,
55  const uint64_t msDatas);
56  ~GEMVFAT() {}
57 
59  void read_fw(uint64_t word) { fw_ = word; }
60  uint64_t get_fw() const { return fw_; }
61 
63  void read_sw(uint64_t word) { sw_ = word; }
64  uint64_t get_sw() const { return sw_; }
65 
67  void read_tw(uint64_t word) { tw_ = word; }
68  uint64_t get_tw() const { return tw_; }
69 
70  // local phi in chamber
71  void setPhi(int i) { phiPos_ = i; }
72  int phi() const { return phiPos_; }
73 
74  uint64_t lsData() const { return uint64_t(VFATsecond{sw_}.lsData1) << 48 | VFATthird{tw_}.lsData2; }
75  uint64_t msData() const { return uint64_t(VFATfirst{fw_}.msData1) << 48 | VFATsecond{sw_}.msData2; }
76 
77  uint16_t bc() const {
78  if (ver_ == 2)
79  return VFATfirst{fw_}.bcV2;
80  return VFATfirst{fw_}.bc;
81  }
82  uint8_t ec() const {
83  if (ver_ == 2)
84  return VFATfirst{fw_}.ecV2;
85  return VFATfirst{fw_}.ec;
86  }
87  uint16_t vfatId() const {
88  if (ver_ == 2)
89  return VFATfirst{fw_}.chipID;
90  return VFATfirst{fw_}.pos;
91  }
92 
93  void setVersion(int i) { ver_ = i; }
94  int version() const { return ver_; }
95 
97  uint8_t quality();
98 
100  uint8_t header() const { return VFATfirst{fw_}.header; }
101  bool vc() const { return VFATfirst{fw_}.vc; }
102  uint8_t position() const { return VFATfirst{fw_}.pos; }
103  uint8_t crcCheck() const { return VFATfirst{fw_}.vc; } // to be removed
104 
106  uint8_t b1010() const { return VFATfirst{fw_}.b1010; }
107  uint8_t b1100() const { return VFATfirst{fw_}.b1100; }
108  uint8_t b1110() const { return VFATfirst{fw_}.b1110; }
109  uint8_t flag() const { return VFATfirst{fw_}.flag; }
110  uint16_t chipID() const { return VFATfirst{fw_}.chipID; }
111  uint16_t crc() const { return VFATthird{tw_}.crc; }
112 
113  uint16_t crc_cal(uint16_t crc_in, uint16_t dato);
114  uint16_t checkCRC();
115 
116  static const int nChannels = 128;
117  static const int sizeChipID = 12;
118 
119 private:
120  int ver_;
121  int phiPos_;
122 
123  uint64_t fw_; // VFAT first word
124  uint64_t sw_; // VFAT second word
125  uint64_t tw_; // VFAT third word
126 };
127 
128 #endif
uint64_t flag
Control Flags: 4 bits, Hamming Error/AFULL/SEUlogic/SUEI2C.
Definition: GEMVFAT.h:26
uint64_t word
Definition: GEMVFAT.h:34
uint8_t b1110() const
Definition: GEMVFAT.h:108
uint64_t fw_
phi position of vfat in chamber
Definition: GEMVFAT.h:123
uint64_t lsData2
channels from 1to64
Definition: GEMVFAT.h:44
uint64_t msData() const
Definition: GEMVFAT.h:75
uint64_t ecV2
Event Counter, 8 bits.
Definition: GEMVFAT.h:27
uint64_t crc
Check Sum value, 16 bits.
Definition: GEMVFAT.h:43
uint16_t chipID() const
Definition: GEMVFAT.h:110
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:30
bool vc() const
Definition: GEMVFAT.h:101
uint64_t b1110
1110:4 Control bits, shoud be 1110
Definition: GEMVFAT.h:25
void setPhi(int i)
Definition: GEMVFAT.h:71
uint64_t ec
Event Counter, 8 bits.
Definition: GEMVFAT.h:14
uint64_t msData2
channels from 65to128
Definition: GEMVFAT.h:37
void read_sw(uint64_t word)
Read second word from the block.
Definition: GEMVFAT.h:63
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:29
uint64_t chipID
Chip ID, 12 bits.
Definition: GEMVFAT.h:24
uint64_t pos
Definition: GEMVFAT.h:19
static const int nChannels
Definition: GEMVFAT.h:116
GEMVFAT()
Definition: GEMVFAT.cc:4
uint64_t msData1
channels from 65to128
Definition: GEMVFAT.h:12
void setVersion(int i)
Definition: GEMVFAT.h:93
uint16_t vfatId() const
Definition: GEMVFAT.h:87
uint64_t word
Definition: GEMVFAT.h:5
uint8_t flag() const
Definition: GEMVFAT.h:109
uint8_t b1100() const
Definition: GEMVFAT.h:107
uint64_t bc
Bunch Crossing number, 16 bits.
Definition: GEMVFAT.h:13
uint8_t ec() const
Definition: GEMVFAT.h:82
uint64_t sw_
Definition: GEMVFAT.h:124
uint64_t get_sw() const
Definition: GEMVFAT.h:64
int ver_
Definition: GEMVFAT.h:120
uint64_t lsData1
channels from 1to64
Definition: GEMVFAT.h:36
uint64_t lsData() const
Definition: GEMVFAT.h:74
uint8_t crcCheck() const
Definition: GEMVFAT.h:103
uint64_t get_fw() const
Definition: GEMVFAT.h:60
uint64_t b1100
1100:4, Control bits, shoud be 1100
Definition: GEMVFAT.h:28
int phiPos_
vfat version
Definition: GEMVFAT.h:121
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
uint8_t position() const
Definition: GEMVFAT.h:102
~GEMVFAT()
Definition: GEMVFAT.h:56
void read_tw(uint64_t word)
Read third word from the block.
Definition: GEMVFAT.h:67
static const int sizeChipID
Definition: GEMVFAT.h:117
uint64_t vc
Definition: GEMVFAT.h:17
uint16_t checkCRC()
Definition: GEMVFAT.cc:85
uint64_t msData1v2
channels from 65to128 - placeholder since msData1 reads same info
Definition: GEMVFAT.h:23
uint64_t tw_
Definition: GEMVFAT.h:125
uint16_t bc() const
Definition: GEMVFAT.h:77
int phi() const
Definition: GEMVFAT.h:72
uint8_t b1010() const
v2
Definition: GEMVFAT.h:106
int version() const
Definition: GEMVFAT.h:94
uint8_t header() const
v3
Definition: GEMVFAT.h:100
uint64_t word
Definition: GEMVFAT.h:9
void read_fw(uint64_t word)
Read first word from the block.
Definition: GEMVFAT.h:59
uint64_t word
Definition: GEMVFAT.h:41
uint16_t crc() const
Definition: GEMVFAT.h:111
VFAT data structure - 3 words of 64 bits each.
Definition: GEMVFAT.h:8
uint64_t get_tw() const
Definition: GEMVFAT.h:68