CMS 3D CMS Logo

GEMAMCStatus.h
Go to the documentation of this file.
1 #ifndef DataFormats_GEMDigi_GEMAMCStatus_h
2 #define DataFormats_GEMDigi_GEMAMCStatus_h
3 #include "GEMAMC13.h"
4 #include "GEMAMC.h"
5 #include <bitset>
6 #include <ostream>
7 
8 class GEMAMCStatus {
9 public:
10  union Errors {
11  uint16_t ecodes;
12  struct {
13  uint16_t badEC : 1; // event counter
14  uint16_t badBC : 1; // bunch crossing
15  uint16_t badOC : 1; // orbit number
16  uint16_t badRunType : 1;
17  uint16_t badCRC : 1;
18  uint16_t MMCMlocked : 1;
19  uint16_t DAQclocklocked : 1;
20  uint16_t DAQnotReday : 1;
21  uint16_t BC0locked : 1;
22  uint16_t badFEDId : 1;
23  uint16_t L1AFull : 1;
24  };
25  };
26  union Warnings {
27  uint8_t wcodes;
28  struct {
29  uint8_t InValidOH : 1;
30  uint8_t backPressure : 1;
31  uint8_t L1ANearFull : 1;
32  };
33  };
34 
36  GEMAMCStatus(const GEMAMC13* amc13, const GEMAMC& amc) {
37  amcNum_ = amc.amcNum();
38  Errors error{0};
39  error.badEC = (amc13->lv1Id() != amc.lv1Id());
40  // Last BC in AMC13 is different to TCDS, AMC, and VFAT
41  error.badBC = !((amc13->bunchCrossing() == amc.bunchCrossing()) ||
42  (amc13->bunchCrossing() == 0 && amc.bunchCrossing() == GEMAMC13::lastBC));
43  error.badRunType = amc.runType() != 0x1;
44  if (amc.formatVer() == 0)
45  // Last OC in AMC13 is different to TCDS, AMC, and VFAT
46  error.badOC =
47  !((uint16_t(amc13->orbitNumber()) == amc.orbitNumber()) ||
48  (amc13->bunchCrossing() == 0 && uint16_t(amc.orbitNumber() + 1) == uint16_t(amc13->orbitNumber())));
49  else
50  error.badOC = (amc13->orbitNumber() != amc.orbitNumber());
51  error.MMCMlocked = !amc.mmcmLocked();
52  error.DAQclocklocked = !amc.daqClockLocked();
53  error.DAQnotReday = !amc.daqReady();
54  error.BC0locked = !amc.bc0locked();
55  error.badFEDId = (amc13->sourceId() != amc.softSrcId() and amc.formatVer() != 0);
56  error.L1AFull = (amc.l1aF() and amc.formatVer() != 0);
57  errors_ = error.ecodes;
58 
59  Warnings warn{0};
60  warn.backPressure = amc.backPressure();
61  warn.L1ANearFull = (amc.l1aNF() and amc.formatVer() != 0);
62  warnings_ = warn.wcodes;
63  }
64 
65  void inValidOH() {
67  warn.InValidOH = 1;
68  warnings_ = warn.wcodes;
69  }
70 
71  uint8_t amcNumber() const { return amcNum_; };
72  bool isBad() const { return errors_ != 0; }
73  uint16_t errors() const { return errors_; }
74  uint8_t warnings() const { return warnings_; }
75 
76 private:
77  uint8_t amcNum_;
78  uint16_t errors_;
79  uint8_t warnings_;
80 };
81 
82 inline std::ostream& operator<<(std::ostream& out, const GEMAMCStatus& status) {
83  out << "GEMAMCStatus errors " << std::bitset<16>(status.errors()) << " warnings "
84  << std::bitset<8>(status.warnings());
85  return out;
86 }
87 
88 #endif
void inValidOH()
Definition: GEMAMCStatus.h:65
def warn(args, kwargs)
Definition: __init__.py:21
uint8_t amcNumber() const
Definition: GEMAMCStatus.h:71
uint16_t errors() const
Definition: GEMAMCStatus.h:73
GEMAMCStatus(const GEMAMC13 *amc13, const GEMAMC &amc)
Definition: GEMAMCStatus.h:36
static const int lastBC
Definition: GEMAMC13.h:112
bool isBad() const
Definition: GEMAMCStatus.h:72
uint8_t warnings_
Definition: GEMAMCStatus.h:79
uint16_t errors_
Definition: GEMAMCStatus.h:78
Definition: GEMAMC.h:6
std::ostream & operator<<(std::ostream &out, const GEMAMCStatus &status)
Definition: GEMAMCStatus.h:82
uint8_t amcNum_
Definition: GEMAMCStatus.h:77
uint8_t warnings() const
Definition: GEMAMCStatus.h:74
Definition: AMCSpec.h:8