CMS 3D CMS Logo

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