#include <fstream>
#include <iostream>
#include <cstdlib>
#include "eformat/eformat.h"
Go to the source code of this file.
Functions | |
int | main (int argc, char **argv) |
Variables | |
const size_t | MAX_EVENT_SIZE = 2500000 |
Definition in file check.cxx.
int main | ( | int | argc, | |
char ** | argv | |||
) |
Reads a file and check its validity (for the time being)
Definition at line 30 of file check.cxx.
References MAX_EVENT_SIZE, eformat::next_fragment(), and ers::Issue::what().
00031 { 00032 using namespace eformat; 00033 00034 if ( argc != 2 ) { 00035 std::cerr << "usage: " << argv[0] << " <file>" << std::endl; 00036 std::exit(1); 00037 } 00038 00039 //open normally a file 00040 std::fstream in(argv[1], std::ios::in|std::ios::binary); 00041 if (!in) { 00042 std::cerr << "File `" << argv[1] << "' does not exist?!" << std::endl; 00043 std::exit(1); 00044 } 00045 uint32_t* event = new uint32_t[MAX_EVENT_SIZE]; 00046 uint32_t sevent = 0; 00047 while(in.good() && !in.eof() && sevent != 0xaa1234aa) { 00048 in.read((char*)&sevent, 4); 00049 } 00050 if (sevent == 0xaa1234aa) in.seekg(in.tellg()-(std::streampos)4); 00051 else exit(1); 00052 //for (int i = 0; i < 100; i++) { 00053 // in.read((char*)&sevent, 4); 00054 // std::cout << std::hex << sevent << std::endl; 00055 //} 00056 00057 while (true) { 00058 00059 if (!(next_fragment(in, event, MAX_EVENT_SIZE*4))) break; 00060 00061 try { 00062 FullEventFragment<const uint32_t*> fe(event); 00063 fe.check_tree(); 00064 //if check is ok, print the lvl1 identifier 00065 std::cout << "Event " << fe.lvl1_id() << " is Ok." << std::endl; 00066 } 00067 catch (eformat::Issue& ex) { 00068 std::cerr << std::endl 00069 << "Uncaught eformat issue: " << ex.what() << std::endl; 00070 std::cout << "Trying to continue..." << std::endl; 00071 continue; 00072 } 00073 catch (ers::Issue& ex) { 00074 std::cerr << std::endl 00075 << "Uncaught ERS issue: " << ex.what() << std::endl; 00076 delete[] event; 00077 std::exit(1); 00078 } 00079 catch (std::exception& ex) { 00080 std::cerr << std::endl 00081 << "Uncaught std exception: " << ex.what() << std::endl; 00082 delete[] event; 00083 std::exit(1); 00084 } 00085 catch (...) { 00086 std::cerr << std::endl << "Uncaught unknown exception" << std::endl; 00087 delete[] event; 00088 std::exit(1); 00089 } 00090 00091 } 00092 00093 delete[] event; 00094 return 0; 00095 }
const size_t MAX_EVENT_SIZE = 2500000 |