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