13int main(
int argc,
char* argv[])
17 cout <<
"Usage: tstio <choice> " << endl;
18 cout <<
"where choice = " << endl;
19 cout <<
" 1. open a file and print raw data" << endl;
20 cout <<
" 2. filter data from file1 to file2" << endl;
21 cout <<
" 3. Make a fast sum of event types" << endl;
29 cerr <<
"ERROR: Cannot open CODA data" << endl;
30 cerr <<
"Perhaps you mistyped it" << endl;
31 cerr <<
"... exiting." << endl;
35 int Choice = atoi(argv[1]);
41 for (
unsigned iev=0; iev<NUMEVT; iev++) {
45 cout <<
"Normal end of file. Bye bye." << endl;
48 cout << hex <<
"ERROR: codaRread status = " << status << endl;
56 cout << endl<<endl<<
"Event number " << dec << iev;
57 cout <<
" length " <<
len <<
" type " << evtype << endl;
58 CodaDecoder::hexdump((
const char*)
data,
len);
74 int my_event_list[] = { 4, 15, 20, 1050, 80014, 5605001 };
75 for (
auto ievnum : my_event_list) {
83 const char* output_file =
"filter_output.dat";
85 cout << endl <<
"Return status from filtering " << dec << ret << endl;
92 static const unsigned MAXEVTYPE = 200;
93 unsigned evtype_sum[MAXEVTYPE];
94 for (
auto & isum : evtype_sum) isum = 0;
96 cout <<
"Scanning " <<
filename << endl;
98 if( (nevt%1000)==0 ) cout <<
"." << flush;
101 unsigned event_type = dbuff[1]>>16;
102 if (event_type < MAXEVTYPE) {
103 evtype_sum[event_type]++;
106 ios_base::fmtflags fmt = cout.flags();
107 cout << endl <<
"Summary of event types";
108 cout << endl <<
" Total number events read "<<dec<<nevt<<endl;
109 for (
unsigned ety=0; ety<MAXEVTYPE; ety++) {
110 if (evtype_sum[ety] != 0) {
111 cout <<
" Event type " << setw(3) << right << ety;
112 cout <<
", count = " << setw(7) << right << evtype_sum[ety] << endl;