CMS 3D CMS Logo

GEMVFATStatus.h
Go to the documentation of this file.
1 #ifndef DataFormats_GEMDigi_GEMVFATStatus_h
2 #define DataFormats_GEMDigi_GEMVFATStatus_h
3 #include "GEMAMC.h"
4 #include "GEMOptoHybrid.h"
5 #include "GEMVFAT.h"
6 #include <bitset>
7 #include <ostream>
8 
9 class GEMVFATStatus {
10 public:
11  union Errors {
12  uint8_t codes;
13  struct {
14  uint8_t vc : 1; // VFAT CRC error
15  uint8_t InValidHeader : 1;
16  uint8_t EC : 1; // does not match AMC EC
17  uint8_t BC : 1; // does not match AMC BC
18  uint8_t vfatMask : 1; // VFAT mask error
19  uint8_t zsMask : 1; // Zero Suppression mask error
20  };
21  };
22  union Warnings {
23  uint8_t wcodes;
24  struct {
25  uint8_t basicOFW : 1; // Basic overflow warning
26  uint8_t zeroSupOFW : 1; // Zero-sup overflow warning
27  };
28  };
29 
31  GEMVFATStatus(const GEMAMC& amc, const GEMOptoHybrid& oh, const GEMVFAT& vfat, int chamberType, bool readMultiBX)
33  Errors error{0};
34  Warnings warn{0};
35 
36  error.EC = vfat.ec() != amc.lv1Idt();
37  if (!readMultiBX)
38  error.BC = vfat.bc() != amc.bunchCrossing();
39 
40  if (oh.version() != 0) {
41  error.vfatMask = (oh.vfatMask() >> vfat.vfatId()) ^ 0x1;
42  error.zsMask = (oh.zsMask() >> vfat.vfatId()) & 0x1;
43  }
44 
45  if (vfat.version() > 2) {
46  error.vc = vfat.vc();
47  if (vfat.header() == 0x1E)
48  warn.basicOFW = 0;
49  else if (vfat.header() == 0x5E)
50  warn.basicOFW = 1;
51  else if (vfat.header() == 0x1A)
52  warn.zeroSupOFW = 0;
53  else if (vfat.header() == 0x56)
54  warn.zeroSupOFW = 1;
55  else
56  error.InValidHeader = 1;
57  }
58  vfatPosition_ = vfat.vfatId();
59 
60  errors_ = error.codes;
61  warnings_ = warn.wcodes;
62  }
63 
64  uint16_t vfatPosition() const { return vfatPosition_; }
65  bool isBad() const { return errors_ != 0; }
66  uint8_t errors() const { return errors_; }
67  uint8_t warnings() const { return warnings_; }
68  int chamberType() const { return chamberType_; }
69 
70 private:
72  uint16_t vfatPosition_;
73  uint8_t errors_;
74  uint8_t warnings_;
75 };
76 
77 inline std::ostream& operator<<(std::ostream& out, const GEMVFATStatus& status) {
78  out << "GEMVFATStatus errors " << std::bitset<8>(status.errors()) << " warnings "
79  << std::bitset<8>(status.warnings());
80  return out;
81 }
82 #endif
std::ostream & operator<<(std::ostream &out, const GEMVFATStatus &status)
Definition: GEMVFATStatus.h:77
uint8_t warnings() const
Definition: GEMVFATStatus.h:67
uint8_t header() const
v3
Definition: GEMVFAT.h:100
uint8_t warnings_
Definition: GEMVFATStatus.h:74
uint32_t zsMask() const
def warn(args, kwargs)
Definition: __init__.py:21
bool isBad() const
Definition: GEMVFATStatus.h:65
uint8_t version() const
Definition: GEMOptoHybrid.h:80
Definition: GEMVFAT.h:5
uint16_t bc() const
Definition: GEMVFAT.h:77
uint8_t ec() const
Definition: GEMVFAT.h:82
uint16_t vfatPosition_
Definition: GEMVFATStatus.h:72
uint8_t errors_
Definition: GEMVFATStatus.h:73
uint8_t errors() const
Definition: GEMVFATStatus.h:66
uint16_t vfatId() const
Definition: GEMVFAT.h:87
int chamberType() const
Definition: GEMVFATStatus.h:68
uint16_t vfatPosition() const
Definition: GEMVFATStatus.h:64
Definition: GEMAMC.h:6
int version() const
Definition: GEMVFAT.h:94
uint32_t vfatMask() const
GEMVFATStatus(const GEMAMC &amc, const GEMOptoHybrid &oh, const GEMVFAT &vfat, int chamberType, bool readMultiBX)
Definition: GEMVFATStatus.h:31
bool vc() const
Definition: GEMVFAT.h:101
Definition: AMCSpec.h:8