BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
SimpleRawReader.cxx
Go to the documentation of this file.
4
5#define DefaultEventBufferSize 1024*32
6
7static DataSeparatorRecord _dataSeparatorRecord;
8
9SimpleRawReader::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
17{
18 delete[] m_buffer;
19 m_rfs->close();
20 delete m_rfs;
21}
22
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}
#define DefaultEventBufferSize
const data_separator_record & getRecord() const
Definition: RawFileUtil.h:132
virtual ~SimpleRawReader()
const uint32_t * nextEvent()
SimpleRawReader(const std::string &fname)