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 <fstream>
12#include <iostream>
14
15std::istream& o2::phos::operator>>(std::istream& stream, o2::header::RAWDataHeaderV4& header)
16{
17 //std::cout << "called, 10 words" << std::endl;
18 using wordtype = uint64_t;
19 constexpr int RAWHEADERWORDS = sizeof(header) / sizeof(wordtype);
20 wordtype message[RAWHEADERWORDS];
21 auto address = reinterpret_cast<char*>(message);
22 for (int i = 0; i < RAWHEADERWORDS; i++) {
23 stream.read(address + i * sizeof(wordtype) / sizeof(char), sizeof(message[i]));
24 //std::cout << "Word " << i << ": " << std::hex << message[i] << std::dec << std::endl;
25 }
26 header.word0 = message[0];
27 header.word1 = message[1];
28 header.word2 = message[2];
29 header.word3 = message[3];
30 header.word4 = message[4];
31 header.word5 = message[5];
32 header.word6 = message[6];
33 header.word7 = message[7];
34 return stream;
35}
36
37std::istream& o2::phos::operator>>(std::istream& stream, o2::header::RAWDataHeaderV5& header)
38{
39 //std::cout << "called, 10 words" << std::endl;
40 using wordtype = uint64_t;
41 constexpr int RAWHEADERWORDS = sizeof(header) / sizeof(wordtype);
42 wordtype message[RAWHEADERWORDS];
43 auto address = reinterpret_cast<char*>(message);
44 for (int i = 0; i < RAWHEADERWORDS; i++) {
45 stream.read(address + i * sizeof(wordtype) / sizeof(char), sizeof(message[i]));
46 //std::cout << "Word " << i << ": " << std::hex << message[i] << std::dec << std::endl;
47 }
48 header.word0 = message[0];
49 header.word1 = message[1];
50 header.word2 = message[2];
51 header.word3 = message[3];
52 header.word4 = message[4];
53 header.word5 = message[5];
54 header.word6 = message[6];
55 header.word7 = message[7];
56 return stream;
57}
58
59std::ostream& o2::phos::operator<<(std::ostream& stream, const o2::header::RAWDataHeaderV4& header)
60{
61 stream << "Raw data header V4:\n"
62 << " Word0 " << header.word0 << " (0x" << std::hex << header.word0 << std::dec << ")\n"
63 << " Version: " << header.version << "\n"
64 << " Header size: " << header.headerSize << "\n"
65 << " Block length: " << header.blockLength << "\n"
66 << " FEE ID: " << header.feeId << "\n"
67 << " Priority: " << header.priority << "\n"
68 << " Word1 " << header.word1 << " (0x" << std::hex << header.word1 << std::dec << ")\n"
69 << " Offset to next: " << header.offsetToNext << "\n"
70 << " Payload size (B):" << header.memorySize << "\n"
71 << " Packet counter: " << static_cast<int>(header.packetCounter) << "\n"
72 << " Link ID: " << static_cast<int>(header.linkID) << "\n"
73 << " Card ID: " << header.cruID << "\n"
74 << " Endpoint: " << static_cast<int>(header.endPointID) << "\n"
75 << " Word2 " << header.word2 << " (0x" << std::hex << header.word2 << std::dec << ")\n"
76 << " Trigger orbit: " << header.triggerOrbit << "\n"
77 << " Heartbeat orbit: " << header.heartbeatOrbit << "\n"
78 << " Word3 " << header.word3 << " (0x" << std::hex << header.word3 << std::dec << ")\n"
79 << " Word4 " << header.word4 << " (0x" << std::hex << header.word4 << std::dec << ")\n"
80 << " Trigger BC: " << header.triggerBC << "\n"
81 << " Heartbeat BC: " << header.heartbeatBC << "\n"
82 << " Trigger Type: " << header.triggerType << "\n"
83 << " Word5 " << header.word5 << " (0x" << std::hex << header.word5 << std::dec << ")\n"
84 << " Word6 " << header.word6 << " (0x" << std::hex << header.word6 << std::dec << ")\n"
85 << " Detector Field: " << header.detectorField << "\n"
86 << " PAR: " << header.par << "\n"
87 << " STOP: " << header.stop << "\n"
88 << " Page count: " << header.pageCnt << "\n"
89 << " Word7 " << header.word7 << " (0x" << std::hex << header.word7 << std::dec << ")\n"
90 << "End header\n";
91 return stream;
92}
93
94std::ostream& o2::phos::operator<<(std::ostream& stream, const o2::header::RAWDataHeaderV5& header)
95{
96 stream << "Raw data header V5:\n"
97 << " Word0 " << header.word0 << " (0x" << std::hex << header.word0 << std::dec << ")\n"
98 << " Word1 " << header.word1 << " (0x" << std::hex << header.word1 << std::dec << ")\n"
99 << " Word2 " << header.word2 << " (0x" << std::hex << header.word2 << std::dec << ")\n"
100 << " Word3 " << header.word3 << " (0x" << std::hex << header.word3 << std::dec << ")\n"
101 << " Word4 " << header.word4 << " (0x" << std::hex << header.word4 << std::dec << ")\n"
102 << " Word5 " << header.word5 << " (0x" << std::hex << header.word5 << std::dec << ")\n"
103 << " Word6 " << header.word6 << " (0x" << std::hex << header.word6 << std::dec << ")\n"
104 << " Word7 " << header.word7 << " (0x" << std::hex << header.word7 << std::dec << ")\n"
105 << "End header\n";
106 return stream;
107}
int32_t i
Input stream operators for raw header 4 and 5 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::ostream & operator<<(std::ostream &in, const BadChannelsMap &bcm)
Printing bad channel map on the stream.
std::istream & operator>>(std::istream &stream, 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