BOSS
7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
SimpleRawReader.cxx
Go to the documentation of this file.
1
#include "
RawFile/SimpleRawReader.h
"
2
#include "
RawFile/RawFileUtil.h
"
3
#include "
IRawFile/RawFileExceptions.h
"
4
5
#define DefaultEventBufferSize 1024*32
6
7
static
DataSeparatorRecord
_dataSeparatorRecord;
8
9
SimpleRawReader::SimpleRawReader
(
const
std::string& fname)
10
: m_bufferSize(
DefaultEventBufferSize
),
11
m_buffer( new uint32_t[
DefaultEventBufferSize
] )
12
{
13
m_rfs =
new
raw_ifstream
(std::vector<std::string>(1, fname));
14
}
15
16
SimpleRawReader::~SimpleRawReader
()
17
{
18
delete
[] m_buffer;
19
m_rfs->close();
20
delete
m_rfs;
21
}
22
23
const
uint32_t*
SimpleRawReader::nextEvent
()
24
{
25
(*m_rfs) >> _dataSeparatorRecord;
26
27
uint32_t size = _dataSeparatorRecord.
getRecord
().
data_block_size
;
28
if
( size > m_bufferSize*4 ) {
29
while
( size > m_bufferSize*4 ) {
30
m_bufferSize *= 2;
31
}
32
delete
[] m_buffer;
33
m_buffer =
new
uint32_t[m_bufferSize];
34
}
35
36
m_rfs->read((
char
*)m_buffer, size);
37
if
( ! m_rfs->good() ) {
38
//std::cerr << "[RawFile] Failed to read FullEventFragment to buffer" << std::endl;
39
throw
BadInputStream
(
"event_data_block"
);
40
}
41
42
return
m_buffer;
43
}
RawFileExceptions.h
RawFileUtil.h
DefaultEventBufferSize
#define DefaultEventBufferSize
Definition
SimpleRawReader.cxx:5
SimpleRawReader.h
BadInputStream
Definition
RawFileExceptions.h:36
DataSeparatorRecord
Definition
RawFileUtil.h:125
DataSeparatorRecord::getRecord
const data_separator_record & getRecord() const
Definition
RawFileUtil.h:132
SimpleRawReader::~SimpleRawReader
virtual ~SimpleRawReader()
Definition
SimpleRawReader.cxx:16
SimpleRawReader::nextEvent
const uint32_t * nextEvent()
Definition
SimpleRawReader.cxx:23
SimpleRawReader::SimpleRawReader
SimpleRawReader(const std::string &fname)
Definition
SimpleRawReader.cxx:9
raw_ifstream
Definition
raw_ifstream.h:14
data_separator_record::data_block_size
uint32_t data_block_size
Definition
RawFileUtil.h:122
7.1.1
Event
RawFile
RawFile-00-01-00
src
SimpleRawReader.cxx
Generated by
1.12.0