24 if((argc>=2 && ( (strcmp(argv[1],
"-h")==0) || (strcmp(argv[1],
"--help")==0) ))
26 cout <<
"Usage: recycleTccEmu infile outfile\n";
30 string ifilename = argv[1];
31 string ofilename = argv[2];
33 for(
int iCh=0; iCh<
nChs; ++iCh){
34 for(
int iEvts = 0; iEvts<
nEvts; ++iEvts){
35 mem[iCh][iEvts] = 0xFFFF;
39 ifstream
in(ifilename.c_str());
49 in >>
dec>> chnb >> bcnb >>hex>> val >> dummy ;
50 mem[chnb-1][bcnb] = val&0x7FF;
51 if(
mem[chnb-1][bcnb]!=val){
52 cout <<
"Invalid Et value at line " << oldLineCnt+1 <<
".\n";
61 cout <<
"Failed to open file " << ifilename <<
"\n";
65 ofstream
out(ofilename.c_str());
68 cout <<
"Failed to open file '" << ofilename
69 <<
"' in write mode.\n";
74 bool singleOldEventCnt =
true;
75 int oldEventCnt[
nChs];
77 for(
int iCh = 0; iCh<
nChs; ++iCh){
80 while(evtcnt<
nEvts &&
mem[iCh][evtcnt]!=0xFFFF){++evtcnt;}
82 oldEventCnt[iCh] = evtcnt;
83 if(oldEventCnt[0]!=oldEventCnt[iCh]) singleOldEventCnt =
false;
85 cout <<
"Error: no data found for channel "<< iCh <<
"\n";
88 for(
int ievt = evtcnt; ievt<
nEvts; ++ievt){
89 if(
mem[iCh][ievt]!=0xFFFF){
90 cout <<
"Error: memory offset of channel " << iCh
91 <<
" events are not contiguous.\n";
94 mem[iCh][ievt] =
mem[iCh][ievt%evtcnt];
97 for(
int ievt=0; ievt<
nEvts; ++ievt){
98 out << iCh+1 <<
"\t" << ievt
99 <<
"\t" << hex <<
"0x" << setfill(
'0') << setw(4)
101 << setfill(
' ') <<
dec <<
"\t0" 107 if(singleOldEventCnt && (
nEvts%oldEventCnt[0]!=0)){
108 cout <<
"Warning: ouput event count (2048) is not a mulitple of input " 111 if(!singleOldEventCnt){
113 for(
int iCh=0; iCh<
nChs; ++iCh){
114 if(
nEvts%oldEventCnt[iCh]){
115 s << (s.str().empty()?
"":
", ") << iCh;
119 cout <<
"Warning: ouput event count (2048) for channel" 120 << (s.str().size()>1?
"s":
"") <<
" " 122 <<
" is not a mulitple of input event counts\n" ;
125 if(!singleOldEventCnt){
126 cout <<
"Info: in the input file the event count depends on the channel";
int main(int argc, char *argv[])
uint16_t mem[nChs][nEvts]