19 if ( !m_fidx->open4read(
file ) ) {
20 std::cerr <<
"Error: failed to open index file " <<
file << std::endl;
24 if ( !openDestFile( m_fcount ) ) {
25 std::cerr <<
"Error: failed to open destination file" << std::endl;
29 uint32_t* srcEvt = m_srcfile->nextEvent();
31 while ( srcEvt !=
nullptr ) {
33 if ( m_fs.tellp() > 0xFFF00000 ) {
34 m_fs << m_srcfile->fileEndRecord();
36 if ( !openDestFile( ++m_fcount ) )
return false;
40 uint32_t l1id = srcEvt[10 + srcEvt[5]] + 1;
41 uint32_t* cgemData = m_fidx->getCgemData( l1id );
42 if ( cgemData[1] != 0 ) {
44 uint32_t sizeWords = srcEvt[1] + cgemData[1];
45 uint32_t sizeBytes = sizeWords *
sizeof( uint32_t );
46 uint32_t* destEvt = m_cache->reserve<uint32_t>( sizeWords );
47 auto nptr = mempcpy( destEvt, srcEvt, srcEvt[1] *
sizeof( uint32_t ) );
48 memcpy( nptr, cgemData, cgemData[1] *
sizeof( uint32_t ) );
50 destEvt[1] = sizeWords;
51 auto destDSR = m_srcfile->dataSeparatorRecord();
52 destDSR.setDataBlockSize( sizeBytes );
56 m_fs.write(
reinterpret_cast<const char*
>( destEvt ), sizeBytes );
59 std::cout <<
"Warning: CGEM with L1ID " << l1id <<
" will be ignored!!!" << std::endl;
63 srcEvt = m_srcfile->nextEvent();
66 if ( m_srcfile->eof() ) {
67 m_fs << m_srcfile->fileEndRecord();