CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GEMAMC.h
Go to the documentation of this file.
1 #ifndef DataFormats_GEMDigi_GEMAMC_h
2 #define DataFormats_GEMDigi_GEMAMC_h
3 #include "GEMOptoHybrid.h"
4 #include <vector>
5 
6 class GEMAMC {
7 public:
8  union AMCheader1 {
10  struct {
11  uint64_t dataLength : 20; // Always 0xfffff, use trailer dataLengthT
12  uint64_t bxID : 12; // Bunch crossing ID
13  uint64_t l1AID : 24; // L1A number – basically this is like event number, but reset by resync
14  uint64_t AMCnum : 4; // Slot number of the AMC
15  uint64_t reserved : 4; // not used
16  };
17  };
18  union AMCheader2 {
20  struct {
21  uint64_t boardID : 16; // 8bit long GLIB serial number
22  uint64_t orbitNum : 16; // Orbit number, Reset by EC0
23  uint64_t param3 : 8; // RunPar - Controlled by software, normally used only for calibrations
24  uint64_t param2 : 8; // RunPar - Controlled by software, normally used only for calibrations
25  uint64_t param1 : 8; // RunPar - Controlled by software, normally used only for calibrations
26  uint64_t runType : 4; // run types like physics, cosmics, threshold scan, latency scan, etc..
27  uint64_t formatVer : 4; // Current format version = 0x0
28  };
29  };
30  union AMCTrailer {
32  struct {
33  uint64_t dataLength : 20; // Number of 64bit words in this event
34  uint64_t : 4;
35  uint64_t l1AID : 8; // L1A number (first 8 bits)
36  uint64_t crc : 32; // CRC added by the AMC13
37  };
38  };
39  union EventHeader {
41  struct {
42  uint64_t ttsState : 4; // GLIB TTS state at the moment when this event was built.
43  uint64_t pType : 4; // Payload type: can be one refering to different zero suppression schemes
44  // in normal data taking or calibration type.
45  // Note in calibration type the entire GCT (GEM Chamber Trailer) is skipped
46  uint64_t pVer : 3; // Version of the payload type
47  uint64_t davCnt : 5; // Number of chamber blocks in this event
48  uint64_t buffState : 24; // Buffer status, Always 0 in current fw
49  uint64_t davList : 24; // Data Available list: a bitmask indicating which chambers have data in this event
50  };
51  };
52  union EventTrailer {
54  struct {
55  uint64_t BCL : 4; // 1st bit, BC0 locked - If 0, this is a bad condition indicating a
56  // problem in the clock or TTC command stream (critical condition)
57  uint64_t DR : 1; // DAQ Ready - If 0, this means that AMC13 is not ready to take data (critical condition)
58  uint64_t CL : 1; // DAQ clock locked- If 0, this indicates a problem in the DAQ clock (critical condition)
59  uint64_t ML : 1; // MMCM locked - Should always be 1
60  uint64_t BP : 1; // Backpressure - If this is 1, it means that we are receiving backpressure from AMC13
61  uint64_t oosGlib : 32; // GLIB is out‐of‐sync (critical): L1A ID is different for
62  // different chambers in this event (1 bit)
63  uint64_t linkTo : 24; // Link timeout flags (one bit for each link indicating timeout condition)
64  };
65  };
66 
67  GEMAMC() : amch1_(0), amch2_(0), amct_(0), eh_(0), et_(0){};
68  ~GEMAMC() { gebd_.clear(); }
69 
70  int status();
71 
73  void setAMCheader1(uint32_t dataLength, uint16_t bxID, uint32_t l1AID, uint8_t AMCnum);
74  uint64_t getAMCheader1() const { return amch1_; }
75 
77  void setAMCheader2(uint16_t boardID, uint16_t orbitNum, uint8_t runType);
78  uint64_t getAMCheader2() const { return amch2_; }
79 
81  uint64_t getAMCTrailer() const { return amct_; }
82 
84  void setGEMeventHeader(uint8_t davCnt, uint32_t davList);
85  uint64_t getGEMeventHeader() const { return eh_; }
86 
88  uint64_t getGEMeventTrailer() const { return et_; }
89 
90  uint32_t dataLength() const { return AMCTrailer{amct_}.dataLength; }
91  uint16_t bunchCrossing() const { return AMCheader1{amch1_}.bxID; }
92  uint32_t lv1Id() const { return AMCheader1{amch1_}.l1AID; }
93  uint8_t amcNum() const { return AMCheader1{amch1_}.AMCnum; }
94 
95  uint16_t boardId() const { return AMCheader2{amch2_}.boardID; }
96  uint16_t orbitNumber() const { return AMCheader2{amch2_}.orbitNum; }
97  uint8_t param3() const { return AMCheader2{amch2_}.param3; }
98  uint8_t param2() const { return AMCheader2{amch2_}.param2; }
99  uint8_t param1() const { return AMCheader2{amch2_}.param1; }
100  uint8_t runType() const { return AMCheader2{amch2_}.runType; }
101  uint8_t formatVer() const { return AMCheader2{amch2_}.formatVer; }
102 
103  uint8_t lv1Idt() const { return AMCTrailer{amct_}.l1AID; }
104  uint32_t crc() const { return AMCTrailer{amct_}.crc; }
105 
106  uint16_t ttsState() const { return EventHeader{eh_}.ttsState; }
107  uint8_t davCnt() const { return EventHeader{eh_}.davCnt; }
108  uint32_t buffState() const { return EventHeader{eh_}.buffState; }
109  uint32_t davList() const { return EventHeader{eh_}.davList; }
110 
111  uint8_t bc0locked() const { return EventTrailer{et_}.BCL; }
112  uint8_t daqReady() const { return EventTrailer{et_}.DR; }
113  uint8_t daqClockLocked() const { return EventTrailer{et_}.CL; }
114  uint8_t mmcmLocked() const { return EventTrailer{et_}.ML; }
115  uint8_t backPressure() const { return EventTrailer{et_}.BP; }
116  uint8_t oosGlib() const { return EventTrailer{et_}.oosGlib; }
117  uint32_t linkTo() const { return EventTrailer{et_}.linkTo; }
118 
120  void addGEB(GEMOptoHybrid g) { gebd_.push_back(g); }
122  const std::vector<GEMOptoHybrid>* gebs() const { return &gebd_; }
124  void clearGEBs() { gebd_.clear(); }
125 
126 private:
132 
133  std::vector<GEMOptoHybrid> gebd_;
134 };
135 #endif
void setAMCheader1(uint64_t word)
Definition: GEMAMC.h:72
uint64_t amch2_
Definition: GEMAMC.h:128
uint64_t formatVer
Definition: GEMAMC.h:27
uint64_t ttsState
Definition: GEMAMC.h:42
uint8_t bc0locked() const
Definition: GEMAMC.h:111
void setAMCheader2(uint64_t word)
Definition: GEMAMC.h:76
uint64_t param2
Definition: GEMAMC.h:24
uint8_t daqReady() const
Definition: GEMAMC.h:112
~GEMAMC()
Definition: GEMAMC.h:68
uint64_t BCL
Definition: GEMAMC.h:55
uint64_t getGEMeventTrailer() const
Definition: GEMAMC.h:88
uint64_t pType
Definition: GEMAMC.h:43
uint8_t lv1Idt() const
Definition: GEMAMC.h:103
void setAMCTrailer(uint64_t word)
Definition: GEMAMC.h:80
uint64_t amct_
Definition: GEMAMC.h:129
uint64_t dataLength
Definition: GEMAMC.h:33
uint64_t crc
Definition: GEMAMC.h:36
uint64_t getAMCheader1() const
Definition: GEMAMC.h:74
uint64_t runType
Definition: GEMAMC.h:26
uint64_t dataLength
Definition: GEMAMC.h:11
uint32_t lv1Id() const
Definition: GEMAMC.h:92
uint64_t l1AID
Definition: GEMAMC.h:35
uint8_t mmcmLocked() const
Definition: GEMAMC.h:114
uint64_t et_
Definition: GEMAMC.h:131
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
uint64_t amch1_
Definition: GEMAMC.h:127
uint32_t davList() const
Definition: GEMAMC.h:109
uint32_t buffState() const
Definition: GEMAMC.h:108
uint64_t word
uint64_t reserved
Definition: GEMAMC.h:15
uint64_t oosGlib
Definition: GEMAMC.h:61
uint8_t amcNum() const
Definition: GEMAMC.h:93
uint16_t boardId() const
Definition: GEMAMC.h:95
uint16_t orbitNumber() const
Definition: GEMAMC.h:96
uint64_t orbitNum
Definition: GEMAMC.h:22
uint64_t buffState
Definition: GEMAMC.h:48
int status()
uint64_t param1
Definition: GEMAMC.h:25
const std::vector< GEMOptoHybrid > * gebs() const
Returns a vector of GEB data.
Definition: GEMAMC.h:122
uint64_t param3
Definition: GEMAMC.h:23
uint64_t pVer
Definition: GEMAMC.h:46
uint8_t runType() const
Definition: GEMAMC.h:100
void setGEMeventTrailer(uint64_t word)
Definition: GEMAMC.h:87
uint64_t eh_
Definition: GEMAMC.h:130
uint64_t linkTo
Definition: GEMAMC.h:63
uint64_t word
Definition: GEMAMC.h:53
uint64_t getAMCheader2() const
Definition: GEMAMC.h:78
uint32_t dataLength() const
Definition: GEMAMC.h:90
uint64_t davList
Definition: GEMAMC.h:49
uint64_t bxID
Definition: GEMAMC.h:12
unsigned long long uint64_t
Definition: Time.h:13
std::vector< GEMOptoHybrid > gebd_
Vector of GEB data.
Definition: GEMAMC.h:133
uint64_t getAMCTrailer() const
Definition: GEMAMC.h:81
uint64_t davCnt
Definition: GEMAMC.h:47
uint8_t formatVer() const
Definition: GEMAMC.h:101
Definition: GEMAMC.h:6
void setGEMeventHeader(uint64_t word)
Definition: GEMAMC.h:83
uint64_t word
Definition: GEMAMC.h:9
uint64_t word
Definition: GEMAMC.h:31
uint64_t word
Definition: GEMAMC.h:40
void addGEB(GEMOptoHybrid g)
Adds GEB data to vector.
Definition: GEMAMC.h:120
uint8_t davCnt() const
Definition: GEMAMC.h:107
uint16_t ttsState() const
Definition: GEMAMC.h:106
uint8_t param3() const
Definition: GEMAMC.h:97
uint8_t daqClockLocked() const
Definition: GEMAMC.h:113
uint64_t getGEMeventHeader() const
Definition: GEMAMC.h:85
uint8_t param1() const
Definition: GEMAMC.h:99
void clearGEBs()
Clear a vector of GEB data.
Definition: GEMAMC.h:124
GEMAMC()
Definition: GEMAMC.h:67
uint64_t AMCnum
Definition: GEMAMC.h:14
uint32_t linkTo() const
Definition: GEMAMC.h:117
uint64_t boardID
Definition: GEMAMC.h:21
uint32_t crc() const
Definition: GEMAMC.h:104
uint64_t word
Definition: GEMAMC.h:19
uint8_t oosGlib() const
Definition: GEMAMC.h:116
uint16_t bunchCrossing() const
Definition: GEMAMC.h:91
uint8_t param2() const
Definition: GEMAMC.h:98
uint64_t l1AID
Definition: GEMAMC.h:13
uint8_t backPressure() const
Definition: GEMAMC.h:115