CMS 3D CMS Logo

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  // v301 dataformat
21  struct {
22  uint64_t boardID : 16; // 8bit long GLIB serial number
23  uint64_t orbitNum : 16; // Orbit number, Reset by EC0
24  uint64_t param3 : 8; // RunPar - Controlled by software, normally used only for calibrations
25  uint64_t param2 : 8; // RunPar - Controlled by software, normally used only for calibrations
26  uint64_t param1 : 8; // RunPar - Controlled by software, normally used only for calibrations
27  uint64_t runType : 4; // run types like physics, cosmics, threshold scan, latency scan, etc..
28  uint64_t formatVer : 4; // Current format version = 0x0
29  };
30  // v302 dataformat
31  struct {
32  uint64_t softSrcId : 12; // FED ID - Configruation Error if does not match with CDF header
33  uint64_t softSlot : 4; // AMC slot number - Configuation Error if does not match with AMC13 AHn header
34  uint64_t orbitNumV302 : 32; // Orbit counter, Reset by EC0 - Error if does not match AMC BH header
35  uint64_t : 12; // unused
36  uint64_t FVv302 : 4; // Current version = 0x1
37  };
38  };
39  union AMCTrailer {
41  struct {
42  uint64_t dataLength : 20; // Number of 64bit words in this event
43  uint64_t : 4; // unused
44  uint64_t l1AID : 8; // L1A number (first 8 bits)
45  uint64_t crc : 32; // CRC added by the AMC13
46  };
47  };
48  union EventHeader {
50  struct {
51  uint64_t ttsState : 4; // GLIB TTS state at the moment when this event was built.
52  uint64_t pType : 4; // Payload type: can be one refering to different zero suppression schemes
53  // in normal data taking or calibration type.
54  // Note in calibration type the entire GCT (GEM Chamber Trailer) is skipped
55  uint64_t pVer : 3; // Version of the payload type
56  uint64_t davCnt : 5; // Number of chamber blocks in this event
57  uint64_t buffState : 24; // Buffer status, Always 0 in current fw
58  uint64_t davList : 24; // Data Available list: a bitmask indicating which chambers have data in this event
59  };
60  };
61  union EventTrailer {
63  // v301 dataformat
64  struct {
65  uint64_t BCL : 4; // 1st bit, BC0 locked - If 0, this is a bad condition indicating a
66  // problem in the clock or TTC command stream (critical condition)
67  uint64_t DR : 1; // DAQ Ready - If 0, this means that AMC13 is not ready to take data (critical condition)
68  uint64_t CL : 1; // DAQ clock locked- If 0, this indicates a problem in the DAQ clock (critical condition)
69  uint64_t ML : 1; // MMCM locked - Should always be 1
70  uint64_t BP : 1; // Backpressure - If this is 1, it means that we are receiving backpressure from AMC13
71  uint64_t oosGlib : 32; // GLIB is out‐of‐sync (critical): L1A ID is different for
72  // different chambers in this event (1 bit)
73  uint64_t linkTo : 24; // Link timeout flags (one bit for each link indicating timeout condition)
74  };
75  // v302 dataformat
76  struct {
77  uint64_t L1aNF : 1; // L1A FIFO near full - Warning
78  uint64_t L1aF : 1; // L1A FIFO full - Error
79  uint64_t : 1; // unused
80  uint64_t BCLv302 : 1; // BC0 locked - If 0, this is a bad condition indicating a
81  // problem in the clock or TTC command stream (critical condition)
82  uint64_t DRv302 : 1; // DAQ Ready - If 0, this means that AMC13 is not ready to take data (critical condition)
83  uint64_t CLv302 : 1; // DAQ clock locked- If 0, this indicates a problem in the DAQ clock (critical condition)
84  uint64_t MLv302 : 1; // MMCM locked - Should always be 1
85  uint64_t BPv302 : 1; // Backpressure - If this is 1, it means that we are receiving backpressure from AMC13
86  uint64_t param3 : 8; // RunPar - Controlled by software, normally used only for calibrations
87  uint64_t param2 : 8; // RunPar - Controlled by software, normally used only for calibrations
88  uint64_t param1 : 8; // RunPar - Controlled by software, normally used only for calibrations
89  uint64_t runType : 4; // Type of Run - Controlled by software, “physics” is assigned 0x1,
90  // hits from events with other run types should be discarded
91  uint64_t : 4; // unused
92  uint64_t linkToV302 : 24; // Link timeout flags (one bit for each link indicating timeout condition)
93  };
94  };
95 
96  GEMAMC() : amch1_(0), amch2_(0), amct_(0), eh_(0), et_(0){};
97  ~GEMAMC() { gebd_.clear(); }
98 
99  int status();
100 
102  void setAMCheader1(uint32_t dataLength, uint16_t bxID, uint32_t l1AID, uint8_t AMCnum);
103  uint64_t getAMCheader1() const { return amch1_; }
104 
106  void setAMCheader2(uint16_t boardID, uint16_t orbitNum, uint8_t runType);
107  uint64_t getAMCheader2() const { return amch2_; }
108 
110  uint64_t getAMCTrailer() const { return amct_; }
111 
113  void setGEMeventHeader(uint8_t davCnt, uint32_t davList);
114  uint64_t getGEMeventHeader() const { return eh_; }
115 
117  uint64_t getGEMeventTrailer() const { return et_; }
118 
119  // v301
120  uint32_t dataLength() const { return AMCTrailer{amct_}.dataLength; }
121  uint16_t bunchCrossing() const { return AMCheader1{amch1_}.bxID; }
122  uint32_t lv1Id() const { return AMCheader1{amch1_}.l1AID; }
123  uint8_t amcNum() const { return AMCheader1{amch1_}.AMCnum; }
124 
125  uint16_t boardId() const { return AMCheader2{amch2_}.boardID; }
126  uint32_t orbitNumber() const {
127  if (formatVer() == 0)
128  return AMCheader2{amch2_}.orbitNum;
129  return AMCheader2{amch2_}.orbitNumV302;
130  }
131  uint8_t param3() const {
132  if (formatVer() == 0)
133  return AMCheader2{amch2_}.param3;
134  return EventTrailer{et_}.param3;
135  }
136  uint8_t param2() const {
137  if (formatVer() == 0)
138  return AMCheader2{amch2_}.param2;
139  return EventTrailer{et_}.param2;
140  }
141  uint8_t param1() const {
142  if (formatVer() == 0)
143  return AMCheader2{amch2_}.param1;
144  return EventTrailer{et_}.param1;
145  }
146  uint8_t runType() const {
147  if (formatVer() == 0)
148  return AMCheader2{amch2_}.runType;
149  return EventTrailer{et_}.runType;
150  }
151  // SAME in V301 and V302
152  uint8_t formatVer() const { return AMCheader2{amch2_}.formatVer; }
153 
154  uint8_t lv1Idt() const { return AMCTrailer{amct_}.l1AID; }
155  uint32_t crc() const { return AMCTrailer{amct_}.crc; }
156 
157  uint16_t ttsState() const { return EventHeader{eh_}.ttsState; }
158  uint8_t davCnt() const { return EventHeader{eh_}.davCnt; }
159  uint32_t buffState() const { return EventHeader{eh_}.buffState; }
160  uint32_t davList() const { return EventHeader{eh_}.davList; }
161 
162  uint8_t bc0locked() const { return EventTrailer{et_}.BCL; }
163  uint8_t daqReady() const { return EventTrailer{et_}.DR; }
164  uint8_t daqClockLocked() const { return EventTrailer{et_}.CL; }
165  uint8_t mmcmLocked() const { return EventTrailer{et_}.ML; }
166  uint8_t backPressure() const { return EventTrailer{et_}.BP; }
167  uint8_t oosGlib() const { return EventTrailer{et_}.oosGlib; }
168  uint32_t linkTo() const { return EventTrailer{et_}.linkTo; }
169 
170  // v302
171  uint16_t softSrcId() const { return AMCheader2{amch2_}.softSrcId; }
172  uint8_t softSlot() const { return AMCheader2{amch2_}.softSlot; }
173 
174  uint8_t l1aNF() const { return EventTrailer{et_}.L1aNF; }
175  uint8_t l1aF() const { return EventTrailer{et_}.L1aF; }
176 
178  void addGEB(GEMOptoHybrid g) { gebd_.push_back(g); }
180  const std::vector<GEMOptoHybrid>* gebs() const { return &gebd_; }
182  void clearGEBs() { gebd_.clear(); }
183 
184 private:
190 
191  std::vector<GEMOptoHybrid> gebd_;
192 };
193 #endif
uint64_t softSlot
Definition: GEMAMC.h:33
uint32_t buffState() const
Definition: GEMAMC.h:159
void setAMCheader1(uint64_t word)
Definition: GEMAMC.h:101
uint64_t amch2_
Definition: GEMAMC.h:186
uint64_t formatVer
Definition: GEMAMC.h:28
uint64_t getAMCheader1() const
Definition: GEMAMC.h:103
uint64_t ttsState
Definition: GEMAMC.h:51
void setAMCheader2(uint64_t word)
Definition: GEMAMC.h:105
uint64_t param2
Definition: GEMAMC.h:25
uint64_t getGEMeventHeader() const
Definition: GEMAMC.h:114
uint8_t bc0locked() const
Definition: GEMAMC.h:162
uint32_t crc() const
Definition: GEMAMC.h:155
~GEMAMC()
Definition: GEMAMC.h:97
uint32_t linkTo() const
Definition: GEMAMC.h:168
uint64_t BCL
Definition: GEMAMC.h:65
const std::vector< GEMOptoHybrid > * gebs() const
Returns a vector of GEB data.
Definition: GEMAMC.h:180
uint8_t mmcmLocked() const
Definition: GEMAMC.h:165
uint64_t pType
Definition: GEMAMC.h:52
uint16_t ttsState() const
Definition: GEMAMC.h:157
void setAMCTrailer(uint64_t word)
Definition: GEMAMC.h:109
uint64_t amct_
Definition: GEMAMC.h:187
uint64_t dataLength
Definition: GEMAMC.h:42
uint64_t crc
Definition: GEMAMC.h:45
uint64_t runType
Definition: GEMAMC.h:89
uint64_t runType
Definition: GEMAMC.h:27
uint64_t dataLength
Definition: GEMAMC.h:11
uint64_t getAMCheader2() const
Definition: GEMAMC.h:107
uint64_t l1AID
Definition: GEMAMC.h:44
uint64_t et_
Definition: GEMAMC.h:189
uint64_t MLv302
Definition: GEMAMC.h:84
uint64_t L1aF
Definition: GEMAMC.h:78
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
uint8_t daqClockLocked() const
Definition: GEMAMC.h:164
uint8_t amcNum() const
Definition: GEMAMC.h:123
uint64_t param1
Definition: GEMAMC.h:88
uint8_t param2() const
Definition: GEMAMC.h:136
uint64_t orbitNumV302
Definition: GEMAMC.h:34
uint64_t amch1_
Definition: GEMAMC.h:185
uint8_t oosGlib() const
Definition: GEMAMC.h:167
uint8_t lv1Idt() const
Definition: GEMAMC.h:154
uint32_t davList() const
Definition: GEMAMC.h:160
uint64_t getGEMeventTrailer() const
Definition: GEMAMC.h:117
uint64_t word
uint64_t reserved
Definition: GEMAMC.h:15
uint64_t oosGlib
Definition: GEMAMC.h:71
uint8_t backPressure() const
Definition: GEMAMC.h:166
uint64_t param2
Definition: GEMAMC.h:87
uint64_t softSrcId
Definition: GEMAMC.h:32
uint64_t orbitNum
Definition: GEMAMC.h:23
uint64_t linkToV302
Definition: GEMAMC.h:92
uint16_t softSrcId() const
Definition: GEMAMC.h:171
uint8_t softSlot() const
Definition: GEMAMC.h:172
uint64_t buffState
Definition: GEMAMC.h:57
int status()
uint64_t param1
Definition: GEMAMC.h:26
uint64_t param3
Definition: GEMAMC.h:24
uint64_t pVer
Definition: GEMAMC.h:55
void setGEMeventTrailer(uint64_t word)
Definition: GEMAMC.h:116
uint64_t eh_
Definition: GEMAMC.h:188
uint64_t linkTo
Definition: GEMAMC.h:73
uint32_t lv1Id() const
Definition: GEMAMC.h:122
uint64_t word
Definition: GEMAMC.h:62
uint8_t davCnt() const
Definition: GEMAMC.h:158
uint32_t orbitNumber() const
Definition: GEMAMC.h:126
uint64_t davList
Definition: GEMAMC.h:58
uint64_t param3
Definition: GEMAMC.h:86
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:191
uint32_t dataLength() const
Definition: GEMAMC.h:120
uint64_t BPv302
Definition: GEMAMC.h:85
uint64_t davCnt
Definition: GEMAMC.h:56
Definition: GEMAMC.h:6
void setGEMeventHeader(uint64_t word)
Definition: GEMAMC.h:112
uint8_t formatVer() const
Definition: GEMAMC.h:152
uint64_t word
Definition: GEMAMC.h:9
uint64_t word
Definition: GEMAMC.h:40
uint64_t CLv302
Definition: GEMAMC.h:83
uint8_t param3() const
Definition: GEMAMC.h:131
uint64_t word
Definition: GEMAMC.h:49
void addGEB(GEMOptoHybrid g)
Adds GEB data to vector.
Definition: GEMAMC.h:178
uint16_t boardId() const
Definition: GEMAMC.h:125
uint8_t l1aF() const
Definition: GEMAMC.h:175
uint16_t bunchCrossing() const
Definition: GEMAMC.h:121
uint64_t DRv302
Definition: GEMAMC.h:82
uint64_t L1aNF
Definition: GEMAMC.h:77
uint8_t runType() const
Definition: GEMAMC.h:146
uint8_t l1aNF() const
Definition: GEMAMC.h:174
uint64_t BCLv302
Definition: GEMAMC.h:80
void clearGEBs()
Clear a vector of GEB data.
Definition: GEMAMC.h:182
GEMAMC()
Definition: GEMAMC.h:96
uint64_t AMCnum
Definition: GEMAMC.h:14
uint64_t FVv302
Definition: GEMAMC.h:36
uint64_t boardID
Definition: GEMAMC.h:22
uint8_t param1() const
Definition: GEMAMC.h:141
uint64_t word
Definition: GEMAMC.h:19
uint8_t daqReady() const
Definition: GEMAMC.h:163
uint64_t getAMCTrailer() const
Definition: GEMAMC.h:110
uint64_t l1AID
Definition: GEMAMC.h:13