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