Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:14

0001 #include <stdio.h>
0002 #include <errno.h>
0003 #include "../src/FileReaderDDU.cc"
0004 // To compile: g++ -o stripDCC stripDCC.cc
0005 
0006 int main(int argc, char *argv[]) {
0007   if (argc != 3) {
0008     printf("Usage: ./stripDCC INPUT_FILENAME OUTPUT_FILENAME\n");
0009     return 0;
0010   }
0011   FILE *out;
0012   if ((out = fopen(argv[2], "wt")) == NULL) {
0013     printf("Cannot open output file: %s (errno=%d)\n", argv[2], errno);
0014     return 1;
0015   }
0016   FileReaderDDU reader;
0017   reader.reject(FileReaderDDU::Unknown);
0018   reader.select(0);
0019   try {
0020     reader.open(argv[1]);
0021   } catch (std::runtime_error &e) {
0022     printf("Cannot open input file: %s (errno=%d)\n", argv[1], errno);
0023   }
0024   const unsigned short *buf = 0;
0025   size_t length = 0;
0026   int nEvents = 0;
0027   while ((length = reader.next(buf)) != 0) {
0028     fwrite(buf, 2, length, out);
0029     nEvents++;
0030   }
0031   fclose(out);
0032 
0033   printf("nEvents=%d\n", nEvents);
0034   return 0;
0035 }