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]);
47 for (
int i = 0; i < newfnames.size (); ++i ) {
48 int size = newfnames[i].size();
49 if ( size > 4 && newfnames[i].substr(size-4) ==
".idx" ) {
50 datafnames.push_back(newfnames[i].substr(0, size-4));
53 if ( datafnames.size() == newfnames.size() ) {
71 for (
int i = 0; i < newfnames.size (); ++i ) {
72 int size = newfnames[i].size();
73 if ( size > 4 && newfnames[i].substr(size-4) ==
".idx" ) {
74 datafnames.push_back(newfnames[i].substr(0, size-4));
77 if ( datafnames.size() == newfnames.size() ) {
93 if ( newidxfnames.size() != newfnames.size() ) {
94 std::cerr <<
"[RawFile] Num(IdxFiles) != Num(DataFiles)" << std::endl;
109 if ( newidxfnames.size() != newfnames.size() ) {
110 std::cerr <<
"[RawFile] Num(IdxFiles) != Num(DataFiles)" << std::endl;
131 if ( m_idxHandler == 0 ) {
156 int nnIgnore = nIgnore;
159 if ( m_idxHandler != 0 ) {
160 int nleft = m_idxHandler->
nEvtLeft(nnIgnore);
162 m_rfs->seekg( m_idxHandler->
nextPos( nnIgnore ) );
171 while ( nnIgnore > 0 ) {
172 (*m_rfs) >> m_dataSeparatorRecord;
174 m_rfs->seekg( size + m_rfs->tellg() );
193 if ( m_idxHandler == 0 ) {
196 uint32_t curEvtId = m_buffer[ m_buffer[5] + 8 ];
197 if ( curEvtId == evtId ) {
225 assert( (evtByte&3) == 0 );
227 uint32_t prePos = m_rfs->tellg();
228 m_rfs->seekg( prePos + nIgnore*evtByte);
230 uint32_t halfEvtWord = evtByte / 8;
231 uint32_t halfEvtByte = halfEvtWord * 4;
233 while ( m_rfs->read((
char*)m_buffer, halfEvtByte).good() ) {
235 while ( i < halfEvtWord && m_buffer[i] != 0x1234cccc ) {
238 if ( i < halfEvtWord ) {
239 uint32_t curPos = m_rfs->tellg();
240 m_rfs->seekg( curPos - (halfEvtWord-i)*4 );
248 m_rfs->seekg( -40, std::ios::end );
249 uint32_t curPos = m_rfs->tellg();
251 int nnIgnore = nIgnore - (curPos - prePos) / evtByte;
252 if ( nnIgnore < 0 ) nnIgnore = 0;
259 return m_rfs->
runNo();
269 return m_rfs->tellg();
276 if ( m_rfs->eof() )
stat |= 1;
277 if ( m_rfs->fail() )
stat |= 2;
278 if ( m_rfs->bad() )
stat |= 4;
283const uint32_t* RawFileReader::notSafeNextEvent()
289 nextFile(e).notSafeNextEvent();
295void RawFileReader::read_one_event()
297 (*m_rfs) >> m_dataSeparatorRecord;
300 if ( size > m_bufferSize*4 ) {
301 while ( size > m_bufferSize*4 ) {
305 m_buffer =
new uint32_t[m_bufferSize];
308 m_rfs->read((
char*)m_buffer, size);
309 if ( ! m_rfs->good() ) {
322 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