CMS 3D CMS Logo

GEMAMC13Status.h
Go to the documentation of this file.
1 #ifndef DataFormats_GEMDigi_GEMAMC13Status_h
2 #define DataFormats_GEMDigi_GEMAMC13Status_h
3 #include "GEMAMC13.h"
4 #include "GEMAMC.h"
7 #include <bitset>
8 #include <ostream>
9 
11 public:
12  union Errors {
13  uint8_t codes;
14  struct {
15  uint8_t InValidSize : 1;
16  uint8_t failTrailerCheck : 1;
17  uint8_t failFragmentLength : 1;
18  uint8_t failTrailerMatch : 1;
19  uint8_t moreTrailers : 1;
20  uint8_t crcModified : 1;
21  uint8_t slinkError : 1;
22  uint8_t wrongFedId : 1;
23  };
24  };
25  union Warnings {
26  uint8_t wcodes;
27  struct {
28  uint8_t InValidAMC : 1; // error for AMC but cant display when not found.
29  };
30  };
31 
33  GEMAMC13Status(const FEDRawData& fedData) {
34  Errors error{0};
35  if ((fedData.size() / sizeof(uint64_t)) < 5) {
36  error.InValidSize = 1;
37  } else {
38  FEDTrailer trailer(fedData.data() + fedData.size() - FEDTrailer::length);
39  error.failTrailerCheck = !trailer.check();
40  error.failFragmentLength = (trailer.fragmentLength() * sizeof(uint64_t) != fedData.size());
41  error.moreTrailers = trailer.moreTrailers();
42  error.crcModified = trailer.crcModified();
43  error.slinkError = trailer.slinkError();
44  error.wrongFedId = trailer.wrongFedId();
45  }
46  errors_ = error.codes;
47 
48  Warnings warn{0};
49  warnings_ = warn.wcodes;
50  }
51  void inValidAMC() {
53  warn.InValidAMC = 1;
54  warnings_ = warn.wcodes;
55  }
56 
57  bool isBad() const { return errors_ != 0; }
58  uint8_t errors() const { return errors_; }
59  uint8_t warnings() const { return warnings_; }
60 
61 private:
62  uint8_t errors_;
63  uint8_t warnings_;
64 };
65 
66 inline std::ostream& operator<<(std::ostream& out, const GEMAMC13Status& status) {
67  out << "GEMAMC13Status errors " << std::bitset<8>(status.errors()) << " warnings "
68  << std::bitset<8>(status.warnings());
69  return out;
70 }
71 
72 #endif
static const uint32_t length
Definition: FEDTrailer.h:57
uint8_t errors() const
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:48
def warn(args, kwargs)
Definition: __init__.py:19
bool isBad() const
unsigned long long uint64_t
Definition: Time.h:13
GEMAMC13Status(const FEDRawData &fedData)
std::ostream & operator<<(std::ostream &out, const GEMAMC13Status &status)
uint8_t warnings() const
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24