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  // Last OC in AMC13 is different to TCDS, AMC, and VFAT
45  if (amc.formatVer() == 0)
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() + 1)) ||
51  (amc13->bunchCrossing() == 0 && amc13->orbitNumber() == (amc.orbitNumber() + 2)));
52  error.MMCMlocked = !amc.mmcmLocked();
53  error.DAQclocklocked = !amc.daqClockLocked();
54  error.DAQnotReday = !amc.daqReady();
55  error.BC0locked = !amc.bc0locked();
56  error.badFEDId = (amc13->sourceId() != amc.softSrcId() and amc.formatVer() != 0);
57  error.L1AFull = (amc.l1aF() and amc.formatVer() != 0);
58  errors_ = error.ecodes;
59 
60  Warnings warn{0};
61  warn.backPressure = amc.backPressure();
62  warn.L1ANearFull = (amc.l1aNF() and amc.formatVer() != 0);
63  warnings_ = warn.wcodes;
64  }
65 
66  void inValidOH() {
68  warn.InValidOH = 1;
69  warnings_ = warn.wcodes;
70  }
71 
72  uint8_t amcNumber() const { return amcNum_; };
73  bool isBad() const { return errors_ != 0; }
74  uint16_t errors() const { return errors_; }
75  uint8_t warnings() const { return warnings_; }
76 
77 private:
78  uint8_t amcNum_;
79  uint16_t errors_;
80  uint8_t warnings_;
81 };
82 
83 inline std::ostream& operator<<(std::ostream& out, const GEMAMCStatus& status) {
84  out << "GEMAMCStatus errors " << std::bitset<16>(status.errors()) << " warnings "
85  << std::bitset<8>(status.warnings());
86  return out;
87 }
88 
89 #endif
void inValidOH()
Definition: GEMAMCStatus.h:66
def warn(args, kwargs)
Definition: __init__.py:21
uint8_t amcNumber() const
Definition: GEMAMCStatus.h:72
uint16_t errors() const
Definition: GEMAMCStatus.h:74
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:73
uint8_t warnings_
Definition: GEMAMCStatus.h:80
uint16_t errors_
Definition: GEMAMCStatus.h:79
Definition: GEMAMC.h:6
std::ostream & operator<<(std::ostream &out, const GEMAMCStatus &status)
Definition: GEMAMCStatus.h:83
uint8_t amcNum_
Definition: GEMAMCStatus.h:78
uint8_t warnings() const
Definition: GEMAMCStatus.h:75
Definition: AMCSpec.h:8