CMS 3D CMS Logo

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