Project
Loading...
Searching...
No Matches
RawHeaderStream.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11#include <bitset>
12#include <fstream>
13#include <iostream>
15
16std::istream& o2::raw::operator>>(std::istream& stream, o2::header::RAWDataHeaderV4& header)
17{
18 // std::cout << "called, 10 words" << std::endl;
19 using wordtype = uint64_t;
20 constexpr int RAWHEADERWORDS = sizeof(header) / sizeof(wordtype);
21 wordtype message[RAWHEADERWORDS];
22 auto address = reinterpret_cast<char*>(message);
23 for (int i = 0; i < RAWHEADERWORDS; i++) {
24 stream.read(address + i * sizeof(wordtype) / sizeof(char), sizeof(message[i]));
25 // std::cout << "Word " << i << ": " << std::hex << message[i] << std::dec << std::endl;
26 }
27 header.word0 = message[0];
28 header.word1 = message[1];
29 header.word2 = message[2];
30 header.word3 = message[3];
31 header.word4 = message[4];
32 header.word5 = message[5];
33 header.word6 = message[6];
34 header.word7 = message[7];
35 return stream;
36}
37
38std::istream& o2::raw::operator>>(std::istream& stream, o2::header::RAWDataHeaderV5& header)
39{
40 // std::cout << "called, 10 words" << std::endl;
41 using wordtype = uint64_t;
42 constexpr int RAWHEADERWORDS = sizeof(header) / sizeof(wordtype);
43 wordtype message[RAWHEADERWORDS];
44 auto address = reinterpret_cast<char*>(message);
45 for (int i = 0; i < RAWHEADERWORDS; i++) {
46 stream.read(address + i * sizeof(wordtype) / sizeof(char), sizeof(message[i]));
47 // std::cout << "Word " << i << ": " << std::hex << message[i] << std::dec << std::endl;
48 }
49 header.word0 = message[0];
50 header.word1 = message[1];
51 header.word2 = message[2];
52 header.word3 = message[3];
53 header.word4 = message[4];
54 header.word5 = message[5];
55 header.word6 = message[6];
56 header.word7 = message[7];
57 return stream;
58}
59
60std::istream& o2::raw::operator>>(std::istream& stream, o2::header::RAWDataHeaderV6& header)
61{
62 // std::cout << "called, 10 words" << std::endl;
63 using wordtype = uint64_t;
64 constexpr int RAWHEADERWORDS = sizeof(header) / sizeof(wordtype);
65 wordtype message[RAWHEADERWORDS];
66 auto address = reinterpret_cast<char*>(message);
67 for (int i = 0; i < RAWHEADERWORDS; i++) {
68 stream.read(address + i * sizeof(wordtype) / sizeof(char), sizeof(message[i]));
69 // std::cout << "Word " << i << ": " << std::hex << message[i] << std::dec << std::endl;
70 }
71 header.word0 = message[0];
72 header.word1 = message[1];
73 header.word2 = message[2];
74 header.word3 = message[3];
75 header.word4 = message[4];
76 header.word5 = message[5];
77 header.word6 = message[6];
78 header.word7 = message[7];
79 return stream;
80}
81
82std::istream& o2::raw::operator>>(std::istream& stream, o2::header::RAWDataHeaderV7& header)
83{
84 // std::cout << "called, 10 words" << std::endl;
85 using wordtype = uint64_t;
86 constexpr int RAWHEADERWORDS = sizeof(header) / sizeof(wordtype);
87 wordtype message[RAWHEADERWORDS];
88 auto address = reinterpret_cast<char*>(message);
89 for (int i = 0; i < RAWHEADERWORDS; i++) {
90 stream.read(address + i * sizeof(wordtype) / sizeof(char), sizeof(message[i]));
91 // std::cout << "Word " << i << ": " << std::hex << message[i] << std::dec << std::endl;
92 }
93 header.word0 = message[0];
94 header.word1 = message[1];
95 header.word2 = message[2];
96 header.word3 = message[3];
97 header.word4 = message[4];
98 header.word5 = message[5];
99 header.word6 = message[6];
100 header.word7 = message[7];
101 return stream;
102}
103
104std::ostream& o2::raw::operator<<(std::ostream& stream, const o2::header::RAWDataHeaderV4& header)
105{
106 stream << "Raw data header V4:\n"
107 << " Word0 " << header.word0 << " (0x" << std::hex << header.word0 << std::dec << ")\n"
108 << " Version: " << header.version << "\n"
109 << " Header size: " << header.headerSize << "\n"
110 << " Block length: " << header.blockLength << "\n"
111 << " FEE ID: " << header.feeId << "\n"
112 << " Priority: " << header.priority << "\n"
113 << " Word1 " << header.word1 << " (0x" << std::hex << header.word1 << std::dec << ")\n"
114 << " Offset to next: " << header.offsetToNext << "\n"
115 << " Payload size (B):" << header.memorySize << "\n"
116 << " Packet counter: " << static_cast<int>(header.packetCounter) << "\n"
117 << " Link ID: " << static_cast<int>(header.linkID) << "\n"
118 << " Card ID: " << header.cruID << "\n"
119 << " Endpoint: " << static_cast<int>(header.endPointID) << "\n"
120 << " Word2 " << header.word2 << " (0x" << std::hex << header.word2 << std::dec << ")\n"
121 << " Trigger orbit: " << header.triggerOrbit << "\n"
122 << " Heartbeat orbit: " << header.heartbeatOrbit << "\n"
123 << " Word3 " << header.word3 << " (0x" << std::hex << header.word3 << std::dec << ")\n"
124 << " Word4 " << header.word4 << " (0x" << std::hex << header.word4 << std::dec << ")\n"
125 << " Trigger BC: " << header.triggerBC << "\n"
126 << " Heartbeat BC: " << header.heartbeatBC << "\n"
127 << " Trigger Type: " << header.triggerType << "\n"
128 << " Word5 " << header.word5 << " (0x" << std::hex << header.word5 << std::dec << ")\n"
129 << " Word6 " << header.word6 << " (0x" << std::hex << header.word6 << std::dec << ")\n"
130 << " Detector Field: " << header.detectorField << "\n"
131 << " PAR: " << header.par << "\n"
132 << " STOP: " << header.stop << "\n"
133 << " Page count: " << header.pageCnt << "\n"
134 << " Word7 " << header.word7 << " (0x" << std::hex << header.word7 << std::dec << ")\n"
135 << "End header\n";
136 return stream;
137}
138
139std::ostream& o2::raw::operator<<(std::ostream& stream, const o2::header::RAWDataHeaderV5& header)
140{
141 stream << "Raw data header V5:\n"
142 << " Word0 " << header.word0 << " (0x" << std::hex << header.word0 << std::dec << ")\n"
143 << " Version: " << header.version << "\n"
144 << " Header size: " << header.headerSize << "\n"
145 << " FEE ID: " << header.feeId << "\n"
146 << " Priority: " << header.priority << "\n"
147 << " Word1 " << header.word1 << " (0x" << std::hex << header.word1 << std::dec << ")\n"
148 << " Offset to next: " << header.offsetToNext << "\n"
149 << " Payload size (B):" << header.memorySize << "\n"
150 << " Packet counter: " << static_cast<int>(header.packetCounter) << "\n"
151 << " Link ID: " << static_cast<int>(header.linkID) << "\n"
152 << " Card ID: " << header.cruID << "\n"
153 << " Endpoint: " << static_cast<int>(header.endPointID) << "\n"
154 << " Word2 " << header.word2 << " (0x" << std::hex << header.word2 << std::dec << ")\n"
155 << " Bunch crossing: " << header.bunchCrossing << "\n"
156 << " Orbit: " << header.orbit << "\n"
157 << " Word3 " << header.word3 << " (0x" << std::hex << header.word3 << std::dec << ")\n"
158 << " Word4 " << header.word4 << " (0x" << std::hex << header.word4 << std::dec << ")\n"
159 << " Trigger Type: " << std::bitset<64>(header.triggerType) << "\n"
160 << " Page count: " << header.pageCnt << "\n"
161 << " Stop: " << (static_cast<bool>(header.stop) ? "yes" : "no") << "\n"
162 << " Word5 " << header.word5 << " (0x" << std::hex << header.word5 << std::dec << ")\n"
163 << " Word6 " << header.word6 << " (0x" << std::hex << header.word6 << std::dec << ")\n"
164 << " Detector Field: " << header.detectorField << "\n"
165 << " PAR: " << header.detectorPAR << "\n"
166 << " Word7 " << header.word7 << " (0x" << std::hex << header.word7 << std::dec << ")\n"
167 << "End header\n";
168 return stream;
169}
170
171std::ostream& o2::raw::operator<<(std::ostream& stream, const o2::header::RAWDataHeaderV6& header)
172{
173 stream << "Raw data header V6:\n"
174 << " Word0 " << header.word0 << " (0x" << std::hex << header.word0 << std::dec << ")\n"
175 << " Version: " << header.version << "\n"
176 << " Header size: " << header.headerSize << "\n"
177 << " Source ID: " << header.sourceID << "\n"
178 << " FEE ID: " << header.feeId << "\n"
179 << " Priority: " << header.priority << "\n"
180 << " Word1 " << header.word1 << " (0x" << std::hex << header.word1 << std::dec << ")\n"
181 << " Offset to next: " << header.offsetToNext << "\n"
182 << " Payload size (B):" << header.memorySize << "\n"
183 << " Packet counter: " << static_cast<int>(header.packetCounter) << "\n"
184 << " Link ID: " << static_cast<int>(header.linkID) << "\n"
185 << " Card ID: " << header.cruID << "\n"
186 << " Endpoint: " << static_cast<int>(header.endPointID) << "\n"
187 << " Word2 " << header.word2 << " (0x" << std::hex << header.word2 << std::dec << ")\n"
188 << " Bunch crossing: " << header.bunchCrossing << "\n"
189 << " Orbit: " << header.orbit << "\n"
190 << " Word3 " << header.word3 << " (0x" << std::hex << header.word3 << std::dec << ")\n"
191 << " Word4 " << header.word4 << " (0x" << std::hex << header.word4 << std::dec << ")\n"
192 << " Trigger Type: " << std::bitset<64>(header.triggerType) << "\n"
193 << " Page count: " << header.pageCnt << "\n"
194 << " Stop: " << (static_cast<bool>(header.stop) ? "yes" : "no") << "\n"
195 << " Word5 " << header.word5 << " (0x" << std::hex << header.word5 << std::dec << ")\n"
196 << " Word6 " << header.word6 << " (0x" << std::hex << header.word6 << std::dec << ")\n"
197 << " Detector Field: " << header.detectorField << "\n"
198 << " PAR: " << header.detectorPAR << "\n"
199 << " Word7 " << header.word7 << " (0x" << std::hex << header.word7 << std::dec << ")\n"
200 << "End header\n";
201 return stream;
202}
203
204std::ostream& o2::raw::operator<<(std::ostream& stream, const o2::header::RAWDataHeaderV7& header)
205{
206 stream << "Raw data header V7:\n"
207 << " Word0 " << header.word0 << " (0x" << std::hex << header.word0 << std::dec << ")\n"
208 << " Version: " << header.version << "\n"
209 << " Header size: " << header.headerSize << "\n"
210 << " Source ID: " << header.sourceID << "\n"
211 << " FEE ID: " << header.feeId << "\n"
212 << " Priority: " << header.priority << "\n"
213 << " Word1 " << header.word1 << " (0x" << std::hex << header.word1 << std::dec << ")\n"
214 << " Offset to next: " << header.offsetToNext << "\n"
215 << " Payload size (B):" << header.memorySize << "\n"
216 << " Packet counter: " << static_cast<int>(header.packetCounter) << "\n"
217 << " Link ID: " << static_cast<int>(header.linkID) << "\n"
218 << " Card ID: " << header.cruID << "\n"
219 << " Endpoint: " << static_cast<int>(header.endPointID) << "\n"
220 << " Word2 " << header.word2 << " (0x" << std::hex << header.word2 << std::dec << ")\n"
221 << " Bunch crossing: " << header.bunchCrossing << "\n"
222 << " Orbit: " << header.orbit << "\n"
223 << " Word3 " << header.word3 << " (0x" << std::hex << header.word3 << std::dec << ")\n"
224 << " Data format: " << header.dataFormat << "\n"
225 << " Word4 " << header.word4 << " (0x" << std::hex << header.word4 << std::dec << ")\n"
226 << " Trigger Type: " << std::bitset<64>(header.triggerType) << "\n"
227 << " Page count: " << header.pageCnt << "\n"
228 << " Stop: " << (static_cast<bool>(header.stop) ? "yes" : "no") << "\n"
229 << " Word5 " << header.word5 << " (0x" << std::hex << header.word5 << std::dec << ")\n"
230 << " Word6 " << header.word6 << " (0x" << std::hex << header.word6 << std::dec << ")\n"
231 << " Detector Field: " << header.detectorField << "\n"
232 << " PAR: " << header.detectorPAR << "\n"
233 << " Word7 " << header.word7 << " (0x" << std::hex << header.word7 << std::dec << ")\n"
234 << "End header\n";
235 return stream;
236}
int32_t i
Input stream operators for raw header 4 to 7 from binary file.
GLuint GLuint64EXT address
Definition glcorearb.h:5846
GLuint GLsizei const GLchar * message
Definition glcorearb.h:2517
GLuint GLuint stream
Definition glcorearb.h:1806
std::istream & operator>>(std::istream &stream, o2::header::RAWDataHeaderV4 &header)
std::ostream & operator<<(std::ostream &stream, const o2::header::RAWDataHeaderV4 &header)
uint8_t endPointID
bit 112 to 123: CRU ID
uint8_t linkID
bit 80 to 95: memory size
uint64_t stop
bit 48 to 63: par
uint64_t pageCnt
bit 0 to 7: stop code
uint64_t priority
bit 32 to 47: FEE identifier
uint64_t blockLength
bit 8 to 15: header size
uint16_t cruID
bit 104 to 111: packet counter
uint64_t triggerType
bit 60 to 63: zeroed
uint8_t packetCounter
bit 96 to 103: link id
uint64_t heartbeatBC
bit 44 to 47: zeroed
uint64_t headerSize
bit 0 to 7: header version
uint64_t feeId
bit 16 to 31: block length
uint32_t heartbeatOrbit
bit 0 to 31: trigger orbit
uint32_t memorySize
bit 64 to 79: offset to next packet in memory
uint64_t par
bit 32 to 47: detector field
uint64_t pageCnt
bit 0 to 31: trigger type
uint32_t endPointID
bit 112 to 123: CRU ID
uint64_t priority
bit 16 to 31: FEE identifier
uint32_t memorySize
bit 64 to 79: offset to next packet in memory
uint64_t stop
bit 32 to 47: pages counter
uint64_t detectorPAR
bit 0 to 31: detector field
uint32_t linkID
bit 80 to 95: memory size
uint32_t packetCounter
bit 96 to 103: link id
uint64_t feeId
bit 8 to 15: header size
uint64_t headerSize
bit 0 to 7: header version
uint32_t orbit
bit 12 to 31: reserved
uint16_t cruID
bit 104 to 111: packet counter
uint32_t endPointID
bit 112 to 123: CRU ID
uint32_t packetCounter
bit 96 to 103: link id
uint32_t orbit
bit 12 to 31: reserved
uint32_t linkID
bit 80 to 95: memory size
uint64_t stop
bit 32 to 47: pages counter
uint64_t sourceID
bit 32 to 39: priority bit
uint64_t feeId
bit 8 to 15: header size
uint64_t headerSize
bit 0 to 7: header version
uint64_t priority
bit 16 to 31: FEE identifier
uint64_t detectorPAR
bit 0 to 31: detector field
uint64_t pageCnt
bit 0 to 31: trigger type
uint32_t memorySize
bit 64 to 79: offset to next packet in memory
uint16_t cruID
bit 104 to 111: packet counter
uint32_t orbit
bit 12 to 31: reserved
uint32_t endPointID
bit 112 to 123: CRU ID
uint32_t packetCounter
bit 96 to 103: link id
uint64_t detectorPAR
bit 0 to 31: detector field
uint64_t sourceID
bit 32 to 39: priority bit
uint32_t linkID
bit 80 to 95: memory size
uint16_t cruID
bit 104 to 111: packet counter
uint64_t stop
bit 32 to 47: pages counter
uint32_t memorySize
bit 64 to 79: offset to next packet in memory
uint64_t headerSize
bit 0 to 7: header version
uint64_t priority
bit 16 to 31: FEE identifier
uint64_t feeId
bit 8 to 15: header size
uint64_t pageCnt
bit 0 to 31: trigger type