2 #include "MonarchLogger.hpp" 13 int main(
const int argc,
const char** argv )
17 MLINFO(
mlog,
"usage:\n" 18 <<
" MonarchDump <input egg file> <output text file> <# of records per channel [optional]>\n" 19 <<
"# of records is optional; the default is 1; use 0 to dump the whole file" );
23 unsigned int nRecords = 1;
26 nRecords = atoi( argv[3] );
29 const Monarch* tReadTest = Monarch::OpenForReading( argv[ 1 ] );
30 tReadTest->ReadHeader();
33 const MonarchHeader* tReadHeader = tReadTest->GetHeader();
34 MLINFO(
mlog, *tReadHeader );
36 unsigned int tRecordCount = 0;
37 unsigned int tAcquisitionCount = 0;
41 ofstream tOutputOne( (
string( argv[ 2 ] ) +
string(
"_ch1.txt" )).c_str() );
42 if( tOutputOne.is_open() == false )
44 MERROR(
mlog,
"could not open channel one output file!" );
50 const unsigned tDataTypeSize = tReadHeader->GetDataTypeSize();
51 const MonarchRecordBytes* tReadRecord = tReadTest->GetRecordSeparateOne();
52 const MonarchRecordDataInterface< uint64_t > tData( tReadRecord->fData, tDataTypeSize );
53 unsigned int tRecordsPerChannel = 0;
54 while( tReadTest->ReadRecord() != false )
58 if( tReadRecord->fAcquisitionId == tAcquisitionCount )
60 tAcquisitionCount = tAcquisitionCount + 1;
63 for(
unsigned int tIndex = 0; tIndex < tReadHeader->GetRecordSize(); tIndex++ )
65 tOutputOne << tIndex <<
" " << tData.at( tIndex ) <<
"\n";
67 if (nRecords != 0 && tRecordsPerChannel >= nRecords)
75 ofstream tOutputOne( (
string( argv[ 2 ] ) +
string(
"_ch1.txt" )).c_str() );
76 ofstream tOutputTwo( (
string( argv[ 2 ] ) +
string(
"_ch2.txt" )).c_str() );
77 if( tOutputOne.is_open() == false )
79 MERROR(
mlog,
"could not open channel one output file!" );
84 if( tOutputTwo.is_open() == false )
86 MERROR(
mlog,
"could not open channel two output file!" );
92 const unsigned tDataTypeSize = tReadHeader->GetDataTypeSize();
93 const MonarchRecordBytes* tReadRecordOne = tReadTest->GetRecordSeparateOne();
94 const MonarchRecordDataInterface< uint64_t > tDataOne( tReadRecordOne->fData, tDataTypeSize );
95 const MonarchRecordBytes* tReadRecordTwo = tReadTest->GetRecordSeparateTwo();
96 const MonarchRecordDataInterface< uint64_t > tDataTwo( tReadRecordTwo->fData , tDataTypeSize);
97 unsigned int tRecordsPerChannel = 0;
98 while( tReadTest->ReadRecord() != false )
100 tRecordCount = tRecordCount + 1;
101 tRecordsPerChannel++;
102 if( tReadRecordOne->fAcquisitionId == tAcquisitionCount )
104 tAcquisitionCount = tAcquisitionCount + 1;
105 tOutputOne <<
"\n\n";
106 tOutputTwo <<
"\n\n";
108 for(
unsigned int tIndex = 0; tIndex < tReadHeader->GetRecordSize(); tIndex++ )
110 tOutputOne << tIndex <<
" " << tDataOne.at( tIndex ) <<
"\n";
111 tOutputTwo << tIndex <<
" " << tDataTwo.at( tIndex ) <<
"\n";
113 if (nRecords != 0 && tRecordsPerChannel >= nRecords)
121 MLINFO(
mlog,
"record count <" << tRecordCount <<
">" );
122 MLINFO(
mlog,
"acquisition count <" << tAcquisitionCount <<
">" );
static const FormatModeType sFormatSingle
MLOGGER(mlog, "MonarchDump")
static scarab::logger mlog("M3Info")
static const FormatModeType sFormatMultiSeparate
static const FormatModeType sFormatMultiInterleaved
static const AccessModeType sInterfaceSeparate
int main(const int argc, const char **argv)