4#include "KVProtobufDataReader.h"
6#include <google/protobuf/io/coded_stream.h>
10#define KV_PROTOBUF_MSG_SIZE 4
55 google::protobuf::io::CodedInputStream codedIStream((
const uint8_t*)(
fBuffer +
fEvOffset), KV_PROTOBUF_MSG_SIZE);
56 codedIStream.ReadLittleEndian32(&
fEvSize);
58 Error(
"GetNextEvent",
"read zero size event");
95 ptrdiff_t fFillOffset = 0;
107 fFile->ReadBuffer((
char*)(
fBuffer + fFillOffset), bytes_to_read);
114 return (bytes_read > 0);
124 fp.
Append(
"?filetype=raw");
125#if ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0)
126 fFile.reset(TFile::Open(fp));
129 fFile = TFile::Open(fp);
132 Info(
"open_file",
"%s : size of file = %lld bytes", filepath,
fFileSize);
148 fBufSize(bufSiz),
fBuffer(new char[bufSiz]), fFile(nullptr), fEvSize(0), fEvOffset(0), fNeedToReadBuffer(true),
149 fReachedEndOfFile(false)
166 fBufSize(bufSiz),
fBuffer(new char[bufSiz]), fFile(nullptr), fFileSize(0), fEvSize(0), fEvOffset(0), fNeedToReadBuffer(true),
167 fReachedEndOfFile(false)
181#if ROOT_VERSION_CODE < ROOT_VERSION(6,0,0)
Read Google Protobuf DAQ files.
void open_file(const Char_t *filepath)
UInt_t fEvSize
size of next event in buffer
virtual bool read_buffer()
read a buffer from the file
UInt_t get_remaining_readable_buffer() const
Int_t fBufSize
buffer size
bool fReachedEndOfFile
true when we have read all bytes from file
KVProtobufDataReader(Int_t bufSiz=16 *1024 *1024)
Create file reader of given buffer size, do not open any files yet.
Int_t GetRunNumberReadFromFile() const
Long64_t fFileSize
size of file in bytes
bool fNeedToReadBuffer
true when the buffer is empty/incomplete
char * fBuffer
current buffer
ptrdiff_t fEvOffset
next position to read in buffer
virtual ~KVProtobufDataReader()
Destructor.
std::unique_ptr< TFile > fFile
TFile plugin handle.
virtual bool parse_event_from_message()=0
Abstract base class for reading raw (DAQ) data.
virtual void Error(const char *method, const char *msgfmt,...) const
virtual void Info(const char *method, const char *msgfmt,...) const
TString & Append(char c, Ssiz_t rep=1)