Project
Loading...
Searching...
No Matches
RawBuffer.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>
13
#include <cstring>
14
#include <fairlogger/Logger.h>
15
#include "
PHOSReconstruction/RawBuffer.h
"
16
17
using namespace
o2::phos
;
18
19
void
RawBuffer::flush
()
20
{
21
mCurrentDataWord = 0;
22
mNDataWords = 0;
23
memset(mDataWords.data(), 0,
sizeof
(uint32_t) * mDataWords.size());
24
}
25
26
void
RawBuffer::readFromStream
(std::istream& in, uint32_t payloadsize)
27
{
28
flush
();
29
uint32_t word(0);
30
auto
address
=
reinterpret_cast<
char
*
>
(&word);
31
uint32_t nbyte = 0;
32
while
(nbyte < payloadsize) {
33
in.read(
address
,
sizeof
(word));
34
nbyte +=
sizeof
(word);
35
if
((word & 0xFFFFFF) == 0x1d3082) {
36
LOG
(error) <<
"Found stop word"
<< std::endl;
37
// Termination word
38
// should normally not be decoded in case the payload size
39
// is determined correctly
40
break
;
41
}
42
mDataWords[mNDataWords++] = word;
43
}
44
}
45
46
void
RawBuffer::readFromMemoryBuffer
(
const
gsl::span<const char> rawmemory)
47
{
48
flush
();
49
auto
address
=
reinterpret_cast<
const
uint32_t*
>
(rawmemory.data());
50
for
(
unsigned
int
iword = 0; iword < static_cast<uint32_t>(rawmemory.size() /
sizeof
(uint32_t)); iword++) {
51
// Run2 code, probably not needed for run3
52
// if ((address[iword] & 0xFFF) == 0x082) {
53
// Termination word
54
// should normally not be decoded in case the payload size
55
// is determined correctly
56
// std::cout << "Found termination word" << std::endl;
57
// break;
58
// }
59
mDataWords[mNDataWords++] =
address
[iword];
60
}
61
}
RawBuffer.h
o2::phos::RawBuffer::readFromMemoryBuffer
void readFromMemoryBuffer(const gsl::span< const char > rawmemory)
Read page from raw memory buffer.
Definition
RawBuffer.cxx:46
o2::phos::RawBuffer::readFromStream
void readFromStream(std::istream &in, uint32_t payloadsize)
Read page from stream.
Definition
RawBuffer.cxx:26
o2::phos::RawBuffer::flush
void flush()
Flush the buffer Does not overwrite the word buffer but just resets the counter and iterator.
Definition
RawBuffer.cxx:19
address
GLuint GLuint64EXT address
Definition
glcorearb.h:5846
o2::phos
Definition
SimTraits.h:135
LOG
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
Detectors
PHOS
reconstruction
src
RawBuffer.cxx
Generated on Tue Feb 25 2025 23:16:25 for Project by
1.9.8