CMS 3D CMS Logo

GEMOptoHybrid.h
Go to the documentation of this file.
1 #ifndef DataFormats_GEMDigi_GEMOptoHybrid_h
2 #define DataFormats_GEMDigi_GEMOptoHybrid_h
3 #include "GEMVFAT.h"
4 #include <vector>
5 
6 class GEMOptoHybrid {
7 public:
10  // v301 dataformat
11  struct {
12  uint64_t : 10; // unused
13  uint64_t BxmVvV : 1; // 1st bit BX mismatch VFAT vs VFAT
14  uint64_t BxmAvV : 1; // BX mismatch AMC vs VFAT
15  uint64_t OOScVvV : 1; // Out of Sync (EC mismatch) VFAT vs VFAT
16  uint64_t OOScAvV : 1; // Out of Sync (EC mismatch) AMC vs VFAT
17  uint64_t Inv : 1; // Invalid event
18  uint64_t EvtSzW : 1; // Event size warning
19  uint64_t L1aNF : 1; // L1A FIFO near full
20  uint64_t InNF : 1; // Input FIFO near full
21  uint64_t EvtNF : 1; // Event FIFO near full
22  uint64_t EvtSzOFW : 1; // Event size overflow
23  uint64_t L1aF : 1; // L1A FIFO full
24  uint64_t InF : 1; // Input FIFO full
25  uint64_t EvtF : 1; // Event FIFO full
26  uint64_t VfWdCnt : 12; // VFAT word count (in number of 64-bit words)
27  uint64_t InputID : 5; // Input link ID
28  uint64_t CALIB_CHAN : 7; // Calibration channel number
29  uint64_t : 17; // unused
30  };
31  // v302 dataformat
32  struct {
33  uint64_t : 10; // unused
34  uint64_t BxmVvVv302 : 1; // 1st bit BX mismatch VFAT vs VFAT
35  uint64_t BxmAvVv302 : 1; // BX mismatch AMC vs VFAT
36  uint64_t OOScVvVv302 : 1; // Out of Sync (EC mismatch) VFAT vs VFAT
37  uint64_t OOScAvVv302 : 1; // Out of Sync (EC mismatch) AMC vs VFAT
38  uint64_t InvV302 : 1; // Invalid event
39  uint64_t EvtSzWv302 : 1; // Event size warning
40  uint64_t : 1; // unused
41  uint64_t InNFv302 : 1; // Input FIFO near full
42  uint64_t EvtNFv302 : 1; // Event FIFO near full
43  uint64_t EvtSzOFWv302 : 1; // Event size overflow
44  uint64_t : 1; // unused
45  uint64_t InFv302 : 1; // Input FIFO full
46  uint64_t EvtFv302 : 1; // Event FIFO full
47  uint64_t VfWdCntV302 : 12; // VFAT word count (in number of 64-bit words)
48  uint64_t InputIDv302 : 5; // Input link ID
49  uint64_t CALIB_CHANv302 : 7; // Calibration channel number
50  uint64_t : 17; // unused
51  };
52  };
53 
56  // v301 dataformat
57  struct {
58  uint64_t ecOH : 20; // NOT USED - OptoHybrid event counter
59  uint64_t bcOH : 13; // NOT USED - OptoHybrid bunch crossing
60  uint64_t InUfw : 1; // Input FIFO underflow
61  uint64_t SkD : 1; // NOT USED - Stuck data
62  uint64_t EvUfw : 1; // NOT USED - Event FIFO underflow
63  uint64_t VfWdCntT : 12; // VFAT word count (in number of 64-bit words)
64  uint64_t crc16 : 16; // CRC of OptoHybrid data (currently not available – filled with 0)
65  };
66  // v302 dataformat
67  struct {
68  uint64_t VFATMask : 24; // Enabled VFAT, Set 1 if the VFAT is enabled
69  uint64_t ZSMask : 24; // Zero-suppressed VFAT, Set 1 if the VFAT payload has been zero-suppressed
70  uint64_t : 3; // unused
71  uint64_t InUfwV302 : 1; // Input FIFO underflow
72  uint64_t VfWdCntTv302 : 12; // VFAT word count (in number of 64-bit words)
73  };
74  };
75 
76  GEMOptoHybrid() : ch_(0), ct_(0), existVFATs_(0) {}
77  ~GEMOptoHybrid() { vfatd_.clear(); }
78 
79  void setVersion(uint8_t i) { ver_ = i; }
80  uint8_t version() const { return ver_; }
81 
84  void setChamberHeader(uint16_t vfatWordCnt, uint8_t inputID) {
85  GEBchamberHeader u{0};
86  u.VfWdCnt = vfatWordCnt;
87  u.InputID = inputID;
88  ch_ = u.word;
89  }
90  uint64_t getChamberHeader() const { return ch_; }
91 
94  void setChamberTrailer(uint32_t ecOH, uint16_t bcOH, uint16_t vfatWordCntT) {
95  GEBchamberTrailer u{0};
96  u.ecOH = ecOH;
97  u.bcOH = bcOH;
98  u.VfWdCntT = vfatWordCntT;
99  ct_ = u.word;
100  }
101  uint64_t getChamberTrailer() const { return ct_; }
102 
103  // v301
104  uint16_t vfatWordCnt() const {
105  if (ver_ == 0)
106  return GEBchamberHeader{ch_}.VfWdCnt;
107  return GEBchamberHeader{ch_}.VfWdCntV302;
108  }
109  uint8_t inputID() const {
110  if (ver_ == 0)
111  return GEBchamberHeader{ch_}.InputID;
112  return GEBchamberHeader{ch_}.InputIDv302;
113  }
114  uint16_t vfatWordCntT() const {
115  if (ver_ == 0)
116  return GEBchamberTrailer{ct_}.VfWdCntT;
117  return GEBchamberTrailer{ct_}.VfWdCntTv302;
118  }
119 
120  bool bxmVvV() const { return GEBchamberHeader{ch_}.BxmVvV; }
121  bool bxmAvV() const { return GEBchamberHeader{ch_}.BxmAvV; }
122  bool oOScVvV() const { return GEBchamberHeader{ch_}.OOScVvV; }
123  bool oOScAvV() const { return GEBchamberHeader{ch_}.OOScAvV; }
124  bool inv() const { return GEBchamberHeader{ch_}.Inv; }
125  bool evtSzW() const { return GEBchamberHeader{ch_}.EvtSzW; }
126  bool inNF() const { return GEBchamberHeader{ch_}.InNF; }
127  bool evtNF() const { return GEBchamberHeader{ch_}.EvtNF; }
128  bool evtSzOFW() const { return GEBchamberHeader{ch_}.EvtSzOFW; }
129  bool inF() const { return GEBchamberHeader{ch_}.InF; }
130  bool evtF() const { return GEBchamberHeader{ch_}.EvtF; }
131  bool inUfw() const {
132  if (ver_ == 0)
133  return GEBchamberTrailer{ct_}.InUfw;
134  return GEBchamberTrailer{ct_}.InUfwV302;
135  }
136 
137  bool noVFAT() const { return false; } // to be removed
138  bool stuckData() const { return false; } // to be removed
139  bool evUfw() const { return false; } // to be removed
140 
141  // v301
142  bool l1aNF() const { return GEBchamberHeader{ch_}.L1aNF; }
143  bool l1aF() const { return GEBchamberHeader{ch_}.L1aF; }
144 
145  // v302
146  uint32_t vfatMask() const { return GEBchamberTrailer{ct_}.VFATMask; }
147  uint32_t zsMask() const { return GEBchamberTrailer{ct_}.ZSMask; }
148 
150  void addVFAT(GEMVFAT v) {
151  existVFATs_ = existVFATs_ | (0x1 << v.vfatId());
152  vfatd_.push_back(v);
153  }
155  const std::vector<GEMVFAT>* vFATs() const { return &vfatd_; }
156  uint32_t existVFATs() const { return existVFATs_; }
158  void clearVFATs() { vfatd_.clear(); }
159 
160  static const int sizeGebID = 5;
161 
162 private:
163  uint8_t ver_; // Data Format version
164 
165  uint64_t ch_; // GEBchamberHeader
166  uint64_t ct_; // GEBchamberTrailer
167 
168  uint32_t existVFATs_;
169 
170  std::vector<GEMVFAT> vfatd_;
171 };
172 #endif
bool l1aNF() const
uint32_t existVFATs_
bool oOScVvV() const
void clearVFATs()
Clear the vector rof VFAT data.
static const int sizeGebID
void addVFAT(GEMVFAT v)
Adds VFAT data to the vector.
uint16_t vfatWordCntT() const
bool evtF() const
uint32_t zsMask() const
uint16_t vfatWordCnt() const
bool evUfw() const
std::vector< GEMVFAT > vfatd_
uint8_t version() const
Definition: GEMOptoHybrid.h:80
uint64_t word
Definition: GEMVFAT.h:5
bool bxmAvV() const
void setChamberTrailer(uint32_t ecOH, uint16_t bcOH, uint16_t vfatWordCntT)
Definition: GEMOptoHybrid.h:94
const std::vector< GEMVFAT > * vFATs() const
Returns the vector of VFAT data.
bool bxmVvV() const
uint32_t existVFATs() const
bool inUfw() const
void setVersion(uint8_t i)
Definition: GEMOptoHybrid.h:79
uint64_t getChamberTrailer() const
void setChamberTrailer(uint64_t word)
Read chamberTrailer from the block.
Definition: GEMOptoHybrid.h:93
bool evtNF() const
bool noVFAT() const
bool oOScAvV() const
unsigned long long uint64_t
Definition: Time.h:13
void setChamberHeader(uint16_t vfatWordCnt, uint8_t inputID)
Definition: GEMOptoHybrid.h:84
uint8_t inputID() const
bool evtSzW() const
bool inv() const
bool stuckData() const
bool inNF() const
uint32_t vfatMask() const
uint64_t getChamberHeader() const
Definition: GEMOptoHybrid.h:90
bool inF() const
bool evtSzOFW() const
void setChamberHeader(uint64_t word)
Read chamberHeader from the block.
Definition: GEMOptoHybrid.h:83
bool l1aF() const