Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-06 07:38:22

0001 #ifndef DataFormats_GEMDigi_GEMOHStatus_h
0002 #define DataFormats_GEMDigi_GEMOHStatus_h
0003 #include "GEMOptoHybrid.h"
0004 #include <bitset>
0005 #include <ostream>
0006 
0007 // GEM OptoHybrid status
0008 class GEMOHStatus {
0009 public:
0010   union Errors {
0011     uint16_t codes;
0012     struct {
0013       uint16_t EvtF : 1;      // Event FIFO full
0014       uint16_t InF : 1;       // Input FIFO full
0015       uint16_t L1aF : 1;      // L1A FIFO full
0016       uint16_t EvtSzOFW : 1;  // Event size overflow
0017       uint16_t Inv : 1;       // Invalid event
0018       uint16_t OOScAvV : 1;   // Out of Sync (EC mismatch) AMC vs VFAT
0019       uint16_t OOScVvV : 1;   // Out of Sync (EC mismatch) VFAT vs VFAT
0020       uint16_t BxmAvV : 1;    // BX mismatch AMC vs VFAT
0021       uint16_t BxmVvV : 1;    // 1st bit BX mismatch VFAT vs VFAT
0022       uint16_t InUfw : 1;     // Input FIFO underflow
0023       uint16_t badVFatCount : 1;
0024     };
0025   };
0026   union Warnings {
0027     uint8_t wcodes;
0028     struct {
0029       uint8_t EvtNF : 1;   // Event FIFO near full
0030       uint8_t InNF : 1;    // Input FIFO near full
0031       uint8_t L1aNF : 1;   // L1A FIFO near full
0032       uint8_t EvtSzW : 1;  // Event size warning
0033       uint8_t InValidVFAT : 1;
0034     };
0035   };
0036 
0037   GEMOHStatus() {}
0038   GEMOHStatus(const GEMOptoHybrid& oh) {
0039     Errors error{0};
0040     error.EvtF = oh.evtF();
0041     error.InF = oh.inF();
0042     error.L1aF = (oh.l1aF() and (oh.version() == 0));
0043     error.EvtSzOFW = oh.evtSzOFW();
0044     error.Inv = oh.inv();
0045     error.OOScAvV = oh.oOScAvV();
0046     error.OOScVvV = oh.oOScVvV();
0047     error.BxmAvV = oh.bxmAvV();
0048     error.BxmVvV = oh.bxmVvV();
0049     error.InUfw = oh.inUfw();
0050     error.badVFatCount = oh.vfatWordCnt() != oh.vfatWordCntT();
0051     errors_ = error.codes;
0052 
0053     Warnings warn{0};
0054     warn.EvtNF = oh.evtNF();
0055     warn.InNF = oh.inNF();
0056     warn.L1aNF = (oh.l1aNF() and (oh.version() == 0));
0057     warn.EvtSzW = oh.evtSzW();
0058     warnings_ = warn.wcodes;
0059   }
0060 
0061   void inValidVFAT() {
0062     Warnings warn{warnings_};
0063     warn.InValidVFAT = 1;
0064     warnings_ = warn.wcodes;
0065   }
0066 
0067   bool isBad() const { return errors_ != 0; }
0068   uint16_t errors() const { return errors_; }
0069   uint8_t warnings() const { return warnings_; }
0070 
0071 private:
0072   uint16_t errors_;
0073   uint8_t warnings_;
0074 };
0075 
0076 inline std::ostream& operator<<(std::ostream& out, const GEMOHStatus& status) {
0077   out << "GEMOHStatus errors " << std::bitset<16>(status.errors()) << " warnings " << std::bitset<8>(status.warnings());
0078   return out;
0079 }
0080 
0081 #endif