CMS 3D CMS Logo

UCTDAQRawData.h
Go to the documentation of this file.
1 #ifndef UCTDAQRawData_hh
2 #define UCTDAQRawData_hh
3 
4 #include <cstdint>
5 #include <iostream>
6 #include <iomanip>
7 
10 
12 public:
14  if (d != nullptr) {
15  if ((d[0] & 0x5000000000000000) != 0x5000000000000000) {
16  edm::LogError("UCTDAQRawData") << "CDF Header does not seem to be correct" << std::showbase << std::internal
17  << std::setfill('0') << std::setw(10) << std::hex << d[0] << "; but continuing!"
18  << std::endl;
19  }
20  }
21  }
22 
23  // No copy constructor and equality operator are needed
24  UCTDAQRawData(const UCTDAQRawData &) = delete;
25  const UCTDAQRawData &operator=(const UCTDAQRawData &i) = delete;
26 
27  virtual ~UCTDAQRawData() { ; }
28 
29  // Access functions for convenience
30 
31  const uint64_t *dataPtr() const { return myDataPtr; }
32 
33  const uint64_t *cdfHeader() const { return &myDataPtr[0]; }
34 
35  uint32_t FOV() { return ((myDataPtr[0] & 0x00000000000000F0) >> 4); }
36  uint32_t sourceID() { return ((myDataPtr[0] & 0x00000000000FFF00) >> 8); }
37  uint32_t BXID() { return ((myDataPtr[0] & 0x00000000FFF00000) >> 20); }
38  uint32_t L1ID() { return ((myDataPtr[0] & 0x00FFFFFF00000000) >> 32); }
39  uint32_t eventType() { return ((myDataPtr[0] & 0x0F00000000000000) >> 56); }
40  uint32_t orbitNumber() { return ((myDataPtr[1] & 0x0000000FFFFFFFF0) >> 4); }
41  uint32_t nAMCs() { return ((myDataPtr[1] & 0x00F0000000000000) >> 52); }
42  uint32_t uFOV() { return ((myDataPtr[1] & 0xF000000000000000) >> 60); }
43 
44  uint32_t boardID(uint32_t amc = 0) {
45  if (amc < nAMCs()) {
46  return myDataPtr[2 + amc] & 0x000000000000FFFF;
47  }
48  edm::LogError("UCTDAQRawData") << "UCTDAQRawData: Failed to fetch board ID for AMC = " << amc
49  << "; Max AMC = " << nAMCs() << std::endl;
50  return 0xDEADBEEF;
51  }
52 
53  uint32_t amcNo(uint32_t amc = 0) {
54  if (amc < nAMCs()) {
55  return ((myDataPtr[2 + amc] & 0x00000000000F0000) >> 16);
56  }
57  edm::LogError("UCTDAQRawData") << "UCTDAQRawData: Failed to fetch amc no for AMC = " << amc
58  << "; Max AMC = " << nAMCs() << std::endl;
59  return 0xDEADBEEF;
60  }
61 
62  uint32_t amcBlkNo(uint32_t amc = 0) {
63  if (amc < nAMCs()) {
64  return ((myDataPtr[2 + amc] & 0x000000000FF00000) >> 20);
65  }
66  edm::LogError("UCTDAQRawData") << "UCTDAQRawData: Failed to fetch amc block no for AMC = " << amc
67  << "; Max AMC = " << nAMCs() << std::endl;
68  return 0xDEADBEEF;
69  }
70 
71  uint32_t amcSize(uint32_t amc = 0) {
72  if (amc < nAMCs()) {
73  return ((myDataPtr[2 + amc] & 0x00FFFFFF00000000) >> 32);
74  }
75  edm::LogError("UCTDAQRawData") << "UCTDAQRawData: Failed to fetch amc size for AMC = " << amc
76  << "; Max AMC = " << nAMCs() << std::endl;
77  return 0xDEADBEEF;
78  }
79 
80  bool crcError(uint32_t amc = 0) {
81  if (amc < nAMCs()) {
82  return ((myDataPtr[2 + amc] & 0x0100000000000000) != 0);
83  }
84  edm::LogError("UCTDAQRawData") << "UCTDAQRawData: Failed to fetch crcError-bit for AMC = " << amc
85  << "; Max AMC = " << nAMCs() << std::endl;
86  return false;
87  }
88 
89  bool isValid(uint32_t amc = 0) {
90  if (amc < nAMCs()) {
91  return ((myDataPtr[2 + amc] & 0x0200000000000000) != 0);
92  }
93  edm::LogError("UCTDAQRawData") << "UCTDAQRawData: Failed to fetch isValid-bit for AMC = " << amc
94  << "; Max AMC = " << nAMCs() << std::endl;
95  return false;
96  }
97 
98  bool isPresent(uint32_t amc = 0) {
99  if (amc < nAMCs()) {
100  return ((myDataPtr[2 + amc] & 0x0400000000000000) != 0);
101  }
102  edm::LogError("UCTDAQRawData") << "UCTDAQRawData: Failed to fetch isPresent-bit for AMC = " << amc
103  << "; Max AMC = " << nAMCs() << std::endl;
104  return false;
105  }
106 
107  bool isEnabled(uint32_t amc = 0) {
108  if (amc < nAMCs()) {
109  return ((myDataPtr[2 + amc] & 0x0800000000000000) != 0);
110  }
111  edm::LogError("UCTDAQRawData") << "UCTDAQRawData: Failed to fetch isEnabled-bit for AMC = " << amc
112  << "; Max AMC = " << nAMCs() << std::endl;
113  return false;
114  }
115 
116  bool isSegmented(uint32_t amc = 0) {
117  if (amc < nAMCs()) {
118  return ((myDataPtr[2 + amc] & 0x1000000000000000) != 0);
119  }
120  edm::LogError("UCTDAQRawData") << "UCTDAQRawData: Failed to fetch isSegmented-bit for AMC = " << amc
121  << "; Max AMC = " << nAMCs() << std::endl;
122  return false;
123  }
124 
125  bool more(uint32_t amc = 0) {
126  if (amc < nAMCs()) {
127  return ((myDataPtr[2 + amc] & 0x2000000000000000) != 0);
128  }
129  edm::LogError("UCTDAQRawData") << "UCTDAQRawData: Failed to fetch more-bit for AMC = " << amc
130  << "; Max AMC = " << nAMCs() << std::endl;
131  return false;
132  }
133 
134  bool lengthError(uint32_t amc = 0) {
135  if (amc < nAMCs()) {
136  return ((myDataPtr[2 + amc] & 0x4000000000000000) != 0);
137  }
138  edm::LogError("UCTDAQRawData") << "UCTDAQRawData: Failed to fetch length error bit for AMC = " << amc
139  << "; Max AMC = " << nAMCs() << std::endl;
140  return false;
141  }
142 
143  const uint32_t *amcPayload(uint32_t amc) {
144  if (amc < nAMCs()) {
145  // Number of 64-bit words to skip
146  uint32_t skip = 2 + nAMCs();
147  for (uint32_t i = 0; i < amc; i++) {
148  skip += amcSize(i);
149  }
150  return (uint32_t *)&myDataPtr[skip];
151  }
152  edm::LogError("UCTDAQRawData") << "UCTDAQRawData: Failed to fetch payload location for AMC = " << amc
153  << "; Max AMC = " << nAMCs() << std::endl;
154  return nullptr;
155  }
156 
158  uint32_t skip = 2;
159  for (uint32_t i = 0; i < nAMCs(); i++) {
160  skip += (1 + amcSize(i));
161  }
162  return &myDataPtr[skip];
163  }
164 
165  uint32_t amc13BXID() {
166  const uint64_t *data = amc13TrailerPtr();
167  return (data[0] & 0x0000000000000FFF);
168  }
169 
170  uint32_t amc13L1ID() {
171  const uint64_t *data = amc13TrailerPtr();
172  return ((data[0] & 0x00000000000FF000) >> 12);
173  }
174 
175  uint32_t amc13BlockNo() {
176  const uint64_t *data = amc13TrailerPtr();
177  return ((data[0] & 0x000000000FF00000) >> 20);
178  }
179 
180  uint32_t amc13CRC32() {
181  const uint64_t *data = amc13TrailerPtr();
182  return ((data[0] & 0xFFFFFFFF00000000) >> 32);
183  }
184 
186  uint32_t skip = 2;
187  for (uint32_t i = 0; i < nAMCs(); i++) {
188  skip += (1 + amcSize(i));
189  }
190  skip++;
191  const uint64_t *data = &myDataPtr[skip];
192  if ((data[0] & 0xF000000000000000) != 0xA000000000000000) {
193  edm::LogError("UCTDAQRawData") << "CDF Trailer seems to be wrong : " << std::showbase << std::internal
194  << std::setfill('0') << std::setw(10) << std::hex << data[1] << std::endl;
195  }
196  return data;
197  }
198 
199  bool crcModified() {
200  const uint64_t *data = cdfTrailerPtr();
201  return ((data[0] & 0x0000000000000004) != 0);
202  }
203 
205  const uint64_t *data = cdfTrailerPtr();
206  return ((data[0] & 0x0000000000000008) != 0);
207  }
208 
209  uint32_t ttsBits() {
210  const uint64_t *data = cdfTrailerPtr();
211  return ((data[0] & 0x00000000000000F0) >> 4);
212  }
213 
214  uint32_t eventStatus() {
215  const uint64_t *data = cdfTrailerPtr();
216  return ((data[0] & 0x0000000000000F00) >> 8);
217  }
218 
219  bool isWrongFEDID() {
220  const uint64_t *data = cdfTrailerPtr();
221  return ((data[0] & 0x0000000000004000) != 0);
222  }
223 
225  const uint64_t *data = cdfTrailerPtr();
226  return ((data[0] & 0x0000000000008000) != 0);
227  }
228 
229  uint32_t crc16() {
230  const uint64_t *data = cdfTrailerPtr();
231  return ((data[0] & 0x00000000FFFF0000) >> 16);
232  }
233 
234  uint32_t eventLength() {
235  const uint64_t *data = cdfTrailerPtr();
236  return ((data[0] & 0x00FFFFFF00000000) >> 32);
237  }
238 
239  void print() {
240  using namespace std;
241  LogDebug("UCTDAQRawData") << "Common cDAQ/AMC13 Data Header:" << endl;
242  LogDebug("UCTDAQRawData") << "Framework Version = " << internal << setfill('0') << setw(3) << hex << FOV() << endl;
243  LogDebug("UCTDAQRawData") << "sourceID......... = " << dec << sourceID() << endl;
244  LogDebug("UCTDAQRawData") << "BXID............. = " << dec << BXID() << endl;
245  LogDebug("UCTDAQRawData") << "L1ID............. = " << internal << setfill('0') << setw(8) << hex << L1ID() << endl;
246  LogDebug("UCTDAQRawData") << "eventType........ = " << internal << setfill('0') << setw(3) << hex << eventType()
247  << endl;
248  LogDebug("UCTDAQRawData") << "orbitNo.......... = " << dec << orbitNumber() << endl;
249  LogDebug("UCTDAQRawData") << "uFOV............. = " << internal << setfill('0') << setw(8) << hex << uFOV() << endl;
250  LogDebug("UCTDAQRawData") << "# of CTP7s....... = " << dec << nAMCs() << endl;
251  LogDebug("UCTDAQRawData")
252  << "Phi SlotNo BlockNo Size CRC? Valid? Present? Enabled? Segmented? More? LengthError?" << endl;
253  for (uint32_t i = 0; i < nAMCs(); i++) {
254  LogDebug("UCTDAQRawData") << dec << setfill(' ') << setw(3) << boardID(i) << " " << dec << setfill(' ') << setw(6)
255  << amcNo(i) << " " << dec << setfill(' ') << setw(7) << amcBlkNo(i) << " " << dec
256  << setfill(' ') << setw(8) << amcSize(i) << " "
257  << " " << crcError(i) << " "
258  << " " << isValid(i) << " "
259  << " " << isPresent(i) << " "
260  << " " << isEnabled(i) << " "
261  << " " << isSegmented(i) << " "
262  << " " << more(i) << " "
263  << " " << lengthError(i) << endl;
264  }
265  LogDebug("UCTDAQRawData") << "AMC13 Trailer:" << endl;
266  LogDebug("UCTDAQRawData") << "AMC13 BXID....... = " << dec << amc13BXID() << endl;
267  LogDebug("UCTDAQRawData") << "AMC13 L1ID....... = " << dec << amc13L1ID() << endl;
268  LogDebug("UCTDAQRawData") << "AMC13 BlockNo.... = " << dec << amc13BlockNo() << endl;
269  LogDebug("UCTDAQRawData") << "AMC13 CRC32...... = " << internal << setfill('0') << setw(10) << hex << amc13BXID()
270  << endl;
271  LogDebug("UCTDAQRawData") << "Common DAQ Trailer:" << endl;
272  LogDebug("UCTDAQRawData") << "CRC Modified?.... = " << crcModified() << endl;
273  LogDebug("UCTDAQRawData") << "Last Trailer Word?= " << isLastTrailerWord() << endl;
274  LogDebug("UCTDAQRawData") << "ttsBits.......... = " << internal << setfill('0') << setw(3) << hex << ttsBits()
275  << endl;
276  LogDebug("UCTDAQRawData") << "Event Status..... = " << internal << setfill('0') << setw(3) << hex << eventStatus()
277  << endl;
278  LogDebug("UCTDAQRawData") << "Wrong FED ID?.... = " << isWrongFEDID() << endl;
279  LogDebug("UCTDAQRawData") << "SLink Error?..... = " << isSLinkErrorDetectedByFRL() << endl;
280  LogDebug("UCTDAQRawData") << "CRC 16........... = " << internal << setfill('0') << setw(6) << hex << crc16()
281  << endl;
282  LogDebug("UCTDAQRawData") << "Event Length..... = " << dec << eventLength() << endl;
283  }
284 
285 private:
286  // RawData data
287 
289 };
290 
291 #endif
uint32_t sourceID()
Definition: UCTDAQRawData.h:36
uint32_t amc13BlockNo()
uint32_t eventType()
Definition: UCTDAQRawData.h:39
UCTDAQRawData(const uint64_t *d)
Definition: UCTDAQRawData.h:13
const uint64_t * cdfHeader() const
Definition: UCTDAQRawData.h:33
uint32_t BXID()
Definition: UCTDAQRawData.h:37
bool isPresent(uint32_t amc=0)
Definition: UCTDAQRawData.h:98
uint32_t amc13L1ID()
const uint64_t * myDataPtr
bool crcError(uint32_t amc=0)
Definition: UCTDAQRawData.h:80
uint32_t eventStatus()
const uint64_t * cdfTrailerPtr()
const uint64_t * amc13TrailerPtr()
Log< level::Error, false > LogError
uint32_t L1ID()
Definition: UCTDAQRawData.h:38
uint32_t boardID(uint32_t amc=0)
Definition: UCTDAQRawData.h:44
bool isEnabled(uint32_t amc=0)
const UCTDAQRawData & operator=(const UCTDAQRawData &i)=delete
double amc
Definition: hdecay.h:20
bool isLastTrailerWord()
uint32_t amcSize(uint32_t amc=0)
Definition: UCTDAQRawData.h:71
bool isSegmented(uint32_t amc=0)
virtual ~UCTDAQRawData()
Definition: UCTDAQRawData.h:27
const uint64_t * dataPtr() const
Definition: UCTDAQRawData.h:31
uint32_t amcBlkNo(uint32_t amc=0)
Definition: UCTDAQRawData.h:62
d
Definition: ztail.py:151
uint32_t nAMCs()
Definition: UCTDAQRawData.h:41
uint32_t amc13BXID()
const uint32_t * amcPayload(uint32_t amc)
unsigned long long uint64_t
Definition: Time.h:13
uint32_t amc13CRC32()
bool isSLinkErrorDetectedByFRL()
bool lengthError(uint32_t amc=0)
bool isWrongFEDID()
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
uint32_t amcNo(uint32_t amc=0)
Definition: UCTDAQRawData.h:53
uint32_t uFOV()
Definition: UCTDAQRawData.h:42
uint32_t FOV()
Definition: UCTDAQRawData.h:35
uint32_t orbitNumber()
Definition: UCTDAQRawData.h:40
Definition: AMCSpec.h:8
bool crcModified()
uint32_t eventLength()
bool isValid(uint32_t amc=0)
Definition: UCTDAQRawData.h:89
bool more(uint32_t amc=0)
uint32_t crc16()
#define LogDebug(id)
uint32_t ttsBits()