Project
Loading...
Searching...
No Matches
RawReaderMemory.h
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#ifndef ALICEO2_PHOS_RAWREADERMEMORY_H
12#define ALICEO2_PHOS_RAWREADERMEMORY_H
13
14#include <gsl/span>
15#include <Rtypes.h>
16
17#include "PHOSBase/RCUTrailer.h"
21#include "Headers/RDHAny.h"
22
23namespace o2
24{
25
26namespace phos
27{
28
37{
38 public:
40 RawReaderMemory(const gsl::span<const char> rawmemory);
41
43 ~RawReaderMemory() = default;
44
47 void setRawMemory(const gsl::span<const char> rawmemory);
48
52 void next();
53
62 void nextPage(bool resetPayload = true);
63
67 const o2::header::RDHAny& getRawHeader() const;
68
69 // /// \brief access to the raw buffer (single DMA page)
70 // /// \return Raw buffer of the current page
71 // /// \throw Error with PAYLOAD_INCALID if payload was not decoded
72 // const RawBuffer& getRawBuffer() const;
73
76 const RawPayload& getPayload() const { return mRawPayload; }
77
80 int getPayloadSize() const { return mRawPayload.getPayloadSize(); }
81
84 int getFileSize() const noexcept { return mRawMemoryBuffer.size(); }
85
88 int getNumberOfPages() const noexcept { return mNumData; }
89
92 bool hasNext() const { return mCurrentPosition < mRawMemoryBuffer.size(); }
93
94 protected:
98 void init();
99
100 o2::header::RDHAny decodeRawHeader(const void* headerwords);
101
102 private:
103 gsl::span<const char> mRawMemoryBuffer;
104 RawBuffer mRawBuffer;
105 o2::header::RDHAny mRawHeader;
106 RawPayload mRawPayload;
107 RCUTrailer mCurrentTrailer;
108 uint64_t mTrailerPayloadWords = 0;
109 uint32_t mCurrentPosition = 0;
110 int mNumData = 0;
111 bool mRawHeaderInitialized = false;
112 bool mPayloadInitialized = false;
113
114 ClassDefNV(RawReaderMemory, 1);
115};
116
117} // namespace phos
118
119} // namespace o2
120
121#endif
Definition of the RAW Data Header.
Information stored in the RCU trailer.
Definition RCUTrailer.h:56
Buffer for PHOS raw pages.
Definition RawBuffer.h:30
Class for raw payload excluding raw data headers from one or multiple DMA pages.
Definition RawPayload.h:37
int getPayloadSize() const
Get the size of the payload.
Definition RawPayload.h:78
Reader for raw data produced by the Readout application in in-memory format.
const o2::header::RDHAny & getRawHeader() const
access to the raw header of the current page
int getPayloadSize() const
Return size of the payload.
int getNumberOfPages() const noexcept
get the number of pages in the file
~RawReaderMemory()=default
Destructor.
void setRawMemory(const gsl::span< const char > rawmemory)
set new raw memory chunk
int getFileSize() const noexcept
get the size of the file in bytes
void init()
Initialize the raw stream.
void next()
Read next payload from the stream.
void nextPage(bool resetPayload=true)
Read the next page from the stream (single DMA page)
o2::header::RDHAny decodeRawHeader(const void *headerwords)
const RawPayload & getPayload() const
access to the full raw payload (single or multiple DMA pages)
bool hasNext() const
check if more pages are available in the raw file
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...