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 "GEMVFAT.h"
5 #include <bitset>
6 #include <ostream>
7 
8 class GEMVFATStatus {
9 public:
10  union Errors {
11  uint8_t codes;
12  struct {
13  uint8_t vc : 1; // VFAT CRC error
14  uint8_t InValidHeader : 1;
15  uint8_t EC : 1; // does not match AMC EC
16  uint8_t BC : 1; // does not match AMC BC
17  };
18  };
19  union Warnings {
20  uint8_t wcodes;
21  struct {
22  uint8_t basicOFW : 1; // Basic overflow warning
23  uint8_t zeroSupOFW : 1; // Zero-sup overflow warning
24  };
25  };
26 
28  GEMVFATStatus(const GEMAMC& amc, const GEMVFAT& vfat, uint16_t position, bool readMultiBX) {
29  Errors error{0};
30  Warnings warn{0};
31 
32  error.EC = vfat.ec() != amc.lv1Idt();
33  if (!readMultiBX)
34  error.BC = vfat.bc() != amc.bunchCrossing();
35 
36  if (vfat.version() > 2) {
37  error.vc = vfat.vc();
38  if (vfat.header() == 0x1E)
39  warn.basicOFW = 0;
40  else if (vfat.header() == 0x5E)
41  warn.basicOFW = 1;
42  else if (vfat.header() == 0x1A)
43  warn.zeroSupOFW = 0;
44  else if (vfat.header() == 0x56)
45  warn.zeroSupOFW = 1;
46  else
47  error.InValidHeader = 1;
48  }
50 
51  errors_ = error.codes;
52  warnings_ = warn.wcodes;
53  }
54 
55  uint16_t vfatPosition() const { return vfatPosition_; }
56  bool isBad() const { return errors_ != 0; }
57  uint16_t errors() const { return errors_; }
58  uint8_t warnings() const { return warnings_; }
59 
60 private:
61  uint16_t vfatPosition_;
62  uint16_t errors_;
63  uint8_t warnings_;
64 };
65 
66 inline std::ostream& operator<<(std::ostream& out, const GEMVFATStatus& status) {
67  out << "GEMVFATStatus errors " << std::bitset<8>(status.errors()) << " warnings "
68  << std::bitset<8>(status.warnings());
69  return out;
70 }
71 #endif
std::ostream & operator<<(std::ostream &out, const GEMVFATStatus &status)
Definition: GEMVFATStatus.h:66
uint8_t warnings() const
Definition: GEMVFATStatus.h:58
uint8_t header() const
v3
Definition: GEMVFAT.h:100
uint16_t errors_
Definition: GEMVFATStatus.h:62
uint8_t warnings_
Definition: GEMVFATStatus.h:63
def warn(args, kwargs)
Definition: __init__.py:21
bool isBad() const
Definition: GEMVFATStatus.h:56
GEMVFATStatus(const GEMAMC &amc, const GEMVFAT &vfat, uint16_t position, bool readMultiBX)
Definition: GEMVFATStatus.h:28
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:61
uint16_t vfatPosition() const
Definition: GEMVFATStatus.h:55
Definition: GEMAMC.h:6
int version() const
Definition: GEMVFAT.h:94
static int position[264][3]
Definition: ReadPGInfo.cc:289
bool vc() const
Definition: GEMVFAT.h:101
Definition: AMCSpec.h:8
uint16_t errors() const
Definition: GEMVFATStatus.h:57