8#define DefaultEventBufferSize 1024*32
9#define EstimatedEventSize 1024*14
14 std::vector<int> vNevt;
17 VFileNames_t::const_iterator it = newfnames.begin();
18 while ( it != newfnames.end() ) {
19 if ( access( it->c_str(), F_OK ) < 0 ) {
20 std::cerr <<
"[RawFile] Invalid IDX file: " << *it << std::endl;
24 std::ifstream fs( it->c_str(), std::ios::binary );
26 fs.read( (
char*)(itmp),
sizeof(uint32_t)*2 );
28 std::cerr <<
"[RawFile] Wrong IdxFileStartMarker!" << std::endl;
31 vNevt.push_back(itmp[1]);
65 if ( newidxfnames.size() != newfnames.size() ) {
66 std::cerr <<
"[RawFile] Num(IdxFiles) != Num(DataFiles)" << std::endl;
81 if ( newidxfnames.size() != newfnames.size() ) {
82 std::cerr <<
"[RawFile] Num(IdxFiles) != Num(DataFiles)" << std::endl;
123 int nnIgnore = nIgnore;
126 if ( m_idxHandler != 0 ) {
127 int nleft = m_idxHandler->
nEvtLeft(nnIgnore);
129 m_rfs->seekg( m_idxHandler->
nextPos( nnIgnore ) );
138 while ( nnIgnore > 0 ) {
139 (*m_rfs) >> m_dataSeparatorRecord;
141 m_rfs->seekg( size + m_rfs->tellg() );
160 if ( m_idxHandler == 0 ) {
163 uint32_t curEvtId = m_buffer[ m_buffer[5] + 8 ];
164 if ( curEvtId == evtId ) {
192 assert( (evtByte&3) == 0 );
194 uint32_t prePos = m_rfs->tellg();
195 m_rfs->seekg( prePos + nIgnore*evtByte);
197 uint32_t halfEvtWord = evtByte / 8;
198 uint32_t halfEvtByte = halfEvtWord * 4;
200 while ( m_rfs->read((
char*)m_buffer, halfEvtByte).good() ) {
202 while ( i < halfEvtWord && m_buffer[i] != 0x1234cccc ) {
205 if ( i < halfEvtWord ) {
206 uint32_t curPos = m_rfs->tellg();
207 m_rfs->seekg( curPos - (halfEvtWord-i)*4 );
215 m_rfs->seekg( -40, std::ios::end );
216 uint32_t curPos = m_rfs->tellg();
218 int nnIgnore = nIgnore - (curPos - prePos) / evtByte;
219 if ( nnIgnore < 0 ) nnIgnore = 0;
226 return m_rfs->
runNo();
236 return m_rfs->tellg();
243 if ( m_rfs->eof() )
stat |= 1;
244 if ( m_rfs->fail() )
stat |= 2;
245 if ( m_rfs->bad() )
stat |= 4;
250const uint32_t* RawFileReader::notSafeNextEvent()
256 nextFile(e).notSafeNextEvent();
262void RawFileReader::read_one_event()
264 (*m_rfs) >> m_dataSeparatorRecord;
267 if ( size > m_bufferSize*4 ) {
268 while ( size > m_bufferSize*4 ) {
272 m_buffer =
new uint32_t[m_bufferSize];
275 m_rfs->read((
char*)m_buffer, size);
276 if ( ! m_rfs->good() ) {
289 if ( m_idxHandler != 0 ) {
#define DefaultEventBufferSize
#define EstimatedEventSize
std::vector< std::string > VFileNames_t
const data_separator_record & getRecord() const
static EvtIdxHandler * instance(const std::vector< std::string > &fnames)
uint32_t findPosById(uint32_t evtId)
static uint32_t IdxFileStartMarker()
int nEvtLeft(int nIgnore) const
uint32_t nextPos(int nIgnore)
virtual void print() const
const uint32_t * findEventById(uint32_t evtId)
const uint32_t * roughlyNextEvent(int nIgnore, int evtByte=0)
RawFileReader(const std::string &fname)
const uint32_t * nextEvent()
static std::vector< int > getEventNumber(const VFileNames_t &idxfnames)
std::string currentFile()
virtual void print() const
static raw_ifstream * instance(const std::vector< std::string > &fnames)
std::string currentFile() const